fix(ui): dash a cut-off's head-locked overcut past the sheet edge

The cut-off line renderer paired codes as rapid/cut at even indices. A
head-locked far-edge segment carries lock and unlock comments between its
cuts, so its overcut was never dashed and later segments could fall out of
step. Past the sheet only the dark part outline showed, which read as the
line having lost its orange-red color. Walk the motions instead and draw
each cut from the previous point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-03 10:03:13 -05:00
1 parent d133f6879b
commit 2721375e8b
2 files changed
+39 -8

No files matched your search

@@ -77,6 +77,35 @@ public class CutOffDisplayTests
}
}, TimeSpan.FromMinutes(1), "Cut-off display test timed out.");
[Fact]
public void HeadLockedOvercutPastTheSheetIsDashedOrange() => StaTestThread.Run(() =>
{
// Quadrant 4's far edge for a vertical cut-off is the bottom (graph row 100); a 10
// overcut runs on to row 110, past the sheet.
var (view, cutoff) = BuildPlateWithCutOff();
using (view)
using (var image = new Bitmap(100, 130))
using (var g = Graphics.FromImage(image))
{
cutoff.HeadLockOvercut = 10;
view.Plate.RegenerateCutOffs(new CutOffSettings());
g.Clear(Color.White);
view.Renderer.DrawCutOffs(g);
var overcut = 0;
for (var y = 102; y <= 109; y++)
for (var x = 48; x <= 52; x++)
{
var c = image.GetPixel(x, y);
if (c.R >= 200 && c.G <= 120 && c.B <= 80)
overcut++;
}
Assert.True(overcut >= 4, $"Expected the orange dash on the overcut, found {overcut} pixels.");
var (orange, _, _, _) = CountLinePixels(image);
Assert.True(orange >= 10, $"Expected the orange dash on the sheet, found {orange} pixels.");
}
}, TimeSpan.FromMinutes(1), "Head-locked cut-off display test timed out.");
[Fact]
public void SelectedCutOffKeepsSolidBlueHighlight() => StaTestThread.Run(() =>
{
+10 -8
View File
@@ -382,17 +382,19 @@ namespace OpenNest.Controls
}
}
// Walk the motions rather than pairing rapid/cut codes: a head-locked far-edge segment
// carries lock comments between its cuts, and its overcut past the sheet must dash too.
private void DrawCutOffSegments(Graphics g, Program program, Vector offset, Pen pen)
{
for (var i = 0; i < program.Codes.Count - 1; i += 2)
Vector? position = null;
foreach (var code in program.Codes)
{
if (
program.Codes[i] is RapidMove rapid
&& program.Codes[i + 1] is LinearMove linear
)
{
DrawLine(g, rapid.EndPoint + offset, linear.EndPoint + offset, pen);
}
if (code is not Motion motion)
continue;
var end = motion.EndPoint + offset;
if (motion is LinearMove && position is { } start)
DrawLine(g, start, end, pen);
position = end;
}
}