From 5f15eeeb26262d4a5eb08fa6f2d1edf64f1d9f48 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Thu, 6 Aug 2026 11:32:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A2=B0=E6=92=9E=E6=8A=A5=E5=91=8A/?= =?UTF-8?q?=E5=88=86=E6=9E=90=E7=AA=97=E5=8F=A3=E8=87=AA=E5=8A=A8=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=A4=84=E7=90=86=20+=20=E9=A2=84=E9=80=89=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E6=B8=85=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CollisionAnalysisDialog(预计算结果分析): - 自动关闭时清除所有预选排除(智能预选可能选中唯一候选项, 导致排除全部 → 无检测对象);默认动作 = 去掉选择 + 继续生成动画 - 日志记录清除数量 CollisionReportDialog(碰撞检测报告): - ShowReport 自动模式下跳过窗口(数据已落库/日志),返回 null; 调用方区分自动模式 null(正常)与非自动模式 null(错误) 验证:F1 批处理跑完 NW 零残留窗口(EnumWindows 确认仅主窗口); 日志确认'自动模式下已清除 1 个预选排除';集成测试 25/25 --- .../ViewModels/AnimationControlViewModel.cs | 2 +- .../WPF/Views/CollisionAnalysisDialog.xaml.cs | 22 +++++++++++++++++++ .../WPF/Views/CollisionReportDialog.xaml.cs | 9 ++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs index 402c448..ac60081 100644 --- a/src/UI/WPF/ViewModels/AnimationControlViewModel.cs +++ b/src/UI/WPF/ViewModels/AnimationControlViewModel.cs @@ -1492,7 +1492,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels UpdateMainStatus("碰撞报告已显示"); LogManager.Info("成功显示缓存的碰撞报告"); } - else + else if (!AutomationModeContext.IsAutomaticMode) { UpdateMainStatus("显示报告对话框失败"); LogManager.Error("CollisionReportDialog.ShowReport返回null"); diff --git a/src/UI/WPF/Views/CollisionAnalysisDialog.xaml.cs b/src/UI/WPF/Views/CollisionAnalysisDialog.xaml.cs index 54b6784..d1fd34f 100644 --- a/src/UI/WPF/Views/CollisionAnalysisDialog.xaml.cs +++ b/src/UI/WPF/Views/CollisionAnalysisDialog.xaml.cs @@ -81,6 +81,28 @@ namespace NavisworksTransport.UI.WPF.Views } LogManager.Info("[碰撞分析] 测试自动化已接管分析窗口,自动选择继续生成"); + + // 🔥 自动模式下清除所有预选排除: + // 智能预选(碰撞>100次或>50%)可能排除全部候选项(如唯一候选被选中), + // 导致后续检测无任何对象。默认动作 = 去掉选择 + 继续生成动画(检测所有物体)。 + int clearedCount = 0; + if (HotspotsDataGrid.ItemsSource is System.Collections.IEnumerable items) + { + foreach (var vm in items.OfType()) + { + if (vm.IsExcluded) + { + vm.IsExcluded = false; + clearedCount++; + } + } + } + + if (clearedCount > 0) + { + LogManager.Info($"[碰撞分析] 自动模式下已清除 {clearedCount} 个预选排除(避免排除全部候选项导致无检测对象)"); + } + ModelHighlightHelper.ClearCategory(PrecomputedHighlightCategory); SelectedAction = CollisionAnalysisAction.Continue; Close(); diff --git a/src/UI/WPF/Views/CollisionReportDialog.xaml.cs b/src/UI/WPF/Views/CollisionReportDialog.xaml.cs index 21c60be..eab69f0 100644 --- a/src/UI/WPF/Views/CollisionReportDialog.xaml.cs +++ b/src/UI/WPF/Views/CollisionReportDialog.xaml.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; +using NavisworksTransport.Utils; using NavisworksTransport.UI.WPF.ViewModels; using NavisworksTransport.Commands; using CollisionReportScreenshot = NavisworksTransport.Commands.CollisionReportScreenshot; @@ -368,6 +369,14 @@ namespace NavisworksTransport.UI.WPF.Views /// 对话框实例 public static CollisionReportDialog ShowReport(CollisionReportResult reportResult, Window owner = null) { + // 自动模式(批处理/自动测试)下跳过碰撞报告窗口: + // 报告数据已落库/日志,避免残留窗口阻塞自动化流程 + if (AutomationModeContext.IsAutomaticMode) + { + LogManager.Info("[碰撞报告] 自动模式下跳过碰撞报告窗口(数据已保存至检测记录)"); + return null; + } + try { lock (_lock)