Files
OpenNest/OpenNest.Data/ThicknessCuttingConfig.cs
T
ajandClaude Opus 5.5 3108fdb64a fix(labels): etch labels in place on imported drawings and keep them out of drawings
Imported drawings are incremental programs, but PartLabels.AddTo appended
absolute points, so each stroke was read as a step from the last and the label
ran far off the sheet. It now writes steps from where the program stops
(ConvertMode.EndPosition).

On load, DrawingMarkRecovery took the etched label from applied part programs
back into the drawing as a lost mark, so it was etched again by every later
plan, labels off included. Drawings with a label box are now skipped.

Also load a labelMode number that names no mode as if it were absent, and show
such a mode as Off in the Cutting Parameters dropdown instead of throwing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:56:57 -05:00

68 lines
2.9 KiB
C#

using System.Text.Json;
using System.Text.Json.Serialization;
using OpenNest.CNC.CuttingStrategy;
namespace OpenNest.Data;
/// <summary>
/// The Cutting Parameters dialog's settings beyond leads for one thickness: lead-in angle
/// rounding, tabs and pierce. Lengths are in the machine's units. A thickness without them
/// (<see cref="ThicknessConfig.Cutting"/> null) takes this PC's last cutting settings.
/// </summary>
public class ThicknessCuttingConfig
{
public bool RoundLeadInAngles { get; set; }
public double LeadInAngleIncrement { get; set; } = 5;
/// <summary>Whether parts are tabbed at all: by the support grid, or by size with <see cref="TabBySize"/>.</summary>
public bool Tabs { get; set; }
/// <summary>With <see cref="Tabs"/>, ignore the support grid and tab parts whose narrow side is in the size range.</summary>
public bool TabBySize { get; set; }
public double TabSize { get; set; } = 0.03;
/// <summary>The longest part its tab alone holds; 0 turns the rule off.</summary>
public double TabHeldMaxLength { get; set; } = 6;
public double TabSizeMinWidth { get; set; }
/// <summary>The widest part tabbed by size; 0 tabs nothing by size.</summary>
public double TabSizeMaxWidth { get; set; }
/// <summary>Whether cutouts the support grid can't hold level have their slugs sliced; written only when on.</summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool SliceTippingSlugs { get; set; }
/// <summary>What Plan Cutting etches in each part's label box; written only when not off.</summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public PartLabelMode LabelMode { get; set; }
/// <summary>
/// Read only: the old on/off part label option, which meant the number with its bend
/// groups. Never written; files saved with it load as <see cref="PartLabelMode.PartNumberAndBendGroups"/>.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool EtchPartLabels { get; set; }
/// <summary>
/// <see cref="LabelMode"/>, or the full label when only the old on/off option is set. A number
/// that names no mode (the reader accepts numbers) loads as the old option, so as Off without it.
/// </summary>
[JsonIgnore]
public PartLabelMode ResolvedLabelMode =>
LabelMode != PartLabelMode.Off && System.Enum.IsDefined(LabelMode) ? LabelMode
: EtchPartLabels ? PartLabelMode.PartNumberAndBendGroups
: PartLabelMode.Off;
public double PierceClearance { get; set; } = 0.0625;
/// <summary>The pierce zone's diameter; 0 turns it off.</summary>
public double PierceDiameter { get; set; }
/// <summary>Fields a newer OpenNest wrote, kept so saving here does not drop them.</summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? Unknown { get; set; }
}