From c10abfe9963d24b2e39257257fa2a1b4402880ee Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 18 Nov 2026 08:17:58 -0500 Subject: [PATCH] refactor(overlap): drop Check Active Plate and Cancel Check from the menu The nest window rechecks the active plate automatically half a second after each edit, so a manual run/cancel pair in View > Overlap Check is redundant. With only Display left, its Off/Areas/Markers/Both items move up to sit directly under Overlap Check. Auto Nest still runs its explicit check, and undo/redo still cancel a running check internally. Co-Authored-By: Claude Opus 5.5 --- .../PlateOverlapOverlayTests.cs | 23 +++++++--------- OpenNest/Forms/MainForm.Designer.cs | 27 +------------------ OpenNest/Forms/MainForm.View.cs | 12 --------- docs/geometry/visual-overlap-check.md | 21 +++++++-------- 4 files changed, 21 insertions(+), 62 deletions(-) diff --git a/OpenNest.WinForms.Tests/PlateOverlapOverlayTests.cs b/OpenNest.WinForms.Tests/PlateOverlapOverlayTests.cs index 4c4575a2..dd9c906a 100644 --- a/OpenNest.WinForms.Tests/PlateOverlapOverlayTests.cs +++ b/OpenNest.WinForms.Tests/PlateOverlapOverlayTests.cs @@ -578,29 +578,28 @@ public class PlateOverlapOverlayTests }); [Fact] - public void MenusFollowMdiActivationDocumentDisplayAndRunningState() => RunSta(() => + public void MenusFollowMdiActivationAndDocumentDisplay() => RunSta(() => { using var host = new MenuHost(); host.Show(); - var check = Menu(host, "mnuOverlapCheckActive"); - var cancel = Menu(host, "mnuOverlapCancel"); + var overlap = Menu(host, "mnuViewOverlapCheck"); var off = Menu(host, "mnuOverlapOff"); var areas = Menu(host, "mnuOverlapAreas"); var centroids = Menu(host, "mnuOverlapCentroids"); var both = Menu(host, "mnuOverlapBoth"); - Assert.False(check.Enabled); - Assert.False(cancel.Enabled); + Assert.False(overlap.Enabled); Assert.False(off.Enabled); Assert.False(areas.Enabled); Assert.False(centroids.Enabled); Assert.False(both.Enabled); - Assert.All(new[] { check, cancel, off, areas, centroids, both }, item => Assert.Equal(Keys.None, item.ShortcutKeys)); + Assert.All(new[] { overlap, off, areas, centroids, both }, item => Assert.Equal(Keys.None, item.ShortcutKeys)); using var first = new EditNestForm(new Nest("first")) { MdiParent = host }; // Manual-command test: an auto-check timer pumped during a wait would race its requests. first.PlateView.SetOverlapAutoCheck(null); first.Show(); - Assert.True(check.Enabled); + Assert.True(overlap.Enabled); + Assert.True(off.Enabled); Assert.True(areas.Checked); off.PerformClick(); Assert.Equal(OverlapDisplayMode.Off, first.OverlapDisplay); @@ -641,10 +640,8 @@ public class PlateOverlapOverlayTests }; var task = first.CheckOverlapsAsync(); Assert.True(pending.TryTake(out var request, TimeSpan.FromSeconds(15))); - Assert.True(cancel.Enabled); Assert.True(areas.Checked); // Checking from Off selects Areas. - cancel.PerformClick(); - Assert.False(cancel.Enabled); + first.CancelOverlapCheck(); Assert.True(request!.Token.IsCancellationRequested); request.Complete(); context.Pump(task); @@ -656,8 +653,8 @@ public class PlateOverlapOverlayTests } first.Dispose(); second.Dispose(); - Assert.False(check.Enabled); - Assert.False(cancel.Enabled); + Assert.False(overlap.Enabled); + Assert.False(off.Enabled); }); [Fact] @@ -1192,7 +1189,7 @@ public class PlateOverlapOverlayTests Assert.Equal(OverlapDisplayMode.Off, run.View.OverlapDisplay); run.View.Plate.Parts[1].Offset(0.25, 0); - task = run.Start(); // manual Check Active Plate + task = run.Start(); // explicit check, as Auto Nest runs run.Next().Complete(); run.Pump(task); Assert.Equal(OverlapDisplayMode.Areas, run.View.OverlapDisplay); diff --git a/OpenNest/Forms/MainForm.Designer.cs b/OpenNest/Forms/MainForm.Designer.cs index 5d8970bc..b2a12f53 100644 --- a/OpenNest/Forms/MainForm.Designer.cs +++ b/OpenNest/Forms/MainForm.Designer.cs @@ -66,9 +66,6 @@ namespace OpenNest.Forms mnuEditSelectAll = new System.Windows.Forms.ToolStripMenuItem(); mnuView = new System.Windows.Forms.ToolStripMenuItem(); mnuViewOverlapCheck = new System.Windows.Forms.ToolStripMenuItem(); - mnuOverlapCheckActive = new System.Windows.Forms.ToolStripMenuItem(); - mnuOverlapCancel = new System.Windows.Forms.ToolStripMenuItem(); - mnuOverlapDisplay = new System.Windows.Forms.ToolStripMenuItem(); mnuOverlapOff = new System.Windows.Forms.ToolStripMenuItem(); mnuOverlapAreas = new System.Windows.Forms.ToolStripMenuItem(); mnuOverlapCentroids = new System.Windows.Forms.ToolStripMenuItem(); @@ -432,28 +429,9 @@ namespace OpenNest.Forms // mnuViewOverlapCheck.Name = "mnuViewOverlapCheck"; mnuViewOverlapCheck.Text = "Overlap Check"; - mnuViewOverlapCheck.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuOverlapCheckActive, mnuOverlapCancel, mnuOverlapDisplay }); + mnuViewOverlapCheck.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuOverlapOff, mnuOverlapAreas, mnuOverlapCentroids, mnuOverlapBoth }); mnuViewOverlapCheck.DropDownOpening += OverlapMenu_Opening; // - // mnuOverlapCheckActive - // - mnuOverlapCheckActive.Name = "mnuOverlapCheckActive"; - mnuOverlapCheckActive.Text = "Check Active Plate"; - mnuOverlapCheckActive.Click += CheckOverlaps_Click; - // - // mnuOverlapCancel - // - mnuOverlapCancel.Name = "mnuOverlapCancel"; - mnuOverlapCancel.Text = "Cancel Check"; - mnuOverlapCancel.Click += CancelOverlapCheck_Click; - // - // mnuOverlapDisplay - // - mnuOverlapDisplay.Name = "mnuOverlapDisplay"; - mnuOverlapDisplay.Text = "Display"; - mnuOverlapDisplay.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuOverlapOff, mnuOverlapAreas, mnuOverlapCentroids, mnuOverlapBoth }); - mnuOverlapDisplay.DropDownOpening += OverlapMenu_Opening; - // // mnuOverlapOff // mnuOverlapOff.Name = "mnuOverlapOff"; @@ -1478,9 +1456,6 @@ namespace OpenNest.Forms private System.Windows.Forms.ToolStripMenuItem mnuEditSelectAll; private System.Windows.Forms.ToolStripMenuItem mnuView; private System.Windows.Forms.ToolStripMenuItem mnuViewOverlapCheck; - private System.Windows.Forms.ToolStripMenuItem mnuOverlapCheckActive; - private System.Windows.Forms.ToolStripMenuItem mnuOverlapCancel; - private System.Windows.Forms.ToolStripMenuItem mnuOverlapDisplay; private System.Windows.Forms.ToolStripMenuItem mnuOverlapOff; private System.Windows.Forms.ToolStripMenuItem mnuOverlapAreas; private System.Windows.Forms.ToolStripMenuItem mnuOverlapCentroids; diff --git a/OpenNest/Forms/MainForm.View.cs b/OpenNest/Forms/MainForm.View.cs index e01d11bf..4e450db6 100644 --- a/OpenNest/Forms/MainForm.View.cs +++ b/OpenNest/Forms/MainForm.View.cs @@ -57,9 +57,6 @@ namespace OpenNest.Forms { var hasPlate = activeForm != null && !activeForm.IsDisposed && activeForm.PlateView.Plate != null; mnuViewOverlapCheck.Enabled = hasPlate; - mnuOverlapCheckActive.Enabled = hasPlate; - mnuOverlapCancel.Enabled = hasPlate && activeForm.PlateView.IsOverlapCheckRunning; - mnuOverlapDisplay.Enabled = hasPlate; mnuOverlapOff.Enabled = hasPlate; mnuOverlapAreas.Enabled = hasPlate; mnuOverlapCentroids.Enabled = hasPlate; @@ -70,15 +67,6 @@ namespace OpenNest.Forms mnuOverlapBoth.Checked = hasPlate && activeForm.OverlapDisplay == OverlapDisplayMode.Both; } - private async void CheckOverlaps_Click(object sender, EventArgs e) - { - var form = activeForm; - if (form != null) - await form.CheckOverlapsAsync(); - } - - private void CancelOverlapCheck_Click(object sender, EventArgs e) => activeForm?.CancelOverlapCheck(); - private void OverlapOff_Click(object sender, EventArgs e) { if (activeForm != null) diff --git a/docs/geometry/visual-overlap-check.md b/docs/geometry/visual-overlap-check.md index ade1fa86..de1b7ed4 100644 --- a/docs/geometry/visual-overlap-check.md +++ b/docs/geometry/visual-overlap-check.md @@ -2,13 +2,13 @@ ## Desktop use -Choose **View > Overlap Check > Check Active Plate** to check committed parts on -this plate. Shared material is shaded red/magenta without changing the nest, -selection, cutting paths, or export behavior. Cutoffs and temporary preview parts -are excluded. **Cancel Check** discards the running request. **Display > Off / -Areas / Markers / Both** changes visibility without rerunning analysis. Areas -is the default; rechecking preserves a visible mode, while checking from Off -shows Areas. Clamp overlaps are shown as part/clamp findings with the clamp ID +A nest window checks committed parts on its active plate automatically (see below); +there is no menu command to run or cancel a check. Shared material is shaded +red/magenta without changing the nest, selection, cutting paths, or export +behavior. Cutoffs and temporary preview parts are excluded. **View > Overlap +Check > Off / Areas / Markers / Both** changes visibility without rerunning +analysis. Areas is the default; an explicit check (the one Auto Nest runs when it +finishes) preserves a visible mode, while checking from Off shows Areas. Clamp overlaps are shown as part/clamp findings with the clamp ID in hover details; clamps are not selectable parts and are not added to quantity or machining. A clamp edit invalidates the diagnostic and schedules a fresh check. Display preferences belong to the current document and are not saved. @@ -76,12 +76,11 @@ mouse button, modal dialog, or fill progress window is active, the check reruns. Automatic results do not replace the status bar's message, so it keeps the last command's text; a separate **Layout** section beside utilization follows the check instead, as `Layout: OK`, `Layout: checking…` or `Layout: 1 overlap, 3 too close`, -in red for findings or an unfinished check, with the full wording in its tooltip, and an automatic check keeps Display > Off rather than +in red for findings or an unfinished check, with the full wording in its tooltip, and an automatic check keeps Off rather than switching to Areas. Rechecks are incremental: drawing material is prepared once and reused, and pairs whose two parts have not moved reuse the previous result, -so only the moved parts' neighbors are clipped again. Canceling a check is -respected until the layout changes again, and a failed layout is not retried -until it changes. Check Active Plate remains available and always runs at once. +so only the moved parts' neighbors are clipped again. A failed layout is not +retried until it changes. Plate changes reset the check. Pan, zoom, selection, and display changes do not rerun geometry. Drawing-editor loading invalidates before loading (dropping cached