From b966e0b8e8e8e0a1b7c9e82b858a8396ea4f1993 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Tue, 21 Apr 2026 12:56:22 +0800 Subject: [PATCH] =?UTF-8?q?#CNC=E6=A3=80=E6=B5=8B=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=A6=82=E5=BF=B5=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/Cnc/CncNodeViewModel.cs | 13 + .../PipelineEditorViewModel.cs | 12 +- XplorePlane/ViewModels/Main/MainViewModel.cs | 20 +- XplorePlane/Views/Cnc/CncEditorWindow.xaml | 4 +- XplorePlane/Views/Cnc/CncPageView.xaml | 316 +++--------------- XplorePlane/Views/Cnc/CncPageView.xaml.cs | 33 +- .../PipelineEditorView.xaml.cs | 25 +- XplorePlane/Views/Main/ImagePanelView.xaml | 2 +- XplorePlane/Views/Main/MainWindow.xaml | 6 +- XplorePlane/Views/Main/ViewportPanelView.xaml | 4 +- 10 files changed, 134 insertions(+), 301 deletions(-) diff --git a/XplorePlane/ViewModels/Cnc/CncNodeViewModel.cs b/XplorePlane/ViewModels/Cnc/CncNodeViewModel.cs index 886ba15..5b7516a 100644 --- a/XplorePlane/ViewModels/Cnc/CncNodeViewModel.cs +++ b/XplorePlane/ViewModels/Cnc/CncNodeViewModel.cs @@ -261,6 +261,18 @@ namespace XplorePlane.ViewModels.Cnc } } + public PipelineModel Pipeline + { + get => _model is InspectionModuleNode im ? im.Pipeline : null; + set + { + if (_model is InspectionModuleNode im) + { + UpdateModel(im with { Pipeline = value ?? new PipelineModel() }); + } + } + } + public string MarkerType { get => _model is InspectionMarkerNode mk ? mk.MarkerType : string.Empty; @@ -508,6 +520,7 @@ namespace XplorePlane.ViewModels.Cnc RaisePropertyChanged(nameof(FrameRate)); RaisePropertyChanged(nameof(Resolution)); RaisePropertyChanged(nameof(ImageFileName)); + RaisePropertyChanged(nameof(Pipeline)); RaisePropertyChanged(nameof(PipelineName)); RaisePropertyChanged(nameof(MarkerType)); RaisePropertyChanged(nameof(MarkerX)); diff --git a/XplorePlane/ViewModels/ImageProcessing/PipelineEditorViewModel.cs b/XplorePlane/ViewModels/ImageProcessing/PipelineEditorViewModel.cs index 6ba4b19..618f111 100644 --- a/XplorePlane/ViewModels/ImageProcessing/PipelineEditorViewModel.cs +++ b/XplorePlane/ViewModels/ImageProcessing/PipelineEditorViewModel.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; +using System.Windows.Input; using System.Windows.Media.Imaging; using XP.Common.Logging.Interfaces; using XplorePlane.Events; @@ -16,7 +17,7 @@ using XplorePlane.Services; namespace XplorePlane.ViewModels { - public class PipelineEditorViewModel : BindableBase + public class PipelineEditorViewModel : BindableBase, IPipelineEditorHostViewModel { private const int MaxPipelineLength = 20; private const int DebounceDelayMs = 300; @@ -165,6 +166,15 @@ namespace XplorePlane.ViewModels public DelegateCommand MoveNodeUpCommand { get; } public DelegateCommand MoveNodeDownCommand { get; } + ICommand IPipelineEditorHostViewModel.AddOperatorCommand => AddOperatorCommand; + ICommand IPipelineEditorHostViewModel.RemoveOperatorCommand => RemoveOperatorCommand; + ICommand IPipelineEditorHostViewModel.MoveNodeUpCommand => MoveNodeUpCommand; + ICommand IPipelineEditorHostViewModel.MoveNodeDownCommand => MoveNodeDownCommand; + ICommand IPipelineEditorHostViewModel.NewPipelineCommand => NewPipelineCommand; + ICommand IPipelineEditorHostViewModel.SavePipelineCommand => SavePipelineCommand; + ICommand IPipelineEditorHostViewModel.SaveAsPipelineCommand => SaveAsPipelineCommand; + ICommand IPipelineEditorHostViewModel.LoadPipelineCommand => LoadPipelineCommand; + // ── Command Implementations ─────────────────────────────────── private bool CanAddOperator(string operatorKey) => diff --git a/XplorePlane/ViewModels/Main/MainViewModel.cs b/XplorePlane/ViewModels/Main/MainViewModel.cs index 3891463..49d7349 100644 --- a/XplorePlane/ViewModels/Main/MainViewModel.cs +++ b/XplorePlane/ViewModels/Main/MainViewModel.cs @@ -21,6 +21,7 @@ namespace XplorePlane.ViewModels { public class MainViewModel : BindableBase { + private const double CncEditorHostWidth = 1162d; private readonly ILoggerService _logger; private readonly IContainerProvider _containerProvider; private readonly IEventAggregator _eventAggregator; @@ -92,6 +93,13 @@ namespace XplorePlane.ViewModels set => SetProperty(ref _imagePanelWidth, value); } + /// 主视图区宽度 | Main viewport width + public GridLength ViewportPanelWidth + { + get => _viewportPanelWidth; + set => SetProperty(ref _viewportPanelWidth, value); + } + // 窗口引用(单例窗口防止重复打开) private Window _motionDebugWindow; private Window _detectorConfigWindow; @@ -100,7 +108,8 @@ namespace XplorePlane.ViewModels private Window _toolboxWindow; private Window _raySourceConfigWindow; private object _imagePanelContent; - private GridLength _imagePanelWidth = new GridLength(350); + private GridLength _viewportPanelWidth = new GridLength(1, GridUnitType.Star); + private GridLength _imagePanelWidth = new GridLength(320); private bool _isCncEditorMode; public MainViewModel(ILoggerService logger, IContainerProvider containerProvider, IEventAggregator eventAggregator) @@ -156,7 +165,8 @@ namespace XplorePlane.ViewModels OpenRealTimeLogViewerCommand = new DelegateCommand(ExecuteOpenRealTimeLogViewer); ImagePanelContent = new PipelineEditorView(); - ImagePanelWidth = new GridLength(350); + ViewportPanelWidth = new GridLength(1, GridUnitType.Star); + ImagePanelWidth = new GridLength(320); _logger.Info("MainViewModel 已初始化"); } @@ -207,7 +217,8 @@ namespace XplorePlane.ViewModels if (_isCncEditorMode) { ImagePanelContent = new PipelineEditorView(); - ImagePanelWidth = new GridLength(350); + ViewportPanelWidth = new GridLength(1, GridUnitType.Star); + ImagePanelWidth = new GridLength(320); _isCncEditorMode = false; _logger.Info("已退出 CNC 编辑模式"); return; @@ -227,7 +238,8 @@ namespace XplorePlane.ViewModels private void ShowCncEditor() { ImagePanelContent = _cncPageView; - ImagePanelWidth = new GridLength(720); + ViewportPanelWidth = new GridLength(1, GridUnitType.Star); + ImagePanelWidth = new GridLength(CncEditorHostWidth); _isCncEditorMode = true; _logger.Info("CNC 编辑器已切换到主界面图像区域"); } diff --git a/XplorePlane/Views/Cnc/CncEditorWindow.xaml b/XplorePlane/Views/Cnc/CncEditorWindow.xaml index 1386766..a709fcf 100644 --- a/XplorePlane/Views/Cnc/CncEditorWindow.xaml +++ b/XplorePlane/Views/Cnc/CncEditorWindow.xaml @@ -4,9 +4,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cnc="clr-namespace:XplorePlane.Views.Cnc" Title="CNC 编辑器" - Width="1180" + Width="1040" Height="780" - MinWidth="1040" + MinWidth="960" MinHeight="720" ResizeMode="CanResize" ShowInTaskbar="False" diff --git a/XplorePlane/Views/Cnc/CncPageView.xaml b/XplorePlane/Views/Cnc/CncPageView.xaml index 10a65e5..f78ff2e 100644 --- a/XplorePlane/Views/Cnc/CncPageView.xaml +++ b/XplorePlane/Views/Cnc/CncPageView.xaml @@ -6,9 +6,10 @@ xmlns:local="clr-namespace:XplorePlane.Views.Cnc" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:prism="http://prismlibrary.com/" + xmlns:views="clr-namespace:XplorePlane.Views" xmlns:vm="clr-namespace:XplorePlane.ViewModels.Cnc" d:DesignHeight="760" - d:DesignWidth="1180" + d:DesignWidth="600" prism:ViewModelLocator.AutoWireViewModel="True" mc:Ignorable="d"> @@ -20,36 +21,8 @@ - - Microsoft YaHei UI - - - -