mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 09:15:06 -05:00
Port the WinForms GraphicsHelper program walker to a toolkit-neutral figure list (move/line/arc) with its layer routing: cuts without tabs, leads, etches, and a material fill without break cuts whose tab-gapped pieces are bridged. Suppressed moves are skipped and marks never bound the fill. PartDisplayGeometry picks the fill as LayoutPart does (common-line members, break cuts, open cuts) and keeps display-only entities; PartLabels ports the label points. ViewTransform carries DrawControl's world/screen mapping and zoom rules. PlateOverlays computes what the view draws around parts (sheet, edge spacing, irregular usable area, clamps, cut-off strokes, rapids, pierce points, cut direction, offset outline, support) through the existing Core code. PlateViewOptions reads and writes the View toggles under the WinForms PlateViewDrawRapid/PlateViewDrawBounds names. WinForms still draws with GraphicsHelper; nothing there changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.3 KiB
C#
56 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace OpenNest.Desktop.Rendering;
|
|
|
|
/// <summary>
|
|
/// One plate view's View menu toggles, with the WinForms defaults: rapids off, bounds on, and
|
|
/// pierce points, offset outline, cut direction and support off. Only rapids and bounds are kept
|
|
/// between sessions, under the WinForms names <c>PlateViewDrawRapid</c> and <c>PlateViewDrawBounds</c>:
|
|
/// each nest view reads them when it opens and writes its own when it closes.
|
|
/// </summary>
|
|
public sealed class PlateViewOptions
|
|
{
|
|
public const string DrawRapidName = "PlateViewDrawRapid";
|
|
public const string DrawBoundsName = "PlateViewDrawBounds";
|
|
|
|
/// <summary>The origin axes through world (0, 0).</summary>
|
|
public bool DrawOrigin { get; set; } = true;
|
|
|
|
public bool DrawRapid { get; set; }
|
|
|
|
public bool DrawPiercePoints { get; set; }
|
|
|
|
/// <summary>The box around the selected parts.</summary>
|
|
public bool DrawBounds { get; set; } = true;
|
|
|
|
/// <summary>Each part's outline offset by the plate's part spacing.</summary>
|
|
public bool DrawOffset { get; set; }
|
|
|
|
public bool DrawCutDirection { get; set; }
|
|
|
|
/// <summary>The support bed, each part's contacts and center of gravity.</summary>
|
|
public bool DrawSupport { get; set; }
|
|
|
|
/// <summary>The chord tolerance of the offset outline.</summary>
|
|
public double OffsetTolerance { get; set; } = 0.001;
|
|
|
|
/// <summary>A view's toggles with the saved rapids and bounds; missing or unreadable values are defaults.</summary>
|
|
public static PlateViewOptions Read(IReadOnlyDictionary<string, string> settings)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
var options = new PlateViewOptions();
|
|
options.DrawRapid = UserSettingText.ReadBool(settings, DrawRapidName, options.DrawRapid);
|
|
options.DrawBounds = UserSettingText.ReadBool(settings, DrawBoundsName, options.DrawBounds);
|
|
return options;
|
|
}
|
|
|
|
/// <summary>Stores the rapids and bounds toggles in the WinForms format.</summary>
|
|
public void WriteTo(IDictionary<string, string> settings)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
settings[DrawRapidName] = UserSettingText.Format(DrawRapid);
|
|
settings[DrawBoundsName] = UserSettingText.Format(DrawBounds);
|
|
}
|
|
}
|