diff --git a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs index 2222c99..917ae39 100644 --- a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs +++ b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs @@ -386,12 +386,14 @@ namespace XP.ImageProcessing.RoiControl.Controls private System.Windows.Media.Imaging.WriteableBitmap _bubbleMask; private int _bubbleThreshold = 128; private int _bubbleBrushSize = 5; + private double _bubbleVoidLimit = 25.0; private bool _bubbleBrushDragging; private readonly System.Collections.Generic.Stack _bubbleUndoStack = new(); public void SetBubbleTool(BubbleSubTool tool) => _bubbleTool = tool; public void SetBubbleThreshold(int val) => _bubbleThreshold = val; public void SetBubbleBrushSize(int val) => _bubbleBrushSize = val; + public void SetBubbleVoidLimit(double val) { _bubbleVoidLimit = val; UpdateBubbleResult(); } public Rect? BubbleRoi => _bubbleRoi; /// 设置 BGA 测量的气泡/焊球绘制模式 @@ -467,6 +469,14 @@ namespace XP.ImageProcessing.RoiControl.Controls _angleTempVDot = _angleTempADot = null; _angleTempLineA = null; _angleTempV = _angleTempA = null; _angleClickCount = 0; _mDraggingDot = null; _mDraggingOwner = null; + // 清理气泡测量状态 + _bubbleRoiRect = null; _bubbleRoiHandle = null; _bubbleResultLabel = null; + _bubbleMaskImage = null; _bubbleMask = null; + _bubbleRoi = null; _bubbleRoiStart = null; + _bubbleRoiDragging = false; _bubbleRoiMoving = false; + _bubbleRoiResizing = false; _bubbleBrushDragging = false; + _bubbleTool = BubbleSubTool.Roi; + _bubbleUndoStack.Clear(); } public void ClearMeasurements() => RemoveMeasureOverlay(); @@ -1287,8 +1297,8 @@ namespace XP.ImageProcessing.RoiControl.Controls // 更新 ROI 上方标签 if (_bubbleResultLabel != null) { - string cls = voidRate <= 25.0 ? "PASS" : "FAIL"; - _bubbleResultLabel.Text = $"Void: {voidRate:F1}% | {cls}"; + string cls = voidRate <= _bubbleVoidLimit ? "PASS" : "FAIL"; + _bubbleResultLabel.Text = $"Void: {voidRate:F1}% | Limit: {_bubbleVoidLimit:F1}% | {cls}"; _bubbleResultLabel.Foreground = cls == "PASS" ? Brushes.Lime : Brushes.Red; Canvas.SetLeft(_bubbleResultLabel, roi.X); Canvas.SetTop(_bubbleResultLabel, roi.Y - 20);