diff --git a/embroider_print.py b/embroider_print.py index abf7f91ba..68fafe64b 100644 --- a/embroider_print.py +++ b/embroider_print.py @@ -195,12 +195,22 @@ class Print(InkstitchExtension): view = {'overview': True, 'detailedview': True}, logo = {'src' : '', 'title' : 'LOGO'}, date = date.today(), - client = "The name of the long client name thing", - job = {'title' : 'TITLE OF THE JOB LONG NAME THING', 'totalcolors' : '000', 'totalstops' : '000', 'totaltrims' : '000', 'size' : '0000 x 0000', 'stitchcount' : '000 000 000', 'totalthread' : '000 000 000', 'estimatedtime' : '00h00 @ 000mm/s'}, + client = "", + job = { + 'title': 'Ink/Stitch Design', + 'num_colors': stitch_plan.num_colors, + 'num_color_blocks': len(stitch_plan), + 'num_stops': stitch_plan.num_stops, + 'num_trims': stitch_plan.num_trims, + 'dimensions': stitch_plan.dimensions_mm, + 'num_stitches': stitch_plan.num_stitches, + 'estimated_time': "", # TODO + 'estimated_thread': "", # TODO + }, svg_overview = overview_svg, - svg_scale = '1/1', + svg_scale = '100%', color_blocks = stitch_plan.color_blocks, - num_pages = '2', + num_pages = len(stitch_plan.color_blocks) + 1, ) print_preview_server = PrintPreviewServer(html=html) diff --git a/inkstitch/stitch_plan/stitch_plan.py b/inkstitch/stitch_plan/stitch_plan.py index 4c94237a6..7c7282510 100644 --- a/inkstitch/stitch_plan/stitch_plan.py +++ b/inkstitch/stitch_plan/stitch_plan.py @@ -72,6 +72,32 @@ class StitchPlan(object): def __iter__(self): return iter(self.color_blocks) + def __len__(self): + return len(self.color_blocks) + + @property + def num_colors(self): + """Number of unique colors in the stitch plan.""" + return len({block.color for block in self}) + + @property + def num_stops(self): + return sum(block.num_stops for block in self) + + @property + def num_trims(self): + return sum(block.num_trims for block in self) + + @property + def num_stitches(self): + return sum(block.num_stitches for block in self) + + @property + def dimensions_mm(self): + # TODO: implement this. Should do a bounding box calculation and + # convert to millimeters. + return "" + class ColorBlock(object): """Holds a set of stitches, all with the same thread color.""" @@ -106,6 +132,26 @@ class ColorBlock(object): else: return None + @property + def num_stitches(self): + """Number of stitches in this color block.""" + return len(self.stitches) + + @property + def num_stops(self): + """Number of pauses in this color block.""" + + # Stops are encoded using two STOP stitches each. See the comment in + # stop.py for an explanation. + + return sum(1 for stitch in self if stitch.stop) / 2 + + @property + def num_trims(self): + """Number of trims in this color block.""" + + return sum(1 for stitch in self if stitch.trim) + def filter_duplicate_stitches(self): if not self.stitches: return diff --git a/inkstitch/threads/color.py b/inkstitch/threads/color.py index 9c147257e..c24aa9e0e 100644 --- a/inkstitch/threads/color.py +++ b/inkstitch/threads/color.py @@ -22,6 +22,9 @@ class ThreadColor(object): else: return self == ThreadColor(other) + def __hash__(self): + return hash(self.rgb) + def __ne__(self, other): return not(self == other) diff --git a/messages.po b/messages.po index 0b5d6a784..aef0494c3 100644 --- a/messages.po +++ b/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2018-03-21 20:10-0400\n" +"POT-Creation-Date: 2018-03-21 22:09-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -279,13 +279,13 @@ msgstr "" msgid "thread used" msgstr "" -msgid "nr. stitches" +msgid "# stitches" msgstr "" -msgid "nr. stops" +msgid "# stops" msgstr "" -msgid "nr. trims" +msgid "# trims" msgstr "" msgid "Page" @@ -325,7 +325,10 @@ msgstr "" msgid "Client Signature" msgstr "" -msgid "Total colors" +msgid "Unique Colors" +msgstr "" + +msgid "Color Blocks" msgstr "" msgid "Total nr stops" diff --git a/print/resources/barlow-bold.ttf b/print/resources/barlow-bold.ttf new file mode 100644 index 000000000..af2724042 Binary files /dev/null and b/print/resources/barlow-bold.ttf differ diff --git a/print/resources/barlow-condensed-bold.ttf b/print/resources/barlow-condensed-bold.ttf new file mode 100644 index 000000000..cb5e617c6 Binary files /dev/null and b/print/resources/barlow-condensed-bold.ttf differ diff --git a/print/resources/barlow-condensed-extra-bold.ttf b/print/resources/barlow-condensed-extra-bold.ttf new file mode 100644 index 000000000..d9352f09b Binary files /dev/null and b/print/resources/barlow-condensed-extra-bold.ttf differ diff --git a/print/resources/barlow-extra-bold.ttf b/print/resources/barlow-extra-bold.ttf new file mode 100644 index 000000000..45456d4b7 Binary files /dev/null and b/print/resources/barlow-extra-bold.ttf differ diff --git a/print/resources/style.css b/print/resources/style.css index 3ae7b9041..2a1f22935 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -13,6 +13,35 @@ } +@font-face { + font-family: 'Barlow'; + font-style: normal; + font-weight: 700; + src: url(barlow-bold.ttf) format('truetype'); +} + +@font-face { + font-family: 'Barlow'; + font-style: normal; + font-weight: 800; + src: url(barlow-extra-bold.ttf) format('truetype'); +} + + +@font-face { + font-family: 'Barlow Condensed'; + font-style: normal; + font-weight: 700; + src: url(barlow-condensed-bold.ttf) format('truetype'); +} + +@font-face { + font-family: 'Barlow Condensed'; + font-style: normal; + font-weight: 800; + src: url(barlow-condensed-extra-bold.ttf) format('truetype'); +} + @media screen { .page { margin-top: 20mm !important; @@ -313,7 +342,10 @@ footer { } .colorSwatch { - font-family: "Barlow Condensed", sans-serif; + font-family: "Barlow", sans-serif; + + /* white text on dark colors doesn't print well unless it's bold */ + font-weight: 700; font-size: 12pt; color: black; background: white; diff --git a/print/templates/color_swatch.html b/print/templates/color_swatch.html index 2c10c384e..1ee4aea13 100644 --- a/print/templates/color_swatch.html +++ b/print/templates/color_swatch.html @@ -3,7 +3,7 @@ - {{ _('Color') }}: {{ color_block.color.thred_name }} + {{ _('Color') }}: {{ color_block.color.thread_name }} {# We don't want to see rgb and thread_used if we have more than 7 colorSwatches to show #} {% if view == 'detailedview' or (view != 'detailedview' and color_blocks|length < 7) %} {{ _('rgb') }}: {{ color_block.color.rgb }} @@ -11,12 +11,12 @@ {% endif %} {# We don't want to see num_stitch if we have more than 49 colorSwatches to show #} {% if view == 'detailedview' or (view != 'detailedview' and color_blocks|length < 49) %} - {{ _('nr. stitches') }}: {{ color_block.num_stitches }} + {{ _('# stitches') }}: {{ color_block.num_stitches }} {% endif %} {# We don't want to see stops and trims if we have more than 13 colorSwatches to show #} {% if view == 'detailedview' or (view != 'detailedview' and color_blocks|length < 13) %} - {{ _('nr. stops') }}: {{ color_block.num_stops }} - {{ _('nr. trims') }}: {{ color_block.num_stops }} + {{ _('# stops') }}: {{ color_block.num_stops }} + {{ _('# trims') }}: {{ color_block.num_stops }} {% endif %} diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index cea93b28c..15668d118 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -2,18 +2,19 @@ {% include 'headline.html' %}
-

{{ _('Total colors') }}:{{ job.totalcolors }}

-

{{ _('Total nr stops') }}:{{ job.totalstops }}

-

{{ _('Total nr trims') }}:{{ job.totaltrims }}

+

{{ _('Unique Colors') }}:{{ job.num_colors }}

+

{{ _('Color Blocks') }}:{{ job.num_color_blocks }}

+

{{ _('Total nr stops') }}:{{ job.num_stops }}

+

{{ _('Total nr trims') }}:{{ job.num_trims }}

-

{{ _('Design box size') }}:{{ job.size }}

-

{{ _('Total stitch count') }}:{{job.stitchcount }}

-

{{ _('Total thread used') }}:{{job.totalthread }}

+

{{ _('Design box size') }}:{{ job.dimensions }}

+

{{ _('Total stitch count') }}:{{job.num_stitches }}

+

{{ _('Total thread used') }}:{{job.estimated_thread }}

{{ _('Job estimated time') }}:

-

{{ job.estimatedtime }}

+

{{ job.estimated_time }}