mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-09 03:25:44 -05:00
fix(ui): compute polylabel once from unrotated drawing
Compute the label point from the base drawing's unrotated program and rotate the cached point instead of recomputing on each rotation. Prevents label jitter caused by arc discretization differences. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
79a3410bb9
commit
5553fe6386
1 file changed
+6
-14
+6
-14
@@ -46,16 +46,7 @@ namespace OpenNest
|
||||
Color = part.BaseDrawing.Color;
|
||||
}
|
||||
|
||||
private bool _isDirty;
|
||||
internal bool IsDirty
|
||||
{
|
||||
get => _isDirty;
|
||||
set
|
||||
{
|
||||
_isDirty = value;
|
||||
if (value) _labelPoint = null;
|
||||
}
|
||||
}
|
||||
internal bool IsDirty { get; set; }
|
||||
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
@@ -119,14 +110,14 @@ namespace OpenNest
|
||||
|
||||
private Vector ComputeLabelPoint()
|
||||
{
|
||||
var entities = ConvertProgram.ToGeometry(BasePart.Program);
|
||||
var entities = ConvertProgram.ToGeometry(BasePart.BaseDrawing.Program);
|
||||
var nonRapid = entities.Where(e => e.Layer != SpecialLayers.Rapid).ToList();
|
||||
|
||||
var shapes = ShapeBuilder.GetShapes(nonRapid);
|
||||
|
||||
if (shapes.Count == 0)
|
||||
{
|
||||
var bbox = BasePart.Program.BoundingBox();
|
||||
var bbox = BasePart.BaseDrawing.Program.BoundingBox();
|
||||
return new Vector(bbox.Location.X + bbox.Width / 2, bbox.Location.Y + bbox.Length / 2);
|
||||
}
|
||||
|
||||
@@ -151,9 +142,10 @@ namespace OpenNest
|
||||
Path.Transform(plateView.Matrix);
|
||||
|
||||
_labelPoint ??= ComputeLabelPoint();
|
||||
var rotatedLabel = _labelPoint.Value.Rotate(BasePart.Rotation);
|
||||
var labelPt = new PointF(
|
||||
(float)(_labelPoint.Value.X + BasePart.Location.X),
|
||||
(float)(_labelPoint.Value.Y + BasePart.Location.Y));
|
||||
(float)(rotatedLabel.X + BasePart.Location.X),
|
||||
(float)(rotatedLabel.Y + BasePart.Location.Y));
|
||||
var pts = new[] { labelPt };
|
||||
plateView.Matrix.TransformPoints(pts);
|
||||
_labelScreenPoint = pts[0];
|
||||
|
||||
Reference in new issue
Block a user