feat(core): store Source.Angle; recompute when Program changes

This commit is contained in:
2026-04-20 09:13:37 -04:00
parent 402af91af5
commit 14b7c1cf32
2 changed files with 78 additions and 1 deletions
+21 -1
View File
@@ -54,9 +54,9 @@ namespace OpenNest
Id = Interlocked.Increment(ref nextId);
Name = name;
Material = new Material();
Program = pgm;
Constraints = new NestConstraints();
Source = new SourceInfo();
Program = pgm;
}
public int Id { get; }
@@ -78,9 +78,29 @@ namespace OpenNest
{
program = value;
UpdateArea();
RecomputeCanonicalAngle();
}
}
/// <summary>
/// Recomputes and stores the canonical angle from the current Program.
/// Callers that mutate Program in place (rather than reassigning it) must invoke this explicitly.
/// Cut-off drawings are left with Angle=0.
/// </summary>
public void RecomputeCanonicalAngle()
{
if (Source == null)
Source = new SourceInfo();
if (program == null || IsCutOff)
{
Source.Angle = 0.0;
return;
}
Source.Angle = CanonicalAngle.Compute(this);
}
public Color Color { get; set; }
public bool IsCutOff { get; set; }