From a4df4027f18af409272fc518683bbde96dd68ec2 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 25 Mar 2026 23:37:45 -0400 Subject: [PATCH] feat: add simplifier highlight and preview rendering to EntityView Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Controls/EntityView.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/OpenNest/Controls/EntityView.cs b/OpenNest/Controls/EntityView.cs index d90f517..d052ada 100644 --- a/OpenNest/Controls/EntityView.cs +++ b/OpenNest/Controls/EntityView.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; +using System.Linq; using System.Windows.Forms; namespace OpenNest.Controls @@ -15,6 +16,16 @@ namespace OpenNest.Controls public List Bends = new List(); public int SelectedBendIndex = -1; + private HashSet simplifierHighlightSet; + + public List SimplifierHighlight + { + get => simplifierHighlightSet?.ToList(); + set => simplifierHighlightSet = value != null ? new HashSet(value) : null; + } + + public Arc SimplifierPreview { get; set; } + private readonly Pen gridPen = new Pen(Color.FromArgb(70, 70, 70)); private readonly Dictionary penCache = new Dictionary(); @@ -71,7 +82,10 @@ namespace OpenNest.Controls foreach (var entity in Entities) { if (IsEtchLayer(entity.Layer)) continue; - var pen = GetEntityPen(entity.Color); + var isHighlighted = simplifierHighlightSet != null && simplifierHighlightSet.Contains(entity); + var pen = isHighlighted + ? GetEntityPen(Color.FromArgb(60, entity.Color)) + : GetEntityPen(entity.Color); DrawEntity(e.Graphics, entity, pen); } @@ -86,6 +100,12 @@ namespace OpenNest.Controls DrawEtchMarks(e.Graphics); + if (SimplifierPreview != null) + { + using var previewPen = new Pen(Color.FromArgb(0, 200, 80), 2f / ViewScale); + DrawArc(e.Graphics, SimplifierPreview, previewPen); + } + #if DRAW_OFFSET var offsetShape = new Shape(); @@ -400,6 +420,13 @@ namespace OpenNest.Controls } } + public void ClearSimplifierPreview() + { + SimplifierHighlight = null; + SimplifierPreview = null; + Invalidate(); + } + public void ZoomToFit(bool redraw = true) { ZoomToArea(Entities.GetBoundingBox(), redraw);