summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/auto_fill.py118
-rw-r--r--lib/elements/clone.py5
-rw-r--r--lib/elements/element.py22
-rw-r--r--lib/elements/utils.py5
4 files changed, 81 insertions, 69 deletions
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 87bdb010..81abf7ad 100644
--- a/lib/elements/auto_fill.py
+++ b/lib/elements/auto_fill.py
@@ -12,7 +12,6 @@ import inkex
from shapely import geometry as shgeo
from shapely.validation import explain_validity
-from ..stitches import legacy_fill
from ..i18n import _
from ..stitch_plan import StitchGroup
from ..stitches import auto_fill
@@ -21,12 +20,12 @@ from ..utils import cache, version
from .element import param
from .element import EmbroideryElement
from ..patterns import get_patterns
-#from .fill import Fill
from .validation import ValidationWarning
from ..utils import Point as InkstitchPoint
from ..svg import PIXELS_PER_MM
from ..svg.tags import INKSCAPE_LABEL
+
class SmallShapeWarning(ValidationWarning):
name = _("Small Fill")
description = _("This fill object is so small that it would probably look better as running stitch or satin column. "
@@ -50,38 +49,42 @@ class AutoFill(EmbroideryElement):
element_name = _("AutoFill")
@property
- @param('auto_fill', _('Automatically routed fill stitching'), type='toggle', default=True, sort_index = 1)
+ @param('auto_fill', _('Automatically routed fill stitching'), type='toggle', default=True, sort_index=1)
def auto_fill2(self):
- return self.get_boolean_param('auto_fill', True)
-
+ return self.get_boolean_param('auto_fill', True)
+
@property
- @param('fill_method', _('Fill method'), type='dropdown', default=0, options=[_("Auto Fill"), _("Tangential"), _("Guided Auto Fill")], sort_index = 2)
+ @param('fill_method', _('Fill method'), type='dropdown', default=0,
+ options=[_("Auto Fill"), _("Tangential"), _("Guided Auto Fill")], sort_index=2)
def fill_method(self):
return self.get_int_param('fill_method', 0)
@property
- @param('tangential_strategy', _('Tangential strategy'), type='dropdown', default=1, options=[_("Closest point"), _("Inner to Outer")],select_items=[('fill_method',1)], sort_index = 2)
+ @param('tangential_strategy', _('Tangential strategy'), type='dropdown', default=1,
+ options=[_("Closest point"), _("Inner to Outer")], select_items=[('fill_method', 1)], sort_index=2)
def tangential_strategy(self):
return self.get_int_param('tangential_strategy', 1)
@property
- @param('join_style', _('Join Style'), type='dropdown', default=0, options=[_("Round"), _("Mitered"), _("Beveled")],select_items=[('fill_method',1)], sort_index = 2)
+ @param('join_style', _('Join Style'), type='dropdown', default=0,
+ options=[_("Round"), _("Mitered"), _("Beveled")], select_items=[('fill_method', 1)], sort_index=2)
def join_style(self):
return self.get_int_param('join_style', 0)
@property
- @param('interlaced', _('Interlaced'), type='boolean', default=True,select_items=[('fill_method',1),('fill_method',2)], sort_index = 2)
+ @param('interlaced', _('Interlaced'), type='boolean', default=True, select_items=[('fill_method', 1), ('fill_method', 2)], sort_index=2)
def interlaced(self):
return self.get_boolean_param('interlaced', True)
@property
@param('angle',
_('Angle of lines of stitches'),
- tooltip=_('The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'),
+ tooltip=_(
+ 'The angle increases in a counter-clockwise direction. 0 is horizontal. Negative angles are allowed.'),
unit='deg',
type='float',
- sort_index = 4,
- select_items=[('fill_method',0)],
+ sort_index=4,
+ select_items=[('fill_method', 0)],
default=0)
@cache
def angle(self):
@@ -99,8 +102,8 @@ class AutoFill(EmbroideryElement):
tooltip=_('The last stitch in each row is quite close to the first stitch in the next row. '
'Skipping it decreases stitch count and density.'),
type='boolean',
- sort_index = 4,
- select_items=[('fill_method',0), ('fill_method',2)],
+ sort_index=4,
+ select_items=[('fill_method', 0), ('fill_method', 2)],
default=False)
def skip_last(self):
return self.get_boolean_param("skip_last", False)
@@ -112,8 +115,8 @@ class AutoFill(EmbroideryElement):
tooltip=_('The flip option can help you with routing your stitch path. '
'When you enable flip, stitching goes from right-to-left instead of left-to-right.'),
type='boolean',
- sort_index = 4,
- select_items=[('fill_method',0), ('fill_method',2)],
+ sort_index=4,
+ select_items=[('fill_method', 0), ('fill_method', 2)],
default=False)
def flip(self):
return self.get_boolean_param("flip", False)
@@ -123,7 +126,7 @@ class AutoFill(EmbroideryElement):
_('Spacing between rows'),
tooltip=_('Distance between rows of stitches.'),
unit='mm',
- sort_index = 4,
+ sort_index=4,
type='float',
default=0.25)
def row_spacing(self):
@@ -136,9 +139,10 @@ class AutoFill(EmbroideryElement):
@property
@param('max_stitch_length_mm',
_('Maximum fill stitch length'),
- tooltip=_('The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'),
+ tooltip=_(
+ 'The length of each stitch in a row. Shorter stitch may be used at the start or end of a row.'),
unit='mm',
- sort_index = 4,
+ sort_index=4,
type='float',
default=3.0)
def max_stitch_length(self):
@@ -147,10 +151,11 @@ class AutoFill(EmbroideryElement):
@property
@param('staggers',
_('Stagger rows this many times before repeating'),
- tooltip=_('Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'),
+ tooltip=_(
+ 'Setting this dictates how many rows apart the stitches will be before they fall in the same column position.'),
type='int',
- sort_index = 4,
- select_items=[('fill_method',0)],
+ sort_index=4,
+ select_items=[('fill_method', 0)],
default=4)
def staggers(self):
return max(self.get_int_param("staggers", 4), 1)
@@ -162,10 +167,10 @@ class AutoFill(EmbroideryElement):
# ensure path length
for i, path in enumerate(paths):
if len(path) < 3:
- paths[i] = [(path[0][0], path[0][1]), (path[0][0]+1.0, path[0][1]), (path[0][0], path[0][1]+1.0)]
+ paths[i] = [(path[0][0], path[0][1]), (path[0][0] +
+ 1.0, path[0][1]), (path[0][0], path[0][1]+1.0)]
return paths
-
@property
@cache
def outline(self):
@@ -177,18 +182,15 @@ class AutoFill(EmbroideryElement):
return self.outline.length
@property
- def flip(self):
- return False
-
- @property
@param('running_stitch_length_mm',
_('Running stitch length (traversal between sections)'),
- tooltip=_('Length of stitches around the outline of the fill region used when moving from section to section.'),
+ tooltip=_(
+ 'Length of stitches around the outline of the fill region used when moving from section to section.'),
unit='mm',
type='float',
default=1.5,
- select_items=[('fill_method',0),('fill_method',2)],
- sort_index = 4)
+ select_items=[('fill_method', 0), ('fill_method', 2)],
+ sort_index=4)
def running_stitch_length(self):
return max(self.get_float_param("running_stitch_length_mm", 1.5), 0.01)
@@ -200,7 +202,8 @@ class AutoFill(EmbroideryElement):
@property
@param('fill_underlay_angle',
_('Fill angle'),
- tooltip=_('Default: fill angle + 90 deg. Insert comma-seperated list for multiple layers.'),
+ tooltip=_(
+ 'Default: fill angle + 90 deg. Insert comma-seperated list for multiple layers.'),
unit='deg',
group=_('AutoFill Underlay'),
type='float')
@@ -211,7 +214,8 @@ class AutoFill(EmbroideryElement):
if underlay_angles is not None:
underlay_angles = underlay_angles.strip().split(',')
try:
- underlay_angles = [math.radians(float(angle)) for angle in underlay_angles]
+ underlay_angles = [math.radians(
+ float(angle)) for angle in underlay_angles]
except (TypeError, ValueError):
return default_value
else:
@@ -243,7 +247,8 @@ class AutoFill(EmbroideryElement):
@property
@param('fill_underlay_inset_mm',
_('Inset'),
- tooltip=_('Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'),
+ tooltip=_(
+ 'Shrink the shape before doing underlay, to prevent underlay from showing around the outside of the fill.'),
unit='mm',
group=_('AutoFill Underlay'),
type='float',
@@ -266,12 +271,13 @@ class AutoFill(EmbroideryElement):
@property
@param('expand_mm',
_('Expand'),
- tooltip=_('Expand the shape before fill stitching, to compensate for gaps between shapes.'),
+ tooltip=_(
+ 'Expand the shape before fill stitching, to compensate for gaps between shapes.'),
unit='mm',
type='float',
default=0,
- sort_index = 5,
- select_items=[('fill_method',0),('fill_method',2)])
+ sort_index=5,
+ select_items=[('fill_method', 0), ('fill_method', 2)])
def expand(self):
return self.get_float_param('expand_mm', 0)
@@ -283,8 +289,8 @@ class AutoFill(EmbroideryElement):
'are not visible. This gives them a jagged appearance.'),
type='boolean',
default=True,
- select_items=[('fill_method',0),('fill_method',2)],
- sort_index = 6)
+ select_items=[('fill_method', 0), ('fill_method', 2)],
+ sort_index=6)
def underpath(self):
return self.get_boolean_param('underpath', True)
@@ -308,7 +314,8 @@ class AutoFill(EmbroideryElement):
# from the first. So let's at least make sure the "first" thing is the
# biggest path.
paths = self.paths
- paths.sort(key=lambda point_list: shgeo.Polygon(point_list).area, reverse=True)
+ paths.sort(key=lambda point_list: shgeo.Polygon(
+ point_list).area, reverse=True)
# Very small holes will cause a shape to be rendered as an outline only
# they are too small to be rendered and only confuse the auto_fill algorithm.
# So let's ignore them
@@ -397,7 +404,7 @@ class AutoFill(EmbroideryElement):
color=self.color,
tags=("auto_fill", "auto_fill_underlay"),
stitches=auto_fill(
- self.underlay_shape,
+ self.underlay_shape,
None,
self.fill_underlay_angle[i],
self.fill_underlay_row_spacing,
@@ -410,8 +417,8 @@ class AutoFill(EmbroideryElement):
underpath=self.underlay_underpath))
stitch_groups.append(underlay)
starting_point = underlay.stitches[-1]
-
- if self.fill_method == 0: #Auto Fill
+
+ if self.fill_method == 0: # Auto Fill
stitch_group = StitchGroup(
color=self.color,
tags=("auto_fill", "auto_fill_top"),
@@ -429,30 +436,31 @@ class AutoFill(EmbroideryElement):
ending_point,
self.underpath))
stitch_groups.append(stitch_group)
- elif self.fill_method == 1: #Tangential Fill
+ elif self.fill_method == 1: # Tangential Fill
polygons = list(self.fill_shape)
if not starting_point:
- starting_point = (0,0)
+ starting_point = (0, 0)
for poly in polygons:
connectedLine, connectedLineOrigin = StitchPattern.offset_poly(
- poly,
- -self.row_spacing,
- self.join_style+1,
- self.max_stitch_length,
+ poly,
+ -self.row_spacing,
+ self.join_style+1,
+ self.max_stitch_length,
self.interlaced,
self.tangential_strategy,
shgeo.Point(starting_point))
path = [InkstitchPoint(*p) for p in connectedLine]
stitch_group = StitchGroup(
- color=self.color,
- tags=("auto_fill", "auto_fill_top"),
- stitches=path)
+ color=self.color,
+ tags=("auto_fill", "auto_fill_top"),
+ stitches=path)
stitch_groups.append(stitch_group)
- elif self.fill_method == 2: #Guided Auto Fill
- lines = get_patterns(self.node,"#inkstitch-guide-line-marker")
+ elif self.fill_method == 2: # Guided Auto Fill
+ lines = get_patterns(self.node, "#inkstitch-guide-line-marker")
lines = lines['stroke_patterns']
if not lines or lines[0].is_empty:
- inkex.errormsg(_("No line marked as guide line found within the same group as patch"))
+ inkex.errormsg(
+ _("No line marked as guide line found within the same group as patch"))
else:
stitch_group = StitchGroup(
color=self.color,
diff --git a/lib/elements/clone.py b/lib/elements/clone.py
index bcecf3f0..15e7591c 100644
--- a/lib/elements/clone.py
+++ b/lib/elements/clone.py
@@ -14,7 +14,6 @@ from ..svg.tags import (EMBROIDERABLE_TAGS, INKSTITCH_ATTRIBS,
from ..utils import cache
from .auto_fill import AutoFill
from .element import EmbroideryElement, param
-#from .fill import Fill
from .polyline import Polyline
from .satin_column import SatinColumn
from .stroke import Stroke
@@ -79,9 +78,9 @@ class Clone(EmbroideryElement):
else:
elements = []
if element.get_style("fill", "black") and not element.get_style("stroke", 1) == "0":
- #if element.get_boolean_param("auto_fill", True):
+ # if element.get_boolean_param("auto_fill", True):
elements.append(AutoFill(node))
- #else:
+ # else:
# elements.append(Fill(node))
if element.get_style("stroke", self.node) is not None:
if not is_command(element.node):
diff --git a/lib/elements/element.py b/lib/elements/element.py
index b8728f60..ef70510d 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -33,7 +33,6 @@ class Param(object):
self.tooltip = tooltip
self.sort_index = sort_index
self.select_items = select_items
- #print("IN PARAM: ", self.values)
def __repr__(self):
return "Param(%s)" % vars(self)
@@ -164,7 +163,8 @@ class EmbroideryElement(object):
# Of course, transforms may also involve rotation, skewing, and translation.
# All except translation can affect how wide the stroke appears on the screen.
- node_transform = inkex.transforms.Transform(get_node_transform(self.node))
+ node_transform = inkex.transforms.Transform(
+ get_node_transform(self.node))
# First, figure out the translation component of the transform. Using a zero
# vector completely cancels out the rotation, scale, and skew components.
@@ -198,7 +198,8 @@ class EmbroideryElement(object):
@property
@param('ties',
_('Allow lock stitches'),
- tooltip=_('Tie thread at the beginning and/or end of this object. Manual stitch will not add lock stitches.'),
+ tooltip=_(
+ 'Tie thread at the beginning and/or end of this object. Manual stitch will not add lock stitches.'),
type='dropdown',
# Ties: 0 = Both | 1 = Before | 2 = After | 3 = Neither
# L10N options to allow lock stitch before and after objects
@@ -256,7 +257,8 @@ class EmbroideryElement(object):
d = self.node.get("d", "")
if not d:
- self.fatal(_("Object %(id)s has an empty 'd' attribute. Please delete this object from your document.") % dict(id=self.node.get("id")))
+ self.fatal(_("Object %(id)s has an empty 'd' attribute. Please delete this object from your document.") % dict(
+ id=self.node.get("id")))
return inkex.paths.Path(d).to_superpath()
@@ -266,7 +268,8 @@ class EmbroideryElement(object):
@property
def shape(self):
- raise NotImplementedError("INTERNAL ERROR: %s must implement shape()", self.__class__)
+ raise NotImplementedError(
+ "INTERNAL ERROR: %s must implement shape()", self.__class__)
@property
@cache
@@ -316,7 +319,8 @@ class EmbroideryElement(object):
return self.get_boolean_param('stop_after', False)
def to_stitch_groups(self, last_patch):
- raise NotImplementedError("%s must implement to_stitch_groups()" % self.__class__.__name__)
+ raise NotImplementedError(
+ "%s must implement to_stitch_groups()" % self.__class__.__name__)
def embroider(self, last_patch):
self.validate()
@@ -329,8 +333,10 @@ class EmbroideryElement(object):
patch.force_lock_stitches = self.force_lock_stitches
if patches:
- patches[-1].trim_after = self.has_command("trim") or self.trim_after
- patches[-1].stop_after = self.has_command("stop") or self.stop_after
+ patches[-1].trim_after = self.has_command(
+ "trim") or self.trim_after
+ patches[-1].stop_after = self.has_command(
+ "stop") or self.stop_after
return patches
diff --git a/lib/elements/utils.py b/lib/elements/utils.py
index f858cc81..9fec8b63 100644
--- a/lib/elements/utils.py
+++ b/lib/elements/utils.py
@@ -11,7 +11,6 @@ from .auto_fill import AutoFill
from .clone import Clone, is_clone
from .element import EmbroideryElement
from .empty_d_object import EmptyDObject
-#from .fill import Fill
from .image import ImageObject
from .pattern import PatternObject
from .polyline import Polyline
@@ -41,9 +40,9 @@ def node_to_elements(node): # noqa: C901
else:
elements = []
if element.get_style("fill", "black") and not element.get_style('fill-opacity', 1) == "0":
- #if element.get_boolean_param("auto_fill", True):
+ # if element.get_boolean_param("auto_fill", True):
elements.append(AutoFill(node))
- #else:
+ # else:
# elements.append(Fill(node))
if element.get_style("stroke"):
if not is_command(element.node):