mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 06:41:42 -05:00
fix(avalonia): refresh the status bar utilization when the plate is resized
Resize to Fit and Edit Plate change the plate's area without changing its part count, so the cached utilization text went stale. Also correct the comment on why a failed spacing search records nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f32d04cff
commit
c6b42b448c
2 files changed
+9
-5
No files matched your search
@@ -167,7 +167,8 @@ namespace OpenNest.Avalonia
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// The open step rolls back whatever the failed run changed.
|
||||
// The searches move the live parts only as their last step, so a failed run leaves
|
||||
// them as they were and its unmarked step records nothing.
|
||||
ShowNotice($"{title} failed: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -35,8 +35,9 @@ namespace OpenNest.Avalonia
|
||||
private readonly ConditionalWeakTable<PlateCanvas, StrongBox<Vector>> locations = new();
|
||||
private bool locationFollowsMouse = true;
|
||||
private bool loadingEngines;
|
||||
// Utilization changes only when parts are added or removed: computed once per plate and count.
|
||||
private (Plate Plate, int Parts, string Text) utilization;
|
||||
// Utilization changes only when parts are added or removed or the plate's area changes
|
||||
// (Resize to Fit, Edit Plate): computed once per plate, count and area.
|
||||
private (Plate Plate, int Parts, double Area, string Text) utilization;
|
||||
|
||||
private void InitializeStatusBar()
|
||||
{
|
||||
@@ -182,8 +183,10 @@ namespace OpenNest.Avalonia
|
||||
{
|
||||
if (plate == null)
|
||||
return "";
|
||||
if (!ReferenceEquals(utilization.Plate, plate) || utilization.Parts != plate.Parts.Count)
|
||||
utilization = (plate, plate.Parts.Count, MainStatusText.Utilization(plate.Utilization()));
|
||||
var area = plate.Area();
|
||||
if (!ReferenceEquals(utilization.Plate, plate) || utilization.Parts != plate.Parts.Count
|
||||
|| utilization.Area != area)
|
||||
utilization = (plate, plate.Parts.Count, area, MainStatusText.Utilization(plate.Utilization()));
|
||||
return utilization.Text;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user