给选择路径和开始动画增加视角自动调整到路径功能

This commit is contained in:
tian 2026-01-26 22:30:03 +08:00
parent 7f72ad5935
commit a2018576e5
4 changed files with 57 additions and 10 deletions

View File

@ -4,7 +4,8 @@
### [2026/1/26]
1. [ ] 优化完善碰撞报告截图保存机制自动导出html报告。
1. [x] 优化完善碰撞报告截图保存机制自动导出html报告。
2. [x] (优化)增加视角自动调整到路径上方合适位置功能,方便截图和观察
### [2026/1/18]

View File

@ -1018,7 +1018,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
LogManager.Info("已清理之前的碰撞高亮");
// 首先重置进度(开始全新动画时)
_pathAnimationManager.StartAnimation();
LogManager.Info($"开始物体移动动画播放: {CurrentPathRoute.Name}, 帧率: {SelectedFrameRate}fps");
@ -1167,6 +1166,25 @@ namespace NavisworksTransport.UI.WPF.ViewModels
{
try
{
// 自动调整视角到路径中心
try
{
var coreRoute = CurrentPathRoute?.Route;
if (coreRoute != null)
{
ViewpointHelper.AdjustViewpointToPathCenter(coreRoute);
LogManager.Info($"正向播放前:已自动调整视角到路径中心: {CurrentPathRoute.Name}");
}
else
{
LogManager.Warning($"正向播放前CurrentPathRoute.Route 为 null");
}
}
catch (Exception ex)
{
LogManager.Error($"正向播放前:调整视角失败: {ex.Message}");
}
_pathAnimationManager?.PlayForward();
UpdateMediaControlProperties();
LogManager.Info("执行正向播放命令");
@ -1185,6 +1203,25 @@ namespace NavisworksTransport.UI.WPF.ViewModels
{
try
{
// 自动调整视角到路径中心
try
{
var coreRoute = CurrentPathRoute?.Route;
if (coreRoute != null)
{
ViewpointHelper.AdjustViewpointToPathCenter(coreRoute);
LogManager.Info($"反向播放前:已自动调整视角到路径中心: {CurrentPathRoute.Name}");
}
else
{
LogManager.Warning($"反向播放前CurrentPathRoute.Route 为 null");
}
}
catch (Exception ex)
{
LogManager.Error($"反向播放前:调整视角失败: {ex.Message}");
}
_pathAnimationManager?.PlayReverse();
UpdateMediaControlProperties();
LogManager.Info("执行反向播放命令");
@ -1395,9 +1432,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 同步路径到 PathAnimationManager
if (pathRoute != null && _pathAnimationManager != null)
{
// 从 PathPlanningManager 获取对应的 PathRoute 对象
var pathPlanningManager = PathPlanningManager.Instance;
var coreRoute = pathPlanningManager.GetAllRoutes().FirstOrDefault(r => r.Id == pathRoute.Id);
// 直接使用 PathRouteViewModel 的 Route 属性
var coreRoute = pathRoute.Route;
if (coreRoute != null)
{
_pathAnimationManager.SetRoute(coreRoute);
@ -2513,9 +2549,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
LogManager.Info($"[ExecuteGenerateAnimation] 准备创建动画: 路径名称='{CurrentPathRoute.Name}', ID='{CurrentPathRoute.Id}', " +
$"动画对象='{animatedObject.DisplayName}'");
// 从PathPlanningManager获取PathRoute对象
var pathPlanningManager = PathPlanningManager.Instance;
var pathRoute = pathPlanningManager.GetAllRoutes().FirstOrDefault(r => r.Id == CurrentPathRoute.Id);
// 直接使用 CurrentPathRoute.Route
var pathRoute = CurrentPathRoute.Route;
if (pathRoute == null)
{
@ -2794,7 +2829,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
// 刷新路径可视化以应用新的尺寸
var coreRoute = PathPlanningManager.Instance?.Routes?.FirstOrDefault(r => r.Id == CurrentPathRoute.Id);
var coreRoute = CurrentPathRoute.Route;
if (coreRoute != null)
{
PathPlanningManager.Instance.DrawRouteVisualization(coreRoute, isAutoPath: false);

View File

@ -132,6 +132,17 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 根据路径类型自动设置通行空间可视化
UpdatePassageSpaceVisualizationForPathType(coreRoute.PathType);
// 自动调整视角到路径中心
try
{
ViewpointHelper.AdjustViewpointToPathCenter(coreRoute);
LogManager.Info($"UI路径切换已自动调整视角到路径中心: {value.Name}");
}
catch (Exception ex)
{
LogManager.Error($"UI路径切换调整视角失败: {ex.Message}");
}
}
else
{

View File

@ -279,7 +279,7 @@ namespace NavisworksTransport.Utils
}
}
HighlightItems(PrecomputeCollisionResultsCategory, highlightItems);
HighlightItems(ClashDetectiveResultsCategory, highlightItems);
}
catch (Exception ex)
{