From 9db7abcd371ca693338c2c12851820e8f0f98541 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 1 Apr 2026 21:00:59 -0400 Subject: [PATCH] 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) --- OpenNest.Api/NestRunner.cs | 4 +- OpenNest.Console/Program.cs | 5 +- OpenNest.Core/Nest.cs | 21 ++------ OpenNest.Core/Plate.cs | 21 ++------ OpenNest.IO/NestFormat.cs | 4 +- OpenNest.IO/NestReader.cs | 11 ++-- OpenNest.IO/NestWriter.cs | 22 ++++---- OpenNest.Mcp/Tools/InspectionTools.cs | 4 +- OpenNest.Mcp/Tools/SetupTools.cs | 4 +- .../CincinnatiPostProcessor.cs | 12 ++--- OpenNest/Controls/PlateView.cs | 2 - OpenNest/Forms/BomImportForm.cs | 4 +- OpenNest/Forms/EditNestInfoForm.Designer.cs | 53 ++++++++++++++----- OpenNest/Forms/EditNestInfoForm.cs | 12 ++++- OpenNest/Forms/EditPlateForm.Designer.cs | 53 ++++--------------- OpenNest/Forms/EditPlateForm.cs | 9 ---- OpenNest/Forms/MainForm.cs | 2 - OpenNest/Forms/PatternTileForm.Designer.cs | 18 ------- 18 files changed, 101 insertions(+), 160 deletions(-) diff --git a/OpenNest.Api/NestRunner.cs b/OpenNest.Api/NestRunner.cs index f48ba2c..234061c 100644 --- a/OpenNest.Api/NestRunner.cs +++ b/OpenNest.Api/NestRunner.cs @@ -59,6 +59,8 @@ public static class NestRunner // 3. Multi-plate loop var nest = new Nest(); + nest.Thickness = request.Thickness; + nest.Material = new Material(request.Material); var remaining = items.Select(item => item.Quantity).ToList(); while (remaining.Any(q => q > 0)) @@ -67,9 +69,7 @@ public static class NestRunner var plate = new Plate(request.SheetSize) { - Thickness = request.Thickness, PartSpacing = request.Spacing, - Material = new Material(request.Material) }; // Build items for this pass with remaining quantities diff --git a/OpenNest.Console/Program.cs b/OpenNest.Console/Program.cs index 18fb896..3367193 100644 --- a/OpenNest.Console/Program.cs +++ b/OpenNest.Console/Program.cs @@ -279,10 +279,9 @@ static class NestConsole return; } - var templatePlate = new NestReader(options.TemplateFile).Read().PlateDefaults.CreateNew(); - plate.Thickness = templatePlate.Thickness; + var templateNest = new NestReader(options.TemplateFile).Read(); + var templatePlate = templateNest.PlateDefaults.CreateNew(); plate.Quadrant = templatePlate.Quadrant; - plate.Material = templatePlate.Material; plate.EdgeSpacing = templatePlate.EdgeSpacing; plate.PartSpacing = templatePlate.PartSpacing; Console.WriteLine($"Template: {options.TemplateFile}"); diff --git a/OpenNest.Core/Nest.cs b/OpenNest.Core/Nest.cs index 511f28a..ce7e7a8 100644 --- a/OpenNest.Core/Nest.cs +++ b/OpenNest.Core/Nest.cs @@ -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 }; diff --git a/OpenNest.Core/Plate.cs b/OpenNest.Core/Plate.cs index cdd2df0..01949d7 100644 --- a/OpenNest.Core/Plate.cs +++ b/OpenNest.Core/Plate.cs @@ -43,7 +43,6 @@ namespace OpenNest { EdgeSpacing = new Spacing(); Size = size; - Material = new Material(); Parts = new ObservableList(); Parts.ItemAdded += Parts_PartAdded; Parts.ItemRemoved += Parts_PartRemoved; @@ -63,11 +62,6 @@ namespace OpenNest e.Item.BaseDrawing.Quantity.Nested -= Quantity; } - /// - /// Thickness of the plate. - /// - public double Thickness { get; set; } - /// /// The spacing between parts. /// @@ -83,11 +77,6 @@ namespace OpenNest /// public Size Size { get; set; } - /// - /// Material the plate is made out of. - /// - public Material Material { get; set; } - public CNC.CuttingStrategy.CuttingParameters CuttingParameters { get; set; } /// @@ -571,19 +560,17 @@ namespace OpenNest /// /// Gets the volume of the plate. /// - /// - public double Volume() + public double Volume(double thickness) { - return Area() * Thickness; + return Area() * thickness; } /// /// Gets the weight of the plate. /// - /// - public double Weight() + public double Weight(double thickness, double density) { - return Volume() * Material.Density; + return Volume(thickness) * density; } /// diff --git a/OpenNest.IO/NestFormat.cs b/OpenNest.IO/NestFormat.cs index 7aa326a..90b6889 100644 --- a/OpenNest.IO/NestFormat.cs +++ b/OpenNest.IO/NestFormat.cs @@ -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 Drawings { get; init; } = new(); public List 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 Parts { get; init; } = new(); diff --git a/OpenNest.IO/NestReader.cs b/OpenNest.IO/NestReader.cs index 9a35d19..6c4ffb7 100644 --- a/OpenNest.IO/NestReader.cs +++ b/OpenNest.IO/NestReader.cs @@ -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; diff --git a/OpenNest.IO/NestWriter.cs b/OpenNest.IO/NestWriter.cs index 52292bc..29692cc 100644 --- a/OpenNest.IO/NestWriter.cs +++ b/OpenNest.IO/NestWriter.cs @@ -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, diff --git a/OpenNest.Mcp/Tools/InspectionTools.cs b/OpenNest.Mcp/Tools/InspectionTools.cs index f72a1b9..40b2c3b 100644 --- a/OpenNest.Mcp/Tools/InspectionTools.cs +++ b/OpenNest.Mcp/Tools/InspectionTools.cs @@ -33,8 +33,8 @@ namespace OpenNest.Mcp.Tools sb.AppendLine($"Plate {plateIndex}:"); sb.AppendLine($" Size: {plate.Size.Width:F1} x {plate.Size.Length:F1}"); sb.AppendLine($" Quadrant: {plate.Quadrant}"); - sb.AppendLine($" Thickness: {plate.Thickness:F2}"); - sb.AppendLine($" Material: {plate.Material.Name}"); + sb.AppendLine($" Thickness: {_session.Nest?.Thickness:F2}"); + sb.AppendLine($" Material: {_session.Nest?.Material?.Name}"); sb.AppendLine($" Part spacing: {plate.PartSpacing:F2}"); sb.AppendLine($" Edge spacing: L={plate.EdgeSpacing.Left:F2} B={plate.EdgeSpacing.Bottom:F2} R={plate.EdgeSpacing.Right:F2} T={plate.EdgeSpacing.Top:F2}"); sb.AppendLine($" Work area: {work.X:F1},{work.Y:F1} {work.Width:F1}x{work.Length:F1}"); diff --git a/OpenNest.Mcp/Tools/SetupTools.cs b/OpenNest.Mcp/Tools/SetupTools.cs index 53c1173..bb1daf9 100644 --- a/OpenNest.Mcp/Tools/SetupTools.cs +++ b/OpenNest.Mcp/Tools/SetupTools.cs @@ -31,8 +31,8 @@ namespace OpenNest.Mcp.Tools plate.Quadrant = quadrant; plate.Quantity = 1; - if (!string.IsNullOrEmpty(material)) - plate.Material.Name = material; + if (!string.IsNullOrEmpty(material) && _session.Nest != null) + _session.Nest.Material = new Material(material); _session.Plates.Add(plate); diff --git a/OpenNest.Posts.Cincinnati/CincinnatiPostProcessor.cs b/OpenNest.Posts.Cincinnati/CincinnatiPostProcessor.cs index 1322cdf..4f50a33 100644 --- a/OpenNest.Posts.Cincinnati/CincinnatiPostProcessor.cs +++ b/OpenNest.Posts.Cincinnati/CincinnatiPostProcessor.cs @@ -75,11 +75,9 @@ namespace OpenNest.Posts.Cincinnati var gas = MaterialLibraryResolver.ResolveGas(nest, Config); var etchLibrary = resolver.ResolveEtchLibrary(Config.DefaultEtchGas); - // Resolve cut library from first plate for preamble + // Resolve cut library from nest material/thickness for preamble var firstPlate = plates.FirstOrDefault(); - var initialCutLibrary = firstPlate != null - ? resolver.ResolveCutLibrary(firstPlate.Material?.Name ?? "", firstPlate.Thickness, gas) - : ""; + var initialCutLibrary = resolver.ResolveCutLibrary(nest.Material?.Name ?? "", nest.Thickness, gas); // 4. Build part sub-program registry (if enabled) Dictionary<(int, long), int> partSubprograms = null; @@ -92,8 +90,8 @@ namespace OpenNest.Posts.Cincinnati var preamble = new CincinnatiPreambleWriter(Config); var sheetWriter = new CincinnatiSheetWriter(Config, vars); - // 6. Build material description from first plate - var material = firstPlate?.Material; + // 6. Build material description from nest + var material = nest.Material; var materialDesc = material != null ? $"{material.Name}{(string.IsNullOrEmpty(material.Grade) ? "" : $", {material.Grade}")}" : ""; @@ -113,7 +111,7 @@ namespace OpenNest.Posts.Cincinnati var plate = plates[i]; var sheetIndex = i + 1; var subNumber = Config.SheetSubprogramStart + i; - var cutLibrary = resolver.ResolveCutLibrary(plate.Material?.Name ?? "", plate.Thickness, gas); + var cutLibrary = resolver.ResolveCutLibrary(nest.Material?.Name ?? "", nest.Thickness, gas); var isLastSheet = i == plates.Count - 1; sheetWriter.Write(writer, plate, nest.Name ?? "NEST", sheetIndex, subNumber, cutLibrary, etchLibrary, partSubprograms, isLastSheet); diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index 7aa94fe..d0c3792 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -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; diff --git a/OpenNest/Forms/BomImportForm.cs b/OpenNest/Forms/BomImportForm.cs index fde561b..fb8f376 100644 --- a/OpenNest/Forms/BomImportForm.cs +++ b/OpenNest/Forms/BomImportForm.cs @@ -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); diff --git a/OpenNest/Forms/EditNestInfoForm.Designer.cs b/OpenNest/Forms/EditNestInfoForm.Designer.cs index 77e60b6..aa4d802 100644 --- a/OpenNest/Forms/EditNestInfoForm.Designer.cs +++ b/OpenNest/Forms/EditNestInfoForm.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/OpenNest/Forms/EditNestInfoForm.cs b/OpenNest/Forms/EditNestInfoForm.cs index 1b28f7d..235c0c2 100644 --- a/OpenNest/Forms/EditNestInfoForm.cs +++ b/OpenNest/Forms/EditNestInfoForm.cs @@ -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); diff --git a/OpenNest/Forms/EditPlateForm.Designer.cs b/OpenNest/Forms/EditPlateForm.Designer.cs index 415b10a..596a080 100644 --- a/OpenNest/Forms/EditPlateForm.Designer.cs +++ b/OpenNest/Forms/EditPlateForm.Designer.cs @@ -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; diff --git a/OpenNest/Forms/EditPlateForm.cs b/OpenNest/Forms/EditPlateForm.cs index 5781329..a2daf7d 100644 --- a/OpenNest/Forms/EditPlateForm.cs +++ b/OpenNest/Forms/EditPlateForm.cs @@ -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) diff --git a/OpenNest/Forms/MainForm.cs b/OpenNest/Forms/MainForm.cs index b0cc586..fa010d7 100644 --- a/OpenNest/Forms/MainForm.cs +++ b/OpenNest/Forms/MainForm.cs @@ -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; diff --git a/OpenNest/Forms/PatternTileForm.Designer.cs b/OpenNest/Forms/PatternTileForm.Designer.cs index 57d8a2b..29eb86e 100644 --- a/OpenNest/Forms/PatternTileForm.Designer.cs +++ b/OpenNest/Forms/PatternTileForm.Designer.cs @@ -15,13 +15,10 @@ namespace OpenNest.Forms { ColorScheme colorScheme1 = new ColorScheme(); Plate plate1 = new Plate(); - Material material1 = new Material(); Collections.ObservableList observableList_11 = new Collections.ObservableList(); Plate plate2 = new Plate(); - Material material2 = new Material(); Collections.ObservableList observableList_12 = new Collections.ObservableList(); Plate plate3 = new Plate(); - Material material3 = new Material(); Collections.ObservableList observableList_13 = new Collections.ObservableList(); 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);