修改手动新建路径时的可视化bug
This commit is contained in:
parent
6cc48c3500
commit
3bae0f0274
@ -12,7 +12,7 @@
|
||||
6. [ ] (优化)优化路径规划分析和分析报告
|
||||
7. [ ] (功能)增加物流属性自定义
|
||||
8. [x] (BUG) 动画时物流车在起点时应该朝向路径方向,切换虚拟车辆和指定物体时,原有的要归位
|
||||
9. [ ] (功能)物流车在路径点转弯时,设置转弯半径等参数,将路径变成曲线
|
||||
9. [x] (功能)物流车在路径点转弯时,设置转弯半径等参数,将路径变成曲线
|
||||
|
||||
### [2025/12/18]
|
||||
|
||||
|
||||
@ -507,11 +507,16 @@ namespace NavisworksTransport
|
||||
LogManager.Info($"*** RaiseRouteGenerated被调用: {route?.Name}, Method: {generationMethod}, GridSize: {gridSize} ***");
|
||||
|
||||
// 在触发事件前,进行曲线化计算和保存
|
||||
if (route != null && route.Points.Count >= 2)
|
||||
// 注意:Manual方法不需要重新计算,因为PathPointsListUpdated已经计算过了
|
||||
if (route != null && route.Points.Count >= 2 && generationMethod != RouteGenerationMethod.Manual)
|
||||
{
|
||||
// 使用统一的曲线化和保存方法
|
||||
RecalculateAndSaveRoute(route, $"RouteGenerated({generationMethod})");
|
||||
}
|
||||
else if (generationMethod == RouteGenerationMethod.Manual)
|
||||
{
|
||||
LogManager.Info($"*** Manual方法跳过重新计算,PathPointsListUpdated已经计算过了 ***");
|
||||
}
|
||||
|
||||
var eventArgs = new RouteGeneratedEventArgs(route, generationMethod, gridSize, _managerId);
|
||||
|
||||
|
||||
@ -474,7 +474,10 @@ namespace NavisworksTransport
|
||||
/// <param name="graphics">图形上下文</param>
|
||||
public override void Render(View view, Graphics graphics)
|
||||
{
|
||||
if (!_isEnabled) return;
|
||||
if (!_isEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@ -482,7 +485,7 @@ namespace NavisworksTransport
|
||||
var activeDoc = Application.ActiveDocument;
|
||||
if (activeDoc?.Models == null || activeDoc.Models.Count == 0)
|
||||
{
|
||||
return; // 静默返回,避免日志泛滥
|
||||
return; // 静默返回
|
||||
}
|
||||
|
||||
// 检查是否有路径或预览点需要渲染
|
||||
@ -494,7 +497,10 @@ namespace NavisworksTransport
|
||||
hasPreviewPoint = _previewMarker != null;
|
||||
}
|
||||
|
||||
if (pathCount == 0 && !hasPreviewPoint) return;
|
||||
if (pathCount == 0 && !hasPreviewPoint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用BeginModelContext确保正确的渲染上下文
|
||||
graphics.BeginModelContext();
|
||||
@ -522,6 +528,10 @@ namespace NavisworksTransport
|
||||
graphics.Cylinder(controlLineMarker.StartPoint, controlLineMarker.EndPoint, controlLineMarker.Radius);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManager.Debug($"[Render] 路径 {visualization.PathId} 的 ShowControlVisualization 为 false,跳过控制点渲染");
|
||||
}
|
||||
|
||||
// 渲染真实路径可视化(根据模式选择)
|
||||
if (_visualizationMode == PathVisualizationMode.VehicleSpace)
|
||||
@ -2131,17 +2141,14 @@ namespace NavisworksTransport
|
||||
{
|
||||
try
|
||||
{
|
||||
// 使用静态变量实现简单的防抖机制
|
||||
var now = DateTime.Now;
|
||||
if ((now - _lastRefreshTime).TotalMilliseconds < 50) // 最小间隔50ms
|
||||
{
|
||||
return; // 忽略过于频繁的刷新请求
|
||||
}
|
||||
_lastRefreshTime = now;
|
||||
|
||||
if (Application.ActiveDocument?.ActiveView != null)
|
||||
{
|
||||
Application.ActiveDocument.ActiveView.RequestDelayedRedraw(ViewRedrawRequests.Render);
|
||||
LogManager.Debug($"[RequestViewRefresh] 已请求视图刷新");
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManager.Warning($"[RequestViewRefresh] 活动文档或视图为空,无法请求刷新");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@ -215,8 +215,20 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 0. 先同步车辆参数到渲染插件
|
||||
SyncVehicleParametersToRenderPlugin();
|
||||
|
||||
// 1. 清理现有的路径可视化,但保留网格可视化
|
||||
PathPointRenderPlugin.Instance.ClearPathsExcept("grid_visualization_all", "grid_visualization_channel", "grid_visualization_unknown", "grid_visualization_obstacle", "grid_visualization_door");
|
||||
// 检查是否在编辑状态
|
||||
bool isInEditMode = _pathPlanningManager?.IsInEditableState ?? false;
|
||||
|
||||
// 1. 清理现有的路径可视化,但保留网格可视化和正在编辑的路径
|
||||
if (isInEditMode)
|
||||
{
|
||||
// 在编辑状态,不清空路径,避免清空正在编辑的路径
|
||||
LogManager.Debug("[路径可视化] 在编辑状态,跳过清空路径可视化");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 不在编辑状态,清空所有路径可视化,但保留网格可视化
|
||||
PathPointRenderPlugin.Instance.ClearPathsExcept("grid_visualization_all", "grid_visualization_channel", "grid_visualization_unknown", "grid_visualization_obstacle", "grid_visualization_door");
|
||||
}
|
||||
|
||||
// 2. 如果有选中的路径,则显示该路径
|
||||
if (_selectedPathRoute != null && _selectedPathRoute.Points.Count > 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user