diff --git a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs index 2473333..8c1d4b3 100644 --- a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs +++ b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs @@ -477,9 +477,25 @@ namespace XP.ImageProcessing.RoiControl.Controls _bubbleRoiResizing = false; _bubbleBrushDragging = false; _bubbleTool = BubbleSubTool.Roi; _bubbleUndoStack.Clear(); + // 清理外部叠加的结果图层(IsHitTestVisible=false 的 Image,排除背景图) + var toRemove = new System.Collections.Generic.List(); + foreach (UIElement child in mainCanvas.Children) + { + if (child is Image img && img != backgroundImage && !img.IsHitTestVisible) + toRemove.Add(child); + } + foreach (var el in toRemove) + mainCanvas.Children.Remove(el); } public void ClearMeasurements() => RemoveMeasureOverlay(); + + /// 从 mainCanvas 移除指定的 UI 元素(用于外部叠加层清理) + public void RemoveFromCanvas(System.Windows.UIElement element) + { + if (element != null && mainCanvas.Children.Contains(element)) + mainCanvas.Children.Remove(element); + } public int MeasureCount => _ppGroups.Count + _ptlGroups.Count + _angleGroups.Count + _frGroups.Count + _bgaGroups.Count; // ── 点击分发 ── diff --git a/XplorePlane/Assets/Icons/ok.png b/XplorePlane/Assets/Icons/ok.png new file mode 100644 index 0000000..6794418 Binary files /dev/null and b/XplorePlane/Assets/Icons/ok.png differ diff --git a/XplorePlane/Assets/Icons/run32.png b/XplorePlane/Assets/Icons/run32.png new file mode 100644 index 0000000..e14143b Binary files /dev/null and b/XplorePlane/Assets/Icons/run32.png differ diff --git a/XplorePlane/ViewModels/ImageProcessing/BgaDetectionViewModel.cs b/XplorePlane/ViewModels/ImageProcessing/BgaDetectionViewModel.cs index 2db8a1e..d4870bc 100644 --- a/XplorePlane/ViewModels/ImageProcessing/BgaDetectionViewModel.cs +++ b/XplorePlane/ViewModels/ImageProcessing/BgaDetectionViewModel.cs @@ -94,6 +94,7 @@ namespace XplorePlane.ViewModels.ImageProcessing private PolygonRoiCanvas _canvas; private PolygonROI _roiShape; + private System.Windows.Controls.Image _resultOverlayImage; public void SetCanvas(PolygonRoiCanvas canvas) { @@ -215,6 +216,43 @@ namespace XplorePlane.ViewModels.ImageProcessing } _canvas.SelectedROI = null; } + // 关闭面板时不清除结果叠加层,保留显示 + } + + private void ShowResultOnOverlay(BitmapSource resultBmp) + { + if (_canvas == null || resultBmp == null) return; + + // 移除旧的结果图层 + RemoveResultOverlay(); + + // 创建新的结果图层叠加到 canvas 上(插入到背景图之后、ROI之前) + _resultOverlayImage = new System.Windows.Controls.Image + { + Source = resultBmp, + IsHitTestVisible = false, + Opacity = 0.85, + Stretch = System.Windows.Media.Stretch.Fill + }; + _resultOverlayImage.SetBinding(System.Windows.FrameworkElement.WidthProperty, + new System.Windows.Data.Binding("CanvasWidth") { Source = _canvas }); + _resultOverlayImage.SetBinding(System.Windows.FrameworkElement.HeightProperty, + new System.Windows.Data.Binding("CanvasHeight") { Source = _canvas }); + + var mainCanvas = _canvas.FindName("mainCanvas") as System.Windows.Controls.Canvas; + if (mainCanvas != null) + { + // 插入到索引1(背景图是索引0),这样ROI和测量overlay在上面 + int insertIndex = Math.Min(1, mainCanvas.Children.Count); + mainCanvas.Children.Insert(insertIndex, _resultOverlayImage); + } + } + + public void RemoveResultOverlay() + { + if (_resultOverlayImage == null || _canvas == null) return; + _canvas.RemoveFromCanvas(_resultOverlayImage); + _resultOverlayImage = null; } private string _resultText = "结果: --"; @@ -311,9 +349,8 @@ namespace XplorePlane.ViewModels.ImageProcessing // 绘制结果到图像 ResultImage = RenderResults(grayImage, output); - // 将结果图像推送到主界面显示 - if (ResultImage != null) - _viewportService?.SetManualImage(ResultImage, "BGA检测结果"); + // 将结果叠加到 canvas overlay 上 + ShowResultOnOverlay(ResultImage); grayImage.Dispose(); } diff --git a/XplorePlane/Views/ImageProcessing/BgaDetectionPanel.xaml b/XplorePlane/Views/ImageProcessing/BgaDetectionPanel.xaml index a2b6593..fb03f81 100644 --- a/XplorePlane/Views/ImageProcessing/BgaDetectionPanel.xaml +++ b/XplorePlane/Views/ImageProcessing/BgaDetectionPanel.xaml @@ -14,39 +14,81 @@ - - - - - - + + + + + + + + + + @@ -97,10 +139,6 @@ - -