From 5365791acdeab35a378fd7275f76061d1980f97f Mon Sep 17 00:00:00 2001 From: "Mr.Xia" <1424473282@qq.com> Date: Wed, 12 Aug 2026 10:11:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=93=86=E9=92=89=E5=AD=944.503?= =?UTF-8?q?=E4=BD=9C=E4=B8=BAPP=E9=92=BB=E5=B8=A6=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=AD=94=E5=BE=84=20=E2=80=94=20PpSourceDiameters=E9=9B=86?= =?UTF-8?q?=E5=90=88=E5=90=AB3.203/4.503=EF=BC=8Clegacy=203=E5=AD=94?= =?UTF-8?q?=E4=B8=8E=E5=A4=96=E6=A1=8613/15=E5=AD=94=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainWindowViewModel.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/MainWindowViewModel.cs b/MainWindowViewModel.cs index 43cbec1..2a6ee9c 100644 --- a/MainWindowViewModel.cs +++ b/MainWindowViewModel.cs @@ -46,9 +46,16 @@ namespace DrillTools private const int SvsiEnsureVisible = 0x8; private const int SvsiFocused = 0x10; private const int SelectFileFlags = SvsiSelect | SvsiDeselectOthers | SvsiEnsureVisible | SvsiFocused; - private const double PpSourceDiameter = 3.203; + private static readonly double[] PpSourceDiameters = { 3.203, 4.503 }; private const int PpSideCoordinateTolerance = 1500; + /// + /// PP 钻带来源孔径集合(3.203 PP 定位孔 / 4.503 铆钉孔)。 + /// 比较使用容差 < 0.001,与 同风格。 + /// + private static bool IsPpSourceDiameter(double diameter) + => PpSourceDiameters.Any(d => Math.Abs(diameter - d) < 0.001); + [DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); @@ -1226,7 +1233,7 @@ M30"; return null; var sourceTool = OriginalTools[OriginalTools.Count - 2]; - if (Math.Abs(sourceTool.Diameter - PpSourceDiameter) >= 0.001) + if (!IsPpSourceDiameter(sourceTool.Diameter)) return null; if (sourceTool.TotalHoles != 3) @@ -1249,7 +1256,7 @@ M30"; private PpGenerationRule? GetOuterPpGenerationRule() { var sourceTool = OriginalTools.FirstOrDefault(tool => - Math.Abs(tool.Diameter - PpSourceDiameter) < 0.001 + IsPpSourceDiameter(tool.Diameter) && (tool.TotalHoles == 13 || tool.TotalHoles == 15) && tool.HoleLocations != null && tool.HoleLocations.Count >= 4 @@ -1261,13 +1268,13 @@ M30"; } /// - /// 从 3.203 外框孔中按右、上、左、下四边各取一个中位孔,并保持原钻带坐标文本。 + /// 从 PP 来源孔径(3.203 PP 定位孔 / 4.503 铆钉孔)外框中按右、上、左、下四边各取一个中位孔,并保持原钻带坐标文本。 /// private static List SelectPpDrillTapeLocations(ToolItem sourceTool) { var points = ParsePpHolePoints(sourceTool.HoleLocations); if (points.Count < 4) - throw new InvalidOperationException("3.203 刀具坐标不足,无法生成 PP 钻带"); + throw new InvalidOperationException("PP 来源孔径刀具坐标不足,无法生成 PP 钻带"); int minX = points.Min(point => point.X); int maxX = points.Max(point => point.X); @@ -1283,7 +1290,7 @@ M30"; }; if (selected.Any(point => point == null)) - throw new InvalidOperationException("3.203 刀具未形成完整的上下左右四边孔位,无法生成 PP 钻带"); + throw new InvalidOperationException("PP 来源孔径刀具未形成完整的上下左右四边孔位,无法生成 PP 钻带"); var selectedTexts = selected .Select(point => point!.Text) @@ -1291,9 +1298,9 @@ M30"; .ToHashSet(StringComparer.Ordinal); if (selectedTexts.Count != 4) - throw new InvalidOperationException("3.203 刀具四边中位孔存在重复,无法生成 PP 钻带"); + throw new InvalidOperationException("PP 来源孔径刀具四边中位孔存在重复,无法生成 PP 钻带"); - // 输出顺序沿用原 3.203 刀具中的孔位顺序,避免改变已有钻带坐标排序习惯。 + // 输出顺序沿用原 PP 来源孔径刀具(3.203/4.503)中的孔位顺序,避免改变已有钻带坐标排序习惯。 return points .Where(point => selectedTexts.Contains(point.Text)) .Select(point => point.Text)