From 8e49b4431e48b776eef5df465f5bb00f46e9b707 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 1 Mar 2025 09:50:36 +0100 Subject: display stop commands in simulator and print preview (#3545) --- lib/stitch_plan/color_block.py | 8 ++++++++ lib/stitch_plan/stitch_plan.py | 2 +- print/templates/color_swatch.html | 2 +- print/templates/operator_detailedview.html | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/stitch_plan/color_block.py b/lib/stitch_plan/color_block.py index 3cec826d..75b72a3b 100644 --- a/lib/stitch_plan/color_block.py +++ b/lib/stitch_plan/color_block.py @@ -73,6 +73,12 @@ class ColorBlock(object): previous_stitch = stitch return length + @property + def num_stops(self): + """Number of stops in this color block.""" + + return sum(1 for stitch in self if stitch.stop) + @property def num_trims(self): """Number of trims in this color block.""" @@ -87,6 +93,8 @@ class ColorBlock(object): @property def stop_after(self): + # TODO: we do not add the stop command necessarily as the last stitch + # also we do not necessarily start a new color block when a stop command appears if self.last_stitch is not None: return self.last_stitch.stop else: diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index f6e3f0de..8439de18 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -172,7 +172,7 @@ class StitchPlan(object): @property def num_stops(self): - return sum(1 for block in self if block.stop_after) + return sum(block.num_stops for block in self) @property def num_trims(self): diff --git a/print/templates/color_swatch.html b/print/templates/color_swatch.html index fe64c855..9ff31642 100644 --- a/print/templates/color_swatch.html +++ b/print/templates/color_swatch.html @@ -21,7 +21,7 @@ {# We don't want to see stops and trims if we have more than 13 colorSwatches to show #} {% if color_blocks|length < 13 %} {{ _('# trims') }}: {{ color_block.num_trims }} - {{ _('stop after?') }}: {{ _("yes") if color_block.stop_after else _("no") }} + {{ _('# stops') }}: {{ color_block.num_stops }} {% endif %} diff --git a/print/templates/operator_detailedview.html b/print/templates/operator_detailedview.html index b16691a0..aaa5cd2b 100644 --- a/print/templates/operator_detailedview.html +++ b/print/templates/operator_detailedview.html @@ -65,7 +65,7 @@

{{ _('trims') }}: {{ color_block.num_trims }} - {{ _('stop after?') }}: {{ _("yes") if color_block.stop_after else _("no") }} + {{ _('stops') }}: {{ color_block.num_stops }}

-- cgit v1.2.3