From fab0668da8b77ab2d25382b3dbfb4ae5bb3446ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= Date: Mon, 27 Apr 2026 14:29:54 +0800 Subject: [PATCH] =?UTF-8?q?BGA=E8=BE=85=E5=8A=A9=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=EF=BC=9A=E6=B0=94=E6=B3=A1/=E7=84=8A=E7=90=83=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E5=88=87=E6=8D=A2=E3=80=81VoidLimit=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E8=B0=83=E8=8A=82=E3=80=81=E5=8E=BB=E6=8E=89=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E7=BC=96=E8=BE=91=E3=80=81=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E7=BB=84=E6=B0=94=E6=B3=A1=E5=8F=AF=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controls/PolygonRoiCanvas.xaml.cs | 27 +++++-- XplorePlane/ViewModels/Main/MainViewModel.cs | 18 +++++ .../ImageProcessing/BgaMeasurePanel.xaml | 74 +++++++++++++++++++ .../ImageProcessing/BgaMeasurePanel.xaml.cs | 74 +++++++++++++++++++ 4 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 XplorePlane/Views/ImageProcessing/BgaMeasurePanel.xaml create mode 100644 XplorePlane/Views/ImageProcessing/BgaMeasurePanel.xaml.cs diff --git a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs index 1130f59..2222c99 100644 --- a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs +++ b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs @@ -394,6 +394,23 @@ namespace XP.ImageProcessing.RoiControl.Controls public void SetBubbleBrushSize(int val) => _bubbleBrushSize = val; public Rect? BubbleRoi => _bubbleRoi; + /// 设置 BGA 测量的气泡/焊球绘制模式 + public void SetBgaDrawBall(bool drawBall) + { + _bgaDrawBall = drawBall; + RaiseMeasureStatusChanged(drawBall ? "BGA - 画焊球模式" : "BGA - 画气泡模式"); + } + + /// 设置所有 BGA 组的 VoidLimit 并刷新标签 + public void SetBgaVoidLimit(double limit) + { + foreach (var g in _bgaGroups) + { + g.VoidLimit = limit; + g.UpdateLabel(); + } + } + // 拖拽状态 private Ellipse _mDraggingDot; private object _mDraggingOwner; @@ -722,9 +739,7 @@ namespace XP.ImageProcessing.RoiControl.Controls { _bgaCurrent = new Models.BgaVoidGroup(); var currentGroup = _bgaCurrent; // 局部变量供闭包捕获 - _bgaCurrent.Label = new TextBlock { FontSize = 13, FontWeight = FontWeights.Bold, Cursor = System.Windows.Input.Cursors.Hand, Visibility = Visibility.Collapsed }; - _bgaCurrent.Label.SetValue(ContextMenuService.IsEnabledProperty, false); - _bgaCurrent.Label.PreviewMouseRightButtonUp += (s, ev) => { ShowBgaLimitEditor(currentGroup); ev.Handled = true; }; + _bgaCurrent.Label = new TextBlock { FontSize = 13, FontWeight = FontWeights.Bold, IsHitTestVisible = false, Visibility = Visibility.Collapsed }; _measureOverlay.Children.Add(_bgaCurrent.Label); _bgaDrawBall = false; RaiseMeasureStatusChanged("BGA空隙 - 点击画气泡圆心(右键切换为画焊球)"); @@ -924,10 +939,12 @@ namespace XP.ImageProcessing.RoiControl.Controls if (g.E4BH == dot) { _mDraggingOwner = g; _mDraggingRole = "E4B"; break; } } } - // 查找 BGA 组 + // 查找 BGA 组(已完成的 + 正在编辑的) if (_mDraggingOwner == null) { - foreach (var g in _bgaGroups) + var allBga = new System.Collections.Generic.List(_bgaGroups); + if (_bgaCurrent != null) allBga.Add(_bgaCurrent); + foreach (var g in allBga) { if (g.Ball?.CenterDot == dot) { _mDraggingOwner = g; _mDraggingRole = "BallCenter"; break; } if (g.Ball?.EdgeDot == dot) { _mDraggingOwner = g; _mDraggingRole = "BallEdge"; break; } diff --git a/XplorePlane/ViewModels/Main/MainViewModel.cs b/XplorePlane/ViewModels/Main/MainViewModel.cs index d6e784e..44c4138 100644 --- a/XplorePlane/ViewModels/Main/MainViewModel.cs +++ b/XplorePlane/ViewModels/Main/MainViewModel.cs @@ -492,11 +492,29 @@ namespace XplorePlane.ViewModels _eventAggregator.GetEvent().Publish(MeasurementToolMode.ThroughHoleFillRate); } + private Window _bgaMeasurePanel; + private void ExecuteBgaVoidMeasure() { if (!CheckImageLoaded()) return; _logger.Info("BGA空隙测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.BgaVoid); + + if (_bgaMeasurePanel != null && _bgaMeasurePanel.IsVisible) + { + _bgaMeasurePanel.Activate(); + return; + } + + _bgaMeasurePanel = new Views.ImageProcessing.BgaMeasurePanel + { + Owner = System.Windows.Application.Current.MainWindow + }; + _bgaMeasurePanel.Closed += (s, e) => + { + _eventAggregator.GetEvent().Publish(MeasurementToolMode.None); + }; + _bgaMeasurePanel.Show(); } private Window _bubbleMeasurePanel; diff --git a/XplorePlane/Views/ImageProcessing/BgaMeasurePanel.xaml b/XplorePlane/Views/ImageProcessing/BgaMeasurePanel.xaml new file mode 100644 index 0000000..6467a2e --- /dev/null +++ b/XplorePlane/Views/ImageProcessing/BgaMeasurePanel.xaml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +