kopia lustrzana https://github.com/inkstitch/inkstitch
add stitch plan extension (#640)
rodzic
660c3f2cfa
commit
88ba830a99
|
@ -15,10 +15,11 @@ from params import Params
|
|||
from print_pdf import Print
|
||||
from remove_embroidery_settings import RemoveEmbroiderySettings
|
||||
from simulate import Simulate
|
||||
from stitch_plan_preview import StitchPlanPreview
|
||||
from zip import Zip
|
||||
|
||||
|
||||
__all__ = extensions = [Embroider,
|
||||
StitchPlanPreview,
|
||||
Install,
|
||||
Params,
|
||||
Print,
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
from ..stitch_plan import patches_to_stitch_plan
|
||||
from ..svg import render_stitch_plan
|
||||
from .base import InkstitchExtension
|
||||
|
||||
|
||||
class StitchPlanPreview(InkstitchExtension):
|
||||
|
||||
def effect(self):
|
||||
# delete old stitch plan
|
||||
svg = self.document.getroot()
|
||||
layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']")
|
||||
if layer is not None:
|
||||
del layer[:]
|
||||
|
||||
# create new stitch plan
|
||||
if not self.get_elements():
|
||||
return
|
||||
patches = self.elements_to_patches(self.elements)
|
||||
stitch_plan = patches_to_stitch_plan(patches)
|
||||
render_stitch_plan(svg, stitch_plan)
|
||||
|
||||
# translate stitch plan to the right side of the canvas
|
||||
layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']")
|
||||
layer.set('transform', 'translate(%s)' % svg.get('viewBox', '0 0 800 0').split(' ')[2])
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
|
||||
<name>{% trans %}Stitch Plan Preview{% endtrans %}</name>
|
||||
<id>org.inkstitch.stitch_plan_preview.{{ locale }}</id>
|
||||
<param name="extension" type="string" gui-hidden="true">stitch_plan_preview</param>
|
||||
<effect>
|
||||
<object-type>all</object-type>
|
||||
<effects-menu>
|
||||
<submenu name="Ink/Stitch" />
|
||||
</effects-menu>
|
||||
</effect>
|
||||
<script>
|
||||
{{ command_tag | safe }}
|
||||
</script>
|
||||
</inkscape-extension>
|
Ładowanie…
Reference in New Issue