From 58b8467c39c2dfcfdbc362312c12c25fe2be3880 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 27 Oct 2026 13:25:09 -0400 Subject: [PATCH] fix(ui): keep Draw Support visible while inspecting a cutting plan The support overlay was drawn inside the live-plate-only paint block, and the Plan Cutting preview plate never copied the support bed, so opening the cut planner hid the grid points and each part's support marks. The overlay now follows the displayed plate, the preview carries the bed, and tab-point clearance falls back to the live plate's tab size. Co-Authored-By: Claude Opus 5.5 --- OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs | 2 ++ .../CuttingPlanning/ClampZonePreviewTests.cs | 13 +++++++++++++ OpenNest/Controls/PlateView.cs | 5 +++-- OpenNest/Controls/SupportOverlay.cs | 6 ++++-- docs/support-tabs.md | 3 ++- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs b/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs index e0224b98..cf75f755 100644 --- a/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs +++ b/OpenNest.Engine/CuttingPlanning/CuttingPlanBatch.cs @@ -447,6 +447,8 @@ public sealed class CuttingPlanProposal Quadrant = source.Quadrant, PartSpacing = source.PartSpacing, EdgeSpacing = source.EdgeSpacing, + // View > Draw Support shows the proposal on the same bed. + SupportBed = source.SupportBed, }; // Machine clamps stay visible while inspecting the proposal; zones are immutable. foreach (var zone in source.ClampZones) diff --git a/OpenNest.Tests/CuttingPlanning/ClampZonePreviewTests.cs b/OpenNest.Tests/CuttingPlanning/ClampZonePreviewTests.cs index 26c1de67..dd4972e8 100644 --- a/OpenNest.Tests/CuttingPlanning/ClampZonePreviewTests.cs +++ b/OpenNest.Tests/CuttingPlanning/ClampZonePreviewTests.cs @@ -19,4 +19,17 @@ public class ClampZonePreviewTests Assert.Equal(2, preview.ClampZones.Count); Assert.Null(preview.ClampRail); // a detached display copy never re-resolves } + + [Fact] + public void PreviewCarriesThePlatesSupportBed() + { + var plate = BestEffortCuttingPlanTests.Plate(BestEffortCuttingPlanTests.TouchingContours()); + plate.SupportBed = new OpenNest.Support.SupportGrid(25, 100, 2, 2, stabilityMargin: 0.1); + + var proposal = CuttingPlanBatch.Capture([plate], ExplicitContourTests.Parameters(), false).Plan(); + var preview = proposal.BuildPreview(0); + + Assert.NotNull(preview); + Assert.Same(plate.SupportBed, preview.SupportBed); + } } diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index 5a4065d3..3290566f 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -771,10 +771,11 @@ namespace OpenNest.Controls { renderer.DrawActiveWorkArea(e.Graphics); renderer.DrawDebugRemnants(e.Graphics); - if (DrawSupport) - supportOverlay.Draw(e.Graphics, this); DrawOverlapOverlay(e.Graphics); } + // The support overlay follows the displayed plate, so it shows a proposal's tabbed parts too. + if (DrawSupport) + supportOverlay.Draw(e.Graphics, this); // Plan Cutting marks findings on its proposal as well as on the live plate. validationOverlay.Draw(e.Graphics); if (!HasProposalDisplay) diff --git a/OpenNest/Controls/SupportOverlay.cs b/OpenNest/Controls/SupportOverlay.cs index ac346530..1e314fed 100644 --- a/OpenNest/Controls/SupportOverlay.cs +++ b/OpenNest/Controls/SupportOverlay.cs @@ -49,8 +49,10 @@ namespace OpenNest.Controls using var supportedPen = new Pen(SupportedColor, 2f); using var tippingPen = new Pen(TippingColor, 2f); using var tabBrush = new SolidBrush(TabColor); - // Tab points keep clear of inside corners as Plan Cutting's do. - var clearance = SupportAnalyzer.InsideCornerClearance(plate.CuttingParameters?.TabConfig?.Size ?? 0); + // Tab points keep clear of inside corners as Plan Cutting's do. A proposal preview has no + // parameters of its own, so it uses the live plate's. + var parameters = plate.CuttingParameters ?? view.Plate?.CuttingParameters; + var clearance = SupportAnalyzer.InsideCornerClearance(parameters?.TabConfig?.Size ?? 0); foreach (var part in plate.Parts) { if (part?.BaseDrawing == null || part.BaseDrawing.IsCutOff) diff --git a/docs/support-tabs.md b/docs/support-tabs.md index dfcee7b8..7c85d4ab 100644 --- a/docs/support-tabs.md +++ b/docs/support-tabs.md @@ -75,7 +75,8 @@ inside corner. Only when every outline point is too close does the clearance giv View > Draw Support shows the grid or the slats, cut off to the sheet (while its points or slats are at least 6 pixels apart), each part's contacts, and its center of gravity: green when supported, red when it can tip, with an orange -diamond on a red part's best tab point (keeping the plate's tab-size clearance). +diamond on a red part's best tab point (keeping the plate's tab-size clearance). While Plan +Cutting inspects a proposal, the overlay shows the proposal's parts on the same bed. ## Support tabs in Plan Cutting