From 001b45cc9a2eeceb78d0583adb54c06b67340cf0 Mon Sep 17 00:00:00 2001
From: tian <11429339@qq.com>
Date: Fri, 9 Jan 2026 16:46:38 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E8=B7=AF=E5=BE=84=E8=A7=86?=
=?UTF-8?q?=E5=9B=BE=E6=A8=A1=E5=9E=8B=E7=9A=84=E6=97=B6=E9=97=B4=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF=E8=AE=BE=E7=BD=AE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
default_config.toml | 4 +-
src/Core/Animation/PathAnimationManager.cs | 1 +
.../Collision/ClashDetectiveIntegration.cs | 2 +-
src/Core/PathPlanningManager.cs | 4 +-
src/UI/WPF/Models/PathRouteViewModel.cs | 63 ++++++++++++++++---
src/UI/WPF/ViewModels/PathEditingViewModel.cs | 15 ++++-
src/UI/WPF/Views/AnimationControlView.xaml | 2 +-
7 files changed, 74 insertions(+), 17 deletions(-)
diff --git a/default_config.toml b/default_config.toml
index 60c43ac..8435419 100644
--- a/default_config.toml
+++ b/default_config.toml
@@ -41,8 +41,8 @@ duration_seconds = 10.0
detection_gap_meters = 0.05
# 预计算检测间隙扩大率(>0,表示扩大的倍数)
-# 例如:1.0表示检测间隙增大1倍,即使用2倍的检测间隙进行预计算
-precomputed_detection_gap_expansion_rate = 1.0
+# 例如:0.5表示检测间隙增大0.5倍,即使用1.5倍的检测间隙进行预计算
+precomputed_detection_gap_expansion_rate = 0.5
[logistics]
# 可通行性(默认值:true)
diff --git a/src/Core/Animation/PathAnimationManager.cs b/src/Core/Animation/PathAnimationManager.cs
index dfb8666..059932a 100644
--- a/src/Core/Animation/PathAnimationManager.cs
+++ b/src/Core/Animation/PathAnimationManager.cs
@@ -617,6 +617,7 @@ namespace NavisworksTransport.Core.Animation
if (intersects)
{
+ LogManager.Debug($"帧 {i} 检测到碰撞: {_animatedObject.DisplayName} <-> {collider.DisplayName}, 精确距离: {preciseDistance:F4},阈值: {_precomputedDetectionGap:F4}");
var collisionResult = new CollisionResult
{
ClashGuid = Guid.NewGuid(),
diff --git a/src/Core/Collision/ClashDetectiveIntegration.cs b/src/Core/Collision/ClashDetectiveIntegration.cs
index d58ea4f..1f9d515 100644
--- a/src/Core/Collision/ClashDetectiveIntegration.cs
+++ b/src/Core/Collision/ClashDetectiveIntegration.cs
@@ -614,7 +614,7 @@ namespace NavisworksTransport
LogManager.Info($"[分组测试] 有效碰撞数量: {validCollisions.Count}");
// 创建主测试名称
- var mainTestName = $"碰撞检测_{DateTime.Now:yyyyMMdd_HHmmss}";
+ var mainTestName = $"碰撞检测_{DateTime.Now:MMdd_HHmmss}";
_currentTestName = mainTestName;
LogManager.Info($"[分组测试] 创建主测试: {mainTestName}");
diff --git a/src/Core/PathPlanningManager.cs b/src/Core/PathPlanningManager.cs
index a592a09..4577017 100644
--- a/src/Core/PathPlanningManager.cs
+++ b/src/Core/PathPlanningManager.cs
@@ -1098,7 +1098,7 @@ namespace NavisworksTransport
LogManager.Info($"A*算法找到路径,包含 {pathResult.PathPoints.Count} 个点,完成度: {pathResult.CompletionPercentage:F1}%");
// 6. 创建PathRoute对象并保存GridMap
- var routeName = $"自动路径_{DateTime.Now:HHmmss}";
+ var routeName = $"自动_{DateTime.Now:MMdd_HHmmss}";
// 🔥 关键修复:在创建路径前设置_currentGridMap,确保GetSpeedLimitAtPosition能正常工作
_currentGridMap = gridMap;
@@ -1486,7 +1486,7 @@ namespace NavisworksTransport
PathEditState = PathEditState.Creating;
// 创建新路径
- var newRoute = new PathRoute(routeName ?? $"路径{DateTime.Now:yyyyMMdd_HHmmss}");
+ var newRoute = new PathRoute(routeName ?? $"人工_{DateTime.Now:MMdd_HHmmss}");
_editingRoute = newRoute;
SetCurrentRouteInternal(newRoute, triggerEvent: true);
diff --git a/src/UI/WPF/Models/PathRouteViewModel.cs b/src/UI/WPF/Models/PathRouteViewModel.cs
index 4ab8428..be5a5a5 100644
--- a/src/UI/WPF/Models/PathRouteViewModel.cs
+++ b/src/UI/WPF/Models/PathRouteViewModel.cs
@@ -290,6 +290,17 @@ namespace NavisworksTransport.UI.WPF.ViewModels
private set => SetProperty(ref _lastModifiedTime, value);
}
+ ///
+ /// 设置时间信息(用于从数据库加载)
+ ///
+ public void SetTimeInfo(DateTime createdTime, DateTime lastModifiedTime)
+ {
+ _createdTime = createdTime;
+ _lastModifiedTime = lastModifiedTime;
+ OnPropertyChanged(nameof(CreatedTime));
+ OnPropertyChanged(nameof(LastModifiedTime));
+ }
+
///
/// 创建者
///
@@ -346,9 +357,17 @@ namespace NavisworksTransport.UI.WPF.ViewModels
#region 构造函数和初始化
///
- /// 默认构造函数
+ /// 默认构造函数(用于新建路径)
///
- public PathRouteViewModel() : base()
+ public PathRouteViewModel() : this(isFromDatabase: false)
+ {
+ }
+
+ ///
+ /// 构造函数,控制是否从数据库加载
+ ///
+ /// 是否从数据库/内存加载(false表示新建路径)
+ public PathRouteViewModel(bool isFromDatabase)
{
try
{
@@ -362,8 +381,15 @@ namespace NavisworksTransport.UI.WPF.ViewModels
throw new InvalidOperationException("UIStateManager初始化失败");
}
- // 初始化默认值
- InitializeDefaults();
+ // 根据场景选择初始化方式
+ if (!isFromDatabase)
+ {
+ InitializeDefaultsForNewRoute();
+ }
+ else
+ {
+ InitializeMinimal();
+ }
// 直接完成初始化,不需要异步
CompleteInitialization();
@@ -378,7 +404,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
///
- /// 使用指定名称构造
+ /// 使用指定名称构造(用于新建路径)
///
/// 路径名称
public PathRouteViewModel(string name) : this()
@@ -387,7 +413,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
///
- /// 使用完整参数构造
+ /// 使用完整参数构造(用于新建路径)
///
/// 路径名称
/// 路径描述
@@ -400,9 +426,30 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
///
- /// 初始化默认值
+ /// 最小化初始化(用于从数据库/内存加载路径)
///
- private void InitializeDefaults()
+ private void InitializeMinimal()
+ {
+ _id = string.Empty;
+ _name = string.Empty;
+ _description = string.Empty;
+ _isActive = false;
+ _isOptimal = false;
+ _createdTime = DateTime.MinValue;
+ _lastModifiedTime = DateTime.MinValue;
+ _createdBy = string.Empty;
+ _totalLength = 0.0;
+ _isValidated = false;
+ _validationStatus = "未验证";
+
+ // 初始化点集合
+ Points = new ObservableCollection();
+ }
+
+ ///
+ /// 初始化默认值(用于新建路径)
+ ///
+ private void InitializeDefaultsForNewRoute()
{
_id = Guid.NewGuid().ToString();
_name = "新路径";
diff --git a/src/UI/WPF/ViewModels/PathEditingViewModel.cs b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
index b584e72..9a07126 100644
--- a/src/UI/WPF/ViewModels/PathEditingViewModel.cs
+++ b/src/UI/WPF/ViewModels/PathEditingViewModel.cs
@@ -2077,13 +2077,16 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 重新加载所有路径
foreach (var coreRoute in _pathPlanningManager.Routes)
{
- var pathViewModel = new PathRouteViewModel
+ var pathViewModel = new PathRouteViewModel(isFromDatabase: true)
{
Id = coreRoute.Id, // 添加Id属性设置
Name = coreRoute.Name,
Description = coreRoute.Description,
IsActive = false
};
+
+ // 设置时间信息
+ pathViewModel.SetTimeInfo(coreRoute.CreatedTime, coreRoute.LastModified);
// 转换路径点
foreach (var corePoint in coreRoute.Points)
@@ -2903,13 +2906,16 @@ namespace NavisworksTransport.UI.WPF.ViewModels
LogManager.Info($"*** 开始处理自动路径生成: {e.Route.Name} ***");
// 创建对应的 WPF ViewModel
- var autoPathViewModel = new PathRouteViewModel
+ var autoPathViewModel = new PathRouteViewModel(isFromDatabase: true)
{
Id = e.Route.Id,
Name = e.Route.Name,
Description = e.Route.Description,
IsActive = true
};
+
+ // 设置时间信息
+ autoPathViewModel.SetTimeInfo(e.Route.CreatedTime, e.Route.LastModified);
// 转换路径点
foreach (var corePoint in e.Route.Points)
@@ -3012,13 +3018,16 @@ namespace NavisworksTransport.UI.WPF.ViewModels
LogManager.Info($"*** 开始处理数据库加载路径: {coreRoute.Name} ***");
// 创建对应的 WPF ViewModel
- var dbPathViewModel = new PathRouteViewModel
+ var dbPathViewModel = new PathRouteViewModel(isFromDatabase: true)
{
Id = coreRoute.Id,
Name = coreRoute.Name,
Description = coreRoute.Description,
IsActive = false // 历史路径默认不激活
};
+
+ // 设置时间信息
+ dbPathViewModel.SetTimeInfo(coreRoute.CreatedTime, coreRoute.LastModified);
// 转换路径点
foreach (var corePoint in coreRoute.Points)
diff --git a/src/UI/WPF/Views/AnimationControlView.xaml b/src/UI/WPF/Views/AnimationControlView.xaml
index 49f966d..7035e0e 100644
--- a/src/UI/WPF/Views/AnimationControlView.xaml
+++ b/src/UI/WPF/Views/AnimationControlView.xaml
@@ -445,7 +445,7 @@ NavisworksTransport 检测动画页签视图 - 采用与类别设置和分层管
-
+