修复一些日志警告
This commit is contained in:
parent
eec957ad2e
commit
749eb07cef
@ -567,6 +567,13 @@ namespace NavisworksTransport.Core.Animation
|
||||
/// <param name="pathPoints">路径点(可选,如果不提供则使用当前的_pathPoints)</param>
|
||||
public void MoveObjectToPathStart(ModelItem animatedObject = null, List<Point3D> pathPoints = null)
|
||||
{
|
||||
// 前置检查:必须有路径
|
||||
if (_route == null)
|
||||
{
|
||||
LogManager.Error("[MoveObjectToPathStart] 路径为空,无法移动物体到路径起点");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 🔥 重要:先恢复物体到原始状态(CAD位置和原始朝向),确保每次计算都从相同的状态开始
|
||||
@ -609,7 +616,7 @@ namespace NavisworksTransport.Core.Animation
|
||||
LogManager.Info($"[移动到起点] 路径方向yaw: {pathDirectionYaw * 180 / Math.PI:F2}度, 角度修正: {_objectRotationCorrection:F1}度");
|
||||
|
||||
// 根据路径类型调整朝向
|
||||
if (_route?.PathType == PathType.Hoisting)
|
||||
if (_route.PathType == PathType.Hoisting)
|
||||
{
|
||||
// 吊装路径:使用水平吊运方向(与通行空间方向一致)
|
||||
// 从第2个路径点(提升点)到第3个路径点(平移终点)的水平方向
|
||||
@ -633,13 +640,13 @@ namespace NavisworksTransport.Core.Animation
|
||||
|
||||
// 根据路径类型调整起点位置
|
||||
Point3D startPosition = _pathPoints[0];
|
||||
if (_route?.PathType == PathType.Hoisting)
|
||||
if (_route.PathType == PathType.Hoisting)
|
||||
{
|
||||
// 吊装路径:第一个路径点(起吊点)是地面位置,物体底面应该在这里
|
||||
// 不需要向下移动物体高度
|
||||
LogManager.Debug($"[移动到起点] 吊装路径:起吊点是地面位置,物体底面Z={startPosition.Z:F2}");
|
||||
}
|
||||
else if (_route?.PathType == PathType.Rail)
|
||||
else if (_route.PathType == PathType.Rail)
|
||||
{
|
||||
// 空轨路径:路径点是悬挂点,物体悬挂在下方
|
||||
double objectHeight = _animatedObject.BoundingBox().Max.Z - _animatedObject.BoundingBox().Min.Z;
|
||||
@ -655,43 +662,8 @@ namespace NavisworksTransport.Core.Animation
|
||||
// 使用 UpdateObjectPosition 统一处理移动和旋转
|
||||
UpdateObjectPosition(startPosition, yaw);
|
||||
|
||||
string pathTypeName;
|
||||
if (_route?.PathType == PathType.Rail)
|
||||
{
|
||||
pathTypeName = "空轨";
|
||||
}
|
||||
else if (_route?.PathType == PathType.Hoisting)
|
||||
{
|
||||
pathTypeName = "吊装";
|
||||
}
|
||||
else
|
||||
{
|
||||
pathTypeName = "地面";
|
||||
}
|
||||
|
||||
string pathTypeName = _route.PathType.GetDisplayName();
|
||||
LogManager.Info($"物体已初始化到路径起点并对齐朝向: pos=({startPosition.X:F2},{startPosition.Y:F2},{startPosition.Z:F2}), yaw={yaw:F3}rad, 路径类型={pathTypeName}");
|
||||
|
||||
// 打印实际物体的位置和方向
|
||||
if (_animatedObject != null)
|
||||
{
|
||||
var bbox = _animatedObject.BoundingBox();
|
||||
var actualCenter = bbox.Center;
|
||||
var actualYaw = ModelItemTransformHelper.GetYawFromTransform(_animatedObject.Transform);
|
||||
LogManager.Info($"实际物体位置: X={actualCenter.X:F2}, Y={actualCenter.Y:F2}, Z={actualCenter.Z:F2}");
|
||||
LogManager.Info($"实际物体朝向: {actualYaw * 180 / Math.PI:F2}度");
|
||||
}
|
||||
else if (_isVirtualObject)
|
||||
{
|
||||
var virtualObject = VirtualObjectManager.Instance.CurrentVirtualObject;
|
||||
if (virtualObject != null)
|
||||
{
|
||||
var bbox = virtualObject.BoundingBox();
|
||||
var actualCenter = bbox.Center;
|
||||
var actualYaw = ModelItemTransformHelper.GetYawFromTransform(virtualObject.Transform);
|
||||
LogManager.Info($"虚拟物体位置: X={actualCenter.X:F2}, Y={actualCenter.Y:F2}, Z={actualCenter.Z:F2}");
|
||||
LogManager.Info($"虚拟物体朝向: {actualYaw * 180 / Math.PI:F2}度");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -766,20 +738,7 @@ namespace NavisworksTransport.Core.Animation
|
||||
double metersToModelUnits = UnitsConverter.GetMetersToUnitsConversionFactor();
|
||||
double totalLengthInModelUnits = _route.TotalLength * metersToModelUnits;
|
||||
|
||||
string pathTypeName;
|
||||
if (_route.PathType == PathType.Rail)
|
||||
{
|
||||
pathTypeName = "空轨";
|
||||
}
|
||||
else if (_route.PathType == PathType.Hoisting)
|
||||
{
|
||||
pathTypeName = "吊装";
|
||||
}
|
||||
else
|
||||
{
|
||||
pathTypeName = "地面";
|
||||
}
|
||||
|
||||
string pathTypeName = _route.PathType.GetDisplayName();
|
||||
LogManager.Info($"路径总长度: {totalLengthInModelUnits / metersToModelUnits:F2}米, 采样点数: {allSampledPoints.Count}, 路径类型: {pathTypeName}");
|
||||
|
||||
// 2. 按帧数采样生成动画帧
|
||||
@ -870,7 +829,7 @@ namespace NavisworksTransport.Core.Animation
|
||||
int segmentIndex = FindSegmentForDistance(targetDistance, segmentLengths);
|
||||
if (segmentIndex < 0 || segmentIndex >= segmentLengths.Count)
|
||||
{
|
||||
string subTypeName = _route.PathType == PathType.Rail ? "空轨" : "吊装";
|
||||
string subTypeName = _route.PathType.GetDisplayName();
|
||||
LogManager.Warning($"[{subTypeName}路径] 无法找到线段,目标距离:{targetDistance / metersToModelUnits:F2}米");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1590,6 +1590,13 @@ namespace NavisworksTransport
|
||||
PathType = pathType
|
||||
};
|
||||
_editingRoute = newRoute;
|
||||
|
||||
// 立即添加到路径集合,确保UI能正确找到Core路径
|
||||
if (!_routes.Contains(newRoute))
|
||||
{
|
||||
_routes.Add(newRoute);
|
||||
}
|
||||
|
||||
SetCurrentRouteInternal(newRoute, triggerEvent: true);
|
||||
|
||||
// 如果是吊装路径,清理吊装模式相关状态
|
||||
|
||||
@ -67,6 +67,30 @@ namespace NavisworksTransport
|
||||
Hoisting = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PathType枚举扩展方法
|
||||
/// </summary>
|
||||
public static class PathTypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取路径类型的中文名称
|
||||
/// </summary>
|
||||
public static string GetDisplayName(this PathType pathType)
|
||||
{
|
||||
switch (pathType)
|
||||
{
|
||||
case PathType.Ground:
|
||||
return "地面";
|
||||
case PathType.Rail:
|
||||
return "空轨";
|
||||
case PathType.Hoisting:
|
||||
return "吊装";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 吊装路径点方向类型
|
||||
/// 用于标识吊装路径中每个路径点的移动方向
|
||||
|
||||
@ -14,17 +14,7 @@ namespace NavisworksTransport.UI.WPF.Converters
|
||||
{
|
||||
if (value is NavisworksTransport.PathType pathType)
|
||||
{
|
||||
switch (pathType)
|
||||
{
|
||||
case NavisworksTransport.PathType.Ground:
|
||||
return "地面";
|
||||
case NavisworksTransport.PathType.Rail:
|
||||
return "空轨";
|
||||
case NavisworksTransport.PathType.Hoisting:
|
||||
return "吊装";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
return pathType.GetDisplayName();
|
||||
}
|
||||
return "地面";
|
||||
}
|
||||
|
||||
@ -2939,7 +2939,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 更新楼层属性相关的选择状态(使用新的选择结果)
|
||||
await UpdateFloorAttributeSelectionStateAsync(selectionResult);
|
||||
|
||||
LogManager.Info($"[LayerManagementViewModel] 选择状态已更新: {selectionResult.Count}个项目");
|
||||
LogManager.Debug($"[LayerManagementViewModel] 选择状态已更新: {selectionResult.Count}个项目");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -2979,7 +2979,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
OnPropertyChanged(nameof(CanSetFloorAttribute));
|
||||
OnPropertyChanged(nameof(CanClearFloorAttribute));
|
||||
|
||||
LogManager.Info($"[LayerManagementViewModel] 楼层属性选择状态已更新: 成功={selectionResult.Success}, 数量={selectionResult.Count}");
|
||||
LogManager.Debug($"[LayerManagementViewModel] 楼层属性选择状态已更新: 成功={selectionResult.Success}, 数量={selectionResult.Count}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -1224,7 +1224,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 更新物流属性相关的选择状态(使用新的选择结果)
|
||||
await UpdateModelSelectionStateAsync(selectionResult);
|
||||
|
||||
LogManager.Info($"[ModelSettingsViewModel] 选择状态已更新: {selectionResult.Count}个项目");
|
||||
LogManager.Debug($"[ModelSettingsViewModel] 选择状态已更新: {selectionResult.Count}个项目");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1264,7 +1264,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
OnPropertyChanged(nameof(CanSetLogisticsAttribute));
|
||||
OnPropertyChanged(nameof(CanClearLogisticsAttribute));
|
||||
|
||||
LogManager.Info($"[ModelSettingsViewModel] 模型选择状态已更新: 成功={selectionResult.Success}, 数量={selectionResult.Count}");
|
||||
LogManager.Debug($"[ModelSettingsViewModel] 模型选择状态已更新: 成功={selectionResult.Success}, 数量={selectionResult.Count}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -135,15 +135,22 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
_pathPlanningManager.SetCurrentRoute(coreRoute);
|
||||
LogManager.Info($"UI路径切换:已同步PathPlanningManager的CurrentRoute到 {value.Name}");
|
||||
|
||||
// 自动调整视角到路径中心
|
||||
try
|
||||
// 自动调整视角到路径中心(只有路径有点时才调整)
|
||||
if (coreRoute.Points.Count > 0)
|
||||
{
|
||||
ViewpointHelper.AdjustViewpointToPathCenter(coreRoute);
|
||||
LogManager.Info($"UI路径切换:已自动调整视角到路径中心: {value.Name}");
|
||||
try
|
||||
{
|
||||
ViewpointHelper.AdjustViewpointToPathCenter(coreRoute);
|
||||
LogManager.Info($"UI路径切换:已自动调整视角到路径中心: {value.Name}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"UI路径切换:调整视角失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
else
|
||||
{
|
||||
LogManager.Error($"UI路径切换:调整视角失败: {ex.Message}");
|
||||
LogManager.Info($"UI路径切换:路径还没有点,跳过视角调整: {value.Name}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user