refactor: move material and thickness from Plate to Nest

Material and thickness are properties of the nest (all plates share the
same material/gauge), not individual plates. This moves them to the Nest
class, removes them from Plate and PlateSettings, and updates the UI so
EditNestInfoForm has a material field while EditPlateForm no longer shows
thickness. The nest file format gains top-level thickness/material fields
with backward-compatible reading from PlateDefaults for old files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 21:00:59 -04:00
parent 3e340e67e0
commit 9db7abcd37
18 changed files with 101 additions and 160 deletions
-2
View File
@@ -782,8 +782,6 @@ namespace OpenNest.Controls
{
Quadrant = Plate.Quadrant,
PartSpacing = Plate.PartSpacing,
Thickness = Plate.Thickness,
Material = Plate.Material,
};
previewPlate.EdgeSpacing = Plate.EdgeSpacing;
progressForm.PreviewPlate = previewPlate;
+2 -2
View File
@@ -400,8 +400,8 @@ namespace OpenNest.Forms
nest.DateCreated = DateTime.Now;
nest.DateLastModified = DateTime.Now;
nest.PlateDefaults.Size = new Geometry.Size(plateWidth, plateLength);
nest.PlateDefaults.Thickness = thickness;
nest.PlateDefaults.Material = new Material(material);
nest.Thickness = thickness;
nest.Material = new Material(material);
nest.PlateDefaults.Quadrant = 1;
nest.PlateDefaults.PartSpacing = 1;
nest.PlateDefaults.EdgeSpacing = new Spacing(1, 1, 1, 1);
+39 -14
View File
@@ -62,6 +62,8 @@
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.labelMaterial = new System.Windows.Forms.Label();
this.materialBox = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.notesBox = new System.Windows.Forms.TextBox();
@@ -401,28 +403,31 @@
this.tableLayoutPanel3.ColumnCount = 2;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 1, 5);
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 1, 6);
this.tableLayoutPanel3.Controls.Add(this.label1, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.nameBox, 1, 0);
this.tableLayoutPanel3.Controls.Add(this.label2, 0, 4);
this.tableLayoutPanel3.Controls.Add(this.label2, 0, 5);
this.tableLayoutPanel3.Controls.Add(this.labelThk, 0, 3);
this.tableLayoutPanel3.Controls.Add(this.thicknessBox, 1, 3);
this.tableLayoutPanel3.Controls.Add(this.labelMaterial, 0, 4);
this.tableLayoutPanel3.Controls.Add(this.materialBox, 1, 4);
this.tableLayoutPanel3.Controls.Add(this.label3, 0, 1);
this.tableLayoutPanel3.Controls.Add(this.label4, 0, 2);
this.tableLayoutPanel3.Controls.Add(this.customerBox, 1, 4);
this.tableLayoutPanel3.Controls.Add(this.customerBox, 1, 5);
this.tableLayoutPanel3.Controls.Add(this.textBox1, 1, 1);
this.tableLayoutPanel3.Controls.Add(this.textBox2, 1, 2);
this.tableLayoutPanel3.Controls.Add(this.label5, 0, 5);
this.tableLayoutPanel3.Controls.Add(this.label5, 0, 6);
this.tableLayoutPanel3.Location = new System.Drawing.Point(6, 6);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 6;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(362, 240);
this.tableLayoutPanel3.RowCount = 7;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 14.28571F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(362, 280);
this.tableLayoutPanel3.TabIndex = 0;
//
// tableLayoutPanel4
@@ -497,9 +502,27 @@
this.thicknessBox.Size = new System.Drawing.Size(224, 22);
this.thicknessBox.Suffix = "";
this.thicknessBox.TabIndex = 7;
//
//
// labelMaterial
//
this.labelMaterial.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.labelMaterial.AutoSize = true;
this.labelMaterial.Location = new System.Drawing.Point(3, 162);
this.labelMaterial.Name = "labelMaterial";
this.labelMaterial.Size = new System.Drawing.Size(126, 16);
this.labelMaterial.TabIndex = 10;
this.labelMaterial.Text = "Material :";
//
// materialBox
//
this.materialBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.materialBox.Location = new System.Drawing.Point(135, 159);
this.materialBox.Name = "materialBox";
this.materialBox.Size = new System.Drawing.Size(224, 22);
this.materialBox.TabIndex = 11;
//
// label3
//
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 50);
@@ -705,5 +728,7 @@
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label labelMaterial;
private System.Windows.Forms.TextBox materialBox;
}
}
+10 -2
View File
@@ -106,6 +106,12 @@ namespace OpenNest.Forms
set { thicknessBox.Value = (decimal)value; }
}
public string MaterialName
{
get { return materialBox.Text; }
set { materialBox.Text = value; }
}
public void SetUnits(Units units)
{
switch (units)
@@ -189,7 +195,8 @@ namespace OpenNest.Forms
Customer = nest.Customer;
DateCreated = nest.DateCreated;
DateLastModified = nest.DateLastModified;
Thickness = nest.PlateDefaults.Thickness;
Thickness = nest.Thickness;
MaterialName = nest.Material?.Name ?? "";
SizeString = nest.PlateDefaults.Size.ToString();
PartSpacing = nest.PlateDefaults.PartSpacing;
LeftSpacing = nest.PlateDefaults.EdgeSpacing.Left;
@@ -209,7 +216,8 @@ namespace OpenNest.Forms
nest.Customer = Customer;
nest.DateCreated = DateCreated;
nest.DateLastModified = DateLastModified;
nest.PlateDefaults.Thickness = Thickness;
nest.Thickness = Thickness;
nest.Material = new Material(MaterialName);
nest.PlateDefaults.Size = OpenNest.Geometry.Size.Parse(SizeString);
nest.PlateDefaults.PartSpacing = PartSpacing;
nest.PlateDefaults.EdgeSpacing = new Spacing(LeftSpacing, BottomSpacing, RightSpacing, TopSpacing);
+9 -44
View File
@@ -32,7 +32,6 @@
this.labelQty = new System.Windows.Forms.Label();
this.labelSize = new System.Windows.Forms.Label();
this.textBoxSize = new System.Windows.Forms.TextBox();
this.labelThk = new System.Windows.Forms.Label();
this.labelPartSpacing = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
@@ -50,7 +49,6 @@
this.numericUpDownEdgeSpacingRight = new OpenNest.Controls.NumericUpDown();
this.numericUpDownEdgeSpacingBottom = new OpenNest.Controls.NumericUpDown();
this.numericUpDownQty = new OpenNest.Controls.NumericUpDown();
this.numericUpDownThickness = new OpenNest.Controls.NumericUpDown();
this.numericUpDownPartSpacing = new OpenNest.Controls.NumericUpDown();
this.tableLayoutPanel1.SuspendLayout();
this.groupBox1.SuspendLayout();
@@ -62,7 +60,6 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEdgeSpacingRight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEdgeSpacingBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQty)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownThickness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPartSpacing)).BeginInit();
this.SuspendLayout();
//
@@ -75,18 +72,15 @@
this.tableLayoutPanel1.Controls.Add(this.labelSize, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.textBoxSize, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.numericUpDownQty, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.numericUpDownThickness, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.labelThk, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.labelPartSpacing, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.numericUpDownPartSpacing, 1, 3);
this.tableLayoutPanel1.Controls.Add(this.labelPartSpacing, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.numericUpDownPartSpacing, 1, 2);
this.tableLayoutPanel1.Location = new System.Drawing.Point(18, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(236, 144);
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(236, 108);
this.tableLayoutPanel1.TabIndex = 0;
//
// labelQty
@@ -119,18 +113,7 @@
this.textBoxSize.Size = new System.Drawing.Size(133, 22);
this.textBoxSize.TabIndex = 1;
this.textBoxSize.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// labelThk
//
this.labelThk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.labelThk.AutoSize = true;
this.labelThk.Location = new System.Drawing.Point(3, 82);
this.labelThk.Name = "labelThk";
this.labelThk.Size = new System.Drawing.Size(91, 16);
this.labelThk.TabIndex = 4;
this.labelThk.Text = "Thickness :";
this.labelThk.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
//
// labelPartSpacing
//
this.labelPartSpacing.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@@ -352,22 +335,7 @@
this.numericUpDownQty.Size = new System.Drawing.Size(133, 22);
this.numericUpDownQty.Suffix = "";
this.numericUpDownQty.TabIndex = 3;
//
// numericUpDownThickness
//
this.numericUpDownThickness.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDownThickness.DecimalPlaces = 4;
this.numericUpDownThickness.Increment = new decimal(new int[] {
25,
0,
0,
131072});
this.numericUpDownThickness.Location = new System.Drawing.Point(100, 79);
this.numericUpDownThickness.Name = "numericUpDownThickness";
this.numericUpDownThickness.Size = new System.Drawing.Size(133, 22);
this.numericUpDownThickness.Suffix = "";
this.numericUpDownThickness.TabIndex = 5;
//
//
// numericUpDownPartSpacing
//
this.numericUpDownPartSpacing.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@@ -414,7 +382,6 @@
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEdgeSpacingRight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownEdgeSpacingBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownQty)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownThickness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPartSpacing)).EndInit();
this.ResumeLayout(false);
@@ -441,8 +408,6 @@
private Controls.NumericUpDown numericUpDownQty;
private Controls.QuadrantSelect quadrantSelect1;
private System.Windows.Forms.GroupBox groupBox2;
private Controls.NumericUpDown numericUpDownThickness;
private System.Windows.Forms.Label labelThk;
private System.Windows.Forms.Label labelPartSpacing;
private Controls.NumericUpDown numericUpDownPartSpacing;
private Controls.BottomPanel bottomPanel1;
-9
View File
@@ -58,7 +58,6 @@ namespace OpenNest.Forms
var controls = new[]
{
numericUpDownThickness,
numericUpDownPartSpacing,
numericUpDownEdgeSpacingBottom,
numericUpDownEdgeSpacingLeft,
@@ -110,12 +109,6 @@ namespace OpenNest.Forms
set { numericUpDownPartSpacing.Value = (decimal)value; }
}
public double Thickness
{
get { return (double)numericUpDownThickness.Value; }
set { numericUpDownThickness.Value = (decimal)value; }
}
public int Quantity
{
get { return (int)numericUpDownQty.Value; }
@@ -163,7 +156,6 @@ namespace OpenNest.Forms
PartSpacing = plate.PartSpacing;
Quantity = plate.Quantity;
Quadrant = plate.Quadrant;
Thickness = plate.Thickness;
}
private void Save()
@@ -176,7 +168,6 @@ namespace OpenNest.Forms
plate.PartSpacing = PartSpacing;
plate.Quantity = Quantity;
plate.Quadrant = Quadrant;
plate.Thickness = Thickness;
}
private void textBox1_TextChanged(object sender, EventArgs e)
-2
View File
@@ -1017,8 +1017,6 @@ namespace OpenNest.Forms
{
Quadrant = source.Quadrant,
PartSpacing = source.PartSpacing,
Thickness = source.Thickness,
Material = source.Material,
};
plate.EdgeSpacing = source.EdgeSpacing;
return plate;
-18
View File
@@ -15,13 +15,10 @@ namespace OpenNest.Forms
{
ColorScheme colorScheme1 = new ColorScheme();
Plate plate1 = new Plate();
Material material1 = new Material();
Collections.ObservableList<Part> observableList_11 = new Collections.ObservableList<Part>();
Plate plate2 = new Plate();
Material material2 = new Material();
Collections.ObservableList<Part> observableList_12 = new Collections.ObservableList<Part>();
Plate plate3 = new Plate();
Material material3 = new Material();
Collections.ObservableList<Part> observableList_13 = new Collections.ObservableList<Part>();
topPanel = new System.Windows.Forms.FlowLayoutPanel();
lblDrawingA = new System.Windows.Forms.Label();
@@ -218,15 +215,10 @@ namespace OpenNest.Forms
cellView.Name = "cellView";
cellView.OffsetIncrementDistance = 10D;
cellView.OffsetTolerance = 0.001D;
material1.Density = 0D;
material1.Grade = null;
material1.Name = null;
plate1.Material = material1;
plate1.Parts = observableList_11;
plate1.PartSpacing = 0D;
plate1.Quadrant = 1;
plate1.Quantity = 0;
plate1.Thickness = 0D;
cellView.Plate = plate1;
cellView.RotateIncrementAngle = 10D;
cellView.Size = new System.Drawing.Size(610, 677);
@@ -274,15 +266,10 @@ namespace OpenNest.Forms
hPreview.Name = "hPreview";
hPreview.OffsetIncrementDistance = 10D;
hPreview.OffsetTolerance = 0.001D;
material2.Density = 0D;
material2.Grade = null;
material2.Name = null;
plate2.Material = material2;
plate2.Parts = observableList_12;
plate2.PartSpacing = 0D;
plate2.Quadrant = 1;
plate2.Quantity = 0;
plate2.Thickness = 0D;
hPreview.Plate = plate2;
hPreview.RotateIncrementAngle = 10D;
hPreview.Size = new System.Drawing.Size(605, 313);
@@ -322,15 +309,10 @@ namespace OpenNest.Forms
vPreview.Name = "vPreview";
vPreview.OffsetIncrementDistance = 10D;
vPreview.OffsetTolerance = 0.001D;
material3.Density = 0D;
material3.Grade = null;
material3.Name = null;
plate3.Material = material3;
plate3.Parts = observableList_13;
plate3.PartSpacing = 0D;
plate3.Quadrant = 1;
plate3.Quantity = 0;
plate3.Thickness = 0D;
vPreview.Plate = plate3;
vPreview.RotateIncrementAngle = 10D;
vPreview.Size = new System.Drawing.Size(605, 320);