From 5ca793e093a5b1a5572c0d932ced444f84da3608 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 20 Feb 2026 00:13:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A3=80=E6=B5=8B=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=87=8D=E5=A4=8D=EF=BC=8C=E5=8A=A8=E7=94=BB=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E8=BF=98=E6=A3=80=E6=B5=8B=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82=E8=87=AA=E5=8A=A8=E6=89=93=E5=BC=80=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/guide/user_guide.md | 15 ++- doc/requirement/todo_features.md | 3 +- src/Core/Animation/PathAnimationManager.cs | 95 ++++++++++++------- src/UI/WPF/Resources/NavisworksStyles.xaml | 16 ++++ .../ViewModels/AnimationControlViewModel.cs | 56 ++++++++++- .../ViewModels/CollisionReportViewModel.cs | 78 +++++++++++++++ src/UI/WPF/Views/AnimationControlView.xaml | 3 +- src/UI/WPF/Views/AnimationControlView.xaml.cs | 54 +++++++++++ src/UI/WPF/Views/CollisionReportDialog.xaml | 53 ++++++++--- src/Utils/CollisionReportHtmlGenerator.cs | 52 +++++++++- 10 files changed, 370 insertions(+), 55 deletions(-) diff --git a/doc/guide/user_guide.md b/doc/guide/user_guide.md index e7fb6eb..6abd53b 100644 --- a/doc/guide/user_guide.md +++ b/doc/guide/user_guide.md @@ -17,7 +17,20 @@ CheckExistingDetectionRecord ├── 是 → 提前返回,跳过动画生成和碰撞检测 └── 否 → 继续正常流程 - +用户生成动画 → 检测到相同配置的历史记录 → 弹出对话框询问 + ↓ +用户选择"使用历史记录" + ↓ +1. 设置 IsUsingHistoryRecord = true +2. 在历史列表中选中该记录 +3. 自动滚动到该记录 +4. 自动打开碰撞报告对话框 + ↓ +用户播放动画 → 动画完成 → 检查 IsUsingHistoryRecord + ↓ + ├── true → 跳过 ClashDetective 测试,记录日志 + └── false → 正常执行 ClashDetective 测试 + 生成动画 ↓ 检查动画帧缓存 diff --git a/doc/requirement/todo_features.md b/doc/requirement/todo_features.md index 35981b8..f2c52e1 100644 --- a/doc/requirement/todo_features.md +++ b/doc/requirement/todo_features.md @@ -7,6 +7,7 @@ 1. [x] (优化)实现完整的路径分析功能 2. [x] (功能)用物流分类属性筛选对应的物流元素 3. [x] (优化)实现完整的时间标签功能 +4. [x] (优化)增加路径剖面盒开关 ### [2026/2/8] @@ -76,7 +77,7 @@ 1. [x] (功能)对路径上的各点进行坐标编辑 2. [ ] (功能)记录并查看路径文件操作的历史记录 -3. [ ] (功能)自动隐藏或淡化非关键层,以便专注于物流路径相关的层级。 +3. [x] (功能)自动隐藏或淡化非关键层,以便专注于物流路径相关的层级。 4. [x] (优化)优化路径时间标签功能 5. [ ] (测试)路径规划文件能导入DELMIA 6. [x] (优化)优化路径规划分析和分析报告 diff --git a/src/Core/Animation/PathAnimationManager.cs b/src/Core/Animation/PathAnimationManager.cs index e60ee3d..087754c 100644 --- a/src/Core/Animation/PathAnimationManager.cs +++ b/src/Core/Animation/PathAnimationManager.cs @@ -123,6 +123,7 @@ namespace NavisworksTransport.Core.Animation // === 碰撞测试优化 === private string _currentAnimationHash; // 当前动画配置的哈希值 private int? _currentDetectionRecordId; // 当前检测记录ID(关联CollisionDetectionRecords表) + private bool _isUsingHistoryRecord; // 是否使用历史检测记录(动画完成后跳过ClashDetective) // === 动画播放机制 === private double _frameInterval; // 帧间隔(毫秒) @@ -182,6 +183,15 @@ namespace NavisworksTransport.Core.Animation set => _currentDetectionRecordId = value; } + /// + /// 是否使用历史检测记录(动画完成后跳过ClashDetective测试) + /// + public bool IsUsingHistoryRecord + { + get => _isUsingHistoryRecord; + set => _isUsingHistoryRecord = value; + } + // --- 新增事件 --- /// /// 当动画状态发生改变时触发 @@ -1611,45 +1621,53 @@ namespace NavisworksTransport.Core.Animation _timeLinerManager.UpdateTaskProgress(_currentTaskId, 1.0, AnimationState.Finished); } - // 🔥 执行碰撞检测(重复检查已在保存检测记录时完成,这里直接执行) - LogManager.Info($"开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)..."); - - // 设置等待光标,避免进度条关闭后的无响应 - var oldCursor = System.Windows.Input.Mouse.OverrideCursor; - System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; - - bool testCompleted = false; - try + // 🔥 检查是否使用历史记录,如果是则跳过ClashDetective测试 + if (_isUsingHistoryRecord) { - // 使用用户设置的检测容差(米) - testCompleted = ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests( - _allCollisionResults, - _detectionTolerance, - _currentRouteId, - _animatedObject, - _isVirtualObject, - _animationFrameRate, - _animationDuration, - _virtualObjectLength, - _virtualObjectWidth, - _virtualObjectHeight, - _pathPoints, - _currentDetectionRecordId - ); - } - finally - { - // 恢复光标 - System.Windows.Input.Mouse.OverrideCursor = oldCursor; - } - - if (testCompleted) - { - LogManager.Info($"碰撞测试汇总已创建完成"); + LogManager.Info("[动画完成] 使用历史检测记录,跳过ClashDetective测试"); } else { - LogManager.Info("碰撞检测被取消"); + // 🔥 执行碰撞检测(重复检查已在保存检测记录时完成,这里直接执行) + LogManager.Info($"开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)..."); + + // 设置等待光标,避免进度条关闭后的无响应 + var oldCursor = System.Windows.Input.Mouse.OverrideCursor; + System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; + + bool testCompleted = false; + try + { + // 使用用户设置的检测容差(米) + testCompleted = ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests( + _allCollisionResults, + _detectionTolerance, + _currentRouteId, + _animatedObject, + _isVirtualObject, + _animationFrameRate, + _animationDuration, + _virtualObjectLength, + _virtualObjectWidth, + _virtualObjectHeight, + _pathPoints, + _currentDetectionRecordId + ); + } + finally + { + // 恢复光标 + System.Windows.Input.Mouse.OverrideCursor = oldCursor; + } + + if (testCompleted) + { + LogManager.Info($"碰撞测试汇总已创建完成"); + } + else + { + LogManager.Info("碰撞检测被取消"); + } } } catch (Exception ex) @@ -2762,6 +2780,13 @@ namespace NavisworksTransport.Core.Animation _currentDetectionRecordId = null; } + // 🔥 清除历史记录标志,确保动画生成时状态正确 + if (_isUsingHistoryRecord) + { + LogManager.Info("[CreateAnimation] 清除历史记录标志,将创建新检测"); + _isUsingHistoryRecord = false; + } + _pathName = pathName; _currentRouteId = routeId; _isVirtualObject = isVirtualObject; // 设置是否使用虚拟物体 diff --git a/src/UI/WPF/Resources/NavisworksStyles.xaml b/src/UI/WPF/Resources/NavisworksStyles.xaml index e4711c0..e9401f4 100644 --- a/src/UI/WPF/Resources/NavisworksStyles.xaml +++ b/src/UI/WPF/Resources/NavisworksStyles.xaml @@ -202,6 +202,22 @@ NavisworksTransport 共享样式资源字典 - Navisworks 2026风格 M12,2C6.48,2 2,6.48 2,12C2,17.52 6.48,22 12,22C17.52,22 22,17.52 22,12C22,6.48 17.52,2 12,2ZM12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20ZM12,6C8.69,6 6,8.69 6,12C6,15.31 8.69,18 12,18C15.31,18 18,15.31 18,12C18,8.69 15.31,6 12,6ZM12,16C9.79,16 8,14.21 8,12C8,9.79 9.79,8 12,8C14.21,8 16,9.79 16,12C16,14.21 14.21,16 12,16Z + + + + + + "); html.AppendLine(""); + // 从数据库获取检测记录信息 + var (testName, testTime) = GetDetectionRecordInfo(report.ResultId); + // 报告标题 html.AppendLine($"

NavisworksTransport 碰撞检测报告

"); html.AppendLine($"

生成时间: {now:yyyy年MM月dd日 HH:mm:ss}

"); html.AppendLine($"

报告类型: 综合报告

"); - html.AppendLine($"

路径名称: {report.PathName ?? "未知路径"}

"); + + // 检测记录信息 + html.AppendLine("
"); + html.AppendLine("

检测记录

"); + html.AppendLine("
"); + html.AppendLine("
"); + html.AppendLine("
测试名称
"); + html.AppendLine($"
{testName ?? "未命名"}
"); + html.AppendLine("
"); + html.AppendLine("
"); + html.AppendLine("
检测时间
"); + html.AppendLine($"
{testTime}
"); + html.AppendLine("
"); + html.AppendLine("
"); + html.AppendLine("
"); // 总体统计 html.AppendLine("
"); @@ -426,5 +443,38 @@ namespace NavisworksTransport.Utils return null; } } + + /// + /// 从数据库获取检测记录信息 + /// + private static (string testName, string testTime) GetDetectionRecordInfo(int resultId) + { + try + { + if (resultId <= 0) + { + return (null, "未知时间"); + } + + var pathDatabase = PathPlanningManager.Instance?.GetPathDatabase(); + if (pathDatabase == null) + { + return (null, "未知时间"); + } + + var record = pathDatabase.GetDetectionResultById(resultId); + if (record != null) + { + string timeStr = record.TestTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "未知时间"; + return (record.TestName, timeStr); + } + } + catch (Exception ex) + { + LogManager.Error($"[CollisionReportHtmlGenerator] 获取检测记录信息失败: {ex.Message}"); + } + + return (null, "未知时间"); + } } }