普通模式下图像算子拖动处理流程
This commit is contained in:
@@ -180,7 +180,7 @@ namespace XplorePlane.Services.MainViewport
|
|||||||
_currentDisplayInfo = _latestManualInfo;
|
_currentDisplayInfo = _latestManualInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Info("主界面已加载手动图像 {FileName}", fileName);
|
_logger.Info("[图像链路] MainViewportService.SetManualImage:已更新图像 {FileName},触发 StateChanged", fileName);
|
||||||
RaiseStateChanged();
|
RaiseStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -357,7 +357,12 @@ namespace XplorePlane.ViewModels
|
|||||||
|
|
||||||
private async Task ExecutePipelineAsync()
|
private async Task ExecutePipelineAsync()
|
||||||
{
|
{
|
||||||
if (SourceImage == null || IsExecuting) return;
|
if (SourceImage == null || IsExecuting)
|
||||||
|
{
|
||||||
|
_logger.Debug("[图像链路] ExecutePipelineAsync:跳过,SourceImage={HasImage},IsExecuting={IsExec}",
|
||||||
|
SourceImage != null, IsExecuting);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TryReportInvalidParameters())
|
if (TryReportInvalidParameters())
|
||||||
return;
|
return;
|
||||||
@@ -368,6 +373,7 @@ namespace XplorePlane.ViewModels
|
|||||||
|
|
||||||
IsExecuting = true;
|
IsExecuting = true;
|
||||||
SetInfoStatus("正在执行流水线...");
|
SetInfoStatus("正在执行流水线...");
|
||||||
|
_logger.Info("[图像链路] ExecutePipelineAsync:开始执行,节点数={Count}", PipelineNodes.Count);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -379,19 +385,23 @@ namespace XplorePlane.ViewModels
|
|||||||
|
|
||||||
PreviewImage = result;
|
PreviewImage = result;
|
||||||
SetInfoStatus("流水线执行完成");
|
SetInfoStatus("流水线执行完成");
|
||||||
|
_logger.Info("[图像链路] ExecutePipelineAsync:执行完成,准备发布 PipelinePreviewUpdatedEvent");
|
||||||
PublishPipelinePreviewUpdated(result, StatusMessage);
|
PublishPipelinePreviewUpdated(result, StatusMessage);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
SetInfoStatus("流水线执行已取消");
|
SetInfoStatus("流水线执行已取消");
|
||||||
|
_logger.Info("[图像链路] ExecutePipelineAsync:执行已取消");
|
||||||
}
|
}
|
||||||
catch (PipelineExecutionException ex)
|
catch (PipelineExecutionException ex)
|
||||||
{
|
{
|
||||||
SetErrorStatus($"执行失败:{ex.Message}");
|
SetErrorStatus($"执行失败:{ex.Message}");
|
||||||
|
_logger.Warn("[图像链路] ExecutePipelineAsync:执行失败 {Msg}", ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
SetErrorStatus($"执行错误:{ex.Message}");
|
SetErrorStatus($"执行错误:{ex.Message}");
|
||||||
|
_logger.Error(ex, "[图像链路] ExecutePipelineAsync:未预期异常");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -491,8 +501,13 @@ namespace XplorePlane.ViewModels
|
|||||||
|
|
||||||
private void PublishPipelinePreviewUpdated(BitmapSource bitmap, string statusMessage)
|
private void PublishPipelinePreviewUpdated(BitmapSource bitmap, string statusMessage)
|
||||||
{
|
{
|
||||||
if (bitmap == null) return;
|
if (bitmap == null)
|
||||||
|
{
|
||||||
|
_logger.Warn("[图像链路] PublishPipelinePreviewUpdated:bitmap 为 null,跳过发布");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Info("[图像链路] PublishPipelinePreviewUpdated:发布事件,statusMessage={Msg}", statusMessage);
|
||||||
_eventAggregator.GetEvent<PipelinePreviewUpdatedEvent>()
|
_eventAggregator.GetEvent<PipelinePreviewUpdatedEvent>()
|
||||||
.Publish(new PipelinePreviewUpdatedPayload(bitmap, statusMessage));
|
.Publish(new PipelinePreviewUpdatedPayload(bitmap, statusMessage));
|
||||||
}
|
}
|
||||||
@@ -502,6 +517,7 @@ namespace XplorePlane.ViewModels
|
|||||||
if (payload?.Image == null) return;
|
if (payload?.Image == null) return;
|
||||||
if (ReferenceEquals(SourceImage, payload.Image)) return;
|
if (ReferenceEquals(SourceImage, payload.Image)) return;
|
||||||
|
|
||||||
|
_logger.Info("[图像链路] OnManualImageLoaded:收到图像 {File},设置 SourceImage", payload.FileName);
|
||||||
SourceImage = payload.Image;
|
SourceImage = payload.Image;
|
||||||
PreviewImage = payload.Image;
|
PreviewImage = payload.Image;
|
||||||
SetInfoStatus($"已加载图像:{payload.FileName}");
|
SetInfoStatus($"已加载图像:{payload.FileName}");
|
||||||
@@ -514,8 +530,13 @@ namespace XplorePlane.ViewModels
|
|||||||
|
|
||||||
private void TriggerDebouncedExecution()
|
private void TriggerDebouncedExecution()
|
||||||
{
|
{
|
||||||
if (SourceImage == null) return;
|
if (SourceImage == null)
|
||||||
|
{
|
||||||
|
_logger.Debug("[图像链路] TriggerDebouncedExecution:SourceImage 为 null,跳过执行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Debug("[图像链路] TriggerDebouncedExecution:触发防抖执行,节点数={Count}", PipelineNodes.Count);
|
||||||
_debounceCts?.Cancel();
|
_debounceCts?.Cancel();
|
||||||
_debounceCts = new CancellationTokenSource();
|
_debounceCts = new CancellationTokenSource();
|
||||||
var token = _debounceCts.Token;
|
var token = _debounceCts.Token;
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ namespace XplorePlane.ViewModels
|
|||||||
_cncEditorViewModel.RunCncCommand.CanExecuteChanged += (s, e) => RunCncCommand.RaiseCanExecuteChanged();
|
_cncEditorViewModel.RunCncCommand.CanExecuteChanged += (s, e) => RunCncCommand.RaiseCanExecuteChanged();
|
||||||
_cncEditorViewModel.StopCncCommand.CanExecuteChanged += (s, e) => StopCncCommand.RaiseCanExecuteChanged();
|
_cncEditorViewModel.StopCncCommand.CanExecuteChanged += (s, e) => StopCncCommand.RaiseCanExecuteChanged();
|
||||||
|
|
||||||
|
_eventAggregator.GetEvent<PipelinePreviewUpdatedEvent>()
|
||||||
|
.Subscribe(OnPipelinePreviewUpdated, ThreadOption.UIThread);
|
||||||
|
|
||||||
NavigationTree = new ObservableCollection<object>();
|
NavigationTree = new ObservableCollection<object>();
|
||||||
|
|
||||||
NavigateHomeCommand = new DelegateCommand(OnNavigateHome);
|
NavigateHomeCommand = new DelegateCommand(OnNavigateHome);
|
||||||
@@ -416,7 +419,14 @@ namespace XplorePlane.ViewModels
|
|||||||
bitmap.EndInit();
|
bitmap.EndInit();
|
||||||
bitmap.Freeze();
|
bitmap.Freeze();
|
||||||
|
|
||||||
|
_logger.Info("[图像链路] ExecuteLoadImage:加载图像 {Path},准备推送到 MainViewportService 和 ManualImageLoadedEvent", dialog.FileName);
|
||||||
_mainViewportService.SetManualImage(bitmap, dialog.FileName);
|
_mainViewportService.SetManualImage(bitmap, dialog.FileName);
|
||||||
|
|
||||||
|
// 同时发布事件,让 PipelineEditorViewModel 收到图像并触发流水线执行
|
||||||
|
_eventAggregator.GetEvent<ManualImageLoadedEvent>()
|
||||||
|
.Publish(new ManualImageLoadedPayload(bitmap, dialog.FileName));
|
||||||
|
_logger.Info("[图像链路] ManualImageLoadedEvent 已发布");
|
||||||
|
|
||||||
RaisePropertyChanged(nameof(IsUsingLiveDetectorSource));
|
RaisePropertyChanged(nameof(IsUsingLiveDetectorSource));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -553,5 +563,16 @@ namespace XplorePlane.ViewModels
|
|||||||
RaisePropertyChanged(nameof(IsUsingLiveDetectorSource));
|
RaisePropertyChanged(nameof(IsUsingLiveDetectorSource));
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPipelinePreviewUpdated(PipelinePreviewUpdatedPayload payload)
|
||||||
|
{
|
||||||
|
if (payload?.Image == null)
|
||||||
|
{
|
||||||
|
_logger.Warn("[图像链路] OnPipelinePreviewUpdated:payload 或 Image 为 null,跳过");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.Info("[图像链路] OnPipelinePreviewUpdated:收到流水线结果图像,推送到 MainViewportService");
|
||||||
|
_mainViewportService.SetManualImage(payload.Image, string.Empty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user