可视化色系统一为Google Material Design配色,清除时也清除高亮
This commit is contained in:
parent
a3d1915dec
commit
15a3a29a28
@ -187,4 +187,5 @@ public class PathClickToolPlugin : ToolPlugin { }
|
||||
- **Debugging**: Use LogManager for centralized logging and the built-in log viewer dialog for log analysis
|
||||
- **2026 Features**: Test advanced animation capabilities, enhanced collision detection, and improved model handling
|
||||
- 在编码中,不要用回退或向后兼容的思路和步骤
|
||||
- 程序的日志在:C:\ProgramData\Autodesk\Navisworks Manage 2026\NavisworksTransport\logs\debug.log
|
||||
- 程序的日志在:C:\ProgramData\Autodesk\Navisworks Manage 2026\NavisworksTransport\logs\debug.log
|
||||
- 不要搞向后兼容
|
||||
@ -39,6 +39,99 @@ namespace NavisworksTransport
|
||||
AutoHeight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 渲染颜色类型枚举
|
||||
/// </summary>
|
||||
public enum RenderColorType
|
||||
{
|
||||
/// <summary>
|
||||
/// 路径起点颜色(绿色)
|
||||
/// </summary>
|
||||
StartPoint,
|
||||
|
||||
/// <summary>
|
||||
/// 路径终点颜色(红色)
|
||||
/// </summary>
|
||||
EndPoint,
|
||||
|
||||
/// <summary>
|
||||
/// 路径中间点颜色(洋红色)
|
||||
/// </summary>
|
||||
WayPoint,
|
||||
|
||||
/// <summary>
|
||||
/// 连线颜色(橙色)
|
||||
/// </summary>
|
||||
Line,
|
||||
|
||||
/// <summary>
|
||||
/// 车辆通行空间颜色(淡蓝色亚克力)
|
||||
/// </summary>
|
||||
VehicleSpace,
|
||||
|
||||
/// <summary>
|
||||
/// 预览点颜色(白色)
|
||||
/// </summary>
|
||||
PreviewPoint,
|
||||
|
||||
/// <summary>
|
||||
/// 预览连线颜色(灰色)
|
||||
/// </summary>
|
||||
PreviewLine,
|
||||
|
||||
/// <summary>
|
||||
/// 未到达终点颜色(深红色)
|
||||
/// </summary>
|
||||
UnreachedEndPoint,
|
||||
|
||||
/// <summary>
|
||||
/// 网格通道颜色(绿色)
|
||||
/// </summary>
|
||||
GridChannel,
|
||||
|
||||
/// <summary>
|
||||
/// 网格障碍物颜色(灰色)
|
||||
/// </summary>
|
||||
GridObstacle,
|
||||
|
||||
/// <summary>
|
||||
/// 网格未知区域颜色(红色)
|
||||
/// </summary>
|
||||
GridUnknown
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 渲染样式,包含颜色和透明度
|
||||
/// </summary>
|
||||
public struct RenderStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色
|
||||
/// </summary>
|
||||
public Color Color { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 透明度 (0.0 = 完全透明, 1.0 = 完全不透明)
|
||||
/// </summary>
|
||||
public double Alpha { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="color">颜色</param>
|
||||
/// <param name="alpha">透明度</param>
|
||||
public RenderStyle(Color color, double alpha)
|
||||
{
|
||||
Color = color;
|
||||
Alpha = alpha;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"RenderStyle[Color={Color}, Alpha={Alpha:F2}]";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 车辆通行空间标记,用于渲染车辆通道空间
|
||||
/// </summary>
|
||||
@ -702,7 +795,7 @@ namespace NavisworksTransport
|
||||
{
|
||||
StartPoint = currentPoint.Position,
|
||||
EndPoint = nextPoint.Position,
|
||||
Color = GetLineColor(),
|
||||
Color = GetRenderColor(RenderColorType.Line),
|
||||
Radius = GetLineRadius(),
|
||||
FromIndex = currentPoint.Index,
|
||||
ToIndex = nextPoint.Index
|
||||
@ -727,13 +820,14 @@ namespace NavisworksTransport
|
||||
if (!visualization.PathRoute.IsComplete && visualization.PathRoute.OriginalEndPoint != null)
|
||||
{
|
||||
var originalEndPoint = visualization.PathRoute.OriginalEndPoint;
|
||||
var unreachedStyle = GetRenderStyle(RenderColorType.UnreachedEndPoint);
|
||||
var grayEndMarker = new CircleMarker
|
||||
{
|
||||
Center = originalEndPoint,
|
||||
Normal = new Vector3D(0, 0, 1),
|
||||
Radius = GetRadiusForPointType(PathPointType.EndPoint),
|
||||
Color = Color.FromByteRGB(139, 0, 0), // 深红色
|
||||
Alpha = 0.7, // 半透明效果
|
||||
Color = unreachedStyle.Color, // 未到达终点颜色
|
||||
Alpha = unreachedStyle.Alpha, // 透明度,统一管理
|
||||
Filled = true,
|
||||
PointType = PathPointType.EndPoint,
|
||||
SequenceNumber = -1, // 特殊序号表示这是未到达的终点
|
||||
@ -775,14 +869,15 @@ namespace NavisworksTransport
|
||||
vehicleSpaceHeightInMeters = Math.Max(vehicleSpaceHeightInMeters, _vehicleHeight + _safetyMargin); // 确保不小于车辆高度
|
||||
}
|
||||
|
||||
var style = GetRenderStyle(RenderColorType.VehicleSpace);
|
||||
return new VehicleSpaceMarker
|
||||
{
|
||||
StartPoint = fromPoint.Position,
|
||||
EndPoint = toPoint.Position,
|
||||
Width = vehicleInflationWidthInMeters * metersToModelUnits, // 转换为模型单位
|
||||
Height = vehicleSpaceHeightInMeters * metersToModelUnits, // 转换为模型单位
|
||||
Color = GetLineColor(), // 使用与连线相同的颜色
|
||||
Alpha = 0.5, // 50%透明度
|
||||
Color = style.Color, // 车辆通行空间颜色
|
||||
Alpha = style.Alpha, // 透明度,统一管理
|
||||
FromIndex = fromPoint.Index,
|
||||
ToIndex = toPoint.Index
|
||||
};
|
||||
@ -798,41 +893,40 @@ namespace NavisworksTransport
|
||||
// 检查是否是网格可视化点(通过名称判断)
|
||||
bool isGridVisualization = point.Name.StartsWith("网格(") || point.Name.StartsWith("网格_");
|
||||
|
||||
// 确定网格点颜色
|
||||
Color gridColor = Color.Green; // 默认绿色
|
||||
// 确定网格点样式(颜色+透明度)
|
||||
RenderStyle gridStyle = new RenderStyle(Color.White, 1.0); // 默认样式
|
||||
if (isGridVisualization)
|
||||
{
|
||||
// 根据网格类型确定颜色
|
||||
// 根据网格类型确定样式
|
||||
if (point.Name.Contains("空洞") || point.Name.Contains("Unknown"))
|
||||
{
|
||||
gridColor = Color.Red;
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridUnknown);
|
||||
}
|
||||
else if (point.Name.Contains("障碍") || point.Name.Contains("Obstacle"))
|
||||
{
|
||||
gridColor = Color.FromByteRGB(128, 128, 128); // 灰色
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridObstacle);
|
||||
}
|
||||
else if (point.Name.Contains("通道") || point.Name.Contains("Channel") || point.Name.Contains("开放"))
|
||||
{
|
||||
gridColor = Color.Green;
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridChannel);
|
||||
}
|
||||
// 也可以通过Notes字段检查
|
||||
else if (!string.IsNullOrEmpty(point.Notes) && point.Notes.StartsWith("GridType:"))
|
||||
{
|
||||
var gridTypeStr = point.Notes.Substring(9); // 去掉"GridType:"前缀
|
||||
if (gridTypeStr == "Unknown")
|
||||
gridColor = Color.Red;
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridUnknown);
|
||||
else if (gridTypeStr == "Obstacle")
|
||||
gridColor = Color.FromByteRGB(128, 128, 128); // 灰色
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridObstacle);
|
||||
else
|
||||
gridColor = Color.Green;
|
||||
gridStyle = GetRenderStyle(RenderColorType.GridChannel);
|
||||
}
|
||||
|
||||
// 门网格点使用50%透明度覆盖默认透明度
|
||||
if (point.Name.Contains("门"))
|
||||
{
|
||||
gridStyle = new RenderStyle(gridStyle.Color, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
// 确定透明度
|
||||
double alpha = 1.0;
|
||||
if (isGridVisualization && point.Name.Contains("门"))
|
||||
{
|
||||
alpha = 0.5; // 门网格点使用50%透明度
|
||||
}
|
||||
|
||||
return new CircleMarker
|
||||
@ -840,8 +934,8 @@ namespace NavisworksTransport
|
||||
Center = point.Position,
|
||||
Normal = new Vector3D(0, 0, 1),
|
||||
Radius = isGridVisualization ? GetRadiusForGridVisualization(_currentGridSizeInMeters) : GetRadiusForPointType(point.Type),
|
||||
Color = isGridVisualization ? gridColor : GetColorForPointType(point.Type),
|
||||
Alpha = alpha,
|
||||
Color = isGridVisualization ? gridStyle.Color : GetColorForPointType(point.Type),
|
||||
Alpha = isGridVisualization ? gridStyle.Alpha : 1.0,
|
||||
Filled = true,
|
||||
PointType = point.Type,
|
||||
SequenceNumber = point.Index, // 使用Index而不是任意序号
|
||||
@ -896,15 +990,68 @@ namespace NavisworksTransport
|
||||
}
|
||||
}
|
||||
|
||||
#region 颜色管理
|
||||
|
||||
/// <summary>
|
||||
/// 获取连线颜色(统一使用橙色)
|
||||
/// 根据颜色类型获取对应的渲染样式(颜色+透明度)
|
||||
/// </summary>
|
||||
/// <returns>连线颜色</returns>
|
||||
private Color GetLineColor()
|
||||
/// <param name="colorType">颜色类型</param>
|
||||
/// <returns>对应的渲染样式</returns>
|
||||
private RenderStyle GetRenderStyle(RenderColorType colorType)
|
||||
{
|
||||
return Color.FromByteRGB(255, 165, 0); // 统一使用橙色连线
|
||||
switch (colorType)
|
||||
{
|
||||
case RenderColorType.StartPoint:
|
||||
return new RenderStyle(Color.FromByteRGB(76, 175, 80), 0.9); // Material Green起点,10%透明
|
||||
|
||||
case RenderColorType.EndPoint:
|
||||
return new RenderStyle(Color.FromByteRGB(244, 67, 54), 0.9); // Material Red终点,10%透明
|
||||
|
||||
case RenderColorType.WayPoint:
|
||||
return new RenderStyle(Color.FromByteRGB(33, 150, 243), 0.9); // Material Blue路径点,10%透明
|
||||
|
||||
case RenderColorType.Line:
|
||||
return new RenderStyle(Color.FromByteRGB(255, 152, 0), 0.85); // Material Orange连线,15%透明
|
||||
|
||||
case RenderColorType.VehicleSpace:
|
||||
return new RenderStyle(Color.FromByteRGB(158, 158, 158), 0.4); // Material Grey车辆空间,60%透明
|
||||
|
||||
case RenderColorType.PreviewPoint:
|
||||
return new RenderStyle(Color.White, 0.7); // 白色预览点,30%透明
|
||||
|
||||
case RenderColorType.PreviewLine:
|
||||
return new RenderStyle(Color.FromByteRGB(128, 128, 128), 0.7); // 灰色预览连线,30%透明
|
||||
|
||||
case RenderColorType.UnreachedEndPoint:
|
||||
return new RenderStyle(Color.FromByteRGB(139, 0, 0), 0.7); // 深红色未到达终点,30%透明
|
||||
|
||||
case RenderColorType.GridChannel:
|
||||
return new RenderStyle(Color.FromByteRGB(129, 199, 132), 0.8); // Material Light Green网格通道,20%透明
|
||||
|
||||
case RenderColorType.GridObstacle:
|
||||
return new RenderStyle(Color.FromByteRGB(117, 117, 117), 0.8); // Material Grey网格障碍物,20%透明
|
||||
|
||||
case RenderColorType.GridUnknown:
|
||||
return new RenderStyle(Color.FromByteRGB(255, 112, 67), 0.8); // Material Deep Orange网格未知区域,20%透明
|
||||
|
||||
default:
|
||||
return new RenderStyle(Color.White, 1.0); // 默认白色,完全不透明
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据颜色类型获取对应的颜色(向后兼容方法)
|
||||
/// </summary>
|
||||
/// <param name="colorType">颜色类型</param>
|
||||
/// <returns>对应的颜色</returns>
|
||||
private Color GetRenderColor(RenderColorType colorType)
|
||||
{
|
||||
return GetRenderStyle(colorType).Color;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取连线半径
|
||||
/// </summary>
|
||||
@ -1099,16 +1246,17 @@ namespace NavisworksTransport
|
||||
|
||||
// 获取适当的半径
|
||||
double radius = GetRadiusForPointType(previewPoint.Type);
|
||||
|
||||
// 使用白色作为预览点颜色(灰色在Navisworks API中不可用)
|
||||
Color previewColor = Color.White;
|
||||
|
||||
|
||||
// 获取预览点样式(颜色+透明度)
|
||||
var previewStyle = GetRenderStyle(RenderColorType.PreviewPoint);
|
||||
|
||||
// 创建预览点标记
|
||||
_previewMarker = new CircleMarker
|
||||
{
|
||||
Position = previewPoint.Position,
|
||||
Radius = radius,
|
||||
Color = previewColor,
|
||||
Color = previewStyle.Color,
|
||||
Alpha = previewStyle.Alpha,
|
||||
IsVisible = true,
|
||||
PathPoint = previewPoint
|
||||
};
|
||||
@ -1189,7 +1337,7 @@ namespace NavisworksTransport
|
||||
{
|
||||
StartPoint = prevPoint.Position,
|
||||
EndPoint = previewPoint.Position,
|
||||
Color = Color.FromByteRGB(128, 128, 128), // 统一使用灰色预览连线
|
||||
Color = GetRenderColor(RenderColorType.PreviewLine), // 预览连线颜色
|
||||
Radius = GetLineRadius() // 使用与正常连线相同的直径
|
||||
};
|
||||
_previewLines.Add(line1);
|
||||
@ -1199,7 +1347,7 @@ namespace NavisworksTransport
|
||||
{
|
||||
StartPoint = previewPoint.Position,
|
||||
EndPoint = nextPoint.Position,
|
||||
Color = Color.FromByteRGB(128, 128, 128), // 统一使用灰色预览连线
|
||||
Color = GetRenderColor(RenderColorType.PreviewLine), // 预览连线颜色
|
||||
Radius = GetLineRadius()
|
||||
};
|
||||
_previewLines.Add(line2);
|
||||
@ -1296,7 +1444,7 @@ namespace NavisworksTransport
|
||||
{
|
||||
StartPoint = prevPoint.Position,
|
||||
EndPoint = previewPoint.Position,
|
||||
Color = Color.FromByteRGB(128, 128, 128), // 灰色预览连线
|
||||
Color = GetRenderColor(RenderColorType.PreviewLine), // 预览连线颜色
|
||||
Radius = GetLineRadius()
|
||||
};
|
||||
_previewLines.Add(line1);
|
||||
@ -1310,7 +1458,7 @@ namespace NavisworksTransport
|
||||
{
|
||||
StartPoint = previewPoint.Position,
|
||||
EndPoint = nextPoint.Position,
|
||||
Color = Color.FromByteRGB(128, 128, 128), // 灰色预览连线
|
||||
Color = GetRenderColor(RenderColorType.PreviewLine), // 预览连线颜色
|
||||
Radius = GetLineRadius()
|
||||
};
|
||||
_previewLines.Add(line2);
|
||||
@ -1473,12 +1621,12 @@ namespace NavisworksTransport
|
||||
switch (pointType)
|
||||
{
|
||||
case PathPointType.StartPoint:
|
||||
return Color.Green; // 起点绿色
|
||||
return GetRenderColor(RenderColorType.StartPoint); // 起点绿色
|
||||
case PathPointType.EndPoint:
|
||||
return Color.Red; // 终点红色
|
||||
return GetRenderColor(RenderColorType.EndPoint); // 终点红色
|
||||
case PathPointType.WayPoint:
|
||||
default:
|
||||
return new Color(1.0, 0.0, 1.0); // 路径点洋红色RGB(1,0,1) - 高对比度避免与蓝色通道冲突
|
||||
return GetRenderColor(RenderColorType.WayPoint); // 路径中间点洋红色
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1185,7 +1185,18 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 清理碰撞检测结果
|
||||
HasCollisionResults = false;
|
||||
UpdateMainStatus("碰撞检测重置");
|
||||
|
||||
|
||||
// 清除高亮构件
|
||||
try
|
||||
{
|
||||
_clashIntegration?.ClearHighlights();
|
||||
LogManager.Info("已清除高亮构件");
|
||||
}
|
||||
catch (Exception highlightEx)
|
||||
{
|
||||
LogManager.Warning($"清除高亮构件时出现警告: {highlightEx.Message}");
|
||||
}
|
||||
|
||||
// 更新按钮状态 - 清除动画后应该重新评估按钮状态
|
||||
UpdateAnimationButtonStates();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user