diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2018-05-19 14:41:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-19 14:41:50 -0400 |
| commit | 9dadd836e2f09b0216f7b40c782e2b55bcc90dee (patch) | |
| tree | 128b6f13ea682a8e5a033370ab2e13388801f100 | |
| parent | ba7288d8fcd62678bd17d8fab01d0d488d9e21e8 (diff) | |
| parent | 6fe417cd64090f028c0d07b799620eb94637bf33 (diff) | |
Merge pull request #163 from lexelby/lexelby-single-extension
single code entry point
| -rw-r--r-- | Makefile | 2 | ||||
| -rwxr-xr-x | bin/build-dist | 43 | ||||
| -rwxr-xr-x | bin/gen-input-inx | 2 | ||||
| -rw-r--r-- | embroider_input.py | 61 | ||||
| -rw-r--r-- | inkstitch.py | 32 | ||||
| -rw-r--r-- | inkstitch/__init__.py | 298 | ||||
| -rw-r--r-- | inx/embroider_input_T01.inx | 16 | ||||
| -rw-r--r-- | inx/inkstitch_embroider.inx (renamed from inx/embroider.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_100.inx (renamed from inx/embroider_input_100.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_10O.inx (renamed from inx/embroider_input_10O.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_BRO.inx (renamed from inx/embroider_input_BRO.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_COL.inx (renamed from inx/embroider_input_COL.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_CSD.inx (renamed from inx/embroider_input_CSD.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_CSV.inx (renamed from inx/embroider_input_CSV.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_DAT.inx (renamed from inx/embroider_input_DAT.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_DSB.inx (renamed from inx/embroider_input_DSB.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_DST.inx (renamed from inx/embroider_input_DST.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_DSZ.inx (renamed from inx/embroider_input_DSZ.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_EDR.inx (renamed from inx/embroider_input_EDR.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_EMD.inx (renamed from inx/embroider_input_EMD.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_EXP.inx (renamed from inx/embroider_input_EXP.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_EXY.inx (renamed from inx/embroider_input_EXY.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_FXY.inx (renamed from inx/embroider_input_FXY.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_GT.inx (renamed from inx/embroider_input_GT.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_HUS.inx (renamed from inx/embroider_input_HUS.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_INB.inx (renamed from inx/embroider_input_INB.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_INF.inx (renamed from inx/embroider_input_INF.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_JEF.inx (renamed from inx/embroider_input_JEF.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_KSM.inx (renamed from inx/embroider_input_KSM.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_MAX.inx (renamed from inx/embroider_input_MAX.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_MIT.inx (renamed from inx/embroider_input_MIT.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_NEW.inx (renamed from inx/embroider_input_NEW.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_OFM.inx (renamed from inx/embroider_input_OFM.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PCD.inx (renamed from inx/embroider_input_PCD.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PCM.inx (renamed from inx/embroider_input_PCM.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PCQ.inx (renamed from inx/embroider_input_PCQ.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PCS.inx (renamed from inx/embroider_input_PCS.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PEC.inx (renamed from inx/embroider_input_PEC.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PES.inx (renamed from inx/embroider_input_PES.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PHB.inx (renamed from inx/embroider_input_PHB.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PHC.inx (renamed from inx/embroider_input_PHC.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_PLT.inx (renamed from inx/embroider_input_PLT.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_RGB.inx (renamed from inx/embroider_input_RGB.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_SEW.inx (renamed from inx/embroider_input_SEW.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_SHV.inx (renamed from inx/embroider_input_SHV.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_SST.inx (renamed from inx/embroider_input_SST.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_STX.inx (renamed from inx/embroider_input_STX.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_T09.inx (renamed from inx/embroider_input_T09.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_TAP.inx (renamed from inx/embroider_input_TAP.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_THR.inx (renamed from inx/embroider_input_THR.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_U00.inx (renamed from inx/embroider_input_U00.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_VIP.inx (renamed from inx/embroider_input_VIP.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_VP3.inx (renamed from inx/embroider_input_VP3.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_XXX.inx (renamed from inx/embroider_input_XXX.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_input_ZSK.inx (renamed from inx/embroider_input_ZSK.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_palettes.inx (renamed from inx/embroider_palettes.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_params.inx (renamed from inx/embroider_params.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_print.inx (renamed from inx/embroider_print.inx) | 5 | ||||
| -rw-r--r-- | inx/inkstitch_simulate.inx (renamed from inx/embroider_simulate.inx) | 6 | ||||
| -rw-r--r-- | lib/__init__.py | 0 | ||||
| -rw-r--r-- | lib/elements/__init__.py (renamed from inkstitch/elements/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/elements/auto_fill.py (renamed from inkstitch/elements/auto_fill.py) | 8 | ||||
| -rw-r--r-- | lib/elements/element.py (renamed from inkstitch/elements/element.py) | 18 | ||||
| -rw-r--r-- | lib/elements/fill.py (renamed from inkstitch/elements/fill.py) | 9 | ||||
| -rw-r--r-- | lib/elements/polyline.py (renamed from inkstitch/elements/polyline.py) | 3 | ||||
| -rw-r--r-- | lib/elements/satin_column.py (renamed from inkstitch/elements/satin_column.py) | 6 | ||||
| -rw-r--r-- | lib/elements/stroke.py (renamed from inkstitch/elements/stroke.py) | 5 | ||||
| -rw-r--r-- | lib/extensions/__init__.py | 6 | ||||
| -rw-r--r-- | lib/extensions/base.py (renamed from inkstitch/extensions.py) | 7 | ||||
| -rw-r--r-- | lib/extensions/embroider.py (renamed from embroider.py) | 39 | ||||
| -rw-r--r-- | lib/extensions/input.py | 68 | ||||
| -rw-r--r-- | lib/extensions/palettes.py (renamed from embroider_palettes.py) | 15 | ||||
| -rw-r--r-- | lib/extensions/params.py (renamed from embroider_params.py) | 32 | ||||
| -rw-r--r-- | lib/extensions/print_pdf.py (renamed from embroider_print.py) | 44 | ||||
| -rw-r--r-- | lib/extensions/simulate.py | 28 | ||||
| -rw-r--r-- | lib/i18n.py | 21 | ||||
| -rw-r--r-- | lib/output.py | 131 | ||||
| -rw-r--r-- | lib/simulator.py (renamed from embroider_simulate.py) | 36 | ||||
| -rw-r--r-- | lib/stitch_plan/__init__.py (renamed from inkstitch/stitch_plan/__init__.py) | 1 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch.py | 15 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py (renamed from inkstitch/stitch_plan/stitch_plan.py) | 5 | ||||
| -rw-r--r-- | lib/stitch_plan/stop.py (renamed from inkstitch/stitch_plan/stop.py) | 0 | ||||
| -rw-r--r-- | lib/stitch_plan/ties.py (renamed from inkstitch/stitch_plan/ties.py) | 6 | ||||
| -rw-r--r-- | lib/stitch_plan/trim.py (renamed from inkstitch/stitch_plan/trim.py) | 0 | ||||
| -rw-r--r-- | lib/stitches/__init__.py (renamed from inkstitch/stitches/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/stitches/auto_fill.py (renamed from inkstitch/stitches/auto_fill.py) | 7 | ||||
| -rw-r--r-- | lib/stitches/fill.py (renamed from inkstitch/stitches/fill.py) | 6 | ||||
| -rw-r--r-- | lib/stitches/running_stitch.py (renamed from inkstitch/stitches/running_stitch.py) | 0 | ||||
| -rw-r--r-- | lib/svg/__init__.py | 2 | ||||
| -rw-r--r-- | lib/svg/svg.py (renamed from inkstitch/svg.py) | 7 | ||||
| -rw-r--r-- | lib/svg/tags.py | 12 | ||||
| -rw-r--r-- | lib/svg/units.py | 105 | ||||
| -rw-r--r-- | lib/threads/__init__.py (renamed from inkstitch/threads/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/threads/catalog.py (renamed from inkstitch/threads/catalog.py) | 2 | ||||
| -rw-r--r-- | lib/threads/color.py (renamed from inkstitch/threads/color.py) | 0 | ||||
| -rw-r--r-- | lib/threads/palette.py (renamed from inkstitch/threads/palette.py) | 3 | ||||
| -rw-r--r-- | lib/utils/__init__.py (renamed from inkstitch/utils/__init__.py) | 0 | ||||
| -rw-r--r-- | lib/utils/cache.py (renamed from inkstitch/utils/cache.py) | 0 | ||||
| -rw-r--r-- | lib/utils/geometry.py (renamed from inkstitch/utils/geometry.py) | 0 | ||||
| -rw-r--r-- | lib/utils/inkscape.py (renamed from inkstitch/utils/inkscape.py) | 0 | ||||
| -rw-r--r-- | lib/utils/io.py (renamed from inkstitch/utils/io.py) | 1 | ||||
| -rw-r--r-- | messages.po | 260 | ||||
| -rw-r--r-- | print/resources/inkstitch.js | 2 | ||||
| -rw-r--r-- | requirements.txt | 7 | ||||
| -rw-r--r-- | templates/embroider_input.inx | 5 |
105 files changed, 829 insertions, 808 deletions
@@ -1,4 +1,4 @@ -EXTENSIONS:=embroider embroider_params embroider_simulate embroider_print embroider_input embroider_palettes +EXTENSIONS:=inkstitch # This gets the branch name or the name of the tag VERSION:=$(TRAVIS_BRANCH) diff --git a/bin/build-dist b/bin/build-dist index a1fa82d9..4d73313a 100755 --- a/bin/build-dist +++ b/bin/build-dist @@ -34,26 +34,23 @@ pyinstaller_args+="-p inkscape-0.92.2/share/extensions " # output useful debugging info that helps us trace library dependency issues pyinstaller_args+="--log-level DEBUG " -mkdir -p dist/inkstitch/bin -for extension in "$@"; do - if [ "$BUILD" = "windows" ]; then - wine c:\\Python\\scripts\\pyinstaller.exe $pyinstaller_args ${extension}.py - else - # without the LD_LIBRARY_PATH, it seems that pyinstaller can't find all of - # wxpython's shared libraries - LD_LIBRARY_PATH="${site_packages}/wx" pyinstaller $pyinstaller_args ${extension}.py; - fi - - # By default, pyinstaller will treat each of ink/stitch's extensions - # separately. This means it packages a lot of the same shared libraries (like - # wxPython) multiple times. Turns out that we can just copy the contents of - # the directories pyinstaller creates into one and it works fine, eliminating - # the duplication. This significantly decreases the size of the inkstitch - # tarball/zip. - cp -a dist/${extension}/* dist/inkstitch/bin - rm -rf dist/${extension} - - # Inkscape doesn't let us run native binaries as extensions(?!). Instead we - # add this stub script which executes the binaries that pyinstaller creates. - cp stub.py dist/${extension}.py -done +if [ "$BUILD" = "windows" ]; then + wine c:\\Python\\scripts\\pyinstaller.exe $pyinstaller_args inkstitch.py +else + # without the LD_LIBRARY_PATH, it seems that pyinstaller can't find all of + # wxpython's shared libraries + LD_LIBRARY_PATH="${site_packages}/wx" pyinstaller $pyinstaller_args --strip inkstitch.py; +fi + +# pyinstaller put a whole mess of libraries under dist/inkstitch. We'd like +# to put some more user-accessible stuff like examples and palettes in +# folders under inkstitch/ (see ../Makefile) so let's move the pyinstaller +# stuff into its own dir. +shopt -s dotglob +mkdir dist/bin +mv dist/inkstitch/* dist/bin +mv dist/bin dist/inkstitch + +# Inkscape doesn't let us run native binaries as extensions(?!). Instead we +# add this stub script which executes the binary that pyinstaller creates. +cp stub.py dist/inkstitch.py diff --git a/bin/gen-input-inx b/bin/gen-input-inx index 918adfb9..5f21ce84 100755 --- a/bin/gen-input-inx +++ b/bin/gen-input-inx @@ -37,7 +37,7 @@ def main(): for format, description in libembroidery_input_formats(): inx = template.render(format=format, description=description) - with open("inx/embroider_input_%s.inx" % format.upper(), 'w') as inx_file: + with open("inx/inkstitch_input_%s.inx" % format.upper(), 'w') as inx_file: inx_file.write(inx) diff --git a/embroider_input.py b/embroider_input.py deleted file mode 100644 index 04d79d4f..00000000 --- a/embroider_input.py +++ /dev/null @@ -1,61 +0,0 @@ -import sys -import os -from libembroidery import * -from inkex import etree -import inkex -from inkstitch import PIXELS_PER_MM, INKSCAPE_LABEL, _ -from inkstitch.stitch_plan import StitchPlan -from inkstitch.svg import render_stitch_plan - - -def pattern_stitches(pattern): - stitch_pointer = pattern.stitchList - while stitch_pointer: - yield stitch_pointer.stitch - stitch_pointer = stitch_pointer.next - - -def main(embroidery_file): - pattern = embPattern_create() - embPattern_read(pattern, embroidery_file) - embPattern_flipVertical(pattern) - - stitch_plan = StitchPlan() - color_block = None - current_color = None - - for stitch in pattern_stitches(pattern): - if stitch.color != current_color: - thread = embThreadList_getAt(pattern.threadList, stitch.color) - color = thread.color - color_block = stitch_plan.new_color_block((color.r, color.g, color.b)) - current_color = stitch.color - - if not stitch.flags & END: - color_block.add_stitch(stitch.xx * PIXELS_PER_MM, stitch.yy * PIXELS_PER_MM, - jump=stitch.flags & JUMP, - stop=stitch.flags & STOP, - trim=stitch.flags & TRIM) - - extents = stitch_plan.extents - svg = etree.Element("svg", nsmap=inkex.NSS, attrib= - { - "width": str(extents[0] * 2), - "height": str(extents[1] * 2), - "viewBox": "0 0 %s %s" % (extents[0] * 2, extents[1] * 2), - }) - render_stitch_plan(svg, stitch_plan) - - # rename the Stitch Plan layer so that it doesn't get overwritten by Embroider - layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") - layer.set(INKSCAPE_LABEL, os.path.basename(embroidery_file)) - layer.attrib.pop('id') - - # Shift the design so that its origin is at the center of the canvas - # Note: this is NOT the same as centering the design in the canvas! - layer.set('transform', 'translate(%s,%s)' % (extents[0], extents[1])) - - print etree.tostring(svg) - -if __name__ == '__main__': - sys.exit(main(*sys.argv[1:])) diff --git a/inkstitch.py b/inkstitch.py new file mode 100644 index 00000000..a9ce829e --- /dev/null +++ b/inkstitch.py @@ -0,0 +1,32 @@ +import sys +import traceback +from argparse import ArgumentParser +from lib.utils import save_stderr, restore_stderr +from lib import extensions + + +parser = ArgumentParser() +parser.add_argument("--extension") +my_args, remaining_args = parser.parse_known_args() + +extension_name = my_args.extension +extension_class = getattr(extensions, extension_name.capitalize()) +extension = extension_class() + +exception = None + +save_stderr() +try: + extension.affect(args=remaining_args) +except (SystemExit, KeyboardInterrupt): + raise +except Exception: + exception = traceback.format_exc() +finally: + restore_stderr() + +if exception: + print >> sys.stderr, exception + sys.exit(1) +else: + sys.exit(0) diff --git a/inkstitch/__init__.py b/inkstitch/__init__.py deleted file mode 100644 index 45eed3a6..00000000 --- a/inkstitch/__init__.py +++ /dev/null @@ -1,298 +0,0 @@ -#!/usr/bin/env python -# http://www.achatina.de/sewing/main/TECHNICL.HTM - -import os -import sys -import gettext -from copy import deepcopy -import math -import libembroidery -from inkstitch.utils import cache -from inkstitch.utils.geometry import Point - -import inkex -import simplepath -import simplestyle -import simpletransform -from bezmisc import bezierlength, beziertatlength, bezierpointatt -from cspsubdiv import cspsubdiv -import cubicsuperpath -from shapely import geometry as shgeo - - -# modern versions of Inkscape use 96 pixels per inch as per the CSS standard -PIXELS_PER_MM = 96 / 25.4 - -SVG_PATH_TAG = inkex.addNS('path', 'svg') -SVG_POLYLINE_TAG = inkex.addNS('polyline', 'svg') -SVG_DEFS_TAG = inkex.addNS('defs', 'svg') -SVG_GROUP_TAG = inkex.addNS('g', 'svg') -INKSCAPE_LABEL = inkex.addNS('label', 'inkscape') -INKSCAPE_GROUPMODE = inkex.addNS('groupmode', 'inkscape') - -EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG) - -dbg = open(os.devnull, "w") - -translation = None -_ = lambda message: message - - -def localize(): - if getattr(sys, 'frozen', False): - # we are in a pyinstaller installation - locale_dir = sys._MEIPASS - else: - locale_dir = os.path.dirname(__file__) - - locale_dir = os.path.join(locale_dir, 'locales') - - global translation, _ - - translation = gettext.translation("inkstitch", locale_dir, fallback=True) - _ = translation.gettext - -localize() - -# cribbed from inkscape-silhouette -def parse_length_with_units( str ): - - ''' - Parse an SVG value which may or may not have units attached - This version is greatly simplified in that it only allows: no units, - units of px, mm, and %. Everything else, it returns None for. - There is a more general routine to consider in scour.py if more - generality is ever needed. - ''' - - u = 'px' - s = str.strip() - if s[-2:] == 'px': - s = s[:-2] - elif s[-2:] == 'mm': - u = 'mm' - s = s[:-2] - elif s[-2:] == 'pt': - u = 'pt' - s = s[:-2] - elif s[-2:] == 'pc': - u = 'pc' - s = s[:-2] - elif s[-2:] == 'cm': - u = 'cm' - s = s[:-2] - elif s[-2:] == 'in': - u = 'in' - s = s[:-2] - elif s[-1:] == '%': - u = '%' - s = s[:-1] - try: - v = float( s ) - except: - raise ValueError(_("parseLengthWithUnits: unknown unit %s") % s) - - return v, u - - -def convert_length(length): - value, units = parse_length_with_units(length) - - if not units or units == "px": - return value - - if units == 'pt': - value /= 72 - units = 'in' - - if units == 'pc': - value /= 6 - units = 'in' - - if units == 'cm': - value *= 10 - units = 'mm' - - if units == 'mm': - value = value / 25.4 - units = 'in' - - if units == 'in': - # modern versions of Inkscape use CSS's 96 pixels per inch. When you - # open an old document, inkscape will add a viewbox for you. - return value * 96 - - raise ValueError(_("Unknown unit: %s") % units) - - -@cache -def get_doc_size(svg): - doc_width = convert_length(svg.get('width')) - doc_height = convert_length(svg.get('height')) - - return doc_width, doc_height - -@cache -def get_viewbox_transform(node): - # somewhat cribbed from inkscape-silhouette - doc_width, doc_height = get_doc_size(node) - - viewbox = node.get('viewBox').strip().replace(',', ' ').split() - - dx = -float(viewbox[0]) - dy = -float(viewbox[1]) - transform = simpletransform.parseTransform("translate(%f, %f)" % (dx, dy)) - - try: - sx = doc_width / float(viewbox[2]) - sy = doc_height / float(viewbox[3]) - scale_transform = simpletransform.parseTransform("scale(%f, %f)" % (sx, sy)) - transform = simpletransform.composeTransform(transform, scale_transform) - except ZeroDivisionError: - pass - - return transform - -@cache -def get_stroke_scale(node): - doc_width, doc_height = get_doc_size(node) - viewbox = node.get('viewBox').strip().replace(',', ' ').split() - return doc_width / float(viewbox[2]) - - -class Stitch(Point): - def __init__(self, x, y, color=None, jump=False, stop=False, trim=False, no_ties=False): - self.x = x - self.y = y - self.color = color - self.jump = jump - self.trim = trim - self.stop = stop - self.no_ties = no_ties - - def __repr__(self): - return "Stitch(%s, %s, %s, %s, %s, %s, %s)" % (self.x, self.y, self.color, "JUMP" if self.jump else " ", "TRIM" if self.trim else " ", "STOP" if self.stop else " ", "NO TIES" if self.no_ties else " ") - - -def make_thread(color): - thread = libembroidery.EmbThread() - thread.color = libembroidery.embColor_make(*color.rgb) - - thread.description = color.name - thread.catalogNumber = "" - - return thread - -def add_thread(pattern, thread): - """Add a thread to a pattern and return the thread's index""" - - libembroidery.embPattern_addThread(pattern, thread) - - return libembroidery.embThreadList_count(pattern.threadList) - 1 - -def get_flags(stitch): - flags = 0 - - if stitch.jump: - flags |= libembroidery.JUMP - - if stitch.trim: - flags |= libembroidery.TRIM - - if stitch.stop: - flags |= libembroidery.STOP - - return flags - - -def _string_to_floats(string): - floats = string.split(',') - return [float(num) for num in floats] - - -def get_origin(svg): - # The user can specify the embroidery origin by defining two guides - # named "embroidery origin" that intersect. - - namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) - all_guides = namedview.findall(inkex.addNS('guide', 'sodipodi')) - label_attribute = inkex.addNS('label', 'inkscape') - guides = [guide for guide in all_guides - if guide.get(label_attribute, "").startswith("embroidery origin")] - - # document size used below - doc_size = list(get_doc_size(svg)) - - # convert the size from viewbox-relative to real-world pixels - viewbox_transform = get_viewbox_transform(svg) - simpletransform.applyTransformToPoint(simpletransform.invertTransform(viewbox_transform), doc_size) - - default = [doc_size[0] / 2.0, doc_size[1] / 2.0] - simpletransform.applyTransformToPoint(viewbox_transform, default) - default = Point(*default) - - if len(guides) < 2: - return default - - # Find out where the guides intersect. Only pay attention to the first two. - guides = guides[:2] - - lines = [] - for guide in guides: - # inkscape's Y axis is reversed from SVG's, and the guide is in inkscape coordinates - position = Point(*_string_to_floats(guide.get('position'))) - position.y = doc_size[1] - position.y - - - # This one baffles me. I think inkscape might have gotten the order of - # their vector wrong? - parts = _string_to_floats(guide.get('orientation')) - direction = Point(parts[1], parts[0]) - - # We have a theoretically infinite line defined by a point on the line - # and a vector direction. Shapely can only deal in concrete line - # segments, so we'll pick points really far in either direction on the - # line and call it good enough. - lines.append(shgeo.LineString((position + 100000 * direction, position - 100000 * direction))) - - intersection = lines[0].intersection(lines[1]) - - if isinstance(intersection, shgeo.Point): - origin = [intersection.x, intersection.y] - simpletransform.applyTransformToPoint(viewbox_transform, origin) - return Point(*origin) - else: - # Either the two guides are the same line, or they're parallel. - return default - - -def write_embroidery_file(file_path, stitch_plan, svg): - origin = get_origin(svg) - - pattern = libembroidery.embPattern_create() - - for color_block in stitch_plan: - add_thread(pattern, make_thread(color_block.color)) - - for stitch in color_block: - if stitch.stop and stitch is not color_block.last_stitch: - # A STOP stitch that is not at the end of a color block - # occurs when the user specified "STOP after". "STOP" is the - # same thing as a color change, and the user will assign a - # special color at the machine that tells it to pause after. - # We need to add another copy of the same color here so that - # the stitches after the STOP are still the same color. - add_thread(pattern, make_thread(color_block.color)) - - flags = get_flags(stitch) - libembroidery.embPattern_addStitchAbs(pattern, stitch.x - origin.x, stitch.y - origin.y, flags, 1) - - libembroidery.embPattern_addStitchAbs(pattern, stitch.x - origin.x, stitch.y - origin.y, libembroidery.END, 1) - - # convert from pixels to millimeters - libembroidery.embPattern_scale(pattern, 1/PIXELS_PER_MM) - - # SVG and embroidery disagree on the direction of the Y axis - libembroidery.embPattern_flipVertical(pattern) - - libembroidery.embPattern_write(pattern, file_path) diff --git a/inx/embroider_input_T01.inx b/inx/embroider_input_T01.inx deleted file mode 100644 index 5090310e..00000000 --- a/inx/embroider_input_T01.inx +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>T01 file input</_name> - <id>org.inkstitch.input.t01</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> - <dependency type="executable" location="extensions">inkex.py</dependency> - <input> - <extension>.t01</extension> - <mimetype>application/x-embroidery-t01</mimetype> - <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.t01)</_filetypename> - <_filetypetooltip>convert T01 file to Ink/Stitch manual-stitch paths</_filetypetooltip> - </input> - <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> - </script> -</inkscape-extension> diff --git a/inx/embroider.inx b/inx/inkstitch_embroider.inx index 74217b73..1f5619a3 100644 --- a/inx/embroider.inx +++ b/inx/inkstitch_embroider.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Embroider</_name> <id>jonh.embroider</id> - <dependency type="executable" location="extensions">embroider.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <param name="collapse_len_mm" type="float" min="0.0" max="10.0" _gui-text="Collapse length (mm)"> _gui-description="Jump stitches smaller than this will be treated as normal stitches.">3.0</param> <param name="hide_layers" type="boolean" _gui-text="Hide other layers" description="Hide all other top-level layers when the embroidery layer is generated, in order to make stitching discernable.">true</param> @@ -32,6 +32,7 @@ <_option value="xxx">Singer Embroidery Format(.XXX)</_option> </param> <param name="path" type="string" _gui-text="Directory"></param> + <param name="extension" type="string" gui-hidden="true">embroider</param> <effect> <object-type>all</object-type> <effects-menu> @@ -39,6 +40,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_100.inx b/inx/inkstitch_input_100.inx index 9bbad780..def2011d 100644 --- a/inx/embroider_input_100.inx +++ b/inx/inkstitch_input_100.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>100 file input</_name> <id>org.inkstitch.input.100</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.100</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Toyota Embroidery Format (.100)</_filetypename> <_filetypetooltip>convert 100 file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_10O.inx b/inx/inkstitch_input_10O.inx index 42f1850e..29b14397 100644 --- a/inx/embroider_input_10O.inx +++ b/inx/inkstitch_input_10O.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>10O file input</_name> <id>org.inkstitch.input.10o</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.10o</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Toyota Embroidery Format (.10o)</_filetypename> <_filetypetooltip>convert 10O file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_BRO.inx b/inx/inkstitch_input_BRO.inx index 0dc576bf..928195a6 100644 --- a/inx/embroider_input_BRO.inx +++ b/inx/inkstitch_input_BRO.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>BRO file input</_name> <id>org.inkstitch.input.bro</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.bro</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Bits & Volts Embroidery Format (.bro)</_filetypename> <_filetypetooltip>convert BRO file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_COL.inx b/inx/inkstitch_input_COL.inx index 81002dd7..38ebe7bd 100644 --- a/inx/embroider_input_COL.inx +++ b/inx/inkstitch_input_COL.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>COL file input</_name> <id>org.inkstitch.input.col</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.col</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Embroidery Thread Color Format (.col)</_filetypename> <_filetypetooltip>convert COL file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_CSD.inx b/inx/inkstitch_input_CSD.inx index 8ebb94b9..444270f0 100644 --- a/inx/embroider_input_CSD.inx +++ b/inx/inkstitch_input_CSD.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>CSD file input</_name> <id>org.inkstitch.input.csd</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.csd</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Singer Embroidery Format (.csd)</_filetypename> <_filetypetooltip>convert CSD file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_CSV.inx b/inx/inkstitch_input_CSV.inx index c3f972d9..0c3e2096 100644 --- a/inx/embroider_input_CSV.inx +++ b/inx/inkstitch_input_CSV.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>CSV file input</_name> <id>org.inkstitch.input.csv</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.csv</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Comma Separated Values Format (.csv)</_filetypename> <_filetypetooltip>convert CSV file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_DAT.inx b/inx/inkstitch_input_DAT.inx index 1045153a..e82694b8 100644 --- a/inx/embroider_input_DAT.inx +++ b/inx/inkstitch_input_DAT.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>DAT file input</_name> <id>org.inkstitch.input.dat</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.dat</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Barudan Embroidery Format (.dat)</_filetypename> <_filetypetooltip>convert DAT file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_DSB.inx b/inx/inkstitch_input_DSB.inx index f81c7ca2..8b7c6b02 100644 --- a/inx/embroider_input_DSB.inx +++ b/inx/inkstitch_input_DSB.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>DSB file input</_name> <id>org.inkstitch.input.dsb</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.dsb</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Barudan Embroidery Format (.dsb)</_filetypename> <_filetypetooltip>convert DSB file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_DST.inx b/inx/inkstitch_input_DST.inx index 414b7470..b3eee601 100644 --- a/inx/embroider_input_DST.inx +++ b/inx/inkstitch_input_DST.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>DST file input</_name> <id>org.inkstitch.input.dst</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.dst</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Tajima Embroidery Format (.dst)</_filetypename> <_filetypetooltip>convert DST file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_DSZ.inx b/inx/inkstitch_input_DSZ.inx index 9c81a0ad..388aeda0 100644 --- a/inx/embroider_input_DSZ.inx +++ b/inx/inkstitch_input_DSZ.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>DSZ file input</_name> <id>org.inkstitch.input.dsz</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.dsz</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.dsz)</_filetypename> <_filetypetooltip>convert DSZ file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_EDR.inx b/inx/inkstitch_input_EDR.inx index 9276fd17..92cf7d14 100644 --- a/inx/embroider_input_EDR.inx +++ b/inx/inkstitch_input_EDR.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>EDR file input</_name> <id>org.inkstitch.input.edr</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.edr</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Embird Embroidery Format (.edr)</_filetypename> <_filetypetooltip>convert EDR file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_EMD.inx b/inx/inkstitch_input_EMD.inx index bb20f977..c05da24f 100644 --- a/inx/embroider_input_EMD.inx +++ b/inx/inkstitch_input_EMD.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>EMD file input</_name> <id>org.inkstitch.input.emd</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.emd</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Elna Embroidery Format (.emd)</_filetypename> <_filetypetooltip>convert EMD file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_EXP.inx b/inx/inkstitch_input_EXP.inx index 41bae8ce..2c5997d5 100644 --- a/inx/embroider_input_EXP.inx +++ b/inx/inkstitch_input_EXP.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>EXP file input</_name> <id>org.inkstitch.input.exp</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.exp</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Melco Embroidery Format (.exp)</_filetypename> <_filetypetooltip>convert EXP file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_EXY.inx b/inx/inkstitch_input_EXY.inx index a2e792c4..78de68d8 100644 --- a/inx/embroider_input_EXY.inx +++ b/inx/inkstitch_input_EXY.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>EXY file input</_name> <id>org.inkstitch.input.exy</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.exy</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Eltac Embroidery Format (.exy)</_filetypename> <_filetypetooltip>convert EXY file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_FXY.inx b/inx/inkstitch_input_FXY.inx index 4d77022e..c2be8c60 100644 --- a/inx/embroider_input_FXY.inx +++ b/inx/inkstitch_input_FXY.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>FXY file input</_name> <id>org.inkstitch.input.fxy</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.fxy</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Fortron Embroidery Format (.fxy)</_filetypename> <_filetypetooltip>convert FXY file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_GT.inx b/inx/inkstitch_input_GT.inx index 3b482244..20a9fda0 100644 --- a/inx/embroider_input_GT.inx +++ b/inx/inkstitch_input_GT.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>GT file input</_name> <id>org.inkstitch.input.gt</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.gt</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Gold Thread Embroidery Format (.gt)</_filetypename> <_filetypetooltip>convert GT file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_HUS.inx b/inx/inkstitch_input_HUS.inx index 3b19ee87..bbac96a2 100644 --- a/inx/embroider_input_HUS.inx +++ b/inx/inkstitch_input_HUS.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>HUS file input</_name> <id>org.inkstitch.input.hus</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.hus</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.hus)</_filetypename> <_filetypetooltip>convert HUS file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_INB.inx b/inx/inkstitch_input_INB.inx index 24c6535d..7409a853 100644 --- a/inx/embroider_input_INB.inx +++ b/inx/inkstitch_input_INB.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>INB file input</_name> <id>org.inkstitch.input.inb</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.inb</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Inbro Embroidery Format (.inb)</_filetypename> <_filetypetooltip>convert INB file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_INF.inx b/inx/inkstitch_input_INF.inx index db7e5d57..9c07ed7f 100644 --- a/inx/embroider_input_INF.inx +++ b/inx/inkstitch_input_INF.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>INF file input</_name> <id>org.inkstitch.input.inf</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.inf</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Embroidery Color Format (.inf)</_filetypename> <_filetypetooltip>convert INF file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_JEF.inx b/inx/inkstitch_input_JEF.inx index c2030622..364e969f 100644 --- a/inx/embroider_input_JEF.inx +++ b/inx/inkstitch_input_JEF.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>JEF file input</_name> <id>org.inkstitch.input.jef</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.jef</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Janome Embroidery Format (.jef)</_filetypename> <_filetypetooltip>convert JEF file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_KSM.inx b/inx/inkstitch_input_KSM.inx index 2869ea07..b01eb195 100644 --- a/inx/embroider_input_KSM.inx +++ b/inx/inkstitch_input_KSM.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>KSM file input</_name> <id>org.inkstitch.input.ksm</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.ksm</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.ksm)</_filetypename> <_filetypetooltip>convert KSM file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_MAX.inx b/inx/inkstitch_input_MAX.inx index 2dbbe2cc..0f5ed952 100644 --- a/inx/embroider_input_MAX.inx +++ b/inx/inkstitch_input_MAX.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>MAX file input</_name> <id>org.inkstitch.input.max</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.max</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.max)</_filetypename> <_filetypetooltip>convert MAX file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_MIT.inx b/inx/inkstitch_input_MIT.inx index 10f5dfd3..a0181182 100644 --- a/inx/embroider_input_MIT.inx +++ b/inx/inkstitch_input_MIT.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>MIT file input</_name> <id>org.inkstitch.input.mit</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.mit</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Mitsubishi Embroidery Format (.mit)</_filetypename> <_filetypetooltip>convert MIT file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_NEW.inx b/inx/inkstitch_input_NEW.inx index f13a7009..15d877d8 100644 --- a/inx/embroider_input_NEW.inx +++ b/inx/inkstitch_input_NEW.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>NEW file input</_name> <id>org.inkstitch.input.new</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.new</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Ameco Embroidery Format (.new)</_filetypename> <_filetypetooltip>convert NEW file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_OFM.inx b/inx/inkstitch_input_OFM.inx index 9086900d..3e162355 100644 --- a/inx/embroider_input_OFM.inx +++ b/inx/inkstitch_input_OFM.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>OFM file input</_name> <id>org.inkstitch.input.ofm</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.ofm</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Melco Embroidery Format (.ofm)</_filetypename> <_filetypetooltip>convert OFM file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PCD.inx b/inx/inkstitch_input_PCD.inx index fc9c7362..eff3c2f7 100644 --- a/inx/embroider_input_PCD.inx +++ b/inx/inkstitch_input_PCD.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PCD file input</_name> <id>org.inkstitch.input.pcd</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pcd</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcd)</_filetypename> <_filetypetooltip>convert PCD file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PCM.inx b/inx/inkstitch_input_PCM.inx index fe6c3e22..684b7e20 100644 --- a/inx/embroider_input_PCM.inx +++ b/inx/inkstitch_input_PCM.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PCM file input</_name> <id>org.inkstitch.input.pcm</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pcm</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcm)</_filetypename> <_filetypetooltip>convert PCM file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PCQ.inx b/inx/inkstitch_input_PCQ.inx index 932a9568..44d2d6df 100644 --- a/inx/embroider_input_PCQ.inx +++ b/inx/inkstitch_input_PCQ.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PCQ file input</_name> <id>org.inkstitch.input.pcq</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pcq</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcq)</_filetypename> <_filetypetooltip>convert PCQ file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PCS.inx b/inx/inkstitch_input_PCS.inx index d9d058c0..1a030e53 100644 --- a/inx/embroider_input_PCS.inx +++ b/inx/inkstitch_input_PCS.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PCS file input</_name> <id>org.inkstitch.input.pcs</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pcs</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.pcs)</_filetypename> <_filetypetooltip>convert PCS file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PEC.inx b/inx/inkstitch_input_PEC.inx index 382dedff..885c0125 100644 --- a/inx/embroider_input_PEC.inx +++ b/inx/inkstitch_input_PEC.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PEC file input</_name> <id>org.inkstitch.input.pec</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pec</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Brother Embroidery Format (.pec)</_filetypename> <_filetypetooltip>convert PEC file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PES.inx b/inx/inkstitch_input_PES.inx index 451a4da6..6faa06be 100644 --- a/inx/embroider_input_PES.inx +++ b/inx/inkstitch_input_PES.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PES file input</_name> <id>org.inkstitch.input.pes</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.pes</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Brother Embroidery Format (.pes)</_filetypename> <_filetypetooltip>convert PES file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PHB.inx b/inx/inkstitch_input_PHB.inx index ab4daf67..0e14f097 100644 --- a/inx/embroider_input_PHB.inx +++ b/inx/inkstitch_input_PHB.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PHB file input</_name> <id>org.inkstitch.input.phb</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.phb</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Brother Embroidery Format (.phb)</_filetypename> <_filetypetooltip>convert PHB file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PHC.inx b/inx/inkstitch_input_PHC.inx index e36739af..3c2d10f5 100644 --- a/inx/embroider_input_PHC.inx +++ b/inx/inkstitch_input_PHC.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PHC file input</_name> <id>org.inkstitch.input.phc</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.phc</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Brother Embroidery Format (.phc)</_filetypename> <_filetypetooltip>convert PHC file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_PLT.inx b/inx/inkstitch_input_PLT.inx index ec2374da..d811ff02 100644 --- a/inx/embroider_input_PLT.inx +++ b/inx/inkstitch_input_PLT.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>PLT file input</_name> <id>org.inkstitch.input.plt</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.plt</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: AutoCAD Plot Drawing Format (.plt)</_filetypename> <_filetypetooltip>convert PLT file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_RGB.inx b/inx/inkstitch_input_RGB.inx index a73955c1..b64e285b 100644 --- a/inx/embroider_input_RGB.inx +++ b/inx/inkstitch_input_RGB.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>RGB file input</_name> <id>org.inkstitch.input.rgb</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.rgb</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: RGB Embroidery Format (.rgb)</_filetypename> <_filetypetooltip>convert RGB file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_SEW.inx b/inx/inkstitch_input_SEW.inx index 8cb41136..a7661c97 100644 --- a/inx/embroider_input_SEW.inx +++ b/inx/inkstitch_input_SEW.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>SEW file input</_name> <id>org.inkstitch.input.sew</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.sew</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Janome Embroidery Format (.sew)</_filetypename> <_filetypetooltip>convert SEW file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_SHV.inx b/inx/inkstitch_input_SHV.inx index 20735cc8..7aad470c 100644 --- a/inx/embroider_input_SHV.inx +++ b/inx/inkstitch_input_SHV.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>SHV file input</_name> <id>org.inkstitch.input.shv</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.shv</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Husqvarna Viking Embroidery Format (.shv)</_filetypename> <_filetypetooltip>convert SHV file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_SST.inx b/inx/inkstitch_input_SST.inx index 61f7c782..85533659 100644 --- a/inx/embroider_input_SST.inx +++ b/inx/inkstitch_input_SST.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>SST file input</_name> <id>org.inkstitch.input.sst</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.sst</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Sunstar Embroidery Format (.sst)</_filetypename> <_filetypetooltip>convert SST file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_STX.inx b/inx/inkstitch_input_STX.inx index 5043d6f2..3f1a3065 100644 --- a/inx/embroider_input_STX.inx +++ b/inx/inkstitch_input_STX.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>STX file input</_name> <id>org.inkstitch.input.stx</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.stx</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Data Stitch Embroidery Format (.stx)</_filetypename> <_filetypetooltip>convert STX file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_T09.inx b/inx/inkstitch_input_T09.inx index 5c64541d..eb6ab6d9 100644 --- a/inx/embroider_input_T09.inx +++ b/inx/inkstitch_input_T09.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>T09 file input</_name> <id>org.inkstitch.input.t09</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.t09</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.t09)</_filetypename> <_filetypetooltip>convert T09 file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_TAP.inx b/inx/inkstitch_input_TAP.inx index 496105e2..bf299130 100644 --- a/inx/embroider_input_TAP.inx +++ b/inx/inkstitch_input_TAP.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>TAP file input</_name> <id>org.inkstitch.input.tap</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.tap</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Happy Embroidery Format (.tap)</_filetypename> <_filetypetooltip>convert TAP file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_THR.inx b/inx/inkstitch_input_THR.inx index d01d6184..e6a6e09e 100644 --- a/inx/embroider_input_THR.inx +++ b/inx/inkstitch_input_THR.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>THR file input</_name> <id>org.inkstitch.input.thr</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.thr</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: ThredWorks Embroidery Format (.thr)</_filetypename> <_filetypetooltip>convert THR file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_U00.inx b/inx/inkstitch_input_U00.inx index a98ddaa1..b28da66d 100644 --- a/inx/embroider_input_U00.inx +++ b/inx/inkstitch_input_U00.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>U00 file input</_name> <id>org.inkstitch.input.u00</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.u00</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Barudan Embroidery Format (.u00)</_filetypename> <_filetypetooltip>convert U00 file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_VIP.inx b/inx/inkstitch_input_VIP.inx index f607bfd7..3723285c 100644 --- a/inx/embroider_input_VIP.inx +++ b/inx/inkstitch_input_VIP.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>VIP file input</_name> <id>org.inkstitch.input.vip</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.vip</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vip)</_filetypename> <_filetypetooltip>convert VIP file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_VP3.inx b/inx/inkstitch_input_VP3.inx index cb24f60a..b39f630a 100644 --- a/inx/embroider_input_VP3.inx +++ b/inx/inkstitch_input_VP3.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>VP3 file input</_name> <id>org.inkstitch.input.vp3</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.vp3</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Pfaff Embroidery Format (.vp3)</_filetypename> <_filetypetooltip>convert VP3 file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_XXX.inx b/inx/inkstitch_input_XXX.inx index 64093628..6e8e501e 100644 --- a/inx/embroider_input_XXX.inx +++ b/inx/inkstitch_input_XXX.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>XXX file input</_name> <id>org.inkstitch.input.xxx</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.xxx</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: Singer Embroidery Format (.xxx)</_filetypename> <_filetypetooltip>convert XXX file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_input_ZSK.inx b/inx/inkstitch_input_ZSK.inx index badb36da..4178126f 100644 --- a/inx/embroider_input_ZSK.inx +++ b/inx/inkstitch_input_ZSK.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>ZSK file input</_name> <id>org.inkstitch.input.zsk</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.zsk</extension> @@ -10,7 +10,8 @@ <_filetypename>Ink/Stitch: ZSK USA Embroidery Format (.zsk)</_filetypename> <_filetypetooltip>convert ZSK file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_palettes.inx b/inx/inkstitch_palettes.inx index 47ff6cf3..5daa3196 100644 --- a/inx/embroider_palettes.inx +++ b/inx/inkstitch_palettes.inx @@ -2,8 +2,9 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Install thread manufacturer color palettes</_name> <id>org.inkstitch.palettes</id> - <dependency type="executable" location="extensions">embroider_palettes.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="extension" type="string" gui-hidden="true">palettes</param> <effect> <object-type>all</object-type> <effects-menu> @@ -11,6 +12,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider_palettes.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_params.inx b/inx/inkstitch_params.inx index f3987502..7b3b4e63 100644 --- a/inx/embroider_params.inx +++ b/inx/inkstitch_params.inx @@ -2,8 +2,9 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Params</_name> <id>jonh.embroider.params</id> - <dependency type="executable" location="extensions">embroider_params.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="extension" type="string" gui-hidden="true">params</param> <effect> <object-type>all</object-type> <effects-menu> @@ -11,6 +12,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider_params.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_print.inx b/inx/inkstitch_print.inx index cbba82cc..edc96a4c 100644 --- a/inx/embroider_print.inx +++ b/inx/inkstitch_print.inx @@ -2,8 +2,9 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Print</_name> <id>jonh.embroider.print</id> - <dependency type="executable" location="extensions">embroider_print.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="extension" type="string" gui-hidden="true">print</param> <effect> <object-type>all</object-type> <effects-menu> @@ -11,6 +12,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider_print.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/inx/embroider_simulate.inx b/inx/inkstitch_simulate.inx index 9c38ec97..66f892d8 100644 --- a/inx/embroider_simulate.inx +++ b/inx/inkstitch_simulate.inx @@ -2,9 +2,9 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>Simulate</_name> <id>jonh.embroider.simulate</id> - <dependency type="executable" location="extensions">embroider_simulate.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> - <param name="path" type="string" _gui-text="Directory where embroidery output is stored"></param> + <param name="extension" type="string" gui-hidden="true">simulate</param> <effect> <object-type>all</object-type> <effects-menu> @@ -12,6 +12,6 @@ </effects-menu> </effect> <script> - <command reldir="extensions" interpreter="python">embroider_simulate.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/lib/__init__.py diff --git a/inkstitch/elements/__init__.py b/lib/elements/__init__.py index 7e05e19c..7e05e19c 100644 --- a/inkstitch/elements/__init__.py +++ b/lib/elements/__init__.py diff --git a/inkstitch/elements/auto_fill.py b/lib/elements/auto_fill.py index 6eb1f10c..08ae67f7 100644 --- a/inkstitch/elements/auto_fill.py +++ b/lib/elements/auto_fill.py @@ -1,10 +1,10 @@ import math -from .. import _ -from .element import param, Patch -from ..utils import cache -from .fill import Fill from shapely import geometry as shgeo +from ..i18n import _ +from ..utils import cache from ..stitches import auto_fill +from .element import param, Patch +from .fill import Fill class AutoFill(Fill): diff --git a/inkstitch/elements/element.py b/lib/elements/element.py index cfca3782..300136dd 100644 --- a/inkstitch/elements/element.py +++ b/lib/elements/element.py @@ -1,9 +1,10 @@ import sys from copy import deepcopy +from shapely import geometry as shgeo +from ..i18n import _ from ..utils import cache -from shapely import geometry as shgeo -from .. import _, PIXELS_PER_MM, get_viewbox_transform, get_stroke_scale, convert_length +from ..svg import PIXELS_PER_MM, get_viewbox_transform, convert_length, get_doc_size # inkscape-provided utilities import simpletransform @@ -11,6 +12,7 @@ import simplestyle import cubicsuperpath from cspsubdiv import cspsubdiv + class Patch: """A raw collection of stitches with attached instructions.""" @@ -146,6 +148,15 @@ class EmbroideryElement(object): @property @cache + def stroke_scale(self): + svg = self.node.getroottree().getroot() + doc_width, doc_height = get_doc_size(svg) + viewbox = svg.get('viewBox', '0 0 %s %s' % (doc_width, doc_height)) + viewbox = viewbox.strip().replace(',', ' ').split() + return doc_width / float(viewbox[2]) + + @property + @cache def stroke_width(self): width = self.get_style("stroke-width") @@ -153,8 +164,7 @@ class EmbroideryElement(object): return 1.0 width = convert_length(width) - - return width * get_stroke_scale(self.node.getroottree().getroot()) + return width * self.stroke_scale @property def path(self): diff --git a/inkstitch/elements/fill.py b/lib/elements/fill.py index a74a897d..52a42260 100644 --- a/inkstitch/elements/fill.py +++ b/lib/elements/fill.py @@ -1,10 +1,13 @@ -from .. import _, PIXELS_PER_MM -from .element import param, EmbroideryElement, Patch -from ..utils import cache from shapely import geometry as shgeo import math + +from .element import param, EmbroideryElement, Patch +from ..i18n import _ +from ..svg import PIXELS_PER_MM +from ..utils import cache from ..stitches import running_stitch, auto_fill, legacy_fill + class Fill(EmbroideryElement): element_name = _("Fill") diff --git a/inkstitch/elements/polyline.py b/lib/elements/polyline.py index 6ded9fd1..5c474237 100644 --- a/inkstitch/elements/polyline.py +++ b/lib/elements/polyline.py @@ -1,5 +1,6 @@ -from .. import _, Point from .element import param, EmbroideryElement, Patch +from ..i18n import _ +from ..utils.geometry import Point from ..utils import cache diff --git a/inkstitch/elements/satin_column.py b/lib/elements/satin_column.py index d22f5145..3593db64 100644 --- a/inkstitch/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -1,9 +1,9 @@ from itertools import chain, izip +from shapely import geometry as shgeo, ops as shops -from .. import _, Point from .element import param, EmbroideryElement, Patch -from ..utils import cache -from shapely import geometry as shgeo, ops as shops +from ..i18n import _ +from ..utils import cache, Point class SatinColumn(EmbroideryElement): diff --git a/inkstitch/elements/stroke.py b/lib/elements/stroke.py index 360e3744..48662b6d 100644 --- a/inkstitch/elements/stroke.py +++ b/lib/elements/stroke.py @@ -1,7 +1,8 @@ import sys -from .. import _, Point + from .element import param, EmbroideryElement, Patch -from ..utils import cache +from ..i18n import _ +from ..utils import cache, Point warned_about_legacy_running_stitch = False diff --git a/lib/extensions/__init__.py b/lib/extensions/__init__.py new file mode 100644 index 00000000..ebdd2fc9 --- /dev/null +++ b/lib/extensions/__init__.py @@ -0,0 +1,6 @@ +from embroider import Embroider +from palettes import Palettes +from params import Params +from print_pdf import Print +from simulate import Simulate +from input import Input diff --git a/inkstitch/extensions.py b/lib/extensions/base.py index c02cc579..ff587ca5 100644 --- a/inkstitch/extensions.py +++ b/lib/extensions/base.py @@ -3,9 +3,10 @@ import re import json from copy import deepcopy from collections import MutableMapping -from .elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement -from . import SVG_POLYLINE_TAG, SVG_GROUP_TAG, SVG_DEFS_TAG, INKSCAPE_GROUPMODE, EMBROIDERABLE_TAGS, PIXELS_PER_MM -from .utils import cache + +from ..svg.tags import * +from ..elements import AutoFill, Fill, Stroke, SatinColumn, Polyline, EmbroideryElement +from ..utils import cache SVG_METADATA_TAG = inkex.addNS("metadata", "svg") diff --git a/embroider.py b/lib/extensions/embroider.py index 8c5d135b..a213be64 100644 --- a/embroider.py +++ b/lib/extensions/embroider.py @@ -1,26 +1,13 @@ -#!/usr/bin/python -# -# Important resources: -# lxml interface for walking SVG tree: -# http://codespeak.net/lxml/tutorial.html#elementpath -# Inkscape library for extracting paths from SVG: -# http://wiki.inkscape.org/wiki/index.php/Python_modules_for_extensions#simplepath.py -# Shapely computational geometry library: -# http://gispython.org/shapely/manual.html#multipolygons -# Embroidery file format documentation: -# http://www.achatina.de/sewing/main/TECHNICL.HTM - import sys import traceback -sys.path.append("/usr/share/inkscape/extensions") import os - import inkex -import inkstitch -from inkstitch import _, PIXELS_PER_MM -from inkstitch.extensions import InkstitchExtension -from inkstitch.stitch_plan import patches_to_stitch_plan -from inkstitch.svg import render_stitch_plan + +from .base import InkstitchExtension +from ..i18n import _ +from ..output import write_embroidery_file +from ..stitch_plan import patches_to_stitch_plan +from ..svg import render_stitch_plan, PIXELS_PER_MM class Embroider(InkstitchExtension): @@ -96,17 +83,5 @@ class Embroider(InkstitchExtension): patches = self.elements_to_patches(self.elements) stitch_plan = patches_to_stitch_plan(patches, self.options.collapse_length_mm * PIXELS_PER_MM) - inkstitch.write_embroidery_file(self.get_output_path(), stitch_plan, self.document.getroot()) + write_embroidery_file(self.get_output_path(), stitch_plan, self.document.getroot()) render_stitch_plan(self.document.getroot(), stitch_plan) - - -if __name__ == '__main__': - sys.setrecursionlimit(100000) - e = Embroider() - - try: - e.affect() - except KeyboardInterrupt: - # for use at the command prompt for debugging - print >> sys.stderr, "interrupted!" - print >> sys.stderr, traceback.format_exc() diff --git a/lib/extensions/input.py b/lib/extensions/input.py new file mode 100644 index 00000000..f8bf5a5d --- /dev/null +++ b/lib/extensions/input.py @@ -0,0 +1,68 @@ +import os +from os.path import realpath, dirname, join as path_join +import sys +from inkex import etree +import inkex + +# help python find libembroidery when running in a local repo clone +if getattr(sys, 'frozen', None) is None: + sys.path.append(realpath(path_join(dirname(__file__), '..', '..'))) + +from libembroidery import * + +from ..svg import PIXELS_PER_MM, render_stitch_plan +from ..svg.tags import INKSCAPE_LABEL +from ..i18n import _ +from ..stitch_plan import StitchPlan + + +class Input(object): + def pattern_stitches(self, pattern): + stitch_pointer = pattern.stitchList + while stitch_pointer: + yield stitch_pointer.stitch + stitch_pointer = stitch_pointer.next + + + def affect(self, args): + embroidery_file = args[0] + pattern = embPattern_create() + embPattern_read(pattern, embroidery_file) + embPattern_flipVertical(pattern) + + stitch_plan = StitchPlan() + color_block = None + current_color = None + + for stitch in self.pattern_stitches(pattern): + if stitch.color != current_color: + thread = embThreadList_getAt(pattern.threadList, stitch.color) + color = thread.color + color_block = stitch_plan.new_color_block((color.r, color.g, color.b)) + current_color = stitch.color + + if not stitch.flags & END: + color_block.add_stitch(stitch.xx * PIXELS_PER_MM, stitch.yy * PIXELS_PER_MM, + jump=stitch.flags & JUMP, + stop=stitch.flags & STOP, + trim=stitch.flags & TRIM) + + extents = stitch_plan.extents + svg = etree.Element("svg", nsmap=inkex.NSS, attrib= + { + "width": str(extents[0] * 2), + "height": str(extents[1] * 2), + "viewBox": "0 0 %s %s" % (extents[0] * 2, extents[1] * 2), + }) + render_stitch_plan(svg, stitch_plan) + + # rename the Stitch Plan layer so that it doesn't get overwritten by Embroider + layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") + layer.set(INKSCAPE_LABEL, os.path.basename(embroidery_file)) + layer.attrib.pop('id') + + # Shift the design so that its origin is at the center of the canvas + # Note: this is NOT the same as centering the design in the canvas! + layer.set('transform', 'translate(%s,%s)' % (extents[0], extents[1])) + + print etree.tostring(svg) diff --git a/embroider_palettes.py b/lib/extensions/palettes.py index a3b59834..f7a6c7a5 100644 --- a/embroider_palettes.py +++ b/lib/extensions/palettes.py @@ -1,6 +1,3 @@ -#!/usr/bin/python -# - import sys import traceback import os @@ -13,7 +10,8 @@ import time import logging import wx import inkex -from inkstitch.utils import guess_inkscape_config_path + +from ..utils import guess_inkscape_config_path class InstallPalettesFrame(wx.Frame): @@ -106,16 +104,9 @@ class InstallPalettesFrame(wx.Frame): for palette_file in files: shutil.copy(palette_file, dest) -class InstallPalettes(inkex.Effect): +class Palettes(inkex.Effect): def effect(self): app = wx.App() installer_frame = InstallPalettesFrame(None, title=_("Ink/Stitch Thread Palette Installer"), size=(450, 200)) installer_frame.Show() app.MainLoop() - - -if __name__ == '__main__': - #save_stderr() - effect = InstallPalettes() - effect.affect() - #restore_stderr() diff --git a/embroider_params.py b/lib/extensions/params.py index 607dbb2a..03a6f3cc 100644 --- a/embroider_params.py +++ b/lib/extensions/params.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: UTF-8 -*- import os @@ -11,15 +10,15 @@ from copy import copy import wx from wx.lib.scrolledpanel import ScrolledPanel from collections import defaultdict -import inkstitch from functools import partial from itertools import groupby -from inkstitch import _ -from inkstitch.extensions import InkstitchExtension -from inkstitch.stitch_plan import patches_to_stitch_plan -from inkstitch.elements import EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn -from inkstitch.utils import save_stderr, restore_stderr -from embroider_simulate import EmbroiderySimulator + +from .base import InkstitchExtension +from ..i18n import _ +from ..stitch_plan import patches_to_stitch_plan +from ..elements import EmbroideryElement, Fill, AutoFill, Stroke, SatinColumn +from ..utils import save_stderr, restore_stderr +from ..simulator import EmbroiderySimulator def presets_path(): @@ -633,7 +632,7 @@ class SettingsFrame(wx.Frame): self.Layout() # end wxGlade -class EmbroiderParams(InkstitchExtension): +class Params(InkstitchExtension): def __init__(self, *args, **kwargs): self.cancelled = False InkstitchExtension.__init__(self, *args, **kwargs) @@ -755,18 +754,3 @@ class EmbroiderParams(InkstitchExtension): # This prevents the superclass from outputting the SVG, because we # may have modified the DOM. sys.exit(0) - - -# end of class MyFrame -if __name__ == "__main__": - save_stderr() - - try: - e = EmbroiderParams() - e.affect() - except SystemExit: - raise - except: - traceback.print_exc() - - restore_stderr() diff --git a/embroider_print.py b/lib/extensions/print_pdf.py index 5895bc51..baeb7eba 100644 --- a/embroider_print.py +++ b/lib/extensions/print_pdf.py @@ -1,6 +1,3 @@ -#!/usr/bin/python -# - import sys import traceback import os @@ -13,24 +10,21 @@ from copy import deepcopy import wx import appdirs import json - import inkex -import inkstitch -from inkstitch import _, PIXELS_PER_MM, SVG_GROUP_TAG -from inkstitch.extensions import InkstitchExtension -from inkstitch.stitch_plan import patches_to_stitch_plan -from inkstitch.svg import render_stitch_plan -from inkstitch.utils import save_stderr, restore_stderr -from inkstitch.threads import ThreadCatalog - from jinja2 import Environment, FileSystemLoader, select_autoescape from datetime import date import base64 - from flask import Flask, request, Response, send_from_directory, jsonify import webbrowser import requests +from .base import InkstitchExtension +from ..i18n import _, translation as inkstitch_translation +from ..svg import PIXELS_PER_MM, render_stitch_plan +from ..svg.tags import SVG_GROUP_TAG +from ..stitch_plan import patches_to_stitch_plan +from ..threads import ThreadCatalog + def datetimeformat(value, format='%Y/%m/%d'): return value.strftime(format) @@ -111,7 +105,7 @@ class PrintPreviewServer(Thread): if getattr(sys, 'frozen', False): self.resources_path = os.path.join(sys._MEIPASS, 'print', 'resources') else: - self.resources_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'print', 'resources') + self.resources_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'print', 'resources')) def __setup_app(self): self.__set_resources_path() @@ -288,7 +282,7 @@ class Print(InkstitchExtension): if getattr( sys, 'frozen', False ) : template_dir = os.path.join(sys._MEIPASS, "print", "templates") else: - template_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "print", "templates") + template_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "print", "templates")) env = Environment( loader = FileSystemLoader(template_dir), @@ -297,7 +291,7 @@ class Print(InkstitchExtension): ) env.filters['datetimeformat'] = datetimeformat - env.install_gettext_translations(inkstitch.translation) + env.install_gettext_translations(inkstitch_translation) return env @@ -394,21 +388,3 @@ class Print(InkstitchExtension): info_frame = PrintInfoFrame(None, title=_("Ink/Stitch Print"), size=(450, 350), print_server=print_server) info_frame.Show() app.MainLoop() - - -if __name__ == '__main__': - exception = None - - save_stderr() - try: - effect = Print() - effect.affect() - except: - exception = traceback.format_exc() - restore_stderr() - - if exception: - print >> sys.stderr, exception - sys.exit(1) - else: - sys.exit(0) diff --git a/lib/extensions/simulate.py b/lib/extensions/simulate.py new file mode 100644 index 00000000..0c372d4d --- /dev/null +++ b/lib/extensions/simulate.py @@ -0,0 +1,28 @@ +import wx + +from .base import InkstitchExtension +from ..i18n import _ +from ..simulator import EmbroiderySimulator +from ..stitch_plan import patches_to_stitch_plan + + +class Simulate(InkstitchExtension): + def __init__(self): + InkstitchExtension.__init__(self) + self.OptionParser.add_option("-P", "--path", + action="store", type="string", + dest="path", default=".", + help="Directory in which to store output file") + + def effect(self): + if not self.get_elements(): + return + + patches = self.elements_to_patches(self.elements) + stitch_plan = patches_to_stitch_plan(patches) + app = wx.App() + frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), wx.DefaultPosition, size=(1000, 1000), stitch_plan=stitch_plan) + app.SetTopWindow(frame) + frame.Show() + wx.CallAfter(frame.go) + app.MainLoop() diff --git a/lib/i18n.py b/lib/i18n.py new file mode 100644 index 00000000..d20f5d2f --- /dev/null +++ b/lib/i18n.py @@ -0,0 +1,21 @@ +import sys +import os +import gettext + +_ = translation = None + +def localize(): + if getattr(sys, 'frozen', False): + # we are in a pyinstaller installation + locale_dir = sys._MEIPASS + else: + locale_dir = os.path.dirname(__file__) + + locale_dir = os.path.join(locale_dir, 'locales') + + global translation, _ + + translation = gettext.translation("inkstitch", locale_dir, fallback=True) + _ = translation.gettext + +localize() diff --git a/lib/output.py b/lib/output.py new file mode 100644 index 00000000..b94d7387 --- /dev/null +++ b/lib/output.py @@ -0,0 +1,131 @@ +import libembroidery +import inkex +import simpletransform +import shapely.geometry as shgeo + +from .utils import Point +from .svg import PIXELS_PER_MM, get_doc_size, get_viewbox_transform + + +def make_thread(color): + thread = libembroidery.EmbThread() + thread.color = libembroidery.embColor_make(*color.rgb) + + thread.description = color.name + thread.catalogNumber = "" + + return thread + +def add_thread(pattern, thread): + """Add a thread to a pattern and return the thread's index""" + + libembroidery.embPattern_addThread(pattern, thread) + + return libembroidery.embThreadList_count(pattern.threadList) - 1 + +def get_flags(stitch): + flags = 0 + + if stitch.jump: + flags |= libembroidery.JUMP + + if stitch.trim: + flags |= libembroidery.TRIM + + if stitch.stop: + flags |= libembroidery.STOP + + return flags + + +def _string_to_floats(string): + floats = string.split(',') + return [float(num) for num in floats] + + +def get_origin(svg): + # The user can specify the embroidery origin by defining two guides + # named "embroidery origin" that intersect. + + namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) + all_guides = namedview.findall(inkex.addNS('guide', 'sodipodi')) + label_attribute = inkex.addNS('label', 'inkscape') + guides = [guide for guide in all_guides + if guide.get(label_attribute, "").startswith("embroidery origin")] + + # document size used below + doc_size = list(get_doc_size(svg)) + + # convert the size from viewbox-relative to real-world pixels + viewbox_transform = get_viewbox_transform(svg) + simpletransform.applyTransformToPoint(simpletransform.invertTransform(viewbox_transform), doc_size) + + default = [doc_size[0] / 2.0, doc_size[1] / 2.0] + simpletransform.applyTransformToPoint(viewbox_transform, default) + default = Point(*default) + + if len(guides) < 2: + return default + + # Find out where the guides intersect. Only pay attention to the first two. + guides = guides[:2] + + lines = [] + for guide in guides: + # inkscape's Y axis is reversed from SVG's, and the guide is in inkscape coordinates + position = Point(*_string_to_floats(guide.get('position'))) + position.y = doc_size[1] - position.y + + + # This one baffles me. I think inkscape might have gotten the order of + # their vector wrong? + parts = _string_to_floats(guide.get('orientation')) + direction = Point(parts[1], parts[0]) + + # We have a theoretically infinite line defined by a point on the line + # and a vector direction. Shapely can only deal in concrete line + # segments, so we'll pick points really far in either direction on the + # line and call it good enough. + lines.append(shgeo.LineString((position + 100000 * direction, position - 100000 * direction))) + + intersection = lines[0].intersection(lines[1]) + + if isinstance(intersection, shgeo.Point): + origin = [intersection.x, intersection.y] + simpletransform.applyTransformToPoint(viewbox_transform, origin) + return Point(*origin) + else: + # Either the two guides are the same line, or they're parallel. + return default + + +def write_embroidery_file(file_path, stitch_plan, svg): + origin = get_origin(svg) + + pattern = libembroidery.embPattern_create() + + for color_block in stitch_plan: + add_thread(pattern, make_thread(color_block.color)) + + for stitch in color_block: + if stitch.stop and stitch is not color_block.last_stitch: + # A STOP stitch that is not at the end of a color block + # occurs when the user specified "STOP after". "STOP" is the + # same thing as a color change, and the user will assign a + # special color at the machine that tells it to pause after. + # We need to add another copy of the same color here so that + # the stitches after the STOP are still the same color. + add_thread(pattern, make_thread(color_block.color)) + + flags = get_flags(stitch) + libembroidery.embPattern_addStitchAbs(pattern, stitch.x - origin.x, stitch.y - origin.y, flags, 1) + + libembroidery.embPattern_addStitchAbs(pattern, stitch.x - origin.x, stitch.y - origin.y, libembroidery.END, 1) + + # convert from pixels to millimeters + libembroidery.embPattern_scale(pattern, 1/PIXELS_PER_MM) + + # SVG and embroidery disagree on the direction of the Y axis + libembroidery.embPattern_flipVertical(pattern) + + libembroidery.embPattern_write(pattern, file_path) diff --git a/embroider_simulate.py b/lib/simulator.py index c7c3f6bd..c7e74353 100644 --- a/embroider_simulate.py +++ b/lib/simulator.py @@ -1,17 +1,10 @@ import sys -import os import numpy import wx -import inkex -import simplestyle import colorsys from itertools import izip -import inkstitch -from inkstitch.extensions import InkstitchExtension -from inkstitch import PIXELS_PER_MM -from inkstitch.stitch_plan import patches_to_stitch_plan -from inkstitch.svg import color_block_to_point_lists +from .svg import PIXELS_PER_MM, color_block_to_point_lists class EmbroiderySimulator(wx.Frame): @@ -256,30 +249,3 @@ class EmbroiderySimulator(wx.Frame): self.last_pos = (x2, y2) except IndexError: self.timer.Stop() - -class SimulateEffect(InkstitchExtension): - def __init__(self): - InkstitchExtension.__init__(self) - self.OptionParser.add_option("-P", "--path", - action="store", type="string", - dest="path", default=".", - help="Directory in which to store output file") - - def effect(self): - if not self.get_elements(): - return - - patches = self.elements_to_patches(self.elements) - stitch_plan = patches_to_stitch_plan(patches) - app = wx.App() - frame = EmbroiderySimulator(None, -1, _("Embroidery Simulation"), wx.DefaultPosition, size=(1000, 1000), stitch_plan=stitch_plan) - app.SetTopWindow(frame) - frame.Show() - wx.CallAfter(frame.go) - app.MainLoop() - - -if __name__ == "__main__": - effect = SimulateEffect() - effect.affect() - sys.exit(0) diff --git a/inkstitch/stitch_plan/__init__.py b/lib/stitch_plan/__init__.py index 6c1f418a..791a5f20 100644 --- a/inkstitch/stitch_plan/__init__.py +++ b/lib/stitch_plan/__init__.py @@ -1 +1,2 @@ from stitch_plan import patches_to_stitch_plan, StitchPlan, ColorBlock +from .stitch import Stitch diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py new file mode 100644 index 00000000..6a8579c2 --- /dev/null +++ b/lib/stitch_plan/stitch.py @@ -0,0 +1,15 @@ +from ..utils.geometry import Point + + +class Stitch(Point): + def __init__(self, x, y, color=None, jump=False, stop=False, trim=False, no_ties=False): + self.x = x + self.y = y + self.color = color + self.jump = jump + self.trim = trim + self.stop = stop + self.no_ties = no_ties + + def __repr__(self): + return "Stitch(%s, %s, %s, %s, %s, %s, %s)" % (self.x, self.y, self.color, "JUMP" if self.jump else " ", "TRIM" if self.trim else " ", "STOP" if self.stop else " ", "NO TIES" if self.no_ties else " ") diff --git a/inkstitch/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index fab87876..570a7645 100644 --- a/inkstitch/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -1,8 +1,9 @@ -from .. import Stitch, PIXELS_PER_MM -from ..utils.geometry import Point +from .stitch import Stitch from .stop import process_stop from .trim import process_trim from .ties import add_ties +from ..svg import PIXELS_PER_MM +from ..utils.geometry import Point from ..threads import ThreadColor diff --git a/inkstitch/stitch_plan/stop.py b/lib/stitch_plan/stop.py index c5e9f7e4..c5e9f7e4 100644 --- a/inkstitch/stitch_plan/stop.py +++ b/lib/stitch_plan/stop.py diff --git a/inkstitch/stitch_plan/ties.py b/lib/stitch_plan/ties.py index 1207ea51..f9c5b721 100644 --- a/inkstitch/stitch_plan/ties.py +++ b/lib/stitch_plan/ties.py @@ -1,7 +1,9 @@ +from copy import deepcopy + +from .stitch import Stitch from ..utils import cut_path from ..stitches import running_stitch -from .. import Stitch -from copy import deepcopy + def add_tie(stitches, tie_path): if stitches[-1].no_ties: diff --git a/inkstitch/stitch_plan/trim.py b/lib/stitch_plan/trim.py index f692a179..f692a179 100644 --- a/inkstitch/stitch_plan/trim.py +++ b/lib/stitch_plan/trim.py diff --git a/inkstitch/stitches/__init__.py b/lib/stitches/__init__.py index d2ff0446..d2ff0446 100644 --- a/inkstitch/stitches/__init__.py +++ b/lib/stitches/__init__.py diff --git a/inkstitch/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 7f265909..518a2812 100644 --- a/inkstitch/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -1,5 +1,3 @@ -from fill import intersect_region_with_grating, row_num, stitch_row -from .. import _, PIXELS_PER_MM, Point as InkstitchPoint import sys import shapely import networkx @@ -7,6 +5,11 @@ import math from itertools import groupby from collections import deque +from .fill import intersect_region_with_grating, row_num, stitch_row +from ..i18n import _ +from ..svg import PIXELS_PER_MM +from ..utils.geometry import Point as InkstitchPoint + class MaxQueueLengthExceeded(Exception): pass diff --git a/inkstitch/stitches/fill.py b/lib/stitches/fill.py index 1b7377b0..14971cb4 100644 --- a/inkstitch/stitches/fill.py +++ b/lib/stitches/fill.py @@ -1,9 +1,10 @@ -from .. import PIXELS_PER_MM -from ..utils import cache, Point as InkstitchPoint import shapely import math import sys +from ..svg import PIXELS_PER_MM +from ..utils import cache, Point as InkstitchPoint + def legacy_fill(shape, angle, row_spacing, end_row_spacing, max_stitch_length, flip, staggers): rows_of_segments = intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing, flip) @@ -242,4 +243,3 @@ def pull_runs(rows, shape, row_spacing): count += 1 return runs - diff --git a/inkstitch/stitches/running_stitch.py b/lib/stitches/running_stitch.py index 81124339..81124339 100644 --- a/inkstitch/stitches/running_stitch.py +++ b/lib/stitches/running_stitch.py diff --git a/lib/svg/__init__.py b/lib/svg/__init__.py new file mode 100644 index 00000000..1895bba4 --- /dev/null +++ b/lib/svg/__init__.py @@ -0,0 +1,2 @@ +from .svg import color_block_to_point_lists, render_stitch_plan +from .units import * diff --git a/inkstitch/svg.py b/lib/svg/svg.py index 0728309b..3bc546e7 100644 --- a/inkstitch/svg.py +++ b/lib/svg/svg.py @@ -1,5 +1,10 @@ import simpletransform, simplestyle, inkex -from . import _, get_viewbox_transform, cache, SVG_GROUP_TAG, INKSCAPE_LABEL, INKSCAPE_GROUPMODE, SVG_PATH_TAG + +from .units import get_viewbox_transform +from .tags import SVG_GROUP_TAG, INKSCAPE_LABEL, INKSCAPE_GROUPMODE, SVG_PATH_TAG +from ..i18n import _ +from ..utils import cache + def color_block_to_point_lists(color_block): point_lists = [[]] diff --git a/lib/svg/tags.py b/lib/svg/tags.py new file mode 100644 index 00000000..fee59957 --- /dev/null +++ b/lib/svg/tags.py @@ -0,0 +1,12 @@ +import inkex + + +SVG_PATH_TAG = inkex.addNS('path', 'svg') +SVG_POLYLINE_TAG = inkex.addNS('polyline', 'svg') +SVG_DEFS_TAG = inkex.addNS('defs', 'svg') +SVG_GROUP_TAG = inkex.addNS('g', 'svg') + +INKSCAPE_LABEL = inkex.addNS('label', 'inkscape') +INKSCAPE_GROUPMODE = inkex.addNS('groupmode', 'inkscape') + +EMBROIDERABLE_TAGS = (SVG_PATH_TAG, SVG_POLYLINE_TAG) diff --git a/lib/svg/units.py b/lib/svg/units.py new file mode 100644 index 00000000..015da60e --- /dev/null +++ b/lib/svg/units.py @@ -0,0 +1,105 @@ +import simpletransform + +from ..utils import cache + +# modern versions of Inkscape use 96 pixels per inch as per the CSS standard +PIXELS_PER_MM = 96 / 25.4 + +# cribbed from inkscape-silhouette +def parse_length_with_units( str ): + + ''' + Parse an SVG value which may or may not have units attached + This version is greatly simplified in that it only allows: no units, + units of px, mm, and %. Everything else, it returns None for. + There is a more general routine to consider in scour.py if more + generality is ever needed. + ''' + + u = 'px' + s = str.strip() + if s[-2:] == 'px': + s = s[:-2] + elif s[-2:] == 'mm': + u = 'mm' + s = s[:-2] + elif s[-2:] == 'pt': + u = 'pt' + s = s[:-2] + elif s[-2:] == 'pc': + u = 'pc' + s = s[:-2] + elif s[-2:] == 'cm': + u = 'cm' + s = s[:-2] + elif s[-2:] == 'in': + u = 'in' + s = s[:-2] + elif s[-1:] == '%': + u = '%' + s = s[:-1] + try: + v = float( s ) + except: + raise ValueError(_("parseLengthWithUnits: unknown unit %s") % s) + + return v, u + + +def convert_length(length): + value, units = parse_length_with_units(length) + + if not units or units == "px": + return value + + if units == 'pt': + value /= 72 + units = 'in' + + if units == 'pc': + value /= 6 + units = 'in' + + if units == 'cm': + value *= 10 + units = 'mm' + + if units == 'mm': + value = value / 25.4 + units = 'in' + + if units == 'in': + # modern versions of Inkscape use CSS's 96 pixels per inch. When you + # open an old document, inkscape will add a viewbox for you. + return value * 96 + + raise ValueError(_("Unknown unit: %s") % units) + + +@cache +def get_doc_size(svg): + doc_width = convert_length(svg.get('width')) + doc_height = convert_length(svg.get('height')) + + return doc_width, doc_height + +@cache +def get_viewbox_transform(node): + # somewhat cribbed from inkscape-silhouette + doc_width, doc_height = get_doc_size(node) + + viewbox = node.get('viewBox').strip().replace(',', ' ').split() + + dx = -float(viewbox[0]) + dy = -float(viewbox[1]) + transform = simpletransform.parseTransform("translate(%f, %f)" % (dx, dy)) + + try: + sx = doc_width / float(viewbox[2]) + sy = doc_height / float(viewbox[3]) + scale_transform = simpletransform.parseTransform("scale(%f, %f)" % (sx, sy)) + transform = simpletransform.composeTransform(transform, scale_transform) + except ZeroDivisionError: + pass + + return transform diff --git a/inkstitch/threads/__init__.py b/lib/threads/__init__.py index 03cd777b..03cd777b 100644 --- a/inkstitch/threads/__init__.py +++ b/lib/threads/__init__.py diff --git a/inkstitch/threads/catalog.py b/lib/threads/catalog.py index cebae4ff..d9981dc6 100644 --- a/inkstitch/threads/catalog.py +++ b/lib/threads/catalog.py @@ -3,8 +3,10 @@ from os.path import dirname, realpath import sys from glob import glob from collections import Sequence + from .palette import ThreadPalette + class _ThreadCatalog(Sequence): """Holds a set of ThreadPalettes.""" diff --git a/inkstitch/threads/color.py b/lib/threads/color.py index af474127..af474127 100644 --- a/inkstitch/threads/color.py +++ b/lib/threads/color.py diff --git a/inkstitch/threads/palette.py b/lib/threads/palette.py index e1f47c7f..785fb082 100644 --- a/inkstitch/threads/palette.py +++ b/lib/threads/palette.py @@ -1,9 +1,10 @@ from collections import Set -from .color import ThreadColor from colormath.color_objects import sRGBColor, LabColor from colormath.color_conversions import convert_color from colormath.color_diff import delta_e_cie1994 +from .color import ThreadColor + def compare_thread_colors(color1, color2): # K_L=2 indicates textiles diff --git a/inkstitch/utils/__init__.py b/lib/utils/__init__.py index ff06d4a9..ff06d4a9 100644 --- a/inkstitch/utils/__init__.py +++ b/lib/utils/__init__.py diff --git a/inkstitch/utils/cache.py b/lib/utils/cache.py index 38fe8f2c..38fe8f2c 100644 --- a/inkstitch/utils/cache.py +++ b/lib/utils/cache.py diff --git a/inkstitch/utils/geometry.py b/lib/utils/geometry.py index 61b98bcb..61b98bcb 100644 --- a/inkstitch/utils/geometry.py +++ b/lib/utils/geometry.py diff --git a/inkstitch/utils/inkscape.py b/lib/utils/inkscape.py index 2d0298bc..2d0298bc 100644 --- a/inkstitch/utils/inkscape.py +++ b/lib/utils/inkscape.py diff --git a/inkstitch/utils/io.py b/lib/utils/io.py index e87b9881..be1fdf24 100644 --- a/inkstitch/utils/io.py +++ b/lib/utils/io.py @@ -2,6 +2,7 @@ import os import sys from cStringIO import StringIO + def save_stderr(): # GTK likes to spam stderr, which inkscape will show in a dialog. null = open(os.devnull, 'w') diff --git a/messages.po b/messages.po index d1968764..7b2ca815 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-04-29 21:29-0400\n" +"POT-Creation-Date: 2018-05-01 21:21-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -17,310 +17,299 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.5.3\n" -msgid "" -"\n" -"\n" -"Seeing a 'no such option' message? Please restart Inkscape to fix." +msgid "Auto-Fill" msgstr "" -msgid "Directory in which to install palettes:" +msgid "Automatically routed fill stitching" msgstr "" -msgid "Choose another directory..." +msgid "Running stitch length (traversal between sections)" msgstr "" -msgid "Install" +msgid "Underlay" msgstr "" -msgid "Cancel" +msgid "AutoFill Underlay" msgstr "" -msgid "Choose Inkscape palettes directory" +msgid "Fill angle (default: fill angle + 90 deg)" msgstr "" -msgid "Thread palette installation failed" +msgid "Row spacing (default: 3x fill row spacing)" msgstr "" -msgid "Installation Failed" +msgid "Max stitch length" msgstr "" -msgid "" -"Thread palette files have been installed. Please restart Inkscape to " -"load the new palettes." +msgid "Inset" msgstr "" -msgid "Installation Completed" +msgid "TRIM after" msgstr "" -msgid "Ink/Stitch Thread Palette Installer" +msgid "Trim thread after this object (for supported machines and file formats)" msgstr "" -msgid "These settings will be applied to 1 object." +msgid "STOP after" msgstr "" -#, python-format -msgid "These settings will be applied to %d objects." +msgid "" +"Add STOP instruction after this object (for supported machines and file " +"formats)" msgstr "" -msgid "" -"Some settings had different values across objects. Select a value from " -"the dropdown or enter a new one." +msgid "Fill" msgstr "" -#, python-format -msgid "Disabling this tab will disable the following %d tabs." +msgid "Manually routed fill stitching" msgstr "" -msgid "Disabling this tab will disable the following tab." +msgid "Angle of lines of stitches" msgstr "" -#, python-format -msgid "Enabling this tab will disable %s and vice-versa." +msgid "Flip fill (start right-to-left)" msgstr "" -msgid "Inkscape objects" +msgid "Spacing between rows" msgstr "" -msgid "Embroidery Params" +msgid "Maximum fill stitch length" msgstr "" -msgid "Presets" +msgid "Stagger rows this many times before repeating" msgstr "" -msgid "Load" +msgid "Satin Column" msgstr "" -msgid "Add" +msgid "Custom satin column" msgstr "" -msgid "Overwrite" +msgid "Zig-zag spacing (peak-to-peak)" msgstr "" -msgid "Delete" +msgid "Pull compensation" msgstr "" -msgid "Use Last Settings" +msgid "Contour underlay" msgstr "" -msgid "Apply and Quit" +msgid "Contour Underlay" msgstr "" -msgid "Preview" +msgid "Stitch length" msgstr "" -msgid "Internal Error" +msgid "Contour underlay inset amount" msgstr "" -msgid "Please enter or select a preset name first." +msgid "Center-walk underlay" msgstr "" -msgid "Preset" +msgid "Center-Walk Underlay" msgstr "" -#, python-format -msgid "Preset \"%s\" not found." +msgid "Zig-zag underlay" msgstr "" -#, python-format -msgid "" -"Preset \"%s\" already exists. Please use another name or press " -"\"Overwrite\"" +msgid "Zig-zag Underlay" msgstr "" -msgid "Closing..." +msgid "Zig-Zag spacing (peak-to-peak)" msgstr "" -msgid "It is safe to close this window now." +msgid "Inset amount (default: half of contour underlay inset)" msgstr "" msgid "" -"A print preview has been opened in your web browser. This window will " -"stay open in order to communicate with the JavaScript code running in " -"your browser.\n" -"\n" -"This window will close after you close the print preview in your browser," -" or you can close it manually if necessary." +"One or more rails crosses itself, and this is not allowed. Please split " +"into multiple satin columns." msgstr "" -msgid "Ink/Stitch Print" +msgid "satin column: One or more of the rungs doesn't intersect both rails." msgstr "" -msgid "Embroidery Simulation" +msgid "Each rail should intersect both rungs once." msgstr "" -#, python-format -msgid "parseLengthWithUnits: unknown unit %s" +msgid "" +"satin column: One or more of the rungs intersects the rails more than " +"once." msgstr "" #, python-format -msgid "Unknown unit: %s" -msgstr "" - -msgid "No embroiderable paths selected." -msgstr "" - -msgid "No embroiderable paths found in document." +msgid "satin column: object %s has a fill (but should not)" msgstr "" -msgid "Tip: use Path -> Object to Path to convert non-paths before embroidering." +#, python-format +msgid "" +"satin column: object %(id)s has two paths with an unequal number of " +"points (%(length1)d and %(length2)d)" msgstr "" -msgid "Stitch Plan" +msgid "Satin stitch along paths" msgstr "" -msgid "Auto-Fill" +msgid "Running stitch length" msgstr "" -msgid "Automatically routed fill stitching" +msgid "Repeats" msgstr "" -msgid "Running stitch length (traversal between sections)" +msgid "Manual stitch placement" msgstr "" -msgid "Underlay" +msgid "" +"Stitch every node in the path. Stitch length and zig-zag spacing are " +"ignored." msgstr "" -msgid "AutoFill Underlay" +msgid "" +"Legacy running stitch setting detected!\n" +"\n" +"It looks like you're using a stroke smaller than 0.5 units to indicate a " +"running stitch, which is deprecated. Instead, please set your stroke to " +"be dashed to indicate running stitch. Any kind of dash will work." msgstr "" -msgid "Fill angle (default: fill angle + 90 deg)" +msgid "No embroiderable paths selected." msgstr "" -msgid "Row spacing (default: 3x fill row spacing)" +msgid "No embroiderable paths found in document." msgstr "" -msgid "Max stitch length" +msgid "Tip: use Path -> Object to Path to convert non-paths before embroidering." msgstr "" -msgid "Inset" +msgid "" +"\n" +"\n" +"Seeing a 'no such option' message? Please restart Inkscape to fix." msgstr "" -msgid "TRIM after" +msgid "Directory in which to install palettes:" msgstr "" -msgid "Trim thread after this object (for supported machines and file formats)" +msgid "Choose another directory..." msgstr "" -msgid "STOP after" +msgid "Install" msgstr "" -msgid "" -"Add STOP instruction after this object (for supported machines and file " -"formats)" +msgid "Cancel" msgstr "" -msgid "Fill" +msgid "Choose Inkscape palettes directory" msgstr "" -msgid "Manually routed fill stitching" +msgid "Thread palette installation failed" msgstr "" -msgid "Angle of lines of stitches" +msgid "Installation Failed" msgstr "" -msgid "Flip fill (start right-to-left)" +msgid "" +"Thread palette files have been installed. Please restart Inkscape to " +"load the new palettes." msgstr "" -msgid "Spacing between rows" +msgid "Installation Completed" msgstr "" -msgid "Maximum fill stitch length" +msgid "Ink/Stitch Thread Palette Installer" msgstr "" -msgid "Stagger rows this many times before repeating" +msgid "These settings will be applied to 1 object." msgstr "" -msgid "Satin Column" +#, python-format +msgid "These settings will be applied to %d objects." msgstr "" -msgid "Custom satin column" +msgid "" +"Some settings had different values across objects. Select a value from " +"the dropdown or enter a new one." msgstr "" -msgid "Zig-zag spacing (peak-to-peak)" +#, python-format +msgid "Disabling this tab will disable the following %d tabs." msgstr "" -msgid "Pull compensation" +msgid "Disabling this tab will disable the following tab." msgstr "" -msgid "Contour underlay" +#, python-format +msgid "Enabling this tab will disable %s and vice-versa." msgstr "" -msgid "Contour Underlay" +msgid "Inkscape objects" msgstr "" -msgid "Stitch length" +msgid "Embroidery Params" msgstr "" -msgid "Contour underlay inset amount" +msgid "Presets" msgstr "" -msgid "Center-walk underlay" +msgid "Load" msgstr "" -msgid "Center-Walk Underlay" +msgid "Add" msgstr "" -msgid "Zig-zag underlay" +msgid "Overwrite" msgstr "" -msgid "Zig-zag Underlay" +msgid "Delete" msgstr "" -msgid "Zig-Zag spacing (peak-to-peak)" +msgid "Use Last Settings" msgstr "" -msgid "Inset amount (default: half of contour underlay inset)" +msgid "Apply and Quit" msgstr "" -msgid "" -"One or more rails crosses itself, and this is not allowed. Please split " -"into multiple satin columns." +msgid "Preview" msgstr "" -msgid "satin column: One or more of the rungs doesn't intersect both rails." +msgid "Internal Error" msgstr "" -msgid "Each rail should intersect both rungs once." +msgid "Please enter or select a preset name first." msgstr "" -msgid "" -"satin column: One or more of the rungs intersects the rails more than " -"once." +msgid "Preset" msgstr "" #, python-format -msgid "satin column: object %s has a fill (but should not)" +msgid "Preset \"%s\" not found." msgstr "" #, python-format msgid "" -"satin column: object %(id)s has two paths with an unequal number of " -"points (%(length1)d and %(length2)d)" -msgstr "" - -msgid "Satin stitch along paths" +"Preset \"%s\" already exists. Please use another name or press " +"\"Overwrite\"" msgstr "" -msgid "Running stitch length" +msgid "Closing..." msgstr "" -msgid "Repeats" +msgid "It is safe to close this window now." msgstr "" -msgid "Manual stitch placement" +msgid "" +"A print preview has been opened in your web browser. This window will " +"stay open in order to communicate with the JavaScript code running in " +"your browser.\n" +"\n" +"This window will close after you close the print preview in your browser," +" or you can close it manually if necessary." msgstr "" -msgid "" -"Stitch every node in the path. Stitch length and zig-zag spacing are " -"ignored." +msgid "Ink/Stitch Print" msgstr "" -msgid "" -"Legacy running stitch setting detected!\n" -"\n" -"It looks like you're using a stroke smaller than 0.5 units to indicate a " -"running stitch, which is deprecated. Instead, please set your stroke to " -"be dashed to indicate running stitch. Any kind of dash will work." +msgid "Embroidery Simulation" msgstr "" msgid "" @@ -333,6 +322,17 @@ msgid "" "file to lexelby@github." msgstr "" +msgid "Stitch Plan" +msgstr "" + +#, python-format +msgid "parseLengthWithUnits: unknown unit %s" +msgstr "" + +#, python-format +msgid "Unknown unit: %s" +msgstr "" + msgid "Color" msgstr "" diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index daa2cf4b..67690df2 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -300,7 +300,7 @@ $(function() { // Logo $('#logo-picker').change(function(e) { - var file = e.originalEvent.srcElement.files[0]; + var file = e.originalEvent.currentTarget.files[0]; var reader = new FileReader(); reader.onloadend = function() { var data = reader.result; diff --git a/requirements.txt b/requirements.txt index 450786cd..314a2b0e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,8 +6,11 @@ lxml appdirs numpy jinja2 -flask requests +colormath + +# We're not ready for flask 1.0 yet. Logging changed, among othe things. +flask==0.* + pywinutils; sys.platform == 'win32' pywin32; sys.platform == 'win32' -colormath diff --git a/templates/embroider_input.inx b/templates/embroider_input.inx index 3af8f79e..24bba7e4 100644 --- a/templates/embroider_input.inx +++ b/templates/embroider_input.inx @@ -2,7 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>{{ format | upper }} file input</_name> <id>org.inkstitch.input.{{ format }}</id> - <dependency type="executable" location="extensions">embroider_input.py</dependency> + <dependency type="executable" location="extensions">inkstitch.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> <input> <extension>.{{ format }}</extension> @@ -10,8 +10,9 @@ <_filetypename>Ink/Stitch: {{ description }} (.{{ format }})</_filetypename> <_filetypetooltip>convert {{ format | upper }} file to Ink/Stitch manual-stitch paths</_filetypetooltip> </input> + <param name="extension" type="string" gui-hidden="true">input</param> <script> - <command reldir="extensions" interpreter="python">embroider_input.py</command> + <command reldir="extensions" interpreter="python">inkstitch.py</command> </script> </inkscape-extension> |
