feat: add Shape Library UI with configurable shapes and flange presets

Add a Shape Library dialog (Nest > Shape Library) for creating drawings
from built-in parametric shapes. Supports configuration presets loaded
from JSON files — ships with 136 standard pipe flanges. Parameters use
TextBox inputs with architectural unit parsing (feet/inches, fractions).

- ShapeLibraryForm with split layout: shape list, preview, parameters
- ShapePreviewControl for auto-zoom rendering with info overlay
- ArchUnits utility for parsing architectural measurements
- SetPreviewDefaults() on all ShapeDefinition subclasses
- Convention-based config discovery (Configurations/{ShapeName}.json)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 07:44:03 -04:00
parent 3dca25c601
commit b2a723ca60
21 changed files with 2138 additions and 2 deletions

View File

@@ -7,6 +7,11 @@ namespace OpenNest.Shapes
{
public double Diameter { get; set; }
public override void SetPreviewDefaults()
{
Diameter = 8;
}
public override Drawing GetDrawing()
{
var entities = new List<Entity>

View File

@@ -11,6 +11,15 @@ namespace OpenNest.Shapes
public double HolePatternDiameter { get; set; }
public int HoleCount { get; set; }
public override void SetPreviewDefaults()
{
NominalPipeSize = 2;
OD = 7.5;
HoleDiameter = 0.875;
HolePatternDiameter = 5.5;
HoleCount = 8;
}
public override Drawing GetDrawing()
{
var entities = new List<Entity>();

View File

@@ -8,6 +8,12 @@ namespace OpenNest.Shapes
public double Base { get; set; }
public double Height { get; set; }
public override void SetPreviewDefaults()
{
Base = 8;
Height = 10;
}
public override Drawing GetDrawing()
{
var midX = Base / 2.0;

View File

@@ -10,6 +10,14 @@ namespace OpenNest.Shapes
public double LegWidth { get; set; }
public double LegHeight { get; set; }
public override void SetPreviewDefaults()
{
Width = 8;
Height = 10;
LegWidth = 3;
LegHeight = 3;
}
public override Drawing GetDrawing()
{
var lw = LegWidth > 0 ? LegWidth : Width / 2.0;

View File

@@ -7,6 +7,11 @@ namespace OpenNest.Shapes
{
public double Width { get; set; }
public override void SetPreviewDefaults()
{
Width = 8;
}
public override Drawing GetDrawing()
{
var center = Width / 2.0;

View File

@@ -8,6 +8,12 @@ namespace OpenNest.Shapes
public double Length { get; set; }
public double Width { get; set; }
public override void SetPreviewDefaults()
{
Length = 12;
Width = 6;
}
public override Drawing GetDrawing()
{
var entities = new List<Entity>

View File

@@ -8,6 +8,12 @@ namespace OpenNest.Shapes
public double Width { get; set; }
public double Height { get; set; }
public override void SetPreviewDefaults()
{
Width = 8;
Height = 6;
}
public override Drawing GetDrawing()
{
var entities = new List<Entity>

View File

@@ -8,6 +8,12 @@ namespace OpenNest.Shapes
public double OuterDiameter { get; set; }
public double InnerDiameter { get; set; }
public override void SetPreviewDefaults()
{
OuterDiameter = 10;
InnerDiameter = 6;
}
public override Drawing GetDrawing()
{
var entities = new List<Entity>

View File

@@ -10,6 +10,13 @@ namespace OpenNest.Shapes
public double Width { get; set; }
public double Radius { get; set; }
public override void SetPreviewDefaults()
{
Length = 12;
Width = 6;
Radius = 1;
}
public override Drawing GetDrawing()
{
var r = Radius;

View File

@@ -26,6 +26,8 @@ namespace OpenNest.Shapes
public abstract Drawing GetDrawing();
public virtual void SetPreviewDefaults() { }
public static List<T> LoadFromJson<T>(string path) where T : ShapeDefinition
{
var json = File.ReadAllText(path);

View File

@@ -10,6 +10,14 @@ namespace OpenNest.Shapes
public double StemWidth { get; set; }
public double BarHeight { get; set; }
public override void SetPreviewDefaults()
{
Width = 10;
Height = 8;
StemWidth = 3;
BarHeight = 3;
}
public override Drawing GetDrawing()
{
var sw = StemWidth > 0 ? StemWidth : Width / 3.0;

View File

@@ -9,6 +9,13 @@ namespace OpenNest.Shapes
public double BottomWidth { get; set; }
public double Height { get; set; }
public override void SetPreviewDefaults()
{
TopWidth = 6;
BottomWidth = 10;
Height = 6;
}
public override Drawing GetDrawing()
{
var offset = (BottomWidth - TopWidth) / 2.0;