优化碰撞高亮管理,使用类别管理方法替代直接高亮,调整预计算碰撞颜色为紫色以便区分
This commit is contained in:
parent
6498df1818
commit
dee5f1c834
@ -199,7 +199,11 @@ namespace NavisworksTransport.Commands
|
||||
var highlightIntegration = ClashDetectiveIntegration.Instance;
|
||||
if (highlightIntegration != null)
|
||||
{
|
||||
ModelHighlightHelper.HighlightCollisionResults(collisionData.AllCollisions, clearPrevious: false);
|
||||
// 使用 ClashDetectiveResultsCategory(深红色),不是预计算高亮
|
||||
ModelHighlightHelper.ManageCollisionHighlightsByCategory(
|
||||
ModelHighlightHelper.ClashDetectiveResultsCategory,
|
||||
collisionData.AllCollisions,
|
||||
clearOtherCategories: false);
|
||||
LogManager.Info($"碰撞报告生成前高亮 {collisionData.AllCollisions.Count} 个碰撞对象");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2691,7 +2691,7 @@ namespace NavisworksTransport.Core.Animation
|
||||
if (currentHasCollision)
|
||||
{
|
||||
// 有碰撞:高亮当前帧的碰撞对象(使用CollisionResultsCategory的默认颜色)
|
||||
ModelHighlightHelper.HighlightCollisionResults(currentFrame.Collisions);
|
||||
ModelHighlightHelper.ManageCollisionHighlightsByCategory(ModelHighlightHelper.PrecomputeCollisionResultsCategory, currentFrame.Collisions, clearOtherCategories: true);
|
||||
LogManager.Debug($"[高亮状态] 帧{_currentFrameIndex}: 高亮碰撞 ({currentFrame.Collisions.Count}个, 对象{currentCollisionObjects.Count}个)");
|
||||
}
|
||||
else
|
||||
|
||||
@ -2003,7 +2003,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
LogManager.Debug($"[预计算碰撞结果高亮] 碰撞{i+1}: {collision.DisplayName}, Item1={collision.Item1?.DisplayName}, Item2={collision.Item2?.DisplayName}");
|
||||
}
|
||||
|
||||
ModelHighlightHelper.HighlightCollisionResults(deduplicatedResults, clearPrevious: false);
|
||||
ModelHighlightHelper.ManageCollisionHighlightsByCategory(ModelHighlightHelper.PrecomputeCollisionResultsCategory, deduplicatedResults, clearOtherCategories: false);
|
||||
UpdateMainStatus($"已高亮 {deduplicatedResults.Count} 个去重预计算碰撞结果");
|
||||
LogManager.Info($"[预计算碰撞结果高亮] 已高亮 {deduplicatedResults.Count} 个结果");
|
||||
}
|
||||
|
||||
@ -954,13 +954,13 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
if (item?.CollisionData == null)
|
||||
return;
|
||||
|
||||
var clashIntegration = ClashDetectiveIntegration.Instance;
|
||||
if (clashIntegration != null)
|
||||
{
|
||||
var collisions = new List<CollisionResult> { item.CollisionData };
|
||||
ModelHighlightHelper.HighlightCollisionResults(collisions, clearPrevious: true);
|
||||
LogManager.Info($"高亮碰撞对象: {item.Title}");
|
||||
}
|
||||
// 使用 ClashDetectiveResultsCategory(深红色),不是预计算高亮
|
||||
var collisions = new List<CollisionResult> { item.CollisionData };
|
||||
ModelHighlightHelper.ManageCollisionHighlightsByCategory(
|
||||
ModelHighlightHelper.ClashDetectiveResultsCategory,
|
||||
collisions,
|
||||
clearOtherCategories: true);
|
||||
LogManager.Info($"高亮碰撞对象: {item.Title}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -43,7 +43,7 @@ namespace NavisworksTransport.Utils
|
||||
{ "report", Color.Green },
|
||||
{ "preview", Color.Blue },
|
||||
{ ManualTargetsCategory, Color.FromByteRGB(255, 170, 0) },
|
||||
{ PrecomputeCollisionResultsCategory, Color.FromByteRGB(244, 67, 54) }, // Material Red(预计算碰撞)
|
||||
{ PrecomputeCollisionResultsCategory, Color.FromByteRGB(156, 39, 176) }, // Material Purple #9C27B0(预计算碰撞,与红色/橙色明显区分)
|
||||
{ ChannelPreviewCategory, Color.Green },
|
||||
{ ClashDetectiveResultsCategory, Color.Red },
|
||||
{ AnimatedObjectCategory, Color.FromByteRGB(76, 175, 80) } // Material Green(动画车辆)
|
||||
@ -174,6 +174,14 @@ namespace NavisworksTransport.Utils
|
||||
|
||||
if (_categoryColors.TryGetValue(category, out var color))
|
||||
{
|
||||
// 调试用:输出预计算高亮颜色值(转换为0-255整数)
|
||||
if (category == PrecomputeCollisionResultsCategory)
|
||||
{
|
||||
int r = (int)(color.R * 255);
|
||||
int g = (int)(color.G * 255);
|
||||
int b = (int)(color.B * 255);
|
||||
LogManager.Debug($"[GetCategoryColor] 预计算高亮颜色: R={r}, G={g}, B={b} (#{r:X2}{g:X2}{b:X2})");
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -241,55 +249,6 @@ namespace NavisworksTransport.Utils
|
||||
#region 碰撞结果高亮相关方法
|
||||
|
||||
/// <summary>
|
||||
/// 高亮显示碰撞对象(使用类别默认颜色)
|
||||
/// </summary>
|
||||
/// <param name="results">碰撞结果列表</param>
|
||||
/// <param name="clearPrevious">是否清除之前的高亮</param>
|
||||
public static void HighlightCollisionResults(List<CollisionResult> results, bool clearPrevious = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var validResults = results?.Where(r => r != null).ToList() ?? new List<CollisionResult>();
|
||||
|
||||
if (validResults.Count == 0)
|
||||
{
|
||||
if (clearPrevious)
|
||||
{
|
||||
ClearCategory(PrecomputeCollisionResultsCategory);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (clearPrevious)
|
||||
{
|
||||
ClearCategory(PrecomputeCollisionResultsCategory);
|
||||
}
|
||||
|
||||
var highlightItems = new List<ModelItem>();
|
||||
foreach (var collision in validResults)
|
||||
{
|
||||
var item1 = collision.Item1;
|
||||
var item2 = collision.Item2;
|
||||
|
||||
// 只高亮被撞物体(Item2),排除车辆对象(Item1)
|
||||
// 车辆对象由 AnimatedObjectCategory 单独高亮为绿色
|
||||
if (item2 != null && !highlightItems.Contains(item2))
|
||||
{
|
||||
highlightItems.Add(item2);
|
||||
}
|
||||
}
|
||||
|
||||
HighlightItems(ClashDetectiveResultsCategory, highlightItems);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"高亮显示碰撞对象失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按类别管理碰撞结果高亮
|
||||
/// </summary>
|
||||
/// <param name="category">类别名称</param>
|
||||
/// <param name="results">碰撞结果列表</param>
|
||||
/// <param name="clearOtherCategories">是否清除其他类别</param>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user