using System.Text.Json;
using System.Text.Json.Serialization;
using OpenNest.CNC.CuttingStrategy;
namespace OpenNest.Data;
///
/// 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
/// ( null) takes this PC's last cutting settings.
///
public class ThicknessCuttingConfig
{
public bool RoundLeadInAngles { get; set; }
public double LeadInAngleIncrement { get; set; } = 5;
/// Whether parts are tabbed at all: by the support grid, or by size with .
public bool Tabs { get; set; }
/// With , ignore the support grid and tab parts whose narrow side is in the size range.
public bool TabBySize { get; set; }
public double TabSize { get; set; } = 0.03;
public double TabSizeMinWidth { get; set; }
/// The widest part tabbed by size; 0 tabs nothing by size.
public double TabSizeMaxWidth { get; set; }
/// Whether cutouts the support grid can't hold level have their slugs sliced; written only when on.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool SliceTippingSlugs { get; set; }
/// What Plan Cutting etches in each part's label box; written only when not off.
[JsonConverter(typeof(JsonStringEnumConverter))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public PartLabelMode LabelMode { get; set; }
///
/// 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 .
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public bool EtchPartLabels { get; set; }
///
/// , 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.
///
[JsonIgnore]
public PartLabelMode ResolvedLabelMode =>
LabelMode != PartLabelMode.Off && System.Enum.IsDefined(LabelMode) ? LabelMode
: EtchPartLabels ? PartLabelMode.PartNumberAndBendGroups
: PartLabelMode.Off;
public double PierceClearance { get; set; } = 0.0625;
/// The pierce zone's diameter; 0 turns it off.
public double PierceDiameter { get; set; }
/// Fields a newer OpenNest wrote, kept so saving here does not drop them.
[JsonExtensionData]
public Dictionary? Unknown { get; set; }
}