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:
@@ -24,6 +24,8 @@ namespace OpenNest.IO
|
||||
public string DateLastModified { get; init; } = "";
|
||||
public string Notes { get; init; } = "";
|
||||
public string AssistGas { get; init; } = "";
|
||||
public double Thickness { get; init; }
|
||||
public MaterialDto Material { get; init; } = new();
|
||||
public PlateDefaultsDto PlateDefaults { get; init; } = new();
|
||||
public List<DrawingDto> Drawings { get; init; } = new();
|
||||
public List<PlateDto> Plates { get; init; } = new();
|
||||
@@ -57,11 +59,9 @@ namespace OpenNest.IO
|
||||
{
|
||||
public int Id { get; init; }
|
||||
public SizeDto Size { get; init; } = new();
|
||||
public double Thickness { get; init; }
|
||||
public int Quadrant { get; init; } = 1;
|
||||
public int Quantity { get; init; } = 1;
|
||||
public double PartSpacing { get; init; }
|
||||
public MaterialDto Material { get; init; } = new();
|
||||
public SpacingDto EdgeSpacing { get; init; } = new();
|
||||
public double GrainAngle { get; init; }
|
||||
public List<PartDto> Parts { get; init; } = new();
|
||||
|
||||
@@ -180,13 +180,16 @@ namespace OpenNest.IO
|
||||
nest.Notes = dto.Notes;
|
||||
nest.AssistGas = dto.AssistGas ?? "";
|
||||
|
||||
// Plate defaults
|
||||
// Nest-level material and thickness (fall back to PlateDefaults for old files)
|
||||
var pd = dto.PlateDefaults;
|
||||
var matDto = dto.Material ?? pd.Material;
|
||||
nest.Thickness = dto.Thickness > 0 ? dto.Thickness : pd.Thickness;
|
||||
nest.Material = new Material(matDto.Name, matDto.Grade, matDto.Density);
|
||||
|
||||
// Plate defaults
|
||||
nest.PlateDefaults.Size = new OpenNest.Geometry.Size(pd.Size.Width, pd.Size.Length);
|
||||
nest.PlateDefaults.Thickness = pd.Thickness;
|
||||
nest.PlateDefaults.Quadrant = pd.Quadrant;
|
||||
nest.PlateDefaults.PartSpacing = pd.PartSpacing;
|
||||
nest.PlateDefaults.Material = new Material(pd.Material.Name, pd.Material.Grade, pd.Material.Density);
|
||||
nest.PlateDefaults.EdgeSpacing = new Spacing(pd.EdgeSpacing.Left, pd.EdgeSpacing.Bottom, pd.EdgeSpacing.Right, pd.EdgeSpacing.Top);
|
||||
|
||||
// Drawings
|
||||
@@ -198,11 +201,9 @@ namespace OpenNest.IO
|
||||
{
|
||||
var plate = new Plate();
|
||||
plate.Size = new OpenNest.Geometry.Size(p.Size.Width, p.Size.Length);
|
||||
plate.Thickness = p.Thickness;
|
||||
plate.Quadrant = p.Quadrant;
|
||||
plate.Quantity = p.Quantity;
|
||||
plate.PartSpacing = p.PartSpacing;
|
||||
plate.Material = new Material(p.Material.Name, p.Material.Grade, p.Material.Density);
|
||||
plate.EdgeSpacing = new Spacing(p.EdgeSpacing.Left, p.EdgeSpacing.Bottom, p.EdgeSpacing.Right, p.EdgeSpacing.Top);
|
||||
plate.GrainAngle = p.GrainAngle;
|
||||
|
||||
|
||||
@@ -79,6 +79,13 @@ namespace OpenNest.IO
|
||||
DateLastModified = nest.DateLastModified.ToString("o"),
|
||||
Notes = nest.Notes ?? "",
|
||||
AssistGas = nest.AssistGas ?? "",
|
||||
Thickness = nest.Thickness,
|
||||
Material = new MaterialDto
|
||||
{
|
||||
Name = nest.Material.Name ?? "",
|
||||
Grade = nest.Material.Grade ?? "",
|
||||
Density = nest.Material.Density
|
||||
},
|
||||
PlateDefaults = BuildPlateDefaultsDto(),
|
||||
Drawings = BuildDrawingDtos(),
|
||||
Plates = BuildPlateDtos()
|
||||
@@ -91,14 +98,14 @@ namespace OpenNest.IO
|
||||
return new PlateDefaultsDto
|
||||
{
|
||||
Size = new SizeDto { Width = pd.Size.Width, Length = pd.Size.Length },
|
||||
Thickness = pd.Thickness,
|
||||
Thickness = nest.Thickness,
|
||||
Quadrant = pd.Quadrant,
|
||||
PartSpacing = pd.PartSpacing,
|
||||
Material = new MaterialDto
|
||||
{
|
||||
Name = pd.Material.Name ?? "",
|
||||
Grade = pd.Material.Grade ?? "",
|
||||
Density = pd.Material.Density
|
||||
Name = nest.Material.Name ?? "",
|
||||
Grade = nest.Material.Grade ?? "",
|
||||
Density = nest.Material.Density
|
||||
},
|
||||
EdgeSpacing = new SpacingDto
|
||||
{
|
||||
@@ -196,16 +203,9 @@ namespace OpenNest.IO
|
||||
{
|
||||
Id = i + 1,
|
||||
Size = new SizeDto { Width = plate.Size.Width, Length = plate.Size.Length },
|
||||
Thickness = plate.Thickness,
|
||||
Quadrant = plate.Quadrant,
|
||||
Quantity = plate.Quantity,
|
||||
PartSpacing = plate.PartSpacing,
|
||||
Material = new MaterialDto
|
||||
{
|
||||
Name = plate.Material.Name ?? "",
|
||||
Grade = plate.Material.Grade ?? "",
|
||||
Density = plate.Material.Density
|
||||
},
|
||||
EdgeSpacing = new SpacingDto
|
||||
{
|
||||
Left = plate.EdgeSpacing.Left,
|
||||
|
||||
Reference in New Issue
Block a user