气泡测量: 修复清除后无法再次使用、VoidLimit同步、调整ROI后重新计算

This commit is contained in:
李伟
2026-04-28 14:39:14 +08:00
parent 1822e15908
commit 9d059709bd
@@ -386,12 +386,14 @@ namespace XP.ImageProcessing.RoiControl.Controls
private System.Windows.Media.Imaging.WriteableBitmap _bubbleMask; private System.Windows.Media.Imaging.WriteableBitmap _bubbleMask;
private int _bubbleThreshold = 128; private int _bubbleThreshold = 128;
private int _bubbleBrushSize = 5; private int _bubbleBrushSize = 5;
private double _bubbleVoidLimit = 25.0;
private bool _bubbleBrushDragging; private bool _bubbleBrushDragging;
private readonly System.Collections.Generic.Stack<byte[]> _bubbleUndoStack = new(); private readonly System.Collections.Generic.Stack<byte[]> _bubbleUndoStack = new();
public void SetBubbleTool(BubbleSubTool tool) => _bubbleTool = tool; public void SetBubbleTool(BubbleSubTool tool) => _bubbleTool = tool;
public void SetBubbleThreshold(int val) => _bubbleThreshold = val; public void SetBubbleThreshold(int val) => _bubbleThreshold = val;
public void SetBubbleBrushSize(int val) => _bubbleBrushSize = val; public void SetBubbleBrushSize(int val) => _bubbleBrushSize = val;
public void SetBubbleVoidLimit(double val) { _bubbleVoidLimit = val; UpdateBubbleResult(); }
public Rect? BubbleRoi => _bubbleRoi; public Rect? BubbleRoi => _bubbleRoi;
/// <summary>设置 BGA 测量的气泡/焊球绘制模式</summary> /// <summary>设置 BGA 测量的气泡/焊球绘制模式</summary>
@@ -467,6 +469,14 @@ namespace XP.ImageProcessing.RoiControl.Controls
_angleTempVDot = _angleTempADot = null; _angleTempLineA = null; _angleTempVDot = _angleTempADot = null; _angleTempLineA = null;
_angleTempV = _angleTempA = null; _angleClickCount = 0; _angleTempV = _angleTempA = null; _angleClickCount = 0;
_mDraggingDot = null; _mDraggingOwner = null; _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(); public void ClearMeasurements() => RemoveMeasureOverlay();
@@ -1287,8 +1297,8 @@ namespace XP.ImageProcessing.RoiControl.Controls
// 更新 ROI 上方标签 // 更新 ROI 上方标签
if (_bubbleResultLabel != null) if (_bubbleResultLabel != null)
{ {
string cls = voidRate <= 25.0 ? "PASS" : "FAIL"; string cls = voidRate <= _bubbleVoidLimit ? "PASS" : "FAIL";
_bubbleResultLabel.Text = $"Void: {voidRate:F1}% | {cls}"; _bubbleResultLabel.Text = $"Void: {voidRate:F1}% | Limit: {_bubbleVoidLimit:F1}% | {cls}";
_bubbleResultLabel.Foreground = cls == "PASS" ? Brushes.Lime : Brushes.Red; _bubbleResultLabel.Foreground = cls == "PASS" ? Brushes.Lime : Brushes.Red;
Canvas.SetLeft(_bubbleResultLabel, roi.X); Canvas.SetLeft(_bubbleResultLabel, roi.X);
Canvas.SetTop(_bubbleResultLabel, roi.Y - 20); Canvas.SetTop(_bubbleResultLabel, roi.Y - 20);