fix: draw direction arrows after origin transform so they track pan correctly

This commit is contained in:
2026-03-31 22:30:57 -04:00
parent d3a439181c
commit aa156fff57
2 changed files with 9 additions and 4 deletions

View File

@@ -152,8 +152,12 @@ namespace OpenNest.Controls
foreach (var entity in ((Shape)offsetShape.OffsetEntity(0.25, OffsetSide.Left)).Entities)
DrawEntity(e.Graphics, entity, Pens.RoyalBlue);
#endif
PaintOverlay?.Invoke(e.Graphics);
}
public Action<Graphics> PaintOverlay { get; set; }
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);

View File

@@ -26,7 +26,7 @@ namespace OpenNest.Controls
reverseButton.Click += OnReverseClicked;
menuReverse.Click += OnReverseClicked;
applyButton.Click += OnApplyClicked;
preview.Paint += OnPreviewPaint;
preview.PaintOverlay = OnPreviewPaintOverlay;
}
public Program Program { get; private set; }
@@ -258,13 +258,15 @@ namespace OpenNest.Controls
ProgramChanged?.Invoke(this, EventArgs.Empty);
}
private void OnPreviewPaint(object sender, PaintEventArgs e)
private void OnPreviewPaintOverlay(Graphics g)
{
if (contours.Count == 0) return;
var spacing = preview.LengthGuiToWorld(60f);
var arrowSize = 5f;
using var pen = new Pen(Color.FromArgb(60, 60, 60), 1.5f);
for (var i = 0; i < contours.Count; i++)
{
if (!contourList.SelectedIndices.Contains(i)) continue;
@@ -273,9 +275,8 @@ namespace OpenNest.Controls
var pgm = ConvertGeometry.ToProgram(contour.Shape);
if (pgm == null) continue;
using var pen = new Pen(Color.FromArgb(60, 60, 60), 1.5f);
var pos = new Vector();
CutDirectionArrows.DrawProgram(e.Graphics, preview, pgm, ref pos, pen, spacing, arrowSize);
CutDirectionArrows.DrawProgram(g, preview, pgm, ref pos, pen, spacing, arrowSize);
}
}