feat(ui): route progress to stationary/active buckets in MainForm

Replace SetTemporaryParts/ClearTemporaryParts/AcceptTemporaryParts in all
three progress callbacks (RunAutoNest, FillPlate, FillArea) with the new
two-bucket API: SetStationaryParts for IsOverallBest updates,
SetActiveParts for transient updates, AcceptPreviewParts(parts) and
ClearPreviewParts for completion. Also removes the now-redundant
highWaterMark guards from FillPlate_Click and FillArea_Click.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 22:16:55 -04:00
parent 4fc8f1f6cf
commit a9a9dc8a0a

View File

@@ -827,7 +827,12 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p => var progress = new Progress<NestProgress>(p =>
{ {
progressForm.UpdateProgress(p); progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea; activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
}); });
@@ -863,7 +868,7 @@ namespace OpenNest.Forms
var nestParts = await Task.Run(() => var nestParts = await Task.Run(() =>
engine.Nest(remaining, progress, token)); engine.Nest(remaining, progress, token));
activeForm.PlateView.ClearTemporaryParts(); activeForm.PlateView.ClearPreviewParts();
if (nestParts.Count > 0 && (!token.IsCancellationRequested || progressForm.Accepted)) if (nestParts.Count > 0 && (!token.IsCancellationRequested || progressForm.Accepted))
{ {
@@ -881,7 +886,7 @@ namespace OpenNest.Forms
} }
catch (Exception ex) catch (Exception ex)
{ {
activeForm.PlateView.ClearTemporaryParts(); activeForm.PlateView.ClearPreviewParts();
MessageBox.Show($"Nesting error: {ex.Message}", "Error", MessageBox.Show($"Nesting error: {ex.Message}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
@@ -964,7 +969,12 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p => var progress = new Progress<NestProgress>(p =>
{ {
progressForm.UpdateProgress(p); progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea; activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
}); });
@@ -981,15 +991,15 @@ namespace OpenNest.Forms
plate.WorkArea(), progress, token)); plate.WorkArea(), progress, token));
if (parts.Count > 0) if (parts.Count > 0)
activeForm.PlateView.AcceptTemporaryParts(); activeForm.PlateView.AcceptPreviewParts(parts);
else else
activeForm.PlateView.ClearTemporaryParts(); activeForm.PlateView.ClearPreviewParts();
progressForm.ShowCompleted(); progressForm.ShowCompleted();
} }
catch (Exception ex) catch (Exception ex)
{ {
activeForm.PlateView.ClearTemporaryParts(); activeForm.PlateView.ClearPreviewParts();
MessageBox.Show($"Nesting error: {ex.Message}", "Error", MessageBox.Show($"Nesting error: {ex.Message}", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
@@ -1026,16 +1036,21 @@ namespace OpenNest.Forms
var progress = new Progress<NestProgress>(p => var progress = new Progress<NestProgress>(p =>
{ {
progressForm.UpdateProgress(p); progressForm.UpdateProgress(p);
activeForm.PlateView.SetTemporaryParts(p.BestParts);
if (p.IsOverallBest)
activeForm.PlateView.SetStationaryParts(p.BestParts);
else
activeForm.PlateView.SetActiveParts(p.BestParts);
activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea; activeForm.PlateView.ActiveWorkArea = p.ActiveWorkArea;
}); });
Action<List<Part>> onComplete = parts => Action<List<Part>> onComplete = parts =>
{ {
if (parts != null && parts.Count > 0) if (parts != null && parts.Count > 0)
activeForm.PlateView.AcceptTemporaryParts(); activeForm.PlateView.AcceptPreviewParts(parts);
else else
activeForm.PlateView.ClearTemporaryParts(); activeForm.PlateView.ClearPreviewParts();
activeForm.PlateView.ActiveWorkArea = null; activeForm.PlateView.ActiveWorkArea = null;
progressForm.Close(); progressForm.Close();