feat(machine-config): fill a blank thickness name from the standard gauges

Reports now take a thickness's name from the machine config, so a blank
Name / Gauge leaves the report with just the decimal. Machine Configuration
now fills a blank name from the standard steel gauge or plate fraction table
when the thickness value changes, and keeps following the value while the
name is still the old value's standard one; a typed name is never replaced.
A new thickness starts named for its default 0.25 (1/4").

Existing blank names are not filled on open, so viewing a machine never marks
it dirty; editing the value fills them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-12 07:25:41 -05:00
1 parent 76e1acbc51
commit 35d77239b9
3 files changed
+91 -18

No files matched your search

@@ -132,6 +132,56 @@ public class MachineCutsFormsTests
});
}
[Fact]
public void GeneralTab_BlankNameFollowsTheValueToItsStandardGaugeUntilOneIsTyped()
{
RunSta(() =>
{
var directory = Path.Combine(Path.GetTempPath(), "OpenNestTests", Guid.NewGuid().ToString());
Directory.CreateDirectory(directory);
try
{
var provider = new LocalJsonProvider(directory);
provider.SaveMachine(new MachineConfig
{
Name = "Laser",
Units = UnitSystem.Inches,
Materials = { new MaterialConfig { Name = "Mild Steel", Thicknesses = { new ThicknessConfig { Value = 0.3 } } } },
});
using var form = new MachineConfigForm(provider);
var node = Descendants(Find<TreeView>(form, "_tree").Nodes).Single(n => n.Tag is ThicknessConfig);
typeof(MachineConfigForm)
.GetMethod("Tree_AfterSelect", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!
.Invoke(form, new object[] { null, new TreeViewEventArgs(node) });
var shown = (ThicknessConfig)node.Tag;
var page = All<TabControl>(form).Single().TabPages.Cast<TabPage>().Single(p => p.Text == "General");
var value = All<NumericUpDown>(page).First();
var name = All<TextBox>(page).Single(b => b.PlaceholderText == "e.g. 16 ga");
Assert.Equal("", shown.Name);
value.Value = 0.0598m;
Assert.Equal("16 ga", shown.Name);
Assert.Equal("0.0598 (16 ga)", node.Text);
// Still the old value's standard name, so it follows; no standard match clears it.
value.Value = 0.25m;
Assert.Equal("1/4\"", shown.Name);
value.Value = 0.3m;
Assert.Equal("", shown.Name);
name.Text = "Shop plate";
value.Value = 0.0598m;
Assert.Equal("Shop plate", shown.Name);
}
finally
{
Directory.Delete(directory, recursive: true);
}
});
}
private static IEnumerable<TreeNode> Descendants(TreeNodeCollection nodes) =>
nodes.Cast<TreeNode>().SelectMany(n => Descendants(n.Nodes).Prepend(n));
+35 -18
View File
@@ -643,24 +643,6 @@ namespace OpenNest.Forms
var layout = CreateDetailLayout();
var row = 0;
AddField(
layout,
ref row,
"Thickness:",
CreateLabeledNumeric(
thickness.Value,
v =>
{
thickness.Value = v;
node.Text = ThicknessLabel(thickness);
MarkDirty();
},
4,
LengthUnitSuffix,
100,
0.001m
)
);
var nameBox = CreateTextBox(
thickness.Name,
v =>
@@ -671,6 +653,30 @@ namespace OpenNest.Forms
}
);
nameBox.PlaceholderText = "e.g. 16 ga";
AddField(
layout,
ref row,
"Thickness:",
CreateLabeledNumeric(
thickness.Value,
v =>
{
// A blank name, or one still the standard name of the old value, follows
// the value to its standard gauge or fraction; a typed name stays.
var name = nameBox.Text.Trim();
var follows = name.Length == 0 || name == StandardThicknessName(thickness.Value);
thickness.Value = v;
if (follows && StandardThicknessName(v) is var standard && standard != name)
nameBox.Text = standard;
node.Text = ThicknessLabel(thickness);
MarkDirty();
},
4,
LengthUnitSuffix,
100,
0.001m
)
);
AddField(layout, ref row, "Name / Gauge:", nameBox);
AddField(
layout,
@@ -1165,6 +1171,16 @@ namespace OpenNest.Forms
return panel;
}
/// <summary>
/// The standard gauge or plate fraction <paramref name="value"/> (in the machine's units)
/// matches, such as "16 ga" or "1/4\"", or empty when it matches none.
/// </summary>
private string StandardThicknessName(double value) =>
StandardThicknesses.Find(
value,
_currentMachine?.Units == UnitSystem.Millimeters ? Units.Millimeters : Units.Inches
)?.Name ?? "";
private string LengthUnitSuffix(object _) =>
_currentMachine?.Units == UnitSystem.Millimeters ? "mm" : "in";
@@ -1538,6 +1554,7 @@ namespace OpenNest.Forms
var materialNode = _tree.SelectedNode;
var thickness = new ThicknessConfig { Value = 0.250 };
thickness.Name = StandardThicknessName(thickness.Value);
material.Thicknesses.Add(thickness);
var node = BuildThicknessNode(thickness);
materialNode.Nodes.Add(node);
+6
View File
@@ -15,6 +15,12 @@ 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
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.
## Where the Cutting Parameters dialog saves
Every setting in Plan Cutting's Cutting Parameters dialog and the Place Lead-in panel is kept on