feat(core): store Source.Angle; recompute when Program changes
This commit is contained in:
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user