diff --git a/src/UI/WPF/ViewModels/PathEditingViewModel.cs b/src/UI/WPF/ViewModels/PathEditingViewModel.cs index 215c9b5..09aa62a 100644 --- a/src/UI/WPF/ViewModels/PathEditingViewModel.cs +++ b/src/UI/WPF/ViewModels/PathEditingViewModel.cs @@ -2236,28 +2236,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels } } - private async Task ExecuteSelectAssemblyInstallationPointAsync(RailAssemblyWorkflowMode workflowMode) - { - await SafeExecuteAsync(() => - { - if (_pathPlanningManager == null) - { - throw new InvalidOperationException("路径规划管理器未初始化,无法选择安装点。"); - } - - if (_assemblyTerminalObject == null || !ModelItemAnalysisHelper.IsModelItemValid(_assemblyTerminalObject)) - { - throw new InvalidOperationException("终点箱体未设置或已失效,请先捕获终点箱体。"); - } - - PrepareRailAssemblyWorkflowForMode( - workflowMode, - editActionDescription: "请先选中一条需要编辑安装点的 Rail 路径。", - syncMountModeFromRoute: false); - - BeginAssemblyInstallationSelection(); - }, "选择安装点"); - } private async void OnAssemblyReferenceMouseClicked(object sender, PickItemResult pickResult) { @@ -2290,50 +2268,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels } } - private async void OnAssemblyInstallationMouseClicked(object sender, PickItemResult pickResult) - { - try - { - if (!_isSelectingAssemblyInstallationPoint || pickResult == null) - { - return; - } - - await SafeExecuteAsync(() => - { - if (!IsPickOnAssemblyTerminalObject(pickResult)) - { - UpdateMainStatus("请点击当前终点箱体表面,不要点到其他对象。"); - return; - } - - _assemblyInstallationSeedPoints.Add(pickResult.Point); - RenderAssemblyInstallationPickPoints(_assemblyInstallationSeedPoints); - - int pickedCount = _assemblyInstallationSeedPoints.Count; - LogManager.Info($"[直线装配] 已记录安装面点 {pickedCount}: ({pickResult.Point.X:F3}, {pickResult.Point.Y:F3}, {pickResult.Point.Z:F3})"); - - if (pickedCount < 2) - { - UpdateMainStatus("已记录安装面点 1/2,请继续在同一安装面上点击第二个点。"); - return; - } - - BuildAndRenderAssemblyInstallationReference( - _assemblyInstallationSeedPoints[0], - _assemblyInstallationSeedPoints[1]); - - ApplyAssemblyInstallationReferenceForCurrentWorkflow(); - CleanupAssemblyInstallationSelection(clearVisuals: false); - }, "处理安装点拾取"); - } - catch (Exception ex) - { - LogManager.Error($"[直线装配] 安装点计算失败: {ex.Message}", ex); - UpdateMainStatus($"安装点计算失败: {ex.Message}"); - CleanupAssemblyInstallationSelection(clearVisuals: true); - } - } private void PrepareRailAssemblyWorkflowForMode( RailAssemblyWorkflowMode workflowMode, @@ -2643,30 +2577,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels } } - private void BeginAssemblyInstallationSelection() - { - CleanupAssemblyReferenceSelection(); - CleanupAssemblyEndFaceSelection(clearVisuals: false); - CleanupAssemblyInstallationSelection(); - ClearAssemblyInstallationReferenceVisuals(); - - _pathPlanningManager.DisableMouseHandling(); - _isSelectingAssemblyInstallationPoint = true; - NotifyRailAssemblyCommandStateChanged(); - - PathClickToolPlugin.MouseClicked -= OnAssemblyInstallationMouseClicked; - PathClickToolPlugin.MouseClicked += OnAssemblyInstallationMouseClicked; - - if (!ForceReinitializeToolPlugin(subscribeToEvents: false)) - { - CleanupAssemblyInstallationSelection(); - throw new InvalidOperationException("ToolPlugin 初始化失败,请重试。"); - } - - _assemblyInstallationSeedPoints.Clear(); - UpdateMainStatus("请在终点箱体表面连续点击两个安装面点,系统将按两点和光轴计算安装参考面与安装点。"); - LogManager.Info($"[直线装配] 已进入安装点拾取模式,模式={GetRailAssemblyWorkflowLabel(_railAssemblyWorkflowMode)}"); - } private void ApplyAssemblyStartPointForCurrentWorkflow(Point3D projectedStartPoint) { @@ -3359,49 +3269,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels RenderStyleName.AssemblyGuideLine); } - private void BuildAndRenderAssemblyInstallationReference(Point3D firstPickPoint, Point3D secondPickPoint) - { - Point3D opticalAxisReferencePoint = GetAssemblyOpticalAxisReferencePoint(); - Point3D sphereCenterPoint = new Point3D( - AssemblySphereCenterX, - AssemblySphereCenterY, - AssemblySphereCenterZ); - - Vector3 opticalAxisDirection = new Vector3( - (float)(opticalAxisReferencePoint.X - sphereCenterPoint.X), - (float)(opticalAxisReferencePoint.Y - sphereCenterPoint.Y), - (float)(opticalAxisReferencePoint.Z - sphereCenterPoint.Z)); - - AssemblyInstallationReferenceResult result = AssemblyInstallationReferenceBuilder.Build( - new Vector3((float)opticalAxisReferencePoint.X, (float)opticalAxisReferencePoint.Y, (float)opticalAxisReferencePoint.Z), - opticalAxisDirection, - new Vector3((float)firstPickPoint.X, (float)firstPickPoint.Y, (float)firstPickPoint.Z), - new Vector3((float)secondPickPoint.X, (float)secondPickPoint.Y, (float)secondPickPoint.Z)); - - _hasAssemblyInstallationReference = true; - _assemblyInstallationPickPoint = AssemblyEndFaceAnalyzer.ToPoint3D((result.PickPoint + result.SecondaryPickPoint) * 0.5f); - _assemblyInstallationBaseAnchorPoint = AssemblyEndFaceAnalyzer.ToPoint3D(result.AnchorPoint); - _assemblyInstallationPlaneNormal = result.PlaneNormal; - _assemblyInstallationPlaneSpanDirection = result.PlaneSpanDirection; - _assemblyInstallationOffsetDistanceInMeters = UnitsConverter.ConvertToMeters(result.OffsetDistance); - _assemblyAnchorVerticalOffsetInMeters = DefaultAssemblyAnchorVerticalOffsetInMeters; - OnPropertyChanged(nameof(AssemblyAnchorVerticalOffsetInMeters)); - UpdateAssemblyInstallationAnchorFromVerticalOffset(); - - RenderAssemblyInstallationPickPoints(_assemblyInstallationSeedPoints); - RenderAssemblyInstallationCenterLine(AssemblyEndFaceAnalyzer.ToPoint3D(result.InstallLineBasePoint), result.OpticalAxisDirection); - - RefreshAssemblyTerminalObjectInfo(); - RefreshAssemblyReferenceRodIfNeeded(); - UpdateMainStatus( - $"安装参考已计算:安装点=({_assemblyInstallationAnchorPoint.X:F2}, {_assemblyInstallationAnchorPoint.Y:F2}, {_assemblyInstallationAnchorPoint.Z:F2}),偏距={_assemblyInstallationOffsetDistanceInMeters:F3}m,可继续取起点"); - LogManager.Info( - $"[直线装配] 安装参考已计算: 安装面点1=({firstPickPoint.X:F3}, {firstPickPoint.Y:F3}, {firstPickPoint.Z:F3}), " + - $"安装面点2=({secondPickPoint.X:F3}, {secondPickPoint.Y:F3}, {secondPickPoint.Z:F3}), " + - $"安装点=({_assemblyInstallationAnchorPoint.X:F3}, {_assemblyInstallationAnchorPoint.Y:F3}, {_assemblyInstallationAnchorPoint.Z:F3}), " + - $"偏距={_assemblyInstallationOffsetDistanceInMeters:F3}m, 平面法向=({result.PlaneNormal.X:F4}, {result.PlaneNormal.Y:F4}, {result.PlaneNormal.Z:F4})"); - NotifyRailAssemblyCommandStateChanged(); - } private void RenderAssemblyInstallationPickPoints(IReadOnlyList pickPoints) {