feat: integrate geometry simplifier into CadConverterForm

Add "Simplify..." button to the detail bar and wire up SimplifierViewerForm
as a tool window with lazy creation, positioning, and entity replacement on apply.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 23:44:10 -04:00
parent f711a2e4d6
commit 0a294934ae
2 changed files with 51 additions and 2 deletions
+12
View File
@@ -28,6 +28,7 @@ namespace OpenNest.Forms
lblDimensions = new System.Windows.Forms.Label(); lblDimensions = new System.Windows.Forms.Label();
lblEntityCount = new System.Windows.Forms.Label(); lblEntityCount = new System.Windows.Forms.Label();
btnSplit = new System.Windows.Forms.Button(); btnSplit = new System.Windows.Forms.Button();
btnSimplify = new System.Windows.Forms.Button();
lblDetect = new System.Windows.Forms.Label(); lblDetect = new System.Windows.Forms.Label();
cboBendDetector = new System.Windows.Forms.ComboBox(); cboBendDetector = new System.Windows.Forms.ComboBox();
bottomPanel1 = new OpenNest.Controls.BottomPanel(); bottomPanel1 = new OpenNest.Controls.BottomPanel();
@@ -127,6 +128,7 @@ namespace OpenNest.Forms
detailBar.Controls.Add(lblDimensions); detailBar.Controls.Add(lblDimensions);
detailBar.Controls.Add(lblEntityCount); detailBar.Controls.Add(lblEntityCount);
detailBar.Controls.Add(btnSplit); detailBar.Controls.Add(btnSplit);
detailBar.Controls.Add(btnSimplify);
detailBar.Controls.Add(lblDetect); detailBar.Controls.Add(lblDetect);
detailBar.Controls.Add(cboBendDetector); detailBar.Controls.Add(cboBendDetector);
detailBar.Dock = System.Windows.Forms.DockStyle.Bottom; detailBar.Dock = System.Windows.Forms.DockStyle.Bottom;
@@ -214,6 +216,15 @@ namespace OpenNest.Forms
btnSplit.TabIndex = 6; btnSplit.TabIndex = 6;
btnSplit.Text = "Split..."; btnSplit.Text = "Split...";
// //
// btnSimplify
//
btnSimplify.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
btnSimplify.Font = new System.Drawing.Font("Segoe UI", 9F);
btnSimplify.Text = "Simplify...";
btnSimplify.AutoSize = true;
btnSimplify.Margin = new System.Windows.Forms.Padding(4, 0, 0, 0);
btnSimplify.Click += new System.EventHandler(this.OnSimplifyClick);
//
// lblDetect // lblDetect
// //
lblDetect.AutoSize = true; lblDetect.AutoSize = true;
@@ -312,6 +323,7 @@ namespace OpenNest.Forms
private System.Windows.Forms.NumericUpDown numQuantity; private System.Windows.Forms.NumericUpDown numQuantity;
private System.Windows.Forms.TextBox txtCustomer; private System.Windows.Forms.TextBox txtCustomer;
private System.Windows.Forms.Button btnSplit; private System.Windows.Forms.Button btnSplit;
private System.Windows.Forms.Button btnSimplify;
private System.Windows.Forms.ComboBox cboBendDetector; private System.Windows.Forms.ComboBox cboBendDetector;
private System.Windows.Forms.Label lblQty; private System.Windows.Forms.Label lblQty;
private System.Windows.Forms.Label lblCust; private System.Windows.Forms.Label lblCust;
+37
View File
@@ -20,6 +20,7 @@ namespace OpenNest.Forms
public partial class CadConverterForm : Form public partial class CadConverterForm : Form
{ {
private static int colorIndex; private static int colorIndex;
private SimplifierViewerForm simplifierViewer;
public CadConverterForm() public CadConverterForm()
{ {
@@ -378,6 +379,42 @@ namespace OpenNest.Forms
} }
} }
private void OnSimplifyClick(object sender, EventArgs e)
{
if (entityView1.Entities == null || entityView1.Entities.Count == 0)
return;
var shapes = ShapeBuilder.GetShapes(entityView1.Entities);
if (shapes.Count == 0)
return;
if (simplifierViewer == null || simplifierViewer.IsDisposed)
{
simplifierViewer = new SimplifierViewerForm();
simplifierViewer.Owner = this;
simplifierViewer.Applied += OnSimplifierApplied;
// Position next to this form
var screen = Screen.FromControl(this);
simplifierViewer.Location = new Point(
System.Math.Min(Right, screen.WorkingArea.Right - simplifierViewer.Width),
Top);
}
simplifierViewer.LoadShapes(shapes, entityView1);
}
private void OnSimplifierApplied(List<Entity> entities)
{
entityView1.Entities.Clear();
entityView1.Entities.AddRange(entities);
entityView1.ZoomToFit();
entityView1.Invalidate();
// Update entity count label
lblEntityCount.Text = $"{entities.Count} entities";
}
#endregion #endregion
#region Output #region Output