feat: add lead-out parameters and tab toggle to CuttingParametersForm

Restructure the cutting parameters dialog with separate Lead-In and
Lead-Out GroupBoxes per tab, exposing editable length/angle/radius
fields for lead-outs (previously hardcoded). Add Tabs section with
enable checkbox and width control. Also fix lead-in/lead-out angle
calculations and convert cutting strategy output to incremental mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-30 15:08:18 -04:00
parent 5307c5c85a
commit d16ef36d34
10 changed files with 299 additions and 168 deletions
@@ -63,6 +63,10 @@ namespace OpenNest.CNC.CuttingStrategy
result.Codes.AddRange(leadOut.Generate(perimeterPt, normal, winding)); result.Codes.AddRange(leadOut.Generate(perimeterPt, normal, winding));
} }
// Convert to incremental mode to match the convention used by
// the rest of the system (rendering, bounding box, drag, etc.).
result.Mode = Mode.Incremental;
return new CuttingResult return new CuttingResult
{ {
Program = result, Program = result,
@@ -23,7 +23,7 @@ namespace OpenNest.CNC.CuttingStrategy
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle) public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle)
{ {
var approachAngle = contourNormalAngle + Angle.ToRadians(ApproachAngle); var approachAngle = contourNormalAngle + Angle.HalfPI - Angle.ToRadians(ApproachAngle);
return new Vector( return new Vector(
contourStartPoint.X + Length * System.Math.Cos(approachAngle), contourStartPoint.X + Length * System.Math.Cos(approachAngle),
contourStartPoint.Y + Length * System.Math.Sin(approachAngle)); contourStartPoint.Y + Length * System.Math.Sin(approachAngle));
@@ -16,7 +16,7 @@ namespace OpenNest.CNC.CuttingStrategy
{ {
var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle); var piercePoint = GetPiercePoint(contourStartPoint, contourNormalAngle);
var secondAngle = contourNormalAngle + Angle.ToRadians(ApproachAngle1); var secondAngle = contourNormalAngle + Angle.HalfPI - Angle.ToRadians(ApproachAngle1);
var midPoint = new Vector( var midPoint = new Vector(
contourStartPoint.X + Length2 * System.Math.Cos(secondAngle), contourStartPoint.X + Length2 * System.Math.Cos(secondAngle),
contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle)); contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle));
@@ -31,7 +31,7 @@ namespace OpenNest.CNC.CuttingStrategy
public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle) public override Vector GetPiercePoint(Vector contourStartPoint, double contourNormalAngle)
{ {
var secondAngle = contourNormalAngle + Angle.ToRadians(ApproachAngle1); var secondAngle = contourNormalAngle + Angle.HalfPI - Angle.ToRadians(ApproachAngle1);
var midX = contourStartPoint.X + Length2 * System.Math.Cos(secondAngle); var midX = contourStartPoint.X + Length2 * System.Math.Cos(secondAngle);
var midY = contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle); var midY = contourStartPoint.Y + Length2 * System.Math.Sin(secondAngle);
@@ -12,7 +12,7 @@ namespace OpenNest.CNC.CuttingStrategy
public override List<ICode> Generate(Vector contourEndPoint, double contourNormalAngle, public override List<ICode> Generate(Vector contourEndPoint, double contourNormalAngle,
RotationType winding = RotationType.CW) RotationType winding = RotationType.CW)
{ {
var overcutAngle = contourNormalAngle + Angle.ToRadians(ApproachAngle); var overcutAngle = contourNormalAngle + Angle.HalfPI - Angle.ToRadians(ApproachAngle);
var endPoint = new Vector( var endPoint = new Vector(
contourEndPoint.X + Length * System.Math.Cos(overcutAngle), contourEndPoint.X + Length * System.Math.Cos(overcutAngle),
contourEndPoint.Y + Length * System.Math.Sin(overcutAngle)); contourEndPoint.Y + Length * System.Math.Sin(overcutAngle));
+2 -2
View File
@@ -13,9 +13,9 @@ namespace OpenNest
public static readonly Layer Display = new Layer("DISPLAY") { Color = Color.Cyan }; public static readonly Layer Display = new Layer("DISPLAY") { Color = Color.Cyan };
public static readonly Layer Leadin = new Layer("LEADIN") { Color = Color.Yellow }; public static readonly Layer Leadin = new Layer("LEADIN") { Color = Color.Brown };
public static readonly Layer Leadout = new Layer("LEADOUT") { Color = Color.Yellow }; public static readonly Layer Leadout = new Layer("LEADOUT") { Color = Color.Brown };
public static readonly Layer Scribe = new Layer("SCRIBE") { Color = Color.Magenta }; public static readonly Layer Scribe = new Layer("SCRIBE") { Color = Color.Magenta };
} }
+8 -8
View File
@@ -44,12 +44,12 @@ namespace OpenNest.Forms
this.tabControl.Controls.Add(this.tabExternal); this.tabControl.Controls.Add(this.tabExternal);
this.tabControl.Controls.Add(this.tabInternal); this.tabControl.Controls.Add(this.tabInternal);
this.tabControl.Controls.Add(this.tabArcCircle); this.tabControl.Controls.Add(this.tabArcCircle);
this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl.Dock = System.Windows.Forms.DockStyle.Top;
this.tabControl.Location = new System.Drawing.Point(0, 0); this.tabControl.Location = new System.Drawing.Point(0, 0);
this.tabControl.Margin = new System.Windows.Forms.Padding(4); this.tabControl.Margin = new System.Windows.Forms.Padding(4);
this.tabControl.Name = "tabControl"; this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0; this.tabControl.SelectedIndex = 0;
this.tabControl.Size = new System.Drawing.Size(368, 290); this.tabControl.Size = new System.Drawing.Size(380, 348);
this.tabControl.TabIndex = 0; this.tabControl.TabIndex = 0;
// //
// tabExternal // tabExternal
@@ -58,7 +58,7 @@ namespace OpenNest.Forms
this.tabExternal.Margin = new System.Windows.Forms.Padding(4); this.tabExternal.Margin = new System.Windows.Forms.Padding(4);
this.tabExternal.Name = "tabExternal"; this.tabExternal.Name = "tabExternal";
this.tabExternal.Padding = new System.Windows.Forms.Padding(8); this.tabExternal.Padding = new System.Windows.Forms.Padding(8);
this.tabExternal.Size = new System.Drawing.Size(360, 261); this.tabExternal.Size = new System.Drawing.Size(372, 319);
this.tabExternal.TabIndex = 0; this.tabExternal.TabIndex = 0;
this.tabExternal.Text = "External"; this.tabExternal.Text = "External";
this.tabExternal.UseVisualStyleBackColor = true; this.tabExternal.UseVisualStyleBackColor = true;
@@ -69,7 +69,7 @@ namespace OpenNest.Forms
this.tabInternal.Margin = new System.Windows.Forms.Padding(4); this.tabInternal.Margin = new System.Windows.Forms.Padding(4);
this.tabInternal.Name = "tabInternal"; this.tabInternal.Name = "tabInternal";
this.tabInternal.Padding = new System.Windows.Forms.Padding(8); this.tabInternal.Padding = new System.Windows.Forms.Padding(8);
this.tabInternal.Size = new System.Drawing.Size(360, 261); this.tabInternal.Size = new System.Drawing.Size(372, 319);
this.tabInternal.TabIndex = 1; this.tabInternal.TabIndex = 1;
this.tabInternal.Text = "Internal"; this.tabInternal.Text = "Internal";
this.tabInternal.UseVisualStyleBackColor = true; this.tabInternal.UseVisualStyleBackColor = true;
@@ -80,7 +80,7 @@ namespace OpenNest.Forms
this.tabArcCircle.Margin = new System.Windows.Forms.Padding(4); this.tabArcCircle.Margin = new System.Windows.Forms.Padding(4);
this.tabArcCircle.Name = "tabArcCircle"; this.tabArcCircle.Name = "tabArcCircle";
this.tabArcCircle.Padding = new System.Windows.Forms.Padding(8); this.tabArcCircle.Padding = new System.Windows.Forms.Padding(8);
this.tabArcCircle.Size = new System.Drawing.Size(360, 261); this.tabArcCircle.Size = new System.Drawing.Size(372, 319);
this.tabArcCircle.TabIndex = 2; this.tabArcCircle.TabIndex = 2;
this.tabArcCircle.Text = "Arc / Circle"; this.tabArcCircle.Text = "Arc / Circle";
this.tabArcCircle.UseVisualStyleBackColor = true; this.tabArcCircle.UseVisualStyleBackColor = true;
@@ -114,9 +114,9 @@ namespace OpenNest.Forms
this.bottomPanel.Controls.Add(this.acceptButton); this.bottomPanel.Controls.Add(this.acceptButton);
this.bottomPanel.Controls.Add(this.cancelButton); this.bottomPanel.Controls.Add(this.cancelButton);
this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom; this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.bottomPanel.Location = new System.Drawing.Point(0, 290); this.bottomPanel.Location = new System.Drawing.Point(0, 406);
this.bottomPanel.Name = "bottomPanel"; this.bottomPanel.Name = "bottomPanel";
this.bottomPanel.Size = new System.Drawing.Size(368, 50); this.bottomPanel.Size = new System.Drawing.Size(380, 50);
this.bottomPanel.TabIndex = 1; this.bottomPanel.TabIndex = 1;
// //
// CuttingParametersForm // CuttingParametersForm
@@ -125,7 +125,7 @@ namespace OpenNest.Forms
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton; this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(368, 340); this.ClientSize = new System.Drawing.Size(380, 456);
this.Controls.Add(this.tabControl); this.Controls.Add(this.tabControl);
this.Controls.Add(this.bottomPanel); this.Controls.Add(this.bottomPanel);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+196 -67
View File
@@ -16,7 +16,12 @@ namespace OpenNest.Forms
private ComboBox cboInternalLeadIn, cboInternalLeadOut; private ComboBox cboInternalLeadIn, cboInternalLeadOut;
private ComboBox cboArcCircleLeadIn, cboArcCircleLeadOut; private ComboBox cboArcCircleLeadIn, cboArcCircleLeadOut;
private Panel pnlExternalParams, pnlInternalParams, pnlArcCircleParams; private Panel pnlExternalLeadIn, pnlExternalLeadOut;
private Panel pnlInternalLeadIn, pnlInternalLeadOut;
private Panel pnlArcCircleLeadIn, pnlArcCircleLeadOut;
private CheckBox chkTabsEnabled;
private NumericUpDown nudTabWidth;
public CuttingParameters Parameters { get; set; } = new CuttingParameters(); public CuttingParameters Parameters { get; set; } = new CuttingParameters();
@@ -24,15 +29,26 @@ namespace OpenNest.Forms
{ {
InitializeComponent(); InitializeComponent();
SetupTab(tabExternal, out cboExternalLeadIn, out cboExternalLeadOut, out pnlExternalParams); SetupTab(tabExternal,
SetupTab(tabInternal, out cboInternalLeadIn, out cboInternalLeadOut, out pnlInternalParams); out cboExternalLeadIn, out pnlExternalLeadIn,
SetupTab(tabArcCircle, out cboArcCircleLeadIn, out cboArcCircleLeadOut, out pnlArcCircleParams); out cboExternalLeadOut, out pnlExternalLeadOut);
SetupTab(tabInternal,
out cboInternalLeadIn, out pnlInternalLeadIn,
out cboInternalLeadOut, out pnlInternalLeadOut);
SetupTab(tabArcCircle,
out cboArcCircleLeadIn, out pnlArcCircleLeadIn,
out cboArcCircleLeadOut, out pnlArcCircleLeadOut);
SetupTabsSection();
PopulateDropdowns(); PopulateDropdowns();
cboExternalLeadIn.SelectedIndexChanged += OnLeadInTypeChanged; cboExternalLeadIn.SelectedIndexChanged += OnLeadInTypeChanged;
cboInternalLeadIn.SelectedIndexChanged += OnLeadInTypeChanged; cboInternalLeadIn.SelectedIndexChanged += OnLeadInTypeChanged;
cboArcCircleLeadIn.SelectedIndexChanged += OnLeadInTypeChanged; cboArcCircleLeadIn.SelectedIndexChanged += OnLeadInTypeChanged;
cboExternalLeadOut.SelectedIndexChanged += OnLeadOutTypeChanged;
cboInternalLeadOut.SelectedIndexChanged += OnLeadOutTypeChanged;
cboArcCircleLeadOut.SelectedIndexChanged += OnLeadOutTypeChanged;
} }
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
@@ -41,54 +57,113 @@ namespace OpenNest.Forms
LoadFromParameters(Parameters); LoadFromParameters(Parameters);
} }
private static void SetupTab(TabPage tab, out ComboBox leadInCombo, private static void SetupTab(TabPage tab,
out ComboBox leadOutCombo, out Panel paramPanel) out ComboBox leadInCombo, out Panel leadInPanel,
out ComboBox leadOutCombo, out Panel leadOutPanel)
{ {
var y = 12; var grpLeadIn = new GroupBox
var lblLeadIn = new Label
{ {
Text = "Lead-In:", Text = "Lead-In",
Location = new System.Drawing.Point(8, y + 3), Location = new System.Drawing.Point(4, 4),
AutoSize = true Size = new System.Drawing.Size(364, 168)
}; };
tab.Controls.Add(lblLeadIn); tab.Controls.Add(grpLeadIn);
grpLeadIn.Controls.Add(new Label
{
Text = "Type:",
Location = new System.Drawing.Point(8, 22),
AutoSize = true
});
leadInCombo = new ComboBox leadInCombo = new ComboBox
{ {
DropDownStyle = ComboBoxStyle.DropDownList, DropDownStyle = ComboBoxStyle.DropDownList,
Location = new System.Drawing.Point(100, y), Location = new System.Drawing.Point(90, 19),
Size = new System.Drawing.Size(240, 24) Size = new System.Drawing.Size(250, 24)
}; };
tab.Controls.Add(leadInCombo); grpLeadIn.Controls.Add(leadInCombo);
y += 32; leadInPanel = new Panel
var lblLeadOut = new Label
{ {
Text = "Lead-Out:", Location = new System.Drawing.Point(8, 48),
Location = new System.Drawing.Point(8, y + 3), Size = new System.Drawing.Size(340, 112),
AutoSize = true AutoScroll = true
}; };
tab.Controls.Add(lblLeadOut); grpLeadIn.Controls.Add(leadInPanel);
var grpLeadOut = new GroupBox
{
Text = "Lead-Out",
Location = new System.Drawing.Point(4, 176),
Size = new System.Drawing.Size(364, 132)
};
tab.Controls.Add(grpLeadOut);
grpLeadOut.Controls.Add(new Label
{
Text = "Type:",
Location = new System.Drawing.Point(8, 22),
AutoSize = true
});
leadOutCombo = new ComboBox leadOutCombo = new ComboBox
{ {
DropDownStyle = ComboBoxStyle.DropDownList, DropDownStyle = ComboBoxStyle.DropDownList,
Location = new System.Drawing.Point(100, y), Location = new System.Drawing.Point(90, 19),
Size = new System.Drawing.Size(240, 24) Size = new System.Drawing.Size(250, 24)
}; };
tab.Controls.Add(leadOutCombo); grpLeadOut.Controls.Add(leadOutCombo);
y += 40; leadOutPanel = new Panel
paramPanel = new Panel
{ {
Location = new System.Drawing.Point(8, y), Location = new System.Drawing.Point(8, 48),
Size = new System.Drawing.Size(332, 170), Size = new System.Drawing.Size(340, 76),
AutoScroll = true AutoScroll = true
}; };
tab.Controls.Add(paramPanel); grpLeadOut.Controls.Add(leadOutPanel);
}
private void SetupTabsSection()
{
var grpTabs = new GroupBox
{
Text = "Tabs",
Location = new System.Drawing.Point(4, 350),
Size = new System.Drawing.Size(372, 55),
Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right
};
chkTabsEnabled = new CheckBox
{
Text = "Enable Tabs",
Location = new System.Drawing.Point(12, 22),
AutoSize = true
};
chkTabsEnabled.CheckedChanged += (s, e) => nudTabWidth.Enabled = chkTabsEnabled.Checked;
grpTabs.Controls.Add(chkTabsEnabled);
grpTabs.Controls.Add(new Label
{
Text = "Width:",
Location = new System.Drawing.Point(160, 23),
AutoSize = true
});
nudTabWidth = new NumericUpDown
{
Location = new System.Drawing.Point(215, 20),
Size = new System.Drawing.Size(100, 22),
DecimalPlaces = 4,
Increment = 0.0625m,
Minimum = 0,
Maximum = 9999,
Value = 0.25m,
Enabled = false
};
grpTabs.Controls.Add(nudTabWidth);
Controls.Add(grpTabs);
} }
private void PopulateDropdowns() private void PopulateDropdowns()
@@ -109,20 +184,36 @@ namespace OpenNest.Forms
private void OnLeadInTypeChanged(object sender, EventArgs e) private void OnLeadInTypeChanged(object sender, EventArgs e)
{ {
var combo = (ComboBox)sender; var combo = (ComboBox)sender;
var panel = GetParamPanel(combo); var panel = GetLeadInPanel(combo);
if (panel != null) if (panel != null)
BuildParamControls(panel, combo.SelectedIndex); BuildLeadInParamControls(panel, combo.SelectedIndex);
} }
private Panel GetParamPanel(ComboBox combo) private void OnLeadOutTypeChanged(object sender, EventArgs e)
{ {
if (combo == cboExternalLeadIn) return pnlExternalParams; var combo = (ComboBox)sender;
if (combo == cboInternalLeadIn) return pnlInternalParams; var panel = GetLeadOutPanel(combo);
if (combo == cboArcCircleLeadIn) return pnlArcCircleParams; if (panel != null)
BuildLeadOutParamControls(panel, combo.SelectedIndex);
}
private Panel GetLeadInPanel(ComboBox combo)
{
if (combo == cboExternalLeadIn) return pnlExternalLeadIn;
if (combo == cboInternalLeadIn) return pnlInternalLeadIn;
if (combo == cboArcCircleLeadIn) return pnlArcCircleLeadIn;
return null; return null;
} }
private static void BuildParamControls(Panel panel, int typeIndex) private Panel GetLeadOutPanel(ComboBox combo)
{
if (combo == cboExternalLeadOut) return pnlExternalLeadOut;
if (combo == cboInternalLeadOut) return pnlInternalLeadOut;
if (combo == cboArcCircleLeadOut) return pnlArcCircleLeadOut;
return null;
}
private static void BuildLeadInParamControls(Panel panel, int typeIndex)
{ {
panel.Controls.Clear(); panel.Controls.Clear();
var y = 0; var y = 0;
@@ -155,18 +246,37 @@ namespace OpenNest.Forms
} }
} }
private static void BuildLeadOutParamControls(Panel panel, int typeIndex)
{
panel.Controls.Clear();
var y = 0;
switch (typeIndex)
{
case 1: // Line
AddNumericField(panel, "Length:", 0.25, ref y, "Length");
AddNumericField(panel, "Approach Angle:", 90, ref y, "ApproachAngle");
break;
case 2: // Arc
AddNumericField(panel, "Radius:", 0.25, ref y, "Radius");
break;
case 3: // Microtab
AddNumericField(panel, "Gap Size:", 0.06, ref y, "GapSize");
break;
}
}
private static void AddNumericField(Panel panel, string label, double defaultValue, private static void AddNumericField(Panel panel, string label, double defaultValue,
ref int y, string tag) ref int y, string tag)
{ {
var lbl = new Label panel.Controls.Add(new Label
{ {
Text = label, Text = label,
Location = new System.Drawing.Point(0, y + 3), Location = new System.Drawing.Point(0, y + 3),
AutoSize = true AutoSize = true
}; });
panel.Controls.Add(lbl);
var nud = new System.Windows.Forms.NumericUpDown panel.Controls.Add(new NumericUpDown
{ {
Location = new System.Drawing.Point(130, y), Location = new System.Drawing.Point(130, y),
Size = new System.Drawing.Size(120, 22), Size = new System.Drawing.Size(120, 22),
@@ -176,22 +286,25 @@ namespace OpenNest.Forms
Maximum = 9999, Maximum = 9999,
Value = (decimal)defaultValue, Value = (decimal)defaultValue,
Tag = tag Tag = tag
}; });
panel.Controls.Add(nud);
y += 30; y += 30;
} }
private void LoadFromParameters(CuttingParameters p) private void LoadFromParameters(CuttingParameters p)
{ {
LoadLeadIn(cboExternalLeadIn, pnlExternalParams, p.ExternalLeadIn); LoadLeadIn(cboExternalLeadIn, pnlExternalLeadIn, p.ExternalLeadIn);
LoadLeadOut(cboExternalLeadOut, p.ExternalLeadOut); LoadLeadOut(cboExternalLeadOut, pnlExternalLeadOut, p.ExternalLeadOut);
LoadLeadIn(cboInternalLeadIn, pnlInternalParams, p.InternalLeadIn); LoadLeadIn(cboInternalLeadIn, pnlInternalLeadIn, p.InternalLeadIn);
LoadLeadOut(cboInternalLeadOut, p.InternalLeadOut); LoadLeadOut(cboInternalLeadOut, pnlInternalLeadOut, p.InternalLeadOut);
LoadLeadIn(cboArcCircleLeadIn, pnlArcCircleParams, p.ArcCircleLeadIn); LoadLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn, p.ArcCircleLeadIn);
LoadLeadOut(cboArcCircleLeadOut, p.ArcCircleLeadOut); LoadLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut, p.ArcCircleLeadOut);
chkTabsEnabled.Checked = p.TabsEnabled;
if (p.TabConfig != null)
nudTabWidth.Value = (decimal)p.TabConfig.Size;
} }
private static void LoadLeadIn(ComboBox combo, Panel panel, LeadIn leadIn) private static void LoadLeadIn(ComboBox combo, Panel panel, LeadIn leadIn)
@@ -232,18 +345,22 @@ namespace OpenNest.Forms
} }
} }
private static void LoadLeadOut(ComboBox combo, LeadOut leadOut) private static void LoadLeadOut(ComboBox combo, Panel panel, LeadOut leadOut)
{ {
switch (leadOut) switch (leadOut)
{ {
case LineLeadOut _: case LineLeadOut line:
combo.SelectedIndex = 1; combo.SelectedIndex = 1;
SetParam(panel, "Length", line.Length);
SetParam(panel, "ApproachAngle", line.ApproachAngle);
break; break;
case ArcLeadOut _: case ArcLeadOut arc:
combo.SelectedIndex = 2; combo.SelectedIndex = 2;
SetParam(panel, "Radius", arc.Radius);
break; break;
case MicrotabLeadOut _: case MicrotabLeadOut microtab:
combo.SelectedIndex = 3; combo.SelectedIndex = 3;
SetParam(panel, "GapSize", microtab.GapSize);
break; break;
default: default:
combo.SelectedIndex = 0; combo.SelectedIndex = 0;
@@ -255,12 +372,14 @@ namespace OpenNest.Forms
{ {
var p = new CuttingParameters var p = new CuttingParameters
{ {
ExternalLeadIn = BuildLeadIn(cboExternalLeadIn, pnlExternalParams), ExternalLeadIn = BuildLeadIn(cboExternalLeadIn, pnlExternalLeadIn),
ExternalLeadOut = BuildLeadOut(cboExternalLeadOut), ExternalLeadOut = BuildLeadOut(cboExternalLeadOut, pnlExternalLeadOut),
InternalLeadIn = BuildLeadIn(cboInternalLeadIn, pnlInternalParams), InternalLeadIn = BuildLeadIn(cboInternalLeadIn, pnlInternalLeadIn),
InternalLeadOut = BuildLeadOut(cboInternalLeadOut), InternalLeadOut = BuildLeadOut(cboInternalLeadOut, pnlInternalLeadOut),
ArcCircleLeadIn = BuildLeadIn(cboArcCircleLeadIn, pnlArcCircleParams), ArcCircleLeadIn = BuildLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn),
ArcCircleLeadOut = BuildLeadOut(cboArcCircleLeadOut) ArcCircleLeadOut = BuildLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut),
TabsEnabled = chkTabsEnabled.Checked,
TabConfig = new NormalTab { Size = (double)nudTabWidth.Value }
}; };
return p; return p;
} }
@@ -307,16 +426,26 @@ namespace OpenNest.Forms
} }
} }
private static LeadOut BuildLeadOut(ComboBox combo) private static LeadOut BuildLeadOut(ComboBox combo, Panel panel)
{ {
switch (combo.SelectedIndex) switch (combo.SelectedIndex)
{ {
case 1: case 1:
return new LineLeadOut { Length = 0.25, ApproachAngle = 90 }; return new LineLeadOut
{
Length = GetParam(panel, "Length", 0.25),
ApproachAngle = GetParam(panel, "ApproachAngle", 90)
};
case 2: case 2:
return new ArcLeadOut { Radius = 0.25 }; return new ArcLeadOut
{
Radius = GetParam(panel, "Radius", 0.25)
};
case 3: case 3:
return new MicrotabLeadOut(); return new MicrotabLeadOut
{
GapSize = GetParam(panel, "GapSize", 0.06)
};
default: default:
return new NoLeadOut(); return new NoLeadOut();
} }
@@ -326,7 +455,7 @@ namespace OpenNest.Forms
{ {
foreach (Control c in panel.Controls) foreach (Control c in panel.Controls)
{ {
if (c is System.Windows.Forms.NumericUpDown nud && (string)nud.Tag == tag) if (c is NumericUpDown nud && (string)nud.Tag == tag)
{ {
nud.Value = (decimal)value; nud.Value = (decimal)value;
return; return;
@@ -338,7 +467,7 @@ namespace OpenNest.Forms
{ {
foreach (Control c in panel.Controls) foreach (Control c in panel.Controls)
{ {
if (c is System.Windows.Forms.NumericUpDown nud && (string)nud.Tag == tag) if (c is NumericUpDown nud && (string)nud.Tag == tag)
return (double)nud.Value; return (double)nud.Value;
} }
return defaultValue; return defaultValue;
+57 -59
View File
@@ -28,77 +28,75 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label();
this.numericUpDown1 = new OpenNest.Controls.NumericUpDown(); numericUpDown1 = new OpenNest.Controls.NumericUpDown();
this.tableLayoutPanel1.SuspendLayout(); tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
this.tableLayoutPanel1.ColumnCount = 2; tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); tableLayoutPanel1.Controls.Add(label1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.numericUpDown1, 1, 0); tableLayoutPanel1.Controls.Add(numericUpDown1, 1, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1"; tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.tableLayoutPanel1.RowCount = 1; tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.Size = new System.Drawing.Size(220, 36); tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.TabIndex = 0; tableLayoutPanel1.Size = new System.Drawing.Size(266, 35);
tableLayoutPanel1.TabIndex = 0;
// //
// label1 // label1
// //
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); label1.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 11); label1.Location = new System.Drawing.Point(4, 10);
this.label1.Name = "label1"; label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Size = new System.Drawing.Size(62, 13); label1.Name = "label1";
this.label1.TabIndex = 0; label1.Size = new System.Drawing.Size(64, 15);
this.label1.Text = "Sequence :"; label1.TabIndex = 0;
label1.Text = "Sequence :";
// //
// numericUpDown1 // numericUpDown1
// //
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); numericUpDown1.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
this.numericUpDown1.Location = new System.Drawing.Point(71, 8); numericUpDown1.Location = new System.Drawing.Point(76, 6);
this.numericUpDown1.Minimum = new decimal(new int[] { numericUpDown1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
1, numericUpDown1.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
0, numericUpDown1.Name = "numericUpDown1";
0, numericUpDown1.Size = new System.Drawing.Size(186, 23);
0}); numericUpDown1.Suffix = "";
this.numericUpDown1.Name = "numericUpDown1"; numericUpDown1.TabIndex = 1;
this.numericUpDown1.Size = new System.Drawing.Size(146, 20); numericUpDown1.Value = new decimal(new int[] { 1, 0, 0, 0 });
this.numericUpDown1.TabIndex = 1; numericUpDown1.Leave += numericUpDown1_Leave;
this.numericUpDown1.Value = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown1.Leave += new System.EventHandler(this.numericUpDown1_Leave);
// //
// SequenceForm // SequenceForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(220, 36); ClientSize = new System.Drawing.Size(266, 35);
this.ControlBox = false; ControlBox = false;
this.Controls.Add(this.tableLayoutPanel1); Controls.Add(tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = new System.Drawing.Point(100, 100); Location = new System.Drawing.Point(100, 100);
this.MaximizeBox = false; Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MinimizeBox = false; MaximizeBox = false;
this.Name = "SequenceForm"; MinimizeBox = false;
this.ShowIcon = false; MinimumSize = new System.Drawing.Size(268, 74);
this.ShowInTaskbar = false; Name = "SequenceForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; ShowIcon = false;
this.Text = "Set Sequence"; ShowInTaskbar = false;
this.tableLayoutPanel1.ResumeLayout(false); StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.tableLayoutPanel1.PerformLayout(); Text = "Set Sequence";
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false); tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown1).EndInit();
ResumeLayout(false);
} }
+1 -1
View File
@@ -35,7 +35,7 @@ namespace OpenNest
{ {
programIdFont = new Font(SystemFonts.DefaultFont, FontStyle.Bold | FontStyle.Underline); programIdFont = new Font(SystemFonts.DefaultFont, FontStyle.Bold | FontStyle.Underline);
SelectedColor = Color.FromArgb(90, 150, 200, 255); SelectedColor = Color.FromArgb(90, 150, 200, 255);
leadInPen = new Pen(Color.Yellow, 1.5f); leadInPen = new Pen(Color.OrangeRed, 1.5f);
} }
private LayoutPart(Part part) private LayoutPart(Part part)