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

View File

@@ -21,6 +21,7 @@ namespace OpenNest
Plates.ItemRemoved += Plates_PlateRemoved;
Drawings = new DrawingCollection();
PlateDefaults = new PlateSettings();
Material = new Material();
Customer = string.Empty;
Notes = string.Empty;
}
@@ -38,6 +39,10 @@ namespace OpenNest
public string AssistGas { get; set; } = "";
public double Thickness { get; set; }
public Material Material { get; set; }
public Units Units { get; set; }
public DateTime DateCreated { get; set; }
@@ -84,18 +89,6 @@ namespace OpenNest
set { plate.Quadrant = value; }
}
public double Thickness
{
get { return plate.Thickness; }
set { plate.Thickness = value; }
}
public Material Material
{
get { return plate.Material; }
set { plate.Material = value; }
}
public Size Size
{
get { return plate.Size; }
@@ -116,9 +109,7 @@ namespace OpenNest
public void SetFromExisting(Plate plate)
{
Thickness = plate.Thickness;
Quadrant = plate.Quadrant;
Material = plate.Material;
Size = plate.Size;
EdgeSpacing = plate.EdgeSpacing;
PartSpacing = plate.PartSpacing;
@@ -128,11 +119,9 @@ namespace OpenNest
{
return new Plate()
{
Thickness = Thickness,
Size = Size,
EdgeSpacing = EdgeSpacing,
PartSpacing = PartSpacing,
Material = Material,
Quadrant = Quadrant,
Quantity = 1
};

View File

@@ -43,7 +43,6 @@ namespace OpenNest
{
EdgeSpacing = new Spacing();
Size = size;
Material = new Material();
Parts = new ObservableList<Part>();
Parts.ItemAdded += Parts_PartAdded;
Parts.ItemRemoved += Parts_PartRemoved;
@@ -63,11 +62,6 @@ namespace OpenNest
e.Item.BaseDrawing.Quantity.Nested -= Quantity;
}
/// <summary>
/// Thickness of the plate.
/// </summary>
public double Thickness { get; set; }
/// <summary>
/// The spacing between parts.
/// </summary>
@@ -83,11 +77,6 @@ namespace OpenNest
/// </summary>
public Size Size { get; set; }
/// <summary>
/// Material the plate is made out of.
/// </summary>
public Material Material { get; set; }
public CNC.CuttingStrategy.CuttingParameters CuttingParameters { get; set; }
/// <summary>
@@ -571,19 +560,17 @@ namespace OpenNest
/// <summary>
/// Gets the volume of the plate.
/// </summary>
/// <returns></returns>
public double Volume()
public double Volume(double thickness)
{
return Area() * Thickness;
return Area() * thickness;
}
/// <summary>
/// Gets the weight of the plate.
/// </summary>
/// <returns></returns>
public double Weight()
public double Weight(double thickness, double density)
{
return Volume() * Material.Density;
return Volume(thickness) * density;
}
/// <summary>