feat(cutting): group Plan Cutting's settings and keep the plan on Cancel

The Cutting Settings and Cut-off Settings buttons looked alike and were
easy to mix up. Plan Cutting now shows two titled groups: Part cutting
(Leads & Tabs..., its summary and Keep current part order) and Scrap
cut-offs (the box, Strips... and the strip width). Planner messages
name the renamed button.

Canceling Leads & Tabs, or OK with nothing changed, keeps the current
plan. Canceling Strips keeps it too when no cut-offs were staged; with
the box ticked the staged cut-offs had to come off, so it still replans.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-22 23:55:30 -05:00
1 parent 83181570bd
commit b6a9cea93f
8 files changed
+132 -38

No files matched your search

@@ -484,7 +484,7 @@ public sealed class CuttingPlanProposal
/// <summary>Operator-facing summary: one overall line, then each plate and its findings.</summary>
/// <param name="changeSettings">How this front end changes the settings, completed by
/// "a lead-in type other than None..." in the missing lead-in advice.</param>
public IReadOnlyList<string> Describe(string unit, string changeSettings = "Open Cutting Settings... and select")
public IReadOnlyList<string> Describe(string unit, string changeSettings = "Open Leads & Tabs... and select")
{
var lines = new List<string>();
var blocked = Plates.Count(p => !p.CanApplyWithWarnings);
@@ -1430,7 +1430,7 @@ internal static class JointCuttingPlanSearch
&& reportedNoFit.Add(source.SourceOrdinal * 1000 + contour))
rejected.Add(Finding(source, null,
$"No tested lead-in fits on cutting contour {contour + 1}: {selection.Reason} "
+ "Try reducing the lead-in length in Cutting Settings...; if nearby parts obstruct the lead-in, "
+ "Try reducing the lead-in length in Leads & Tabs...; if nearby parts obstruct the lead-in, "
+ "space the parts farther apart." + PierceZoneHint()
+ (scrapReason == null ? "" : $" A pierce in open scrap was also tried: {scrapReason}")
+ (erodedReason == null ? "" : $" A pierce found by eroding the cutout was also tried: {erodedReason}")
@@ -188,7 +188,7 @@ public class CuttingPlanMessageTests
Assert.Contains(CuttingPlanProposal.SearchLimitHint, text);
Assert.Contains("it may still find no plan", CuttingPlanProposal.SearchLimitHint);
Assert.True(proposal.Plates[0].SearchLimitReached);
Assert.DoesNotContain("Open Cutting Settings...", text);
Assert.DoesNotContain("Open Leads & Tabs...", text);
Assert.DoesNotContain("missing or zero-length lead-in", text);
Assert.False(proposal.CanApply);
}
@@ -975,6 +975,41 @@ public class CuttingInspectionPanelTests
}
});
[Fact]
public void LeadsAndTabsReplansOnlyWhenTheSettingsChange() => RunSta(() =>
{
using var editor = Editor();
editor.Show();
editor.PlateManager.LoadAt(0);
editor.OpenCuttingInspection();
var panel = editor.CuttingInspection!;
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
var planned = panel.Proposal;
var settings = Field<Button>(panel, "settingsButton");
panel.ShowCuttingSettings = dialog => DialogResult.Cancel;
settings.PerformClick();
Assert.False(panel.IsPlanning);
Assert.Same(planned, panel.Proposal);
panel.ShowCuttingSettings = dialog => DialogResult.OK; // Unchanged.
settings.PerformClick();
Assert.False(panel.IsPlanning);
Assert.Same(planned, panel.Proposal);
panel.ShowCuttingSettings = dialog =>
{
var changed = dialog.GetParameters();
changed.SupportTabs = !changed.SupportTabs;
dialog.LoadParameters(changed);
return DialogResult.OK;
};
settings.PerformClick();
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
Assert.NotSame(planned, panel.Proposal);
panel.RequestClose();
});
[Fact]
public void CutOffSettingsOpensTheAutomaticCutOffDialogAndReplansWithItsChoice() => RunSta(() =>
{
@@ -991,10 +1026,13 @@ public class CuttingInspectionPanelTests
var panel = editor.CuttingInspection!;
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
Assert.Equal(35, panel.CutOffOptions.Spacing);
var planned = panel.Proposal;
panel.ShowCutOffSettings = form => DialogResult.Cancel;
Field<Button>(panel, "cutOffSettingsButton").PerformClick();
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
Assert.False(panel.IsPlanning); // Nothing was staged, so Cancel keeps the plan.
Assert.Same(planned, panel.Proposal);
Assert.True(Field<Button>(panel, "applyButton").Enabled);
Assert.False(Field<CheckBox>(panel, "autoCutOffsCheckBox").Checked);
Assert.Equal(35, panel.CutOffOptions.Spacing);
Assert.Empty(plate.CutOffs);
@@ -1018,7 +1056,7 @@ public class CuttingInspectionPanelTests
Assert.NotNull(shown);
Assert.Equal((30.0, 10.0), (panel.CutOffOptions.Spacing, panel.CutOffOptions.MinimumTailLength));
Assert.True(Field<CheckBox>(panel, "autoCutOffsCheckBox").Checked);
Assert.Contains("30 in strips", Field<CheckBox>(panel, "autoCutOffsCheckBox").Text);
Assert.Contains("30 in strips", Field<Label>(panel, "cutOffLabel").Text);
Assert.NotNull(panel.StagedCutOffs);
Assert.NotEmpty(plate.CutOffs);
Assert.Equal(plate.CutOffs.Count, panel.Proposal.Plates[0].Result.ProposedOrder.Count(p => p.IsCutOff));
+1 -1
View File
@@ -10,7 +10,7 @@ namespace OpenNest.Controls
{
/// <summary>
/// Edits one contour type's lead-in and lead-out: a type list for each, the chosen type's
/// fields below it, and a <see cref="LeadPreview"/> filling the rest. Cutting Settings and
/// fields below it, and a <see cref="LeadPreview"/> filling the rest. The Cutting Parameters dialog and
/// Machine Configuration both use it; the options hide what a host cannot hold.
/// </summary>
public class LeadsEditor : UserControl
+77 -27
View File
@@ -74,12 +74,12 @@ internal sealed class CuttingInspectionPanel : UserControl
AccessibleName = "Cutting plan remedy or marker hint"
};
private readonly ToolTip toolTip = new();
private readonly Button settingsButton = new() { Text = "Cutting Settings…", AutoSize = true };
private readonly Button settingsButton = new() { Text = "Leads && Tabs…", AutoSize = true };
private readonly Button applyButton = new() { Text = "Apply", AutoSize = true, Enabled = false };
private readonly Button previousButton = new() { Text = "Previous", AutoSize = true };
private readonly Button nextButton = new() { Text = "Next", AutoSize = true };
private readonly CheckBox keepOrderCheckBox = new() { Text = "Keep current part order", AutoSize = true };
private readonly CheckBox autoCutOffsCheckBox = new() { AutoSize = true, MaximumSize = new Size(440, 0) };
private readonly CheckBox autoCutOffsCheckBox = new() { Text = "Add scrap cut-offs", AutoSize = true, Anchor = AnchorStyles.Left };
private readonly StatusBanner existingWorkBanner = new() { Margin = new Padding(3, 3, 3, 8) };
private readonly Label existingWorkLabel = new()
{
@@ -96,7 +96,15 @@ internal sealed class CuttingInspectionPanel : UserControl
BackColor = SystemColors.Control,
UseVisualStyleBackColor = true
};
private readonly Button cutOffSettingsButton = new() { Text = "Cut-off Settings…", AutoSize = true };
private readonly Button cutOffSettingsButton = new() { Text = "Strips…", AutoSize = true, Anchor = AnchorStyles.Left };
private readonly Label cutOffLabel = new()
{
AutoSize = true,
ForeColor = SystemColors.GrayText,
Anchor = AnchorStyles.Left,
};
private readonly GroupBox partCuttingGroup = SettingsGroup("Part cutting");
private readonly GroupBox cutOffGroup = SettingsGroup("Scrap cut-offs");
private readonly Units units;
private bool allPlates;
private AutomaticCutOffOptions cutOffOptions;
@@ -167,6 +175,10 @@ internal sealed class CuttingInspectionPanel : UserControl
var header = new FlowLayoutPanel { Dock = DockStyle.Fill, AutoSize = true, FlowDirection = FlowDirection.TopDown, WrapContents = false };
var settingsRow = new FlowLayoutPanel { AutoSize = true, WrapContents = false, Margin = Padding.Empty };
settingsRow.Controls.AddRange([settingsButton, settingsLabel]);
var partCuttingContent = GroupContent();
partCuttingContent.FlowDirection = FlowDirection.TopDown;
partCuttingContent.Controls.AddRange([settingsRow, keepOrderCheckBox]);
partCuttingGroup.Controls.Add(partCuttingContent);
var buttons = new FlowLayoutPanel { AutoSize = true, Margin = new Padding(0, 6, 0, 0) };
buttons.Controls.AddRange([planButton, applyButton, cancelButton]);
var navigation = new FlowLayoutPanel { AutoSize = true, Margin = Padding.Empty };
@@ -189,18 +201,13 @@ internal sealed class CuttingInspectionPanel : UserControl
units = editor.Nest.Units;
cutOffOptions = lastCutOffOptions.TryGetValue(units, out var last) ? Copy(last) : DefaultCutOffOptions(units);
ShowCutOffOptions();
var cutOffRow = new FlowLayoutPanel
{
AutoSize = true,
FlowDirection = FlowDirection.TopDown,
WrapContents = false,
Margin = Padding.Empty
};
cutOffRow.Controls.AddRange([autoCutOffsCheckBox, cutOffSettingsButton]);
var cutOffContent = GroupContent();
cutOffContent.Controls.AddRange([autoCutOffsCheckBox, cutOffSettingsButton, cutOffLabel]);
cutOffGroup.Controls.Add(cutOffContent);
existingWorkLabel.Font = new Font(Font, FontStyle.Bold);
existingWorkBanner.Controls.AddRange([existingWorkLabel, clearExistingButton]);
existingWorkBanner.SetTone(Tone.Bad);
header.Controls.AddRange([modeSelector, scopeSelector, existingWorkBanner, settingsRow, keepOrderCheckBox, cutOffRow,
header.Controls.AddRange([modeSelector, scopeSelector, existingWorkBanner, partCuttingGroup, cutOffGroup,
validationScopeLabel, buttons, acceptWarningsCheckBox, navigation, previewLabel, detailLabel]);
statusBanner.Controls.Add(statusLabel);
var layout = new TableLayoutPanel { Dock = DockStyle.Fill, ColumnCount = 1, RowCount = 3 };
@@ -304,6 +311,9 @@ internal sealed class CuttingInspectionPanel : UserControl
internal AutomaticCutOffOptions CutOffOptions => Copy(cutOffOptions);
/// <summary>Shows the Leads &amp; Tabs dialog; tests replace it. Null uses ShowDialog.</summary>
internal Func<CuttingParametersDialog, DialogResult> ShowCuttingSettings { get; set; }
private static AutomaticCutOffOptions Copy(AutomaticCutOffOptions options) => new()
{
Spacing = options.Spacing,
@@ -312,18 +322,38 @@ internal sealed class CuttingInspectionPanel : UserControl
KeepHorizontalRemnant = options.KeepHorizontalRemnant,
};
// A titled box around one set of planning options, so each settings button sits under its name.
private static GroupBox SettingsGroup(string title) => new()
{
Text = title,
AutoSize = true,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
MinimumSize = new Size(440, 0),
Padding = new Padding(6, 3, 6, 3),
Margin = new Padding(3, 3, 3, 6),
};
private static FlowLayoutPanel GroupContent() => new()
{
Dock = DockStyle.Fill,
AutoSize = true,
WrapContents = false,
Margin = Padding.Empty,
};
private void ShowCutOffOptions()
{
var unit = UnitsHelper.GetShortString(units);
autoCutOffsCheckBox.Text = $"Add scrap cut-offs ({cutOffOptions.Spacing:0.###} {unit} strips)";
toolTip.SetToolTip(autoCutOffsCheckBox, $"Keeps tails of {cutOffOptions.MinimumTailLength:0.###} {unit} or more. "
cutOffLabel.Text = $"{cutOffOptions.Spacing:0.###} {unit} strips";
toolTip.SetToolTip(autoCutOffsCheckBox, $"Cuts the scrap into {cutOffOptions.Spacing:0.###} {unit} strips. Keeps tails of {cutOffOptions.MinimumTailLength:0.###} {unit} or more. "
+ "The cut-offs are added for planning and removed again unless you Apply.");
}
/// <summary>
/// Opens the Automatic Scrap Cut-offs dialog in settings mode for this panel's scope. Unapplied
/// cut-offs come off first so its preview starts from the plates' real state; OK ticks the box
/// and replans with the chosen settings, Cancel replans with the previous ones.
/// and replans with the chosen settings. Cancel keeps the current plan when nothing had to come
/// off for the dialog; otherwise it replans with the previous settings.
/// </summary>
private void EditCutOffSettings()
{
@@ -343,17 +373,27 @@ internal sealed class CuttingInspectionPanel : UserControl
inspection.RequestClose();
return;
}
ClearResult();
try
// With nothing staged the dialog sees the plates as planned, so the plan only hides behind it.
var keepPlan = stagedCutOffs == null && Proposal != null && !invalidated;
if (keepPlan)
{
RevertStagedCutOffs();
view.ClearProposalDisplay();
view.ClearValidationFinding();
}
catch (Exception ex)
else
{
SetStatus(Tone.Bad, "Couldn't remove the unapplied cut-offs.", ex.Message);
return;
ClearResult();
try
{
RevertStagedCutOffs();
}
catch (Exception ex)
{
SetStatus(Tone.Bad, "Couldn't remove the unapplied cut-offs.", ex.Message);
return;
}
RefreshExistingWork();
}
RefreshExistingWork();
AutomaticCutOffOptions chosen = null;
try
{
@@ -373,6 +413,13 @@ internal sealed class CuttingInspectionPanel : UserControl
}
if (closed || closeRequested)
return;
if (chosen == null && keepPlan)
{
ShowPlate(selectedPlate);
return;
}
if (keepPlan)
ClearResult();
if (chosen != null)
{
cutOffOptions = Copy(chosen);
@@ -423,8 +470,7 @@ internal sealed class CuttingInspectionPanel : UserControl
modeSelector.SelectedIndex = (int)Mode;
ShowScope(planning);
configuringMode = false;
settingsButton.Visible = settingsLabel.Visible = keepOrderCheckBox.Visible = applyButton.Visible = planning;
autoCutOffsCheckBox.Visible = cutOffSettingsButton.Visible = planning;
partCuttingGroup.Visible = cutOffGroup.Visible = applyButton.Visible = planning;
RefreshExistingWork();
previousButton.Visible = nextButton.Visible = planning && plates.Length > 1;
previewLabel.Visible = planning;
@@ -956,7 +1002,7 @@ internal sealed class CuttingInspectionPanel : UserControl
if (plate.Overlap is { } overlap && overlap.Pairs.Count > 0)
return "Move the overlapping parts apart, then Replan.";
if (!plate.IsRouteReady && plate.Result.Findings.Any(f => f.Kind == PostVerificationKind.MissingLeadIn))
return "In Cutting Settings, choose a lead-in with a nonzero length (or unlock the part), then Replan.";
return "In Leads & Tabs, choose a lead-in with a nonzero length (or unlock the part), then Replan.";
if (plate.SearchLimitReached)
return "Raise Cut planning effort in Tools > Options to search further, then Replan; it may still find no plan.";
return null;
@@ -1269,8 +1315,12 @@ internal sealed class CuttingInspectionPanel : UserControl
Source = MachineSettings.DescribeCuttingSource(editor.Nest),
};
dialog.LoadParameters(parameters);
if (dialog.ShowDialog(this) != DialogResult.OK || closed || closeRequested) return;
parameters = dialog.GetParameters();
if ((ShowCuttingSettings?.Invoke(dialog) ?? dialog.ShowDialog(this)) != DialogResult.OK || closed || closeRequested)
return;
var edited = dialog.GetParameters();
if (CuttingParametersSerializer.Serialize(edited) == CuttingParametersSerializer.Serialize(parameters))
return; // OK with nothing changed keeps the current plan.
parameters = edited;
// Saved now, not only on Apply: a plate that will not plan must not lose the edit.
editor.SaveCuttingParameters(parameters);
ShowSettings();
+10 -4
View File
@@ -739,8 +739,12 @@ The former standalone planning dialog is retired; only the docked Plan/Validate
panel is wired in the editor. Non-editor callers still use the shared analyzer.
- The panel starts from the plate's cutting settings (or the last-used settings) and plans
at once. `Cutting Settings...` edits them and `Keep the current part order` fixes the
whole-part order; either change replans. The settings are confirmed parameters: every
at once. Its options sit in two titled groups so the two settings buttons are not
confused: **Part cutting** holds `Leads & Tabs...` (the Cutting Parameters dialog) with a
summary beside it, and **Scrap cut-offs** holds the cut-off box and `Strips...`.
`Leads & Tabs...` edits them and `Keep the current part order` fixes the
whole-part order; either change replans. Canceling the dialog, or OK with nothing
changed, keeps the current plan. The settings are confirmed parameters: every
unlocked part's lead-ins are regenerated. Locked parts keep their exact programs; their
own violations are fixed-lead warnings on an UNVERIFIED plate (see
[fixed emissions](#fixed-emissions-warn)), and any warnings require explicit review below.
@@ -766,9 +770,11 @@ panel is wired in the editor. Non-editor callers still use the shared analyzer.
restores the earlier cut-offs and sequence. The proposal preview draws planned cut-offs
with the same orange-red dashed line as the editor. A blocked cut-off plan adds nothing and
plans nothing; the panel names the plate and reason.
`Cut-off Settings...` opens the Automatic Scrap Cut-offs dialog in settings mode for
`Strips...` opens the Automatic Scrap Cut-offs dialog in settings mode for
the same scope: it previews on the active plate as usual, but `Use These Settings`
only returns the values (it adds nothing), ticks the box and replans. The panel
only returns the values (it adds nothing), ticks the box and replans. Cancel keeps the
current plan when the box is clear; with the box ticked the staged cut-offs had to come
off for the dialog, so Cancel stages them again and replans. The panel
remembers the last settings per unit system until the application closes. Cut-off
order follows the dependency rules above: crossing cut-offs before the parts they
pass through, sheet-separating cut-offs last.
+1 -1
View File
@@ -1,7 +1,7 @@
# Pierce zones
On thick plate, a laser or plasma pierce blows a crater wider than the kerf. Set
`CuttingParameters.PierceDiameter` (Cutting Settings, **Pierce Diameter**) to the crater's
`CuttingParameters.PierceDiameter` (Leads & Tabs, **Pierce Diameter**) to the crater's
diameter for that machine, material and thickness. 0, the default, turns the zone off, and
lead generation, planning and posting then behave exactly as before.