mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-04 08:01:35 -05:00
Priority worked like a rank (lower first) with a default of 0, and the Edit Drawing form stopped at 0, so moving one part ahead of the rest meant renumbering every other drawing. Higher-first lets a user raise a single part to 1 and leave everything else at the default. Every engine, filler and candidate comparer now serves the highest tier first. Stored values keep their order: - .nest files add `nestPriority` and keep writing the negated value under `priority`, so older readers nest in the same order; files without `nestPriority` are negated on read. Drawing packages strip both, so package hashes are unchanged. - Library settings send both keys the same way for older clients. - Server schema v18 negates stored drawing priorities (an older server refuses the upgraded database). - Job documents move to version 2; version 1 jobs are converted, and an older worker refuses version 2 instead of reversing the order. The Edit Drawing form now accepts negative priorities and says higher numbers nest first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.8 KiB
C#
46 lines
1.8 KiB
C#
using System;
|
|
|
|
namespace OpenNest.Engine.Jobs;
|
|
|
|
/// <summary>An immutable requirement, independent of drawing names, UI state, and drawing quantity counters.</summary>
|
|
public sealed class NestJobPart
|
|
{
|
|
/// <summary>Creates an immutable part requirement.</summary>
|
|
/// <param name="id">Unique requirement ID.</param>
|
|
/// <param name="geometry">Snapshot of the part geometry.</param>
|
|
/// <param name="quantity">Positive number requested.</param>
|
|
/// <param name="priority">Placement precedence: higher numbers are placed first and win scarce
|
|
/// stock. Zero is the default; negative numbers place after it. Equal priorities are peers.</param>
|
|
/// <param name="rotation">Allowed rotations, or null for automatic rotation.</param>
|
|
public NestJobPart(
|
|
string id,
|
|
PartGeometrySnapshot geometry,
|
|
int quantity,
|
|
int priority = 0,
|
|
RotationPolicy rotation = null
|
|
)
|
|
{
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(id);
|
|
ArgumentNullException.ThrowIfNull(geometry);
|
|
if (quantity <= 0)
|
|
throw new ArgumentOutOfRangeException(nameof(quantity));
|
|
Id = id;
|
|
Geometry = geometry;
|
|
Quantity = quantity;
|
|
Priority = priority;
|
|
Rotation = rotation ?? RotationPolicy.Automatic;
|
|
}
|
|
|
|
public string Id { get; }
|
|
public PartGeometrySnapshot Geometry { get; }
|
|
|
|
/// <summary>Positive number requested; never decremented by placement code.</summary>
|
|
public int Quantity { get; }
|
|
/// <summary>
|
|
/// Placement precedence: a higher number is placed first and wins scarce stock.
|
|
/// Zero is the default; negative numbers place after it. Parts with equal priority are peers.
|
|
/// </summary>
|
|
public int Priority { get; }
|
|
public RotationPolicy Rotation { get; }
|
|
}
|