修复祝贺对话框的bug
This commit is contained in:
parent
58e7b858f1
commit
f501b40dc4
@ -175,11 +175,6 @@ namespace NavisworksTransport.Core.Animation
|
||||
/// </summary>
|
||||
public event EventHandler<double> ProgressChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 当检测到碰撞时触发
|
||||
/// </summary>
|
||||
public event EventHandler<CollisionDetectedEventArgs> CollisionDetected;
|
||||
|
||||
public PathAnimationManager()
|
||||
{
|
||||
_pathPoints = new List<Point3D>();
|
||||
@ -1110,9 +1105,6 @@ namespace NavisworksTransport.Core.Animation
|
||||
LogManager.Info("TimeLiner 不可用,使用基础动画功能");
|
||||
}
|
||||
|
||||
// 设置碰撞检测转发(用于高亮显示和UI更新)
|
||||
SetupCollisionReportForwarding();
|
||||
|
||||
// 初始化动画状态
|
||||
_animationStartTime = DateTime.Now;
|
||||
_currentFrameIndex = 0; // 重置当前帧索引,确保从第一帧开始
|
||||
@ -1408,10 +1400,7 @@ namespace NavisworksTransport.Core.Animation
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManager.Info("无碰撞数据,跳过碰撞测试创建,但触发CollisionDetected事件以显示祝贺对话框");
|
||||
// 即使没有碰撞,也触发事件,让ViewModel决定是否显示祝贺对话框
|
||||
var eventArgs = new CollisionDetectedEventArgs(new List<CollisionResult>());
|
||||
OnCollisionDetected(eventArgs);
|
||||
LogManager.Info("无碰撞数据,跳过碰撞测试创建");
|
||||
}
|
||||
_completedCollisionTests.Add(_currentAnimationHash); // 记录此配置已完成碰撞检测
|
||||
LogManager.Info($"碰撞测试汇总已创建并记录,此配置后续播放将跳过碰撞检测");
|
||||
@ -1891,50 +1880,6 @@ namespace NavisworksTransport.Core.Animation
|
||||
return Transform3D.CreateTranslation(new Vector3D(center.X, center.Y, center.Z));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置碰撞报告转发(用于高亮显示和UI更新)
|
||||
/// </summary>
|
||||
private void SetupCollisionReportForwarding()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 订阅碰撞检测事件
|
||||
ClashDetectiveIntegration.Instance.CollisionDetected += OnClashDetectiveCollisionDetected;
|
||||
|
||||
LogManager.Info("碰撞报告转发设置完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"设置碰撞报告转发失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理 Clash Detective 碰撞检测事件
|
||||
/// </summary>
|
||||
private void OnClashDetectiveCollisionDetected(object sender, CollisionDetectedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 将碰撞结果转发到动画管理器的事件
|
||||
OnCollisionDetected(e);
|
||||
|
||||
LogManager.Debug($"Clash Detective 检测到 {e.CollisionCount} 个碰撞");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"处理 Clash Detective 碰撞事件失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发碰撞检测事件
|
||||
/// </summary>
|
||||
protected virtual void OnCollisionDetected(CollisionDetectedEventArgs e)
|
||||
{
|
||||
CollisionDetected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置动画持续时间
|
||||
/// </summary>
|
||||
@ -2616,13 +2561,6 @@ namespace NavisworksTransport.Core.Animation
|
||||
_lastHighlightState = currentHasCollision;
|
||||
_lastCollisionObjects = currentCollisionObjects;
|
||||
}
|
||||
|
||||
// 每次都触发碰撞事件(用于UI更新等)
|
||||
if (currentHasCollision)
|
||||
{
|
||||
var eventArgs = new CollisionDetectedEventArgs(currentFrame.Collisions);
|
||||
OnCollisionDetected(eventArgs);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -868,7 +868,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 订阅碰撞检测事件
|
||||
_clashIntegration.CollisionDetected += OnCollisionDetected;
|
||||
_clashIntegration.ClashDetectiveResultSaved += OnClashDetectiveResultSaved;
|
||||
_pathAnimationManager.CollisionDetected += OnAnimationCollisionDetected;
|
||||
|
||||
// 订阅文档状态事件
|
||||
DocumentStateManager.Instance.DocumentInvalidated += OnDocumentInvalidated;
|
||||
@ -1569,10 +1568,10 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有ClashDetective结果
|
||||
// 没有ClashDetective结果,显示祝贺对话框
|
||||
LogManager.Info("🎉 恭喜!本次动画未检测到任何碰撞,路径规划非常安全!");
|
||||
HasClashDetectiveResults = false;
|
||||
// 注意:不在这里显示祝贺对话框,只在OnCollisionDetected事件中显示
|
||||
ShowNoCollisionCongratulations();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -1656,30 +1655,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理PathAnimationManager的碰撞检测事件(只负责显示祝贺对话框)
|
||||
/// </summary>
|
||||
private void OnAnimationCollisionDetected(object sender, CollisionDetectedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var collisionCount = e.Results?.Count ?? 0;
|
||||
|
||||
if (collisionCount == 0)
|
||||
{
|
||||
// 无碰撞,显示祝贺对话框
|
||||
UpdateMainStatus("未发现碰撞");
|
||||
_lastGeneratedReport = null;
|
||||
ShowNoCollisionCongratulations();
|
||||
}
|
||||
// 有碰撞的情况由ClashDetectiveIntegration的OnCollisionDetected事件处理
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"处理PathAnimationManager碰撞检测事件失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ClashDetective结果保存事件处理
|
||||
/// </summary>
|
||||
@ -3311,19 +3286,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
if (_pathAnimationManager != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
_pathAnimationManager.CollisionDetected -= OnAnimationCollisionDetected;
|
||||
LogManager.Debug("PathAnimationManager碰撞检测事件订阅取消完成");
|
||||
}
|
||||
catch (Exception eventEx)
|
||||
{
|
||||
LogManager.Warning($"取消PathAnimationManager碰撞检测事件订阅时出现警告: {eventEx.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_manualCollisionTargets != null)
|
||||
{
|
||||
_manualCollisionTargets.CollectionChanged -= OnManualCollisionTargetsChanged;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user