fix: improve split drawing UX — shorter suffix, piece numbers, axis fix

- 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) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 08:49:02 -04:00
parent f208569e72
commit d9005cccc3
2 changed files with 23 additions and 3 deletions

View File

@@ -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);

View File

@@ -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);