From d9005cccc382860545d36cb3ce77e646266dc73e Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 25 Mar 2026 08:49:02 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20improve=20split=20drawing=20UX=20?= =?UTF-8?q?=E2=80=94=20shorter=20suffix,=20piece=20numbers,=20axis=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change split file suffix from _split# to -# (e.g., PartName-1.dxf) - Add numbered labels at the center of each split region in the preview - Fix fit-to-plate axis calculation to use correct plate dimension instead of min(width, height) for single-axis splits Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Forms/CadConverterForm.cs | 2 +- OpenNest/Forms/SplitDrawingForm.cs | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/OpenNest/Forms/CadConverterForm.cs b/OpenNest/Forms/CadConverterForm.cs index f942b89..f973742 100644 --- a/OpenNest/Forms/CadConverterForm.cs +++ b/OpenNest/Forms/CadConverterForm.cs @@ -263,7 +263,7 @@ namespace OpenNest.Forms // Assign bends from the source item — spatial filtering is a future enhancement splitDrawing.Bends.AddRange(item.Bends); - var splitName = $"{baseName}_split{i + 1}.dxf"; + var splitName = $"{baseName}-{i + 1}.dxf"; var splitPath = GetUniquePath(Path.Combine(writableDir, splitName)); splitWriter.Write(splitPath, splitDrawing); diff --git a/OpenNest/Forms/SplitDrawingForm.cs b/OpenNest/Forms/SplitDrawingForm.cs index 6f77aef..1a11fef 100644 --- a/OpenNest/Forms/SplitDrawingForm.cs +++ b/OpenNest/Forms/SplitDrawingForm.cs @@ -74,7 +74,7 @@ public partial class SplitDrawingForm : Form if (axisIndex == 1) { - var usable = System.Math.Min(plateW, plateH) - 2 * spacing - overhang; + var usable = plateW - 2 * spacing - overhang; if (usable > 0) { var splits = (int)System.Math.Ceiling(_drawingBounds.Width / usable) - 1; @@ -88,7 +88,7 @@ public partial class SplitDrawingForm : Form } else if (axisIndex == 2) { - var usable = System.Math.Min(plateW, plateH) - 2 * spacing - overhang; + var usable = plateH - 2 * spacing - overhang; if (usable > 0) { var splits = (int)System.Math.Ceiling(_drawingBounds.Length / usable) - 1; @@ -381,6 +381,26 @@ public partial class SplitDrawingForm : Form System.Math.Abs(br.X - tl.X), System.Math.Abs(br.Y - tl.Y)); } + // Piece number labels at center of each region + if (regions.Count > 1) + { + using var labelFont = new Font("Segoe UI", 14f, FontStyle.Bold, GraphicsUnit.Pixel); + using var labelBrush = new SolidBrush(Color.FromArgb(200, 255, 255, 255)); + using var shadowBrush = new SolidBrush(Color.FromArgb(160, 0, 0, 0)); + var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; + + for (var i = 0; i < regions.Count; i++) + { + var r = regions[i]; + var center = pnlPreview.PointWorldToGraph(r.Center.X, r.Center.Y); + var label = (i + 1).ToString(); + + // Shadow offset for readability + g.DrawString(label, labelFont, shadowBrush, center.X + 1, center.Y + 1, sf); + g.DrawString(label, labelFont, labelBrush, center.X, center.Y, sf); + } + } + // Split lines — trimmed at feature positions with feature contours var parameters = GetCurrentParameters(); var feature = GetSplitFeature(parameters.Type);