Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 28653e3a9f | |||
| 7c3246c6e7 |
@@ -305,9 +305,6 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
subPgm.Codes.AddRange(leadIn.Generate(relativePoint, normal, winding));
|
subPgm.Codes.AddRange(leadIn.Generate(relativePoint, normal, winding));
|
||||||
var reindexed = relativeShape.ReindexAt(relativePoint, relativeCircle);
|
var reindexed = relativeShape.ReindexAt(relativePoint, relativeCircle);
|
||||||
|
|
||||||
if (Parameters.TabsEnabled && Parameters.TabConfig != null)
|
|
||||||
reindexed = TrimShapeForTab(reindexed, relativePoint, Parameters.TabConfig.Size);
|
|
||||||
|
|
||||||
subPgm.Codes.AddRange(ConvertShapeToMoves(reindexed, relativePoint));
|
subPgm.Codes.AddRange(ConvertShapeToMoves(reindexed, relativePoint));
|
||||||
subPgm.Codes.AddRange(leadOut.Generate(relativePoint, normal, winding));
|
subPgm.Codes.AddRange(leadOut.Generate(relativePoint, normal, winding));
|
||||||
subPgm.Mode = Mode.Incremental;
|
subPgm.Mode = Mode.Incremental;
|
||||||
@@ -331,7 +328,7 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
|
|
||||||
var reindexedShape = shape.ReindexAt(point, entity);
|
var reindexedShape = shape.ReindexAt(point, entity);
|
||||||
|
|
||||||
if (Parameters.TabsEnabled && Parameters.TabConfig != null)
|
if (Parameters.TabsEnabled && Parameters.TabConfig != null && contourType == ContourType.External)
|
||||||
reindexedShape = TrimShapeForTab(reindexedShape, point, Parameters.TabConfig.Size);
|
reindexedShape = TrimShapeForTab(reindexedShape, point, Parameters.TabConfig.Size);
|
||||||
|
|
||||||
program.Codes.AddRange(ConvertShapeToMoves(reindexedShape, point));
|
program.Codes.AddRange(ConvertShapeToMoves(reindexedShape, point));
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ namespace OpenNest.Shapes
|
|||||||
{
|
{
|
||||||
public double Diameter { get; set; }
|
public double Diameter { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Circle {Dim(Diameter)} Dia";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Diameter = 8;
|
Diameter = 8;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace OpenNest.Shapes
|
|||||||
public double Base { get; set; }
|
public double Base { get; set; }
|
||||||
public double Height { get; set; }
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Isosceles Triangle {Dim(Base)}x{Dim(Height)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Base = 8;
|
Base = 8;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace OpenNest.Shapes
|
|||||||
public double LegWidth { get; set; }
|
public double LegWidth { get; set; }
|
||||||
public double LegHeight { get; set; }
|
public double LegHeight { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"L {Dim(Width)}x{Dim(Height)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Width = 8;
|
Width = 8;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace OpenNest.Shapes
|
|||||||
public int Sides { get; set; }
|
public int Sides { get; set; }
|
||||||
public double Width { get; set; }
|
public double Width { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"{Sides}-Sided Polygon {Dim(Width)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Sides = 8;
|
Sides = 8;
|
||||||
|
|||||||
@@ -13,6 +13,14 @@ namespace OpenNest.Shapes
|
|||||||
public double PipeClearance { get; set; }
|
public double PipeClearance { get; set; }
|
||||||
public bool Blind { get; set; }
|
public bool Blind { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName()
|
||||||
|
{
|
||||||
|
var name = $"Pipe Flange {Dim(OD)} OD";
|
||||||
|
if (!string.IsNullOrEmpty(PipeSize))
|
||||||
|
name += $" {PipeSize} Pipe";
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
OD = 7.5;
|
OD = 7.5;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace OpenNest.Shapes
|
|||||||
public double Length { get; set; }
|
public double Length { get; set; }
|
||||||
public double Width { get; set; }
|
public double Width { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Rectangle {Dim(Length)}x{Dim(Width)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Length = 12;
|
Length = 12;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace OpenNest.Shapes
|
|||||||
public double Width { get; set; }
|
public double Width { get; set; }
|
||||||
public double Height { get; set; }
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Right Triangle {Dim(Width)}x{Dim(Height)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Width = 8;
|
Width = 8;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace OpenNest.Shapes
|
|||||||
public double OuterDiameter { get; set; }
|
public double OuterDiameter { get; set; }
|
||||||
public double InnerDiameter { get; set; }
|
public double InnerDiameter { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Ring {Dim(OuterDiameter)}x{Dim(InnerDiameter)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
OuterDiameter = 10;
|
OuterDiameter = 10;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace OpenNest.Shapes
|
|||||||
public double Width { get; set; }
|
public double Width { get; set; }
|
||||||
public double Radius { get; set; }
|
public double Radius { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Rounded Rectangle {Dim(Length)}x{Dim(Width)} R{Dim(Radius)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Length = 12;
|
Length = 12;
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ namespace OpenNest.Shapes
|
|||||||
|
|
||||||
public abstract Drawing GetDrawing();
|
public abstract Drawing GetDrawing();
|
||||||
|
|
||||||
|
public virtual string GenerateName()
|
||||||
|
{
|
||||||
|
var typeName = GetType().Name;
|
||||||
|
return typeName.EndsWith("Shape")
|
||||||
|
? typeName.Substring(0, typeName.Length - 5)
|
||||||
|
: typeName;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void SetPreviewDefaults() { }
|
public virtual void SetPreviewDefaults() { }
|
||||||
|
|
||||||
public static List<T> LoadFromJson<T>(string path) where T : ShapeDefinition
|
public static List<T> LoadFromJson<T>(string path) where T : ShapeDefinition
|
||||||
@@ -34,6 +42,8 @@ namespace OpenNest.Shapes
|
|||||||
return JsonSerializer.Deserialize<List<T>>(json, JsonOptions);
|
return JsonSerializer.Deserialize<List<T>>(json, JsonOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static string Dim(double value) => value.ToString("0.###");
|
||||||
|
|
||||||
protected Drawing CreateDrawing(List<Entity> entities)
|
protected Drawing CreateDrawing(List<Entity> entities)
|
||||||
{
|
{
|
||||||
var pgm = ConvertGeometry.ToProgram(entities);
|
var pgm = ConvertGeometry.ToProgram(entities);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ namespace OpenNest.Shapes
|
|||||||
public double StemWidth { get; set; }
|
public double StemWidth { get; set; }
|
||||||
public double BarHeight { get; set; }
|
public double BarHeight { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"T {Dim(Width)}x{Dim(Height)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
Width = 10;
|
Width = 10;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ namespace OpenNest.Shapes
|
|||||||
public double BottomWidth { get; set; }
|
public double BottomWidth { get; set; }
|
||||||
public double Height { get; set; }
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
public override string GenerateName() => $"Trapezoid {Dim(TopWidth)}x{Dim(BottomWidth)}x{Dim(Height)}";
|
||||||
|
|
||||||
public override void SetPreviewDefaults()
|
public override void SetPreviewDefaults()
|
||||||
{
|
{
|
||||||
TopWidth = 6;
|
TopWidth = 6;
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace OpenNest.Controls
|
|||||||
|
|
||||||
private readonly CheckBox chkTabsEnabled;
|
private readonly CheckBox chkTabsEnabled;
|
||||||
private readonly NumericUpDown nudTabWidth;
|
private readonly NumericUpDown nudTabWidth;
|
||||||
|
private readonly RadioButton rbTabAll;
|
||||||
|
private readonly RadioButton rbAutoTab;
|
||||||
private readonly NumericUpDown nudAutoTabMin;
|
private readonly NumericUpDown nudAutoTabMin;
|
||||||
private readonly NumericUpDown nudAutoTabMax;
|
private readonly NumericUpDown nudAutoTabMax;
|
||||||
private readonly NumericUpDown nudPierceClearance;
|
private readonly NumericUpDown nudPierceClearance;
|
||||||
@@ -112,7 +114,7 @@ namespace OpenNest.Controls
|
|||||||
{
|
{
|
||||||
HeaderText = "Tabs",
|
HeaderText = "Tabs",
|
||||||
Dock = DockStyle.Top,
|
Dock = DockStyle.Top,
|
||||||
ExpandedHeight = 120,
|
ExpandedHeight = 160,
|
||||||
IsExpanded = false
|
IsExpanded = false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,44 +124,78 @@ namespace OpenNest.Controls
|
|||||||
Location = new Point(12, 4),
|
Location = new Point(12, 4),
|
||||||
AutoSize = true
|
AutoSize = true
|
||||||
};
|
};
|
||||||
chkTabsEnabled.CheckedChanged += (s, e) =>
|
|
||||||
{
|
|
||||||
nudTabWidth.Enabled = chkTabsEnabled.Checked;
|
|
||||||
OnParametersChanged();
|
|
||||||
};
|
|
||||||
tabsPanel.ContentPanel.Controls.Add(chkTabsEnabled);
|
tabsPanel.ContentPanel.Controls.Add(chkTabsEnabled);
|
||||||
|
|
||||||
tabsPanel.ContentPanel.Controls.Add(new Label
|
tabsPanel.ContentPanel.Controls.Add(new Label
|
||||||
{
|
{
|
||||||
Text = "Width:",
|
Text = "Tab Size:",
|
||||||
Location = new Point(160, 6),
|
Location = new Point(160, 6),
|
||||||
AutoSize = true
|
AutoSize = true
|
||||||
});
|
});
|
||||||
|
|
||||||
nudTabWidth = CreateNumeric(215, 3, 0.25, 0.0625);
|
nudTabWidth = CreateNumeric(225, 3, 0.25, 0.0625);
|
||||||
nudTabWidth.Enabled = false;
|
nudTabWidth.Enabled = false;
|
||||||
tabsPanel.ContentPanel.Controls.Add(nudTabWidth);
|
tabsPanel.ContentPanel.Controls.Add(nudTabWidth);
|
||||||
|
|
||||||
|
rbTabAll = new RadioButton
|
||||||
|
{
|
||||||
|
Text = "Tab all parts",
|
||||||
|
Location = new Point(28, 28),
|
||||||
|
AutoSize = true,
|
||||||
|
Enabled = false,
|
||||||
|
Checked = true
|
||||||
|
};
|
||||||
|
tabsPanel.ContentPanel.Controls.Add(rbTabAll);
|
||||||
|
|
||||||
|
rbAutoTab = new RadioButton
|
||||||
|
{
|
||||||
|
Text = "Auto-tab when smallest part dimension is between:",
|
||||||
|
Location = new Point(28, 50),
|
||||||
|
AutoSize = true,
|
||||||
|
Enabled = false
|
||||||
|
};
|
||||||
|
tabsPanel.ContentPanel.Controls.Add(rbAutoTab);
|
||||||
|
|
||||||
tabsPanel.ContentPanel.Controls.Add(new Label
|
tabsPanel.ContentPanel.Controls.Add(new Label
|
||||||
{
|
{
|
||||||
Text = "Auto-Tab Min Size:",
|
Text = "Min:",
|
||||||
Location = new Point(12, 32),
|
Location = new Point(44, 76),
|
||||||
AutoSize = true
|
AutoSize = true
|
||||||
});
|
});
|
||||||
|
|
||||||
nudAutoTabMin = CreateNumeric(140, 29, 0, 0.0625);
|
nudAutoTabMin = CreateNumeric(77, 73, 0, 0.0625);
|
||||||
|
nudAutoTabMin.Enabled = false;
|
||||||
tabsPanel.ContentPanel.Controls.Add(nudAutoTabMin);
|
tabsPanel.ContentPanel.Controls.Add(nudAutoTabMin);
|
||||||
|
|
||||||
tabsPanel.ContentPanel.Controls.Add(new Label
|
tabsPanel.ContentPanel.Controls.Add(new Label
|
||||||
{
|
{
|
||||||
Text = "Auto-Tab Max Size:",
|
Text = "Max:",
|
||||||
Location = new Point(12, 58),
|
Location = new Point(210, 76),
|
||||||
AutoSize = true
|
AutoSize = true
|
||||||
});
|
});
|
||||||
|
|
||||||
nudAutoTabMax = CreateNumeric(140, 55, 0, 0.0625);
|
nudAutoTabMax = CreateNumeric(245, 73, 0, 0.0625);
|
||||||
|
nudAutoTabMax.Enabled = false;
|
||||||
tabsPanel.ContentPanel.Controls.Add(nudAutoTabMax);
|
tabsPanel.ContentPanel.Controls.Add(nudAutoTabMax);
|
||||||
|
|
||||||
|
chkTabsEnabled.CheckedChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
var enabled = chkTabsEnabled.Checked;
|
||||||
|
nudTabWidth.Enabled = enabled;
|
||||||
|
rbTabAll.Enabled = enabled;
|
||||||
|
rbAutoTab.Enabled = enabled;
|
||||||
|
nudAutoTabMin.Enabled = enabled && rbAutoTab.Checked;
|
||||||
|
nudAutoTabMax.Enabled = enabled && rbAutoTab.Checked;
|
||||||
|
OnParametersChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
rbTabAll.CheckedChanged += (s, e) =>
|
||||||
|
{
|
||||||
|
nudAutoTabMin.Enabled = chkTabsEnabled.Checked && rbAutoTab.Checked;
|
||||||
|
nudAutoTabMax.Enabled = chkTabsEnabled.Checked && rbAutoTab.Checked;
|
||||||
|
OnParametersChanged();
|
||||||
|
};
|
||||||
|
|
||||||
// Pierce section
|
// Pierce section
|
||||||
var piercePanel = new CollapsiblePanel
|
var piercePanel = new CollapsiblePanel
|
||||||
{
|
{
|
||||||
@@ -246,13 +282,13 @@ namespace OpenNest.Controls
|
|||||||
InternalLeadOut = BuildLeadOut(cboInternalLeadOut, pnlInternalLeadOut),
|
InternalLeadOut = BuildLeadOut(cboInternalLeadOut, pnlInternalLeadOut),
|
||||||
ArcCircleLeadIn = BuildLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn),
|
ArcCircleLeadIn = BuildLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn),
|
||||||
ArcCircleLeadOut = BuildLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut),
|
ArcCircleLeadOut = BuildLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut),
|
||||||
TabsEnabled = chkTabsEnabled.Checked,
|
TabsEnabled = chkTabsEnabled.Checked && rbTabAll.Checked,
|
||||||
TabConfig = new NormalTab { Size = (double)nudTabWidth.Value },
|
TabConfig = new NormalTab { Size = (double)nudTabWidth.Value },
|
||||||
PierceClearance = (double)nudPierceClearance.Value,
|
PierceClearance = (double)nudPierceClearance.Value,
|
||||||
RoundLeadInAngles = chkRoundLeadInAngles.Checked,
|
RoundLeadInAngles = chkRoundLeadInAngles.Checked,
|
||||||
LeadInAngleIncrement = (double)nudLeadInAngleIncrement.Value,
|
LeadInAngleIncrement = (double)nudLeadInAngleIncrement.Value,
|
||||||
AutoTabMinSize = (double)nudAutoTabMin.Value,
|
AutoTabMinSize = chkTabsEnabled.Checked && rbAutoTab.Checked ? (double)nudAutoTabMin.Value : 0,
|
||||||
AutoTabMaxSize = (double)nudAutoTabMax.Value
|
AutoTabMaxSize = chkTabsEnabled.Checked && rbAutoTab.Checked ? (double)nudAutoTabMax.Value : 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +303,10 @@ namespace OpenNest.Controls
|
|||||||
LoadLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn, p.ArcCircleLeadIn);
|
LoadLeadIn(cboArcCircleLeadIn, pnlArcCircleLeadIn, p.ArcCircleLeadIn);
|
||||||
LoadLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut, p.ArcCircleLeadOut);
|
LoadLeadOut(cboArcCircleLeadOut, pnlArcCircleLeadOut, p.ArcCircleLeadOut);
|
||||||
|
|
||||||
chkTabsEnabled.Checked = p.TabsEnabled;
|
var hasAutoTab = p.AutoTabMinSize > 0 || p.AutoTabMaxSize > 0;
|
||||||
|
chkTabsEnabled.Checked = p.TabsEnabled || hasAutoTab;
|
||||||
|
rbAutoTab.Checked = hasAutoTab;
|
||||||
|
rbTabAll.Checked = !hasAutoTab;
|
||||||
if (p.TabConfig != null)
|
if (p.TabConfig != null)
|
||||||
nudTabWidth.Value = (decimal)p.TabConfig.Size;
|
nudTabWidth.Value = (decimal)p.TabConfig.Size;
|
||||||
nudPierceClearance.Value = (decimal)p.PierceClearance;
|
nudPierceClearance.Value = (decimal)p.PierceClearance;
|
||||||
|
|||||||
Generated
+11
-20
@@ -47,11 +47,9 @@
|
|||||||
drawingListBox1 = new OpenNest.Controls.DrawingListBox();
|
drawingListBox1 = new OpenNest.Controls.DrawingListBox();
|
||||||
toolStrip2 = new System.Windows.Forms.ToolStrip();
|
toolStrip2 = new System.Windows.Forms.ToolStrip();
|
||||||
toolStripButton2 = new System.Windows.Forms.ToolStripButton();
|
toolStripButton2 = new System.Windows.Forms.ToolStripButton();
|
||||||
toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
shapeLibraryButton = new System.Windows.Forms.ToolStripButton();
|
||||||
editDrawingsButton = new System.Windows.Forms.ToolStripButton();
|
editDrawingsButton = new System.Windows.Forms.ToolStripButton();
|
||||||
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
|
||||||
toolStripButton3 = new System.Windows.Forms.ToolStripButton();
|
toolStripButton3 = new System.Windows.Forms.ToolStripButton();
|
||||||
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
|
||||||
hideNestedButton = new System.Windows.Forms.ToolStripButton();
|
hideNestedButton = new System.Windows.Forms.ToolStripButton();
|
||||||
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
||||||
splitContainer.Panel1.SuspendLayout();
|
splitContainer.Panel1.SuspendLayout();
|
||||||
@@ -219,7 +217,7 @@
|
|||||||
//
|
//
|
||||||
toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||||
toolStrip2.ImageScalingSize = new System.Drawing.Size(20, 20);
|
toolStrip2.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripButton2, toolStripSeparator4, editDrawingsButton, toolStripSeparator1, toolStripButton3, toolStripSeparator2, hideNestedButton });
|
toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripButton2, shapeLibraryButton, editDrawingsButton, toolStripButton3, hideNestedButton });
|
||||||
toolStrip2.Location = new System.Drawing.Point(4, 3);
|
toolStrip2.Location = new System.Drawing.Point(4, 3);
|
||||||
toolStrip2.Name = "toolStrip2";
|
toolStrip2.Name = "toolStrip2";
|
||||||
toolStrip2.Size = new System.Drawing.Size(265, 27);
|
toolStrip2.Size = new System.Drawing.Size(265, 27);
|
||||||
@@ -238,10 +236,15 @@
|
|||||||
toolStripButton2.Text = "Import Drawings";
|
toolStripButton2.Text = "Import Drawings";
|
||||||
toolStripButton2.Click += ImportDrawings_Click;
|
toolStripButton2.Click += ImportDrawings_Click;
|
||||||
//
|
//
|
||||||
// toolStripSeparator4
|
// shapeLibraryButton
|
||||||
//
|
//
|
||||||
toolStripSeparator4.Name = "toolStripSeparator4";
|
shapeLibraryButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||||
toolStripSeparator4.Size = new System.Drawing.Size(6, 27);
|
shapeLibraryButton.Image = Properties.Resources.shapes;
|
||||||
|
shapeLibraryButton.Name = "shapeLibraryButton";
|
||||||
|
shapeLibraryButton.Padding = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||||
|
shapeLibraryButton.Size = new System.Drawing.Size(34, 24);
|
||||||
|
shapeLibraryButton.Text = "Shape Library";
|
||||||
|
shapeLibraryButton.Click += ShapeLibrary_Click;
|
||||||
//
|
//
|
||||||
// editDrawingsButton
|
// editDrawingsButton
|
||||||
//
|
//
|
||||||
@@ -253,11 +256,6 @@
|
|||||||
editDrawingsButton.Text = "Edit Drawings in Converter";
|
editDrawingsButton.Text = "Edit Drawings in Converter";
|
||||||
editDrawingsButton.Click += EditDrawingsInConverter_Click;
|
editDrawingsButton.Click += EditDrawingsInConverter_Click;
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
|
||||||
//
|
|
||||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
|
||||||
toolStripSeparator1.Size = new System.Drawing.Size(6, 27);
|
|
||||||
//
|
|
||||||
// toolStripButton3
|
// toolStripButton3
|
||||||
//
|
//
|
||||||
toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
toolStripButton3.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||||
@@ -269,11 +267,6 @@
|
|||||||
toolStripButton3.Text = "Cleanup unused Drawings";
|
toolStripButton3.Text = "Cleanup unused Drawings";
|
||||||
toolStripButton3.Click += CleanUnusedDrawings_Click;
|
toolStripButton3.Click += CleanUnusedDrawings_Click;
|
||||||
//
|
//
|
||||||
// toolStripSeparator2
|
|
||||||
//
|
|
||||||
toolStripSeparator2.Name = "toolStripSeparator2";
|
|
||||||
toolStripSeparator2.Size = new System.Drawing.Size(6, 27);
|
|
||||||
//
|
|
||||||
// hideNestedButton
|
// hideNestedButton
|
||||||
//
|
//
|
||||||
hideNestedButton.CheckOnClick = true;
|
hideNestedButton.CheckOnClick = true;
|
||||||
@@ -329,11 +322,9 @@
|
|||||||
private System.Windows.Forms.ColumnHeader utilColumn;
|
private System.Windows.Forms.ColumnHeader utilColumn;
|
||||||
private System.Windows.Forms.ToolStrip toolStrip2;
|
private System.Windows.Forms.ToolStrip toolStrip2;
|
||||||
private System.Windows.Forms.ToolStripButton toolStripButton2;
|
private System.Windows.Forms.ToolStripButton toolStripButton2;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
private System.Windows.Forms.ToolStripButton shapeLibraryButton;
|
||||||
private System.Windows.Forms.ToolStripButton editDrawingsButton;
|
private System.Windows.Forms.ToolStripButton editDrawingsButton;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
|
||||||
private System.Windows.Forms.ToolStripButton toolStripButton3;
|
private System.Windows.Forms.ToolStripButton toolStripButton3;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
|
||||||
private System.Windows.Forms.ToolStripButton hideNestedButton;
|
private System.Windows.Forms.ToolStripButton hideNestedButton;
|
||||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
|
||||||
private System.Windows.Forms.ToolStripButton toolStripLabel1;
|
private System.Windows.Forms.ToolStripButton toolStripLabel1;
|
||||||
|
|||||||
@@ -875,6 +875,18 @@ namespace OpenNest.Forms
|
|||||||
Import();
|
Import();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShapeLibrary_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = new ShapeLibraryForm(Nest.Drawings.Select(d => d.Name));
|
||||||
|
form.ShowDialog();
|
||||||
|
|
||||||
|
var drawings = form.GetDrawings();
|
||||||
|
if (drawings.Count == 0) return;
|
||||||
|
|
||||||
|
drawings.ForEach(d => Nest.Drawings.Add(d));
|
||||||
|
UpdateDrawingList();
|
||||||
|
}
|
||||||
|
|
||||||
private void EditDrawingsInConverter_Click(object sender, EventArgs e)
|
private void EditDrawingsInConverter_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Nest.Drawings.Count == 0)
|
if (Nest.Drawings.Count == 0)
|
||||||
|
|||||||
@@ -837,7 +837,7 @@ namespace OpenNest.Forms
|
|||||||
{
|
{
|
||||||
if (activeForm == null) return;
|
if (activeForm == null) return;
|
||||||
|
|
||||||
var form = new ShapeLibraryForm();
|
var form = new ShapeLibraryForm(activeForm.Nest.Drawings.Select(d => d.Name));
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
|
|
||||||
var drawings = form.GetDrawings();
|
var drawings = form.GetDrawings();
|
||||||
|
|||||||
@@ -21,12 +21,17 @@ namespace OpenNest.Forms
|
|||||||
private readonly List<Drawing> addedDrawings = new List<Drawing>();
|
private readonly List<Drawing> addedDrawings = new List<Drawing>();
|
||||||
private readonly List<ShapeEntry> shapeEntries = new List<ShapeEntry>();
|
private readonly List<ShapeEntry> shapeEntries = new List<ShapeEntry>();
|
||||||
private readonly List<ParameterBinding> parameterBindings = new List<ParameterBinding>();
|
private readonly List<ParameterBinding> parameterBindings = new List<ParameterBinding>();
|
||||||
|
private readonly HashSet<string> existingNames;
|
||||||
|
|
||||||
private ShapeEntry selectedEntry;
|
private ShapeEntry selectedEntry;
|
||||||
private bool suppressPreview;
|
private bool suppressPreview;
|
||||||
|
|
||||||
public ShapeLibraryForm()
|
public ShapeLibraryForm(IEnumerable<string> existingDrawingNames = null)
|
||||||
{
|
{
|
||||||
|
existingNames = existingDrawingNames != null
|
||||||
|
? new HashSet<string>(existingDrawingNames, StringComparer.OrdinalIgnoreCase)
|
||||||
|
: new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DiscoverShapes();
|
DiscoverShapes();
|
||||||
PopulateShapeList();
|
PopulateShapeList();
|
||||||
@@ -259,6 +264,7 @@ namespace OpenNest.Forms
|
|||||||
if (shape == null) return;
|
if (shape == null) return;
|
||||||
|
|
||||||
var drawing = shape.GetDrawing();
|
var drawing = shape.GetDrawing();
|
||||||
|
nameTextBox.Text = shape.GenerateName();
|
||||||
previewBox.ShowDrawing(drawing);
|
previewBox.ShowDrawing(drawing);
|
||||||
|
|
||||||
if (drawing?.Program != null)
|
if (drawing?.Program != null)
|
||||||
@@ -405,10 +411,12 @@ namespace OpenNest.Forms
|
|||||||
if (shape == null) return;
|
if (shape == null) return;
|
||||||
|
|
||||||
var drawing = shape.GetDrawing();
|
var drawing = shape.GetDrawing();
|
||||||
|
drawing.Name = GetUniqueName(drawing.Name);
|
||||||
drawing.Color = Drawing.GetNextColor();
|
drawing.Color = Drawing.GetNextColor();
|
||||||
drawing.Quantity.Required = (int)quantityUpDown.Value;
|
drawing.Quantity.Required = (int)quantityUpDown.Value;
|
||||||
|
|
||||||
addedDrawings.Add(drawing);
|
addedDrawings.Add(drawing);
|
||||||
|
existingNames.Add(drawing.Name);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
addButton.Text = $"Added ({addedDrawings.Count})";
|
addButton.Text = $"Added ({addedDrawings.Count})";
|
||||||
@@ -423,6 +431,19 @@ namespace OpenNest.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetUniqueName(string baseName)
|
||||||
|
{
|
||||||
|
if (!existingNames.Contains(baseName))
|
||||||
|
return baseName;
|
||||||
|
|
||||||
|
for (var i = 2; ; i++)
|
||||||
|
{
|
||||||
|
var candidate = $"{baseName} ({i})";
|
||||||
|
if (!existingNames.Contains(candidate))
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string FriendlyName(string name)
|
private static string FriendlyName(string name)
|
||||||
{
|
{
|
||||||
if (name.EndsWith("Shape"))
|
if (name.EndsWith("Shape"))
|
||||||
|
|||||||
+10
@@ -250,6 +250,16 @@ namespace OpenNest.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap shapes {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("shapes", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -187,4 +187,7 @@
|
|||||||
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="shapes" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\shapes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Reference in New Issue
Block a user