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:
16
OpenNest/Forms/CadConverterForm.Designer.cs
generated
16
OpenNest/Forms/CadConverterForm.Designer.cs
generated
@@ -28,6 +28,7 @@ namespace OpenNest.Forms
|
||||
lblDimensions = new System.Windows.Forms.Label();
|
||||
lblEntityCount = new System.Windows.Forms.Label();
|
||||
btnSplit = new System.Windows.Forms.Button();
|
||||
btnSimplify = new System.Windows.Forms.Button();
|
||||
lblDetect = new System.Windows.Forms.Label();
|
||||
cboBendDetector = new System.Windows.Forms.ComboBox();
|
||||
bottomPanel1 = new OpenNest.Controls.BottomPanel();
|
||||
@@ -127,6 +128,7 @@ namespace OpenNest.Forms
|
||||
detailBar.Controls.Add(lblDimensions);
|
||||
detailBar.Controls.Add(lblEntityCount);
|
||||
detailBar.Controls.Add(btnSplit);
|
||||
detailBar.Controls.Add(btnSimplify);
|
||||
detailBar.Controls.Add(lblDetect);
|
||||
detailBar.Controls.Add(cboBendDetector);
|
||||
detailBar.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
@@ -213,9 +215,18 @@ namespace OpenNest.Forms
|
||||
btnSplit.Size = new System.Drawing.Size(60, 24);
|
||||
btnSplit.TabIndex = 6;
|
||||
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.AutoSize = true;
|
||||
lblDetect.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
lblDetect.Location = new System.Drawing.Point(361, 9);
|
||||
@@ -312,6 +323,7 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.NumericUpDown numQuantity;
|
||||
private System.Windows.Forms.TextBox txtCustomer;
|
||||
private System.Windows.Forms.Button btnSplit;
|
||||
private System.Windows.Forms.Button btnSimplify;
|
||||
private System.Windows.Forms.ComboBox cboBendDetector;
|
||||
private System.Windows.Forms.Label lblQty;
|
||||
private System.Windows.Forms.Label lblCust;
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace OpenNest.Forms
|
||||
public partial class CadConverterForm : Form
|
||||
{
|
||||
private static int colorIndex;
|
||||
private SimplifierViewerForm simplifierViewer;
|
||||
|
||||
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
|
||||
|
||||
#region Output
|
||||
|
||||
Reference in New Issue
Block a user