mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 07:19:24 -05:00
feat(data): store a nest's thickness name and show it
Nests showed only the decimal (0.135), while the shop thinks in gauges. A nest now keeps a ThicknessName in its file, record and the server (schema v20), set from Nest Information's new box, which suggests the machine's name or the nearest standard gauge. The Open list, status bar and reports show "10 ga (0.135)"; nests saved without a name get one looked up for display only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7d0a81b72f
commit
6b161d7a8b
43 files changed
+661
-63
No files matched your search
@@ -353,6 +353,8 @@ namespace OpenNest.Avalonia
|
||||
{
|
||||
Name = (name.Text ?? "").Trim(),
|
||||
Thickness = thicknessValue,
|
||||
// No box edits the name here yet: it stays with its thickness and goes with it.
|
||||
ThicknessName = thicknessValue == shown.Thickness ? shown.ThicknessName : "",
|
||||
MaterialName = material.Text,
|
||||
MaterialGrade = grade.Text,
|
||||
Customer = customer.Text ?? "",
|
||||
|
||||
+19
-1
@@ -53,20 +53,38 @@ namespace OpenNest
|
||||
|
||||
public string MadeBy { get; set; } = "";
|
||||
|
||||
/// <summary>The stock thickness. A different value clears every plate's <see cref="Plate.StockItemCodes"/>.</summary>
|
||||
/// <summary>
|
||||
/// The stock thickness. A different value clears every plate's <see cref="Plate.StockItemCodes"/>
|
||||
/// and the <see cref="ThicknessName"/>, which named the old value.
|
||||
/// </summary>
|
||||
public double Thickness
|
||||
{
|
||||
get { return thickness; }
|
||||
set
|
||||
{
|
||||
if (value != thickness)
|
||||
{
|
||||
ClearStockItemCodes();
|
||||
ThicknessName = "";
|
||||
}
|
||||
thickness = value;
|
||||
}
|
||||
}
|
||||
|
||||
private double thickness;
|
||||
|
||||
/// <summary>
|
||||
/// The name the shop calls <see cref="Thickness"/>, such as a gauge ("10 ga") or a fraction
|
||||
/// ("1/4\""); blank when it has none. Set it after the thickness: a new thickness clears it.
|
||||
/// </summary>
|
||||
public string ThicknessName
|
||||
{
|
||||
get { return thicknessName; }
|
||||
set { thicknessName = value?.Trim() ?? ""; }
|
||||
}
|
||||
|
||||
private string thicknessName = "";
|
||||
|
||||
/// <summary>
|
||||
/// The stock material. A different name or grade (ignoring case and spacing) clears every
|
||||
/// plate's <see cref="Plate.StockItemCodes"/>: the coded items are another material.
|
||||
|
||||
@@ -28,16 +28,24 @@ public static class MachineCuttingDefaults
|
||||
public static ThicknessConfig? Find(MachineConfig? machine, Nest nest)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
var name = nest.Material?.Name;
|
||||
if (machine == null || string.IsNullOrWhiteSpace(name) || !double.IsFinite(nest.Thickness) || nest.Thickness <= 0)
|
||||
return Find(machine, nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The thickness settings of <paramref name="machine"/> for <paramref name="materialName"/>
|
||||
/// (<paramref name="grade"/> when set, otherwise the first grade on file) and
|
||||
/// <paramref name="value"/> in <paramref name="units"/>, or null when the machine has none.
|
||||
/// </summary>
|
||||
public static ThicknessConfig? Find(MachineConfig? machine, string? materialName, string? grade, double value, Units units)
|
||||
{
|
||||
if (machine == null || string.IsNullOrWhiteSpace(materialName) || !double.IsFinite(value) || value <= 0)
|
||||
return null;
|
||||
|
||||
var grade = nest.Material.Grade;
|
||||
var material = string.IsNullOrWhiteSpace(grade) ? machine.GetMaterial(name) : machine.GetMaterial(name, grade);
|
||||
var material = string.IsNullOrWhiteSpace(grade) ? machine.GetMaterial(materialName) : machine.GetMaterial(materialName, grade);
|
||||
if (material == null)
|
||||
return null;
|
||||
|
||||
var thickness = nest.Thickness * Scale(nest.Units, machine.Units);
|
||||
var thickness = value * Scale(units, machine.Units);
|
||||
var tolerance = ThicknessToleranceInches * Scale(Units.Inches, machine.Units);
|
||||
return material.Thicknesses
|
||||
.Where(t => System.Math.Abs(t.Value - thickness) <= tolerance)
|
||||
|
||||
@@ -34,6 +34,12 @@ public sealed class NestRecord
|
||||
|
||||
public double Thickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The shop's name for <see cref="Thickness"/>, such as "10 ga"; blank when the nest names
|
||||
/// none or the server predates thickness names.
|
||||
/// </summary>
|
||||
public string ThicknessName { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// The nest's units, which <see cref="Thickness"/> is in. The server reads them from the
|
||||
/// archive like the counts; inches when the archive has none or the server predates them.
|
||||
|
||||
@@ -23,6 +23,7 @@ public static class NestRecordFactory
|
||||
nest.DateCreated = record.DateCreated;
|
||||
nest.Material = NestMaterialSelection.ApplyRecorded(nest.Material, record.Material, record.MaterialGrade);
|
||||
nest.Thickness = record.Thickness;
|
||||
nest.ThicknessName = record.ThicknessName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,6 +47,7 @@ public static class NestRecordFactory
|
||||
Material = nest.Material?.Name ?? "",
|
||||
MaterialGrade = nest.Material?.Grade ?? "",
|
||||
Thickness = nest.Thickness,
|
||||
ThicknessName = nest.ThicknessName ?? "",
|
||||
Units = nest.Units,
|
||||
Status = nest.Status,
|
||||
// The trailing empty plate is the editor's new-plate slot, not a plate of the nest.
|
||||
|
||||
@@ -128,6 +128,6 @@ public sealed class NestSaveSession
|
||||
private static bool SameEditableMetadata(NestRecord a, NestRecord b) =>
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.DateCreated == b.DateCreated
|
||||
&& a.DateModified == b.DateModified && a.Material == b.Material && a.MaterialGrade == b.MaterialGrade
|
||||
&& a.Thickness == b.Thickness && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount
|
||||
&& a.Thickness == b.Thickness && a.ThicknessName == b.ThicknessName && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount
|
||||
&& a.Comments == b.Comments && a.MadeBy == b.MadeBy;
|
||||
}
|
||||
@@ -61,6 +61,22 @@ public static partial class StandardThicknesses
|
||||
return Entries.FirstOrDefault(e => System.Math.Abs(ValueIn(e, units) - value) < tolerance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The entry nearest <paramref name="value"/> (in <paramref name="units"/>) within
|
||||
/// <paramref name="toleranceInches"/>, or null. A loose tolerance names the rounded decimals
|
||||
/// shops type, such as 0.135 for 10 ga or 0.188 for 3/16".
|
||||
/// </summary>
|
||||
public static Entry? FindNearest(double value, Units units, double toleranceInches)
|
||||
{
|
||||
if (!double.IsFinite(value) || value <= 0)
|
||||
return null;
|
||||
var inches = units == Units.Millimeters ? value / MillimetersPerInch : value;
|
||||
return Entries
|
||||
.Where(e => System.Math.Abs(e.Inches - inches) <= toleranceInches)
|
||||
.OrderBy(e => System.Math.Abs(e.Inches - inches))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a thickness box: a list label, a gauge ("16 ga", "16ga", "#16"), a fraction of
|
||||
/// an inch ("3/32", "1-1/4", "1 1/4\"") or a non-negative number. Blank text reads as 0.
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace OpenNest.Data;
|
||||
|
||||
/// <summary>
|
||||
/// The shop's names for thicknesses, such as "10 ga" for 0.135, and the "10 ga (0.135)" text
|
||||
/// that shows them. A nest stores its name (<see cref="Nest.ThicknessName"/>); one without is
|
||||
/// named here: the machine's name for its material and thickness first, otherwise the nearest
|
||||
/// standard gauge or plate fraction.
|
||||
/// </summary>
|
||||
public static class ThicknessNames
|
||||
{
|
||||
// As machine thicknesses match: decimals typed to three places (0.135 for 10 ga, 0.188 for
|
||||
// 3/16") still name their gauge, and gauges are far further apart.
|
||||
private const double ToleranceInches = 0.001;
|
||||
|
||||
/// <summary>"10 ga (0.135)", or the plain decimal when <paramref name="name"/> is blank.</summary>
|
||||
public static string Format(string? name, double thickness)
|
||||
{
|
||||
var number = thickness.ToString("0.####", CultureInfo.CurrentCulture);
|
||||
return string.IsNullOrWhiteSpace(name) ? number : $"{name.Trim()} ({number})";
|
||||
}
|
||||
|
||||
/// <summary>The thickness text for <paramref name="nest"/>: its name, or one looked up, then the decimal.</summary>
|
||||
public static string Format(Nest nest, IEnumerable<MachineConfig?> machines)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
var name = string.IsNullOrWhiteSpace(nest.ThicknessName) ? For(machines, nest) : nest.ThicknessName;
|
||||
return Format(name, nest.Thickness);
|
||||
}
|
||||
|
||||
/// <summary>The thickness text for a saved nest: its stored name, or one looked up, then the decimal.</summary>
|
||||
public static string Format(NestRecord record, IEnumerable<MachineConfig?> machines)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
var name = string.IsNullOrWhiteSpace(record.ThicknessName)
|
||||
? For(machines, record.Material, record.MaterialGrade, record.Thickness, record.Units)
|
||||
: record.ThicknessName;
|
||||
return Format(name, record.Thickness);
|
||||
}
|
||||
|
||||
/// <summary>The name for the thickness of <paramref name="nest"/>; blank when nothing names it.</summary>
|
||||
public static string For(IEnumerable<MachineConfig?> machines, Nest nest)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
return For(machines, nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name for <paramref name="thickness"/> (in <paramref name="units"/>) of
|
||||
/// <paramref name="material"/>: the first of <paramref name="machines"/> that names it, otherwise
|
||||
/// the nearest standard gauge or plate fraction; blank when nothing names it.
|
||||
/// </summary>
|
||||
public static string For(IEnumerable<MachineConfig?> machines, string? material, string? grade, double thickness, Units units)
|
||||
{
|
||||
if (!double.IsFinite(thickness) || thickness <= 0)
|
||||
return "";
|
||||
|
||||
foreach (var machine in machines ?? Enumerable.Empty<MachineConfig?>())
|
||||
{
|
||||
var name = MachineCuttingDefaults.Find(machine, material, grade, thickness, units)?.Name;
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
return name.Trim();
|
||||
}
|
||||
|
||||
return StandardThicknesses.FindNearest(thickness, units, ToleranceInches)?.Name ?? "";
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,14 @@ public sealed class MainStatusTextTests : IDisposable
|
||||
{
|
||||
var nest = new Nest { Thickness = 0.5, Units = Units.Inches, Material = new Material("Mild Steel", "A36", 0.2836) };
|
||||
|
||||
Assert.Equal("Material: Mild Steel A36 · 0.5 in", MainStatusText.Material(nest));
|
||||
Assert.Equal("Material: Mild Steel A36 · 1/2\" (0.5 in)", MainStatusText.Material(nest));
|
||||
|
||||
nest.Thickness = 0.135;
|
||||
nest.ThicknessName = "Ten";
|
||||
Assert.Equal("Material: Mild Steel A36 · Ten (0.135 in)", MainStatusText.Material(nest));
|
||||
|
||||
nest.Thickness = 0.3;
|
||||
Assert.Equal("Material: Mild Steel A36 · 0.3 in", MainStatusText.Material(nest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -12,6 +12,7 @@ public class NestInfoValuesTests
|
||||
nest.Customer = "Acme";
|
||||
nest.Notes = "rush";
|
||||
nest.Thickness = 0.25;
|
||||
nest.ThicknessName = "1/4\"";
|
||||
nest.Material = new Material("Steel", "A36");
|
||||
nest.Status = NestStatus.ToBeCut;
|
||||
nest.MadeBy = "someone";
|
||||
@@ -42,6 +43,7 @@ public class NestInfoValuesTests
|
||||
Assert.Equal("Acme", target.Customer);
|
||||
Assert.Equal("rush", target.Notes);
|
||||
Assert.Equal(0.25, target.Thickness);
|
||||
Assert.Equal("1/4\"", target.ThicknessName);
|
||||
Assert.Equal("Steel", target.Material.Name);
|
||||
Assert.Equal("A36", target.Material.Grade);
|
||||
Assert.Equal(NestStatus.ToBeCut, target.Status);
|
||||
@@ -103,6 +105,17 @@ public class NestInfoValuesTests
|
||||
Assert.NotEqual(before, NestInfoValues.UndoableKey(nest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UndoableKey_RecordsAThicknessNameEdit()
|
||||
{
|
||||
var nest = InfoNest();
|
||||
var before = NestInfoValues.UndoableKey(nest);
|
||||
|
||||
nest.ThicknessName = "3 ga";
|
||||
|
||||
Assert.NotEqual(before, NestInfoValues.UndoableKey(nest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MaterialNames_MergeThePostsAndTheCatalogOncePerName()
|
||||
{
|
||||
|
||||
@@ -97,10 +97,16 @@ public sealed class NestReportExportTests : IDisposable
|
||||
nest.Machine = new NestMachine(own.Id, own.Name);
|
||||
|
||||
var named = NestReportExport.Capture(nest, At, new[] { own }, new Dictionary<string, string>());
|
||||
nest.ThicknessName = "Sixteen";
|
||||
var stored = NestReportExport.Capture(nest, At, new[] { own }, new Dictionary<string, string>());
|
||||
nest.Thickness = 0.25;
|
||||
var standard = NestReportExport.Capture(nest, At, new[] { own }, new Dictionary<string, string>());
|
||||
nest.Thickness = 0.3;
|
||||
var unnamed = NestReportExport.Capture(nest, At, new[] { own }, new Dictionary<string, string>());
|
||||
|
||||
Assert.Equal("16 ga", named.ThicknessName);
|
||||
Assert.Equal("Sixteen", stored.ThicknessName);
|
||||
Assert.Equal("1/4\"", standard.ThicknessName);
|
||||
Assert.Equal("", unnamed.ThicknessName);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using OpenNest.Data;
|
||||
using OpenNest.Desktop;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
@@ -56,17 +57,31 @@ namespace OpenNest.Forms
|
||||
return "Machine: " + (string.IsNullOrWhiteSpace(machine.Name) ? "(unnamed)" : machine.Name.Trim());
|
||||
}
|
||||
|
||||
/// <summary>The material text for <paramref name="nest"/> (see <see cref="Material(string, string, double, Units)"/>).</summary>
|
||||
/// <summary>
|
||||
/// The material text for <paramref name="nest"/> (see
|
||||
/// <see cref="Material(string, string, double, Units, string)"/>), its thickness named by
|
||||
/// <see cref="Nest.ThicknessName"/> or, without one, the nearest standard gauge or fraction.
|
||||
/// </summary>
|
||||
public static string Material(Nest nest)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
return Material(nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units);
|
||||
var thicknessName = string.IsNullOrWhiteSpace(nest.ThicknessName)
|
||||
? ThicknessNames.For(Array.Empty<MachineConfig>(), nest)
|
||||
: nest.ThicknessName;
|
||||
return Material(nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units, thicknessName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Status text for the nest's material, grade and thickness, e.g. "Material: Steel A36 · 0.25 in".
|
||||
/// </summary>
|
||||
public static string Material(string name, string grade, double thickness, Units units)
|
||||
public static string Material(string name, string grade, double thickness, Units units) =>
|
||||
Material(name, grade, thickness, units, null);
|
||||
|
||||
/// <summary>
|
||||
/// Status text for the nest's material, grade and thickness, the thickness after its name
|
||||
/// when it has one, e.g. "Material: Steel A36 · 10 ga (0.135 in)".
|
||||
/// </summary>
|
||||
public static string Material(string name, string grade, double thickness, Units units, string thicknessName)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
var description = string.Join(" ", new[] { name?.Trim(), grade?.Trim() }
|
||||
@@ -74,7 +89,10 @@ namespace OpenNest.Forms
|
||||
if (description.Length > 0)
|
||||
parts.Add(description);
|
||||
if (thickness > 0)
|
||||
parts.Add(thickness.ToString("0.####", CultureInfo.CurrentCulture) + " " + UnitsHelper.GetShortString(units));
|
||||
{
|
||||
var value = thickness.ToString("0.####", CultureInfo.CurrentCulture) + " " + UnitsHelper.GetShortString(units);
|
||||
parts.Add(string.IsNullOrWhiteSpace(thicknessName) ? value : $"{thicknessName.Trim()} ({value})");
|
||||
}
|
||||
|
||||
return "Material: " + (parts.Count == 0 ? "(none)" : string.Join(" · ", parts));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ using OpenNest.Geometry;
|
||||
namespace OpenNest.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// What Nest > Edit (the Edit Nest dialog) edits: the nest's name, dates, thickness,
|
||||
/// What Nest > Edit (the Edit Nest dialog) edits: the nest's name, dates, thickness and its name,
|
||||
/// material and grade, customer, status, author, units, notes and its plate defaults (size,
|
||||
/// part and edge spacing, quadrant). <see cref="FromNest"/> reads a nest, <see cref="CanApply"/>
|
||||
/// is when the dialog's Done button is enabled and <see cref="ApplyTo"/> writes the nest as
|
||||
@@ -35,6 +35,9 @@ public sealed record NestInfoValues
|
||||
/// <summary>The thickness in <see cref="Units"/>.</summary>
|
||||
public double Thickness { get; init; }
|
||||
|
||||
/// <summary>The shop's name for the thickness, such as "10 ga"; blank when it has none.</summary>
|
||||
public string ThicknessName { get; init; } = "";
|
||||
|
||||
public string MaterialName { get; init; } = "";
|
||||
|
||||
public string MaterialGrade { get; init; } = "";
|
||||
@@ -78,6 +81,7 @@ public sealed record NestInfoValues
|
||||
DateCreated = nest.DateCreated,
|
||||
DateLastModified = nest.DateLastModified,
|
||||
Thickness = nest.Thickness,
|
||||
ThicknessName = nest.ThicknessName ?? "",
|
||||
MaterialName = nest.Material?.Name ?? "",
|
||||
MaterialGrade = nest.Material?.Grade ?? "",
|
||||
Status = nest.Status,
|
||||
@@ -123,6 +127,7 @@ public sealed record NestInfoValues
|
||||
nest.DateCreated = DateCreated;
|
||||
nest.DateLastModified = DateLastModified;
|
||||
nest.Thickness = Thickness;
|
||||
nest.ThicknessName = ThicknessName;
|
||||
nest.Material = NestMaterialSelection.Apply(nest.Material, MaterialName, MaterialGrade);
|
||||
nest.Status = Status;
|
||||
nest.MadeBy = MadeBy;
|
||||
@@ -151,7 +156,7 @@ public sealed record NestInfoValues
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
var defaults = nest.PlateDefaults;
|
||||
return string.Join("|", nest.Units, nest.Notes, nest.Customer, nest.Thickness, nest.Material?.Name,
|
||||
return string.Join("|", nest.Units, nest.Notes, nest.Customer, nest.Thickness, nest.ThicknessName, nest.Material?.Name,
|
||||
nest.Material?.Grade, defaults.Size, defaults.PartSpacing, defaults.EdgeSpacing.Left,
|
||||
defaults.EdgeSpacing.Bottom, defaults.EdgeSpacing.Right, defaults.EdgeSpacing.Top, defaults.Quadrant);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public static class NestReportExport
|
||||
/// The report of <paramref name="nest"/>, captured synchronously while the caller keeps the
|
||||
/// nest stable. The nest material's density comes from <paramref name="machine"/> (the nest's
|
||||
/// machine, may be null) and the <paramref name="materials"/> catalog when the material has
|
||||
/// none, and the thickness's name ("16 ga") from the machine's cutting defaults; with
|
||||
/// none, and the thickness's name ("16 ga", see <see cref="ThicknessName"/>); with
|
||||
/// <paramref name="cutParameters"/> each plate gets an estimated cut time.
|
||||
/// Capturing reads the nest only: no quantity, selection or dirty-state change.
|
||||
/// </summary>
|
||||
@@ -53,13 +53,21 @@ public static class NestReportExport
|
||||
var catalogDensity = MaterialDensityLookup.Resolve(material?.Name, material?.Grade, machine, materials);
|
||||
return NestReportBuilder.Capture(nest, generatedAt, cutParameters, catalogDensity) with
|
||||
{
|
||||
ThicknessName = MachineThicknessName(machine, nest),
|
||||
ThicknessName = ThicknessName(machine, nest),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The name the machine config gives the nest's thickness ("16 ga"), or empty.</summary>
|
||||
public static string MachineThicknessName(MachineConfig machine, Nest nest) =>
|
||||
MachineCuttingDefaults.Find(machine, nest)?.Name?.Trim() ?? "";
|
||||
/// <summary>
|
||||
/// The nest's thickness name ("16 ga"): its own <see cref="Nest.ThicknessName"/>, else the
|
||||
/// machine's, else the nearest standard gauge or fraction (<see cref="ThicknessNames"/>), or empty.
|
||||
/// </summary>
|
||||
public static string ThicknessName(MachineConfig machine, Nest nest)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
return string.IsNullOrWhiteSpace(nest.ThicknessName)
|
||||
? ThicknessNames.For(new[] { machine }, nest)
|
||||
: nest.ThicknessName.Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The report captured as the desktop apps do, from machines already read: the nest's
|
||||
|
||||
@@ -102,6 +102,7 @@ public sealed class NewNestSource
|
||||
{
|
||||
nest.Material = new Material(release.MaterialName, release.MaterialGrade);
|
||||
nest.Thickness = release.Thickness;
|
||||
nest.ThicknessName = ThicknessNames.For(new[] { machine }, nest);
|
||||
MachineCuttingDefaults.ApplySpacingTo(nest, machine);
|
||||
}
|
||||
return nest;
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace OpenNest.IO
|
||||
public MachineDto Machine { get; init; }
|
||||
|
||||
public double Thickness { get; init; }
|
||||
|
||||
/// <summary><c>Nest.ThicknessName</c>; omitted when blank, and older files have none.</summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string ThicknessName { get; init; }
|
||||
|
||||
public MaterialDto Material { get; init; } = new();
|
||||
public PlateDefaultsDto PlateDefaults { get; init; } = new();
|
||||
public List<DrawingDto> Drawings { get; init; } = new();
|
||||
|
||||
@@ -740,6 +740,7 @@ namespace OpenNest.IO
|
||||
var pd = dto.PlateDefaults;
|
||||
var matDto = dto.Material ?? pd.Material;
|
||||
nest.Thickness = dto.Thickness > 0 ? dto.Thickness : pd.Thickness;
|
||||
nest.ThicknessName = dto.ThicknessName ?? "";
|
||||
nest.Material = new Material(matDto.Name, matDto.Grade, matDto.Density);
|
||||
|
||||
// Plate defaults
|
||||
|
||||
@@ -143,6 +143,7 @@ namespace OpenNest.IO
|
||||
? new MachineDto { Id = machine.Id, Name = machine.Name }
|
||||
: null,
|
||||
Thickness = nest.Thickness,
|
||||
ThicknessName = string.IsNullOrEmpty(nest.ThicknessName) ? null : nest.ThicknessName,
|
||||
Material = new MaterialDto
|
||||
{
|
||||
Name = nest.Material.Name ?? "",
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
Assert.Empty(database.QueryDrawings(new DrawingLibraryQuery { IncludeArchived = true }).Items);
|
||||
Assert.Equal(before, NestDigest(factory.DatabasePath));
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
@@ -44,7 +44,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
{
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(before, NestDigest(factory.DatabasePath));
|
||||
// Two distinct blobs across four revisions: the bracket's notes edit and the
|
||||
// plate both reuse the bracket's first package.
|
||||
@@ -81,7 +81,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using (new NestDatabase(factory.DatabasePath, pooling: false)) { }
|
||||
Execute(factory.DatabasePath, "PRAGMA user_version=20");
|
||||
Execute(factory.DatabasePath, "PRAGMA user_version=21");
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => new NestDatabase(factory.DatabasePath, pooling: false));
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public sealed class DrawingLibraryDatabaseTests
|
||||
""");
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(-3, upgraded.GetDrawing(record.Id)!.Settings.Priority);
|
||||
Assert.Equal(-3, Assert.Single(upgraded.DrawingHistory(record.Id, 0, 100)!.Items).Settings.Priority);
|
||||
Assert.Equal(int.MaxValue, upgraded.GetDrawing(other.Id)!.Settings.Priority);
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed class DrawingSetDatabaseTests
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
Assert.Empty(database.QueryDrawingSets(new DrawingSetQuery { IncludeArchived = true }).Items);
|
||||
Assert.Equal(before, Digest(factory.DatabasePath));
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
@@ -48,7 +48,7 @@ public sealed class DrawingSetDatabaseTests
|
||||
Assert.Equal(before, Digest(factory.DatabasePath));
|
||||
Execute(factory.DatabasePath, "DROP TABLE ix_drawing_set_members_drawing");
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -25,7 +25,7 @@ public sealed class MaterialListTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Empty(upgraded.ListMaterials());
|
||||
Assert.Equal((" Stainless ", "304"), (upgraded.Get(nest)!.Material, upgraded.Get(nest)!.MaterialGrade));
|
||||
Assert.Equal(drawing.MaterialName, upgraded.GetDrawing(drawing.Id)!.MaterialName);
|
||||
|
||||
@@ -75,7 +75,7 @@ public sealed class NestMaterialGradeTests
|
||||
Assert.Equal("Stainless", record.Material);
|
||||
Assert.Equal("", record.MaterialGrade);
|
||||
Assert.Equal("", Assert.Single(upgraded.History(id, 0, 10)!.Items).MaterialGrade);
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, string material, string grade) => new()
|
||||
|
||||
@@ -119,7 +119,7 @@ public sealed class NestStockCodesTests
|
||||
database.SetDeleted(deleted, false, record.Revision);
|
||||
Assert.Equal(["SHEET-1", "SHEET-2"], database.StockCodesInUse(null).Select(u => u.ItemCode));
|
||||
}
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static Nest Nest(string name, NestStatus status, params string[][] plateCodes)
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
using OpenNest.Data;
|
||||
using static OpenNest.Server.Tests.TestDatabase;
|
||||
|
||||
namespace OpenNest.Server.Tests;
|
||||
|
||||
public sealed class NestThicknessNameTests
|
||||
{
|
||||
[Fact]
|
||||
public void ThicknessName_RoundTripsThroughInsertUpdateAndHistory()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
var id = Guid.NewGuid();
|
||||
|
||||
var created = database.Insert(id, Record("Job", "10 ga"), [1]);
|
||||
Assert.Equal("10 ga", created.ThicknessName);
|
||||
|
||||
var unchanged = database.UpdateMetadata(id, Record("Job", "10 ga"), created.Revision)!;
|
||||
Assert.Equal(created.Revision, unchanged.Revision);
|
||||
|
||||
var updated = database.UpdateMetadata(id, Record("Job", "10 gauge"), created.Revision)!;
|
||||
Assert.Equal("10 gauge", updated.ThicknessName);
|
||||
Assert.Equal(created.Revision + 1, updated.Revision);
|
||||
|
||||
var history = database.History(id, 0, 10)!;
|
||||
Assert.Equal(["10 gauge", "10 ga"], history.Items.Select(r => r.ThicknessName));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Query_SearchesThicknessNames()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
using var database = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
database.Insert(Guid.NewGuid(), Record("A", "10 ga"), [1]);
|
||||
database.Insert(Guid.NewGuid(), Record("B", "16 ga"), [1]);
|
||||
|
||||
var found = database.Query(new NestQuery { Search = "16 ga" });
|
||||
|
||||
Assert.Equal("B", Assert.Single(found.Items).Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Version19Database_GainsBlankThicknessNamesAndKeepsRecords()
|
||||
{
|
||||
using var factory = new ServerFactory();
|
||||
var id = Guid.NewGuid();
|
||||
using (var database = new NestDatabase(factory.DatabasePath, pooling: false))
|
||||
database.Insert(id, Record("Legacy", "10 ga"), [1]);
|
||||
Execute(factory.DatabasePath, """
|
||||
ALTER TABLE nests DROP COLUMN thicknessName;
|
||||
ALTER TABLE nest_revisions DROP COLUMN thicknessName;
|
||||
PRAGMA user_version=19;
|
||||
""");
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
var record = upgraded.Get(id)!;
|
||||
Assert.Equal(0.135, record.Thickness);
|
||||
Assert.Equal("", record.ThicknessName);
|
||||
Assert.Equal("", Assert.Single(upgraded.History(id, 0, 10)!.Items).ThicknessName);
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, string thicknessName) => new()
|
||||
{
|
||||
Name = name,
|
||||
Material = "Mild Steel",
|
||||
Thickness = 0.135,
|
||||
ThicknessName = thicknessName,
|
||||
DateCreated = new DateTime(2026, 1, 1),
|
||||
DateModified = new DateTime(2026, 1, 2),
|
||||
};
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public sealed class NestUnitsTests
|
||||
Assert.Equal([Units.Millimeters, Units.Millimeters], upgraded.History(metric, 0, 10)!.Items.Select(r => r.Units));
|
||||
Assert.Equal(Units.Inches, upgraded.Get(inch)!.Units);
|
||||
Assert.Equal(Units.Inches, upgraded.Get(unreadable)!.Units);
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
}
|
||||
|
||||
private static NestRecord Record(string name, Units units) => new()
|
||||
|
||||
@@ -152,7 +152,7 @@ public sealed class SetReleaseDrawingTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
var kept = upgraded.GetRelease(releaseId)!;
|
||||
Assert.Empty(kept.Drawings);
|
||||
Assert.Equal(((Guid?)kit.Id, drawing, 2), (kept.Nests[0].Items.Single().SetId, kept.Nests[0].Items.Single().DrawingId, kept.Nests[0].Items.Single().Quantity));
|
||||
|
||||
@@ -295,7 +295,7 @@ public sealed class SetReleaseTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(0L, Scalar(factory.DatabasePath, "SELECT COUNT(*) FROM sqlite_master WHERE name LIKE 'set_release%' OR name LIKE 'ix_set_release%'"));
|
||||
var release = upgraded.GetRelease(releaseId)!;
|
||||
Assert.Equal(("Legacy notes", "Legacy operator", false), (release.Notes, release.ReleasedBy, release.IsUndone));
|
||||
|
||||
@@ -101,7 +101,7 @@ public sealed class SharedSettingsTests
|
||||
|
||||
using var upgraded = new NestDatabase(factory.DatabasePath, pooling: false);
|
||||
|
||||
Assert.Equal(19L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Equal(20L, Scalar(factory.DatabasePath, "PRAGMA user_version"));
|
||||
Assert.Empty(upgraded.ListSharedSettings());
|
||||
}
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Transaction = transaction;
|
||||
command.CommandText = """
|
||||
INSERT INTO nests (id, name, customer, dateCreated, dateModified, material,
|
||||
materialGrade, thickness, units, status, plateCount, partCount, comments, madeBy,
|
||||
materialGrade, thickness, thicknessName, units, status, plateCount, partCount, comments, madeBy,
|
||||
fileSize, savedAt, file)
|
||||
VALUES ($id, $name, $customer, $dateCreated, $dateModified, $material,
|
||||
$materialGrade, $thickness, $units, $status, $plateCount, $partCount, $comments,
|
||||
$materialGrade, $thickness, $thicknessName, $units, $status, $plateCount, $partCount, $comments,
|
||||
$madeBy, $fileSize, $savedAt, $file)
|
||||
""";
|
||||
AddRecordParameters(command, id, record, file, updateFile: true);
|
||||
@@ -212,7 +212,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
UPDATE nests SET
|
||||
name = $name, customer = $customer, dateCreated = $dateCreated,
|
||||
dateModified = $dateModified, material = $material,
|
||||
materialGrade = $materialGrade, thickness = $thickness, units = $units, status = $status, plateCount = $plateCount,
|
||||
materialGrade = $materialGrade, thickness = $thickness, thicknessName = $thicknessName, units = $units, status = $status, plateCount = $plateCount,
|
||||
partCount = $partCount, comments = $comments, madeBy = $madeBy,
|
||||
savedAt = $savedAt, revision = $revision, restoredFromRevision=$source{fileClause}
|
||||
WHERE id = $id
|
||||
@@ -319,7 +319,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
private static bool SameMetadata(NestRecord a, NestRecord b) =>
|
||||
a.Name == b.Name && a.Customer == b.Customer && a.DateCreated == b.DateCreated &&
|
||||
a.DateModified == b.DateModified && a.Material == b.Material && a.MaterialGrade == b.MaterialGrade &&
|
||||
a.Thickness == b.Thickness && a.Units == b.Units && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount &&
|
||||
a.Thickness == b.Thickness && a.ThicknessName == b.ThicknessName && a.Units == b.Units && a.Status == b.Status && a.PlateCount == b.PlateCount && a.PartCount == b.PartCount &&
|
||||
a.Comments == b.Comments && a.MadeBy == b.MadeBy;
|
||||
|
||||
private void Snapshot(Guid id, SqliteTransaction transaction)
|
||||
@@ -352,7 +352,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Transaction = transaction;
|
||||
command.CommandText = "PRAGMA user_version";
|
||||
var version = (long)command.ExecuteScalar()!;
|
||||
if (version > 19) throw new InvalidOperationException("Database schema is newer than this server.");
|
||||
if (version > 20) throw new InvalidOperationException("Database schema is newer than this server.");
|
||||
if (version == 0)
|
||||
{
|
||||
command.CommandText = """
|
||||
@@ -469,6 +469,22 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.CommandText = DrawingGeometrySchema;
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
if (version < 20)
|
||||
{
|
||||
// Thickness names ("10 ga"); existing records stay blank until saved again, and
|
||||
// clients name their thickness from the machines meanwhile.
|
||||
foreach (var table in new[] { "nests", "nest_revisions" })
|
||||
{
|
||||
command.CommandText = $"SELECT COUNT(*) FROM pragma_table_info('{table}') WHERE name='thicknessName'";
|
||||
if ((long)command.ExecuteScalar()! == 0)
|
||||
{
|
||||
command.CommandText = $"ALTER TABLE {table} ADD COLUMN thicknessName TEXT NOT NULL DEFAULT ''";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
command.CommandText = "PRAGMA user_version=20";
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
@@ -542,7 +558,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
private const string RecordColumns = """
|
||||
id, name, customer, dateCreated, dateModified, material, thickness,
|
||||
status, plateCount, partCount, comments, madeBy, fileSize, savedAt, revision, deleted, restoredFromRevision,
|
||||
materialGrade, units
|
||||
materialGrade, units, thicknessName
|
||||
""";
|
||||
|
||||
// Case-insensitive (ASCII) substring over the text columns and the status's stored
|
||||
@@ -552,6 +568,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
OR customer LIKE $pattern ESCAPE '\'
|
||||
OR material LIKE $pattern ESCAPE '\'
|
||||
OR materialGrade LIKE $pattern ESCAPE '\'
|
||||
OR thicknessName LIKE $pattern ESCAPE '\'
|
||||
OR madeBy LIKE $pattern ESCAPE '\'
|
||||
OR comments LIKE $pattern ESCAPE '\'
|
||||
OR status LIKE $pattern ESCAPE '\'
|
||||
@@ -650,6 +667,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
command.Parameters.AddWithValue("$material", record.Material);
|
||||
command.Parameters.AddWithValue("$materialGrade", record.MaterialGrade);
|
||||
command.Parameters.AddWithValue("$thickness", record.Thickness);
|
||||
command.Parameters.AddWithValue("$thicknessName", record.ThicknessName ?? "");
|
||||
command.Parameters.AddWithValue("$units", record.Units.ToString());
|
||||
command.Parameters.AddWithValue("$status", record.Status.ToString());
|
||||
command.Parameters.AddWithValue("$plateCount", record.PlateCount);
|
||||
@@ -689,6 +707,7 @@ public sealed partial class NestDatabase : IDisposable
|
||||
RestoredFromRevision = reader.IsDBNull(first + 16) ? null : reader.GetInt32(first + 16),
|
||||
MaterialGrade = reader.GetString(first + 17),
|
||||
Units = Enum.TryParse<Units>(reader.GetString(first + 18), true, out var units) ? units : Units.Inches,
|
||||
ThicknessName = reader.GetString(first + 19),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ internal static class NestMetadata
|
||||
if (record.Customer is null) return "customer must be a string.";
|
||||
if (record.Material is null) return "material must be a string.";
|
||||
if (record.MaterialGrade is null) return "materialGrade must be a string.";
|
||||
if (record.ThicknessName is null) return "thicknessName must be a string.";
|
||||
if (record.Comments is null) return "comments must be a string.";
|
||||
if (record.MadeBy is null) return "madeBy must be a string.";
|
||||
if (!Enum.IsDefined(record.Status)) return "status must be draft, quote, toBeCut or hasBeenCut.";
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
using OpenNest.Data;
|
||||
|
||||
namespace OpenNest.Tests.Data;
|
||||
|
||||
public class ThicknessNamesTests
|
||||
{
|
||||
private static MachineConfig Machine(UnitSystem units = UnitSystem.Inches, double value = 0.135, string name = "10 ga") => new()
|
||||
{
|
||||
Name = "Fiber 1",
|
||||
Units = units,
|
||||
Materials =
|
||||
{
|
||||
new MaterialConfig
|
||||
{
|
||||
Name = "Mild Steel",
|
||||
Grade = "HR",
|
||||
Thicknesses = { new ThicknessConfig { Value = value, Name = name } },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Format_PutsTheDecimalInParentheses()
|
||||
{
|
||||
Assert.Equal("10 ga (0.135)", ThicknessNames.Format(" 10 ga ", 0.135));
|
||||
Assert.Equal("0.135", ThicknessNames.Format("", 0.135));
|
||||
Assert.Equal("0.135", ThicknessNames.Format(null, 0.135));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void For_TakesTheMachinesNameForTheMaterialAndThickness()
|
||||
{
|
||||
var machines = new[] { Machine(name: "10 gauge") };
|
||||
|
||||
Assert.Equal("10 gauge", ThicknessNames.For(machines, "mild steel", "hr", 0.135, Units.Inches));
|
||||
// Another material falls back to the standard gauges.
|
||||
Assert.Equal("10 ga", ThicknessNames.For(machines, "Aluminum", "", 0.135, Units.Inches));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void For_ConvertsBetweenTheNestAndMachineUnits()
|
||||
{
|
||||
var machines = new[] { Machine(UnitSystem.Millimeters, 3.429, "10 gauge") };
|
||||
|
||||
Assert.Equal("10 gauge", ThicknessNames.For(machines, "Mild Steel", "HR", 0.135, Units.Inches));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void For_SkipsAMachineThatLeavesTheThicknessUnnamed()
|
||||
{
|
||||
var machines = new[] { Machine(name: ""), Machine(name: "Ten") };
|
||||
|
||||
Assert.Equal("Ten", ThicknessNames.For(machines, "Mild Steel", "HR", 0.135, Units.Inches));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0.135, "10 ga")]
|
||||
[InlineData(0.06, "16 ga")]
|
||||
[InlineData(0.075, "14 ga")]
|
||||
[InlineData(0.105, "12 ga")]
|
||||
[InlineData(0.188, "3/16\"")]
|
||||
[InlineData(0.25, "1/4\"")]
|
||||
[InlineData(0.3, "")]
|
||||
[InlineData(0, "")]
|
||||
public void For_NamesTheShopsRoundedDecimalsByTheNearestStandardEntry(double thickness, string expected)
|
||||
{
|
||||
Assert.Equal(expected, ThicknessNames.For(Array.Empty<MachineConfig>(), "Mild Steel", "HR", thickness, Units.Inches));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void For_ReadsMillimeterNests()
|
||||
{
|
||||
Assert.Equal("10 ga", ThicknessNames.For(Array.Empty<MachineConfig>(), "", "", 3.43, Units.Millimeters));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FormatRecord_PrefersTheStoredName()
|
||||
{
|
||||
var record = new NestRecord { Material = "Mild Steel", MaterialGrade = "HR", Thickness = 0.135, ThicknessName = "Ten" };
|
||||
var machines = new[] { Machine() };
|
||||
|
||||
Assert.Equal("Ten (0.135)", ThicknessNames.Format(record, machines));
|
||||
record.ThicknessName = "";
|
||||
Assert.Equal("10 ga (0.135)", ThicknessNames.Format(record, machines));
|
||||
record.Thickness = 0;
|
||||
Assert.Equal("0", ThicknessNames.Format(record, machines));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NewThickness_ClearsTheNameOfTheOldOne()
|
||||
{
|
||||
var nest = new Nest { Thickness = 0.135, ThicknessName = " 10 ga " };
|
||||
Assert.Equal("10 ga", nest.ThicknessName);
|
||||
|
||||
nest.Thickness = 0.135;
|
||||
Assert.Equal("10 ga", nest.ThicknessName);
|
||||
|
||||
nest.Thickness = 0.25;
|
||||
Assert.Equal("", nest.ThicknessName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NestRecord_CarriesTheNameBothWays()
|
||||
{
|
||||
var nest = new Nest { Name = "N1", Thickness = 0.135, ThicknessName = "10 ga" };
|
||||
|
||||
var record = NestRecordFactory.FromNest(nest, Guid.Empty, 0);
|
||||
Assert.Equal("10 ga", record.ThicknessName);
|
||||
|
||||
var loaded = new Nest();
|
||||
NestRecordFactory.ApplyMetadata(loaded, record);
|
||||
Assert.Equal(0.135, loaded.Thickness);
|
||||
Assert.Equal("10 ga", loaded.ThicknessName);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,20 @@ public class NestStatusSerializationTests
|
||||
Assert.Equal("AJ", loaded.MadeBy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_ThicknessName_Preserved()
|
||||
{
|
||||
var nest = CreateMinimalNest();
|
||||
nest.Thickness = 0.135;
|
||||
nest.ThicknessName = "10 ga";
|
||||
|
||||
var loaded = RoundTrip(nest);
|
||||
|
||||
Assert.Equal(0.135, loaded.Thickness);
|
||||
Assert.Equal("10 ga", loaded.ThicknessName);
|
||||
Assert.Equal("", RoundTrip(CreateMinimalNest()).ThicknessName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_DefaultStatus_IsQuote()
|
||||
{
|
||||
|
||||
@@ -74,6 +74,70 @@ public class EditNestInfoFormTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThicknessName_FollowsTheThickness_AndKeepsATypedName()
|
||||
{
|
||||
RunSta(() =>
|
||||
{
|
||||
using var form = new EditNestInfoForm();
|
||||
form.SetThicknessMachines(new[]
|
||||
{
|
||||
new Data.MachineConfig
|
||||
{
|
||||
Materials =
|
||||
{
|
||||
new Data.MaterialConfig
|
||||
{
|
||||
Name = "Stainless",
|
||||
Grade = "304",
|
||||
Thicknesses = { new Data.ThicknessConfig { Value = 0.06, Name = "16 ga SS" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
var nest = AcceptanceNest();
|
||||
form.LoadNestInfo(nest);
|
||||
var thickness = (OpenNest.Controls.ThicknessComboBox)form.Controls.Find("thicknessBox", true).Single();
|
||||
|
||||
// A nest without a stored name shows the suggestion.
|
||||
Assert.Equal("1/4\"", form.ThicknessName);
|
||||
|
||||
thickness.Text = "0.06";
|
||||
Assert.Equal("16 ga SS", form.ThicknessName);
|
||||
|
||||
thickness.SelectedItem = "16 ga - 0.0598";
|
||||
Assert.Equal("16 ga", form.ThicknessName);
|
||||
|
||||
// A typed name stays through a material change, not through a new thickness.
|
||||
thickness.Text = "0.135";
|
||||
form.ThicknessName = "Ten";
|
||||
form.MaterialName = "Aluminum";
|
||||
Assert.Equal("Ten", form.ThicknessName);
|
||||
thickness.Text = "0.5";
|
||||
Assert.Equal("1/2\"", form.ThicknessName);
|
||||
|
||||
form.ThicknessName = "Half";
|
||||
form.SaveNestInfo(nest);
|
||||
Assert.Equal(0.5, nest.Thickness);
|
||||
Assert.Equal("Half", nest.ThicknessName);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ThicknessName_ShowsTheStoredName()
|
||||
{
|
||||
RunSta(() =>
|
||||
{
|
||||
using var form = new EditNestInfoForm();
|
||||
var nest = AcceptanceNest();
|
||||
nest.ThicknessName = "Quarter";
|
||||
|
||||
form.LoadNestInfo(nest);
|
||||
|
||||
Assert.Equal("Quarter", form.ThicknessName);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NewNestDefaultsChoice_NeedsTheOfferAndTheCheck()
|
||||
{
|
||||
|
||||
@@ -54,7 +54,10 @@ namespace OpenNest.Forms.Commands
|
||||
{
|
||||
var repository = NestStorage.CreateRepository();
|
||||
var serverUrl = NestStorage.Settings.ServerUrl;
|
||||
using var dlg = new SavedNestsForm(repository, serverUrl);
|
||||
using var dlg = new SavedNestsForm(repository, serverUrl)
|
||||
{
|
||||
ThicknessMachines = MachineSettings.LoadMachines(),
|
||||
};
|
||||
if (dlg.ShowDialog(owner) != DialogResult.OK)
|
||||
return;
|
||||
|
||||
|
||||
@@ -895,7 +895,7 @@ namespace OpenNest.Forms
|
||||
);
|
||||
var snapshot = PartPrintoutBuilder.Capture(Nest, drawings, DateTimeOffset.Now, catalogDensity) with
|
||||
{
|
||||
ThicknessName = NestReportExport.MachineThicknessName(machine, Nest),
|
||||
ThicknessName = NestReportExport.ThicknessName(machine, Nest),
|
||||
};
|
||||
PartPrintoutWriter.Write(snapshot, destination);
|
||||
}
|
||||
@@ -936,6 +936,7 @@ namespace OpenNest.Forms
|
||||
OfferNewNestDefaults = true,
|
||||
};
|
||||
form.SetMaterialCatalog(MachineSettings.LoadMaterials());
|
||||
form.SetThicknessMachines(MachineSettings.LoadThicknessNameMachines(Nest));
|
||||
form.LoadNestInfo(Nest);
|
||||
_ = ShowReleaseOriginAsync(form);
|
||||
var statusBefore = Nest.Status;
|
||||
|
||||
+37
-14
@@ -46,6 +46,8 @@
|
||||
this.labelPartSpacing = new System.Windows.Forms.Label();
|
||||
this.partSpacingBox = new OpenNest.Controls.NumericUpDown();
|
||||
this.labelThk = new System.Windows.Forms.Label();
|
||||
this.labelThicknessName = new System.Windows.Forms.Label();
|
||||
this.thicknessNameBox = new System.Windows.Forms.TextBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.useForNewNestsBox = new System.Windows.Forms.CheckBox();
|
||||
this.quadrantSelect1 = new OpenNest.Controls.QuadrantSelect();
|
||||
@@ -352,6 +354,22 @@
|
||||
this.labelThk.Size = new System.Drawing.Size(126, 16);
|
||||
this.labelThk.TabIndex = 6;
|
||||
this.labelThk.Text = "Thickness :";
|
||||
//
|
||||
// labelThicknessName
|
||||
//
|
||||
this.labelThicknessName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelThicknessName.AutoSize = true;
|
||||
this.labelThicknessName.Name = "labelThicknessName";
|
||||
this.labelThicknessName.Size = new System.Drawing.Size(126, 16);
|
||||
this.labelThicknessName.TabIndex = 8;
|
||||
this.labelThicknessName.Text = "Thickness name :";
|
||||
//
|
||||
// thicknessNameBox
|
||||
//
|
||||
this.thicknessNameBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.thicknessNameBox.Name = "thicknessNameBox";
|
||||
this.thicknessNameBox.Size = new System.Drawing.Size(224, 22);
|
||||
this.thicknessNameBox.TabIndex = 9;
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
@@ -410,29 +428,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, 7);
|
||||
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 1, 8);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label1, 0, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.nameBox, 1, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label2, 0, 6);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label2, 0, 7);
|
||||
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.labelGrade, 0, 5);
|
||||
this.tableLayoutPanel3.Controls.Add(this.gradeBox, 1, 5);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelThicknessName, 0, 4);
|
||||
this.tableLayoutPanel3.Controls.Add(this.thicknessNameBox, 1, 4);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelMaterial, 0, 5);
|
||||
this.tableLayoutPanel3.Controls.Add(this.materialBox, 1, 5);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelGrade, 0, 6);
|
||||
this.tableLayoutPanel3.Controls.Add(this.gradeBox, 1, 6);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label3, 0, 1);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label4, 0, 2);
|
||||
this.tableLayoutPanel3.Controls.Add(this.customerBox, 1, 6);
|
||||
this.tableLayoutPanel3.Controls.Add(this.customerBox, 1, 7);
|
||||
this.tableLayoutPanel3.Controls.Add(this.textBox1, 1, 1);
|
||||
this.tableLayoutPanel3.Controls.Add(this.textBox2, 1, 2);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label5, 0, 7);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelStatus, 0, 8);
|
||||
this.tableLayoutPanel3.Controls.Add(this.statusBox, 1, 8);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelMadeBy, 0, 9);
|
||||
this.tableLayoutPanel3.Controls.Add(this.madeByBox, 1, 9);
|
||||
this.tableLayoutPanel3.Controls.Add(this.label5, 0, 8);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelStatus, 0, 9);
|
||||
this.tableLayoutPanel3.Controls.Add(this.statusBox, 1, 9);
|
||||
this.tableLayoutPanel3.Controls.Add(this.labelMadeBy, 0, 10);
|
||||
this.tableLayoutPanel3.Controls.Add(this.madeByBox, 1, 10);
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(6, 6);
|
||||
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
this.tableLayoutPanel3.RowCount = 10;
|
||||
this.tableLayoutPanel3.RowCount = 11;
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
@@ -443,7 +463,8 @@
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(362, 311);
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(362, 342);
|
||||
this.tableLayoutPanel3.TabIndex = 0;
|
||||
//
|
||||
// tableLayoutPanel4
|
||||
@@ -780,6 +801,8 @@
|
||||
private System.Windows.Forms.TextBox sizeBox;
|
||||
private Controls.ThicknessComboBox thicknessBox;
|
||||
private System.Windows.Forms.Label labelThk;
|
||||
private System.Windows.Forms.Label labelThicknessName;
|
||||
private System.Windows.Forms.TextBox thicknessNameBox;
|
||||
private System.Windows.Forms.Label labelPartSpacing;
|
||||
private Controls.NumericUpDown partSpacingBox;
|
||||
private Controls.BottomPanel bottomPanel1;
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace OpenNest.Forms
|
||||
private string gradeMaterialKey = "";
|
||||
private bool offerNewNestDefaults;
|
||||
private string shownMadeBy = "";
|
||||
private List<MachineConfig> thicknessMachines = new();
|
||||
private string suggestedThicknessName = "";
|
||||
private double? namedThickness;
|
||||
|
||||
public EditNestInfoForm()
|
||||
{
|
||||
@@ -40,8 +43,17 @@ namespace OpenNest.Forms
|
||||
};
|
||||
Disposed += (sender, e) => timer.Dispose();
|
||||
nameBox.TextChanged += (sender, e) => EnableCheck();
|
||||
thicknessBox.TextChanged += (sender, e) => EnableCheck();
|
||||
materialBox.TextChanged += (sender, e) => RefreshGrades();
|
||||
thicknessBox.TextChanged += (sender, e) =>
|
||||
{
|
||||
EnableCheck();
|
||||
RefreshThicknessName();
|
||||
};
|
||||
materialBox.TextChanged += (sender, e) =>
|
||||
{
|
||||
RefreshGrades();
|
||||
RefreshThicknessName();
|
||||
};
|
||||
gradeBox.TextChanged += (sender, e) => RefreshThicknessName();
|
||||
EnableCheck();
|
||||
}
|
||||
|
||||
@@ -162,6 +174,46 @@ namespace OpenNest.Forms
|
||||
set { thicknessBox.Value = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shop's name for the thickness, such as "10 ga". It follows the thickness: a new
|
||||
/// thickness, or a new material while the name is blank or the one suggested, takes the
|
||||
/// machines' name for it (<see cref="SetThicknessMachines"/>) or the nearest standard gauge.
|
||||
/// </summary>
|
||||
public string ThicknessName
|
||||
{
|
||||
get { return thicknessNameBox.Text.Trim(); }
|
||||
set { thicknessNameBox.Text = value ?? ""; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The machines whose thickness names the dialog suggests, the nest's own first. Set it
|
||||
/// before <see cref="LoadNestInfo"/>.
|
||||
/// </summary>
|
||||
public void SetThicknessMachines(IEnumerable<MachineConfig> machines)
|
||||
{
|
||||
thicknessMachines = (machines ?? Enumerable.Empty<MachineConfig>()).Where(m => m != null).ToList();
|
||||
RefreshThicknessName();
|
||||
}
|
||||
|
||||
private void RefreshThicknessName()
|
||||
{
|
||||
if (!thicknessBox.TryGetValue(out var value))
|
||||
return;
|
||||
|
||||
// A picked list entry ("16 ga - 0.0598") names itself.
|
||||
var text = thicknessBox.Text.Trim();
|
||||
var picked = StandardThicknesses.Entries.FirstOrDefault(entry =>
|
||||
string.Equals(StandardThicknesses.Label(entry, GetUnits()), text, StringComparison.OrdinalIgnoreCase));
|
||||
var suggested = picked?.Name
|
||||
?? ThicknessNames.For(thicknessMachines, MaterialName, MaterialGrade, value, GetUnits());
|
||||
var current = ThicknessName;
|
||||
// A new thickness replaces any name; a new material only a blank or suggested one.
|
||||
if (namedThickness != value || current.Length == 0 || current == suggestedThicknessName)
|
||||
ThicknessName = suggested;
|
||||
suggestedThicknessName = suggested;
|
||||
namedThickness = value;
|
||||
}
|
||||
|
||||
public string MaterialName
|
||||
{
|
||||
get { return materialBox.Text; }
|
||||
@@ -294,6 +346,7 @@ namespace OpenNest.Forms
|
||||
DateCreated = DateCreated,
|
||||
DateLastModified = DateLastModified,
|
||||
Thickness = Thickness,
|
||||
ThicknessName = ThicknessName,
|
||||
MaterialName = MaterialName,
|
||||
MaterialGrade = MaterialGrade,
|
||||
Status = Status,
|
||||
@@ -318,6 +371,9 @@ namespace OpenNest.Forms
|
||||
Thickness = values.Thickness;
|
||||
MaterialName = values.MaterialName;
|
||||
MaterialGrade = values.MaterialGrade;
|
||||
// A stored name stands; a nest without one shows the suggested name.
|
||||
if (!string.IsNullOrWhiteSpace(values.ThicknessName))
|
||||
ThicknessName = values.ThicknessName;
|
||||
Status = values.Status;
|
||||
MadeBy = values.MadeBy;
|
||||
shownMadeBy = MadeBy;
|
||||
|
||||
@@ -28,6 +28,22 @@ namespace OpenNest.Forms
|
||||
/// <summary>Every readable machine configuration, for choosing acceleration limits.</summary>
|
||||
public static List<MachineConfig> LoadMachines() => Source.LoadMachines();
|
||||
|
||||
/// <summary>
|
||||
/// The machines whose names for thicknesses <paramref name="nest"/> takes: its own first,
|
||||
/// then every other readable one.
|
||||
/// </summary>
|
||||
public static List<MachineConfig> LoadThicknessNameMachines(Nest nest)
|
||||
{
|
||||
var machines = LoadMachines();
|
||||
var own = nest?.Machine is { } assigned ? machines.FirstOrDefault(m => m.Id == assigned.Id) : null;
|
||||
if (own != null)
|
||||
{
|
||||
machines.Remove(own);
|
||||
machines.Insert(0, own);
|
||||
}
|
||||
return machines;
|
||||
}
|
||||
|
||||
/// <summary>Every readable machine configuration on this PC, shared or not, for uploading.</summary>
|
||||
public static List<MachineConfig> LoadLocalMachines() => Source.LoadLocalMachines();
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace OpenNest.Forms
|
||||
|
||||
var nest = form.Nest;
|
||||
machine.Text = FormatMachine(nest.Machine);
|
||||
material.Text = FormatMaterial(nest.Material?.Name, nest.Material?.Grade, nest.Thickness, nest.Units);
|
||||
material.Text = MainStatusText.Material(nest);
|
||||
|
||||
plateUtil.Text = MainStatusText.Utilization(form.PlateView.Plate.Utilization());
|
||||
}
|
||||
|
||||
@@ -83,6 +83,12 @@ public sealed class SavedNestsForm : Form
|
||||
/// <summary>Set to the chosen record's id when the dialog closes with OK.</summary>
|
||||
public Guid SelectedId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The machines that name a listed nest's thickness when it stores no name of its own
|
||||
/// (see <see cref="ThicknessNames"/>); with none, only the standard gauges and fractions do.
|
||||
/// </summary>
|
||||
public IReadOnlyList<MachineConfig> ThicknessMachines { get; set; } = Array.Empty<MachineConfig>();
|
||||
|
||||
public SavedNestsForm(INestRepository repository, string serverUrl = null)
|
||||
{
|
||||
this.repository = repository;
|
||||
@@ -122,7 +128,7 @@ public sealed class SavedNestsForm : Form
|
||||
AddNestColumn("Made by", NestSortField.MadeBy, 90);
|
||||
AddNestColumn("Material", NestSortField.Material, 150);
|
||||
AddNestColumn("Grade", NestSortField.MaterialGrade, 80);
|
||||
AddNestColumn("Thickness", NestSortField.Thickness, 80, alignRight: true);
|
||||
AddNestColumn("Thickness", NestSortField.Thickness, 120, alignRight: true);
|
||||
AddNestColumn("Created", NestSortField.DateCreated, 140);
|
||||
AddNestColumn("Saved", NestSortField.SavedAt, 140);
|
||||
AddNestColumn("File size", NestSortField.FileSize, 80, alignRight: true);
|
||||
@@ -487,7 +493,7 @@ public sealed class SavedNestsForm : Form
|
||||
record.MadeBy,
|
||||
record.Material,
|
||||
record.MaterialGrade,
|
||||
record.Thickness.ToString("0.####", CultureInfo.CurrentCulture),
|
||||
ThicknessNames.Format(record, ThicknessMachines),
|
||||
FormatDate(record.DateCreated),
|
||||
FormatDate(record.SavedAt),
|
||||
FormatFileSize(record.FileSize),
|
||||
@@ -934,6 +940,7 @@ public sealed class SavedNestsForm : Form
|
||||
if (IsDisposed) return;
|
||||
using var dialog = new EditNestInfoForm { AllowRename = true };
|
||||
dialog.SetMaterialCatalog(MachineSettings.LoadMaterials());
|
||||
dialog.SetThicknessMachines(MachineSettings.LoadThicknessNameMachines(nest));
|
||||
dialog.LoadNestInfo(nest);
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,9 @@ decimals (PEP stores 3/16 as 0.188) finds the machine's 0.1875; the nearest one
|
||||
file, nothing changes and the previous behavior applies. Lengths are converted from the
|
||||
machine's units to the nest's.
|
||||
|
||||
A thickness's **Name / Gauge** ("16 ga") is display only: the tree shows it and nest reports
|
||||
put it before the decimal. In Machine Configuration a blank name, or one still the standard
|
||||
A thickness's **Name / Gauge** ("16 ga") is display only: the tree shows it, Nest Information
|
||||
suggests it as the nest's thickness name, and the Open list and nest reports show a nest
|
||||
without its own name by it, before the decimal. In Machine Configuration a blank name, or one still the standard
|
||||
name of the old value, follows the thickness value to its standard steel gauge or plate
|
||||
fraction (`StandardThicknesses`, matched to the displayed precision); a typed name is kept.
|
||||
A new thickness starts with the name of its default value. Opening Machine Configuration
|
||||
|
||||
@@ -9,6 +9,9 @@ opening and saving with an older application loses that state.
|
||||
`nest.json` carries the workflow fields shown in the nest info dialog:
|
||||
`name`, `customer`, `dateCreated`, `dateLastModified`, `notes`, `material`,
|
||||
`thickness`, plus `status` (`"Draft"`, `"Quote"`, `"ToBeCut"`, `"HasBeenCut"`) and `madeBy`.
|
||||
`thicknessName` is the shop's name for the thickness ("10 ga", `Nest.ThicknessName`); it
|
||||
is omitted when blank, older files have none, and older readers ignore it. A new
|
||||
thickness value clears it, so a reader sets it after the thickness.
|
||||
Status and made-by are additive: files written before them load as Quote with an
|
||||
empty maker, and an unrecognized status value likewise falls back to Quote. Builds
|
||||
before `Draft` therefore open a Draft nest as Quote, and saving it there keeps Quote.
|
||||
|
||||
+19
-2
@@ -5,7 +5,7 @@ The desktop app can save nests two ways:
|
||||
- **File mode** (default, unchanged behavior): Save/Save As write a `.nest` ZIP
|
||||
archive to disk via the normal file dialog. See [nest-file-format.md](nest-file-format.md).
|
||||
- **Database mode**: Open browses server records 100 at a time. The Find box
|
||||
searches name, customer, material, grade, made by, comments and status on the server
|
||||
searches name, customer, material, grade, thickness name, made by, comments and status on the server
|
||||
after a short typing pause (Enter in the box searches at once); clicking a
|
||||
column header sorts every match on the server (click again to reverse); the
|
||||
arrow buttons move between pages and the title and find bar show the range and
|
||||
@@ -89,6 +89,7 @@ entry, never programs or geometry, and takes the archive-derived fields below fr
|
||||
| `material` | string | Material name (type), e.g. `Stainless`. Read from the uploaded archive (nest material, else plate defaults' on an explicit null); a metadata-only PUT may change it, and the desktop applies the record's value when opening the nest. |
|
||||
| `materialGrade` | string | Optional; default blank. Older servers drop it. A blank grade on a record saved before schema v8 is treated as unrecorded: opening keeps the archive's grade while the material name matches. |
|
||||
| `thickness` | number | Read from the uploaded archive (nest thickness, else plate defaults' when not positive); editable like `material`. |
|
||||
| `thicknessName` | string | Optional; default blank. The shop's name for the thickness ("10 ga"), from the client like `materialGrade`. Older servers drop it. A blank name is filled in for display only (see [Thickness names](#thickness-names)). |
|
||||
| `units` | `"inches"` \| `"millimeters"` | The nest's units, which `thickness` is in. Server-computed from the uploaded archive (absent or unknown values are inches, as `NestReader` reads them); ignored on upload and kept by a metadata-only PUT. Schema v12 read every stored archive, current and historical, to fill it. Older servers omit it, which readers take as inches. |
|
||||
| `status` | `"draft"` \| `"quote"` \| `"toBeCut"` \| `"hasBeenCut"` | Default `quote`. |
|
||||
| `plateCount` / `partCount` | integer | Server-computed from the uploaded archive (non-cutoff parts only; a trailing plate with no parts or cut-offs is not counted); ignored on upload and kept by a metadata-only PUT. |
|
||||
@@ -270,7 +271,7 @@ only the requested page of metadata (never archive bytes):
|
||||
- `search` (optional): trimmed, at most 200 characters, no NUL characters;
|
||||
blank means no filter.
|
||||
Case-insensitive substring of the whole text in `name`, `customer`, `material`,
|
||||
`materialGrade`, `madeBy`, `comments` or the status (`ToBeCut` or the display name `To Be Cut`).
|
||||
`materialGrade`, `thicknessName`, `madeBy`, `comments` or the status (`ToBeCut` or the display name `To Be Cut`).
|
||||
`%`, `_` and `\` are literal. Dates and numbers are not matched as text.
|
||||
Case folding is ASCII-only (SQLite `LIKE`).
|
||||
- Exact filters (optional, all must match; used to find draft nests a release
|
||||
@@ -1122,6 +1123,22 @@ Schema v8 adds a `materialGrade` text column (default blank) to `nests` and
|
||||
A server older than v8 refuses to open a v8 database, so rolling back needs the
|
||||
pre-upgrade backup.
|
||||
|
||||
### Thickness names
|
||||
|
||||
Schema v20 adds a `thicknessName` text column (default blank) to `nests` and
|
||||
`nest_revisions`; existing records keep a blank name until they are next saved.
|
||||
A server older than v20 refuses to open a v20 database, so rolling back needs the
|
||||
pre-upgrade backup.
|
||||
|
||||
The Open list's Thickness column shows the name with the decimal in parentheses,
|
||||
"10 ga (0.135)", still sorting by the decimal. A record without a name is named for
|
||||
display only (`ThicknessNames`): the first machine configuration that names its
|
||||
material and thickness, otherwise the nearest standard steel gauge or plate fraction
|
||||
within 0.001 in, so 0.135 reads as 10 ga and 0.188 as 3/16". Nest Information has a
|
||||
**Thickness name** box that fills in the same way (a picked list entry names itself,
|
||||
the nest's own machine is asked first); a new thickness replaces the name, a new
|
||||
material only a blank or suggested one, and a typed name is kept.
|
||||
|
||||
## Material list endpoints
|
||||
|
||||
The server keeps the company material list: each material with its grades. Both
|
||||
|
||||
Reference in new issue
Block a user