Files
OpenNest/OpenNest/Forms/TabbedCutoutDialog.cs
T
ajandClaude Opus 5.5 ba39c3dc55 feat(cad): add tabbed cutouts with draggable tabs
A hole can now be declared a tabbed cutout in the CAD Converter: pick a
circle or any edge of a closed hole, set the tab count and width, and drag
the tabs around the hole. The definition persists on the drawing and in the
nest file, and stays editable from the source entities.

The builder replaces the hole with open cut pieces and uncut spans on a new
Tab layer. Tabs are material, so area, nesting and overlap checks still see
a closed hole, but they are never cut. Plan Cutting and Assign Lead-ins cut
each piece from the slug with the internal lead-in and no lead-out. A lead
that would reach back over a tab is mirrored, and an arc lead onto an arc
pierces straight in. Planning accounts for each span between tabs and runs
the open-cut proof, so its own tabbed cutouts certify; tabs followed by a
lead-out are still refused. Pre-post review flags programs that still
contain tab motions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 00:50:11 -04:00

98 lines
3.3 KiB
C#

using System.Drawing;
using System.Windows.Forms;
using OpenNest.TabbedCutouts;
namespace OpenNest.Forms
{
public class TabbedCutoutDialog : Form
{
private readonly NumericUpDown numTabs;
private readonly NumericUpDown numTabWidth;
public TabbedCutoutDialog()
{
Text = "Tabbed Cutout";
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
ShowInTaskbar = false;
StartPosition = FormStartPosition.CenterParent;
Size = new Size(300, 200);
var font = new Font("Segoe UI", 9f);
numTabs = AddRow("Tabs:", 12, TabbedCutout.MinTabCount, 50, 0, 1, TabbedCutout.DefaultTabCount);
numTabWidth = AddRow("Tab width:", 44, 0.001m, 10, 4, 0.0625m, (decimal)TabbedCutout.DefaultTabWidth);
Controls.Add(new Label
{
Text = "Tabs keep the slug attached. The hole is cut between tabs, "
+ "with lead-ins from the slug and no lead-outs.",
Location = new Point(12, 78),
Size = new Size(260, 34),
ForeColor = Color.DimGray,
Font = font,
});
var btnOk = new Button
{
Text = "OK",
DialogResult = DialogResult.OK,
Location = new Point(102, 120),
Size = new Size(80, 28),
Font = font,
};
var btnCancel = new Button
{
Text = "Cancel",
DialogResult = DialogResult.Cancel,
Location = new Point(190, 120),
Size = new Size(80, 28),
Font = font,
};
AcceptButton = btnOk;
CancelButton = btnCancel;
Controls.AddRange(new Control[] { btnOk, btnCancel });
NumericUpDown AddRow(string label, int y, decimal min, decimal max, int decimals, decimal step, decimal value)
{
Controls.Add(new Label { Text = label, Location = new Point(12, y + 3), AutoSize = true, Font = font });
var input = new NumericUpDown
{
Location = new Point(140, y),
Width = 130,
Font = font,
Minimum = min,
Maximum = max,
DecimalPlaces = decimals,
Increment = step,
Value = value,
};
Controls.Add(input);
return input;
}
}
public int TabCount
{
get => (int)numTabs.Value;
set => numTabs.Value = Clamp(numTabs, value);
}
public double TabWidth
{
get => (double)numTabWidth.Value;
set => numTabWidth.Value = Clamp(numTabWidth, value);
}
public void LoadCutout(TabbedCutout cutout)
{
TabCount = cutout.TabCenters.Count == 0 ? TabbedCutout.DefaultTabCount : cutout.TabCenters.Count;
TabWidth = cutout.TabWidth;
}
private static decimal Clamp(NumericUpDown input, double value) =>
System.Math.Clamp((decimal)value, input.Minimum, input.Maximum);
}
}