BGA自动检测工具:BGA检测结果以半透明图层叠加在canvas上、添加图标,统一按钮样式
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user