修复自动路径结束的状态bug
This commit is contained in:
parent
1ae3ace54e
commit
6efabb6dae
@ -911,8 +911,31 @@ namespace NavisworksTransport
|
||||
// 7. 自动绘制路径可视化
|
||||
DrawRouteVisualization(autoRoute, isAutoPath: true);
|
||||
|
||||
// 8. 触发事件
|
||||
// 8. 强制设置路径编辑状态为查看状态(修复状态问题)
|
||||
// 在所有事件触发之前设置状态,确保不会被后续操作重置
|
||||
LogManager.Info("自动路径规划完成,强制设置状态为Viewing");
|
||||
PathEditState = PathEditState.Viewing;
|
||||
EditingRoute = null; // 确保没有编辑中的路径
|
||||
|
||||
// 9. 触发事件
|
||||
RaiseRouteGenerated(autoRoute, RouteGenerationMethod.AutoPlanning, gridSize);
|
||||
|
||||
// 10. 最终确保状态正确(防御性编程)
|
||||
// 使用延迟执行确保在所有事件处理完成后状态仍然正确
|
||||
if (_uiStateManager != null)
|
||||
{
|
||||
_uiStateManager.QueueUIUpdate(() =>
|
||||
{
|
||||
LogManager.Info("延迟确保自动路径规划完成后状态为Viewing");
|
||||
if (PathEditState != PathEditState.Viewing)
|
||||
{
|
||||
LogManager.Warning($"检测到状态被意外修改为 {PathEditState},强制重置为Viewing");
|
||||
PathEditState = PathEditState.Viewing;
|
||||
EditingRoute = null;
|
||||
}
|
||||
}, UIUpdatePriority.Normal, forceSync: false);
|
||||
}
|
||||
|
||||
RaiseStatusChanged($"自动路径规划完成: {routeName},使用网格大小 {gridSize:F2}米", PathPlanningStatusType.Success);
|
||||
|
||||
LogManager.Info($"自动路径规划成功完成: 路径长度 {autoRoute.TotalLength:F2}米,包含 {autoRoute.Points.Count} 个点,使用网格大小 {gridSize:F2}米");
|
||||
|
||||
@ -2051,21 +2051,35 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
var pathViewModel = PathRoutes.FirstOrDefault(p => p.Name == e.Route.Name);
|
||||
if (pathViewModel != null)
|
||||
{
|
||||
// 检查是否需要更新:数量变化或名称/类型变化
|
||||
// 检查是否需要更新:数量变化或名称/类型/坐标变化
|
||||
bool needsUpdate = pathViewModel.Points.Count != e.Route.Points.Count;
|
||||
|
||||
if (!needsUpdate && pathViewModel.Points.Count == e.Route.Points.Count)
|
||||
{
|
||||
// 数量相同时,检查名称和类型是否有变化
|
||||
// 数量相同时,检查名称、类型和坐标是否有变化
|
||||
for (int i = 0; i < pathViewModel.Points.Count; i++)
|
||||
{
|
||||
var uiPoint = pathViewModel.Points[i];
|
||||
var corePoint = e.Route.Points[i];
|
||||
|
||||
// 检查名称和类型变化
|
||||
if (uiPoint.Name != corePoint.Name || uiPoint.Type != corePoint.Type)
|
||||
{
|
||||
needsUpdate = true;
|
||||
LogManager.Info($"检测到路径点变化: {uiPoint.Name}({uiPoint.Type}) -> {corePoint.Name}({corePoint.Type})");
|
||||
LogManager.Info($"检测到路径点属性变化: {uiPoint.Name}({uiPoint.Type}) -> {corePoint.Name}({corePoint.Type})");
|
||||
break;
|
||||
}
|
||||
|
||||
// 检查坐标变化(使用小数位精度比较)
|
||||
const double tolerance = 1e-6; // 1微米精度
|
||||
if (Math.Abs(uiPoint.X - corePoint.Position.X) > tolerance ||
|
||||
Math.Abs(uiPoint.Y - corePoint.Position.Y) > tolerance ||
|
||||
Math.Abs(uiPoint.Z - corePoint.Position.Z) > tolerance)
|
||||
{
|
||||
needsUpdate = true;
|
||||
LogManager.Info($"检测到路径点坐标变化: {uiPoint.Name} " +
|
||||
$"({uiPoint.X:F3}, {uiPoint.Y:F3}, {uiPoint.Z:F3}) -> " +
|
||||
$"({corePoint.Position.X:F3}, {corePoint.Position.Y:F3}, {corePoint.Position.Z:F3})");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user