summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2021-08-07 10:58:02 -0400
committerLex Neva <github.com@lexneva.name>2021-08-07 10:58:02 -0400
commit12ef0c84aa732623b210fdce1a7b8301aa435217 (patch)
tree4c7fbb33c4840be4bf8d8fecfd7fe481d0e56895 /lib/elements
parentc1e6558f7852def419adfbeb087b2194e6030a2c (diff)
parentd6e20fae8a03ac162ae0c863fff06b5bd8b77902 (diff)
Merge remote-tracking branch 'origin/main' into kaalleen/satin-patterns
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/auto_fill.py4
-rw-r--r--lib/elements/element.py39
-rw-r--r--lib/elements/empty_d_object.py4
-rw-r--r--lib/elements/satin_column.py2
-rw-r--r--lib/elements/stroke.py2
-rw-r--r--lib/elements/validation.py3
6 files changed, 16 insertions, 38 deletions
diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py
index 29ca3545..3c13a081 100644
--- a/lib/elements/auto_fill.py
+++ b/lib/elements/auto_fill.py
@@ -11,6 +11,7 @@ from shapely import geometry as shgeo
from ..i18n import _
from ..stitches import auto_fill
+from ..svg.tags import INKSCAPE_LABEL
from ..utils import cache, version
from .element import StitchGroup, param
from .fill import Fill
@@ -264,7 +265,8 @@ class AutoFill(Fill):
def validation_warnings(self):
if self.shape.area < 20:
- yield SmallShapeWarning(self.shape.centroid)
+ label = self.node.get(INKSCAPE_LABEL) or self.node.get("id")
+ yield SmallShapeWarning(self.shape.centroid, label)
if self.shrink_or_grow_shape(self.expand, True).is_empty:
yield ExpandWarning(self.shape.centroid)
diff --git a/lib/elements/element.py b/lib/elements/element.py
index bcb59bf4..17ed9167 100644
--- a/lib/elements/element.py
+++ b/lib/elements/element.py
@@ -7,7 +7,6 @@ import sys
from copy import deepcopy
import inkex
-import tinycss2
from inkex import bezier
from ..commands import find_commands
@@ -15,8 +14,7 @@ from ..i18n import _
from ..patterns import apply_patterns
from ..svg import (PIXELS_PER_MM, apply_transforms, convert_length,
get_node_transform)
-from ..svg.tags import (EMBROIDERABLE_TAGS, INKSCAPE_LABEL, INKSTITCH_ATTRIBS,
- SVG_GROUP_TAG, SVG_LINK_TAG, SVG_USE_TAG)
+from ..svg.tags import INKSCAPE_LABEL, INKSTITCH_ATTRIBS
from ..utils import Point, cache
@@ -96,7 +94,7 @@ class EmbroideryElement(object):
elif legacy_tie == "False":
self.set_param('ties', 3)
- # defaut setting for fill_underlay has changed
+ # default setting for fill_underlay has changed
if legacy_attribs and not self.get_param('fill_underlay', ""):
self.set_param('fill_underlay', False)
@@ -166,37 +164,12 @@ class EmbroideryElement(object):
self.node.set(param, str(value))
@cache
- def parse_style(self, node=None):
- if node is None:
- node = self.node
- element_style = node.get("style", "")
- if element_style is None:
- return None
- declarations = tinycss2.parse_declaration_list(node.get("style", ""))
- style = {declaration.lower_name: declaration.value[0].serialize() for declaration in declarations}
- return style
-
- @cache
- def _get_style_raw(self, style_name):
- if self.node is None:
- return None
- if self.node.tag not in [SVG_GROUP_TAG, SVG_LINK_TAG, SVG_USE_TAG] and self.node.tag not in EMBROIDERABLE_TAGS:
- return None
-
- style = self.parse_style()
- if style:
- style = style.get(style_name) or self.node.get(style_name)
- parent = self.node.getparent()
- # style not found, get inherited style elements
- while not style and parent is not None:
- style = self.parse_style(parent)
- if style:
- style = style.get(style_name) or parent.get(style_name)
- parent = parent.getparent()
- return style
+ def _get_specified_style(self):
+ # We want to cache this, because it's quite expensive to generate.
+ return self.node.specified_style()
def get_style(self, style_name, default=None):
- style = self._get_style_raw(style_name) or default
+ style = self._get_specified_style().get(style_name, default)
if style == 'none':
style = None
return style
diff --git a/lib/elements/empty_d_object.py b/lib/elements/empty_d_object.py
index dbb43bc4..19fb58a4 100644
--- a/lib/elements/empty_d_object.py
+++ b/lib/elements/empty_d_object.py
@@ -4,6 +4,7 @@
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
from ..i18n import _
+from ..svg.tags import INKSCAPE_LABEL
from .element import EmbroideryElement
from .validation import ObjectTypeWarning
@@ -19,7 +20,8 @@ class EmptyD(ObjectTypeWarning):
class EmptyDObject(EmbroideryElement):
def validation_warnings(self):
- yield EmptyD((0, 0))
+ label = self.node.get(INKSCAPE_LABEL) or self.node.get("id")
+ yield EmptyD((0, 0), label)
def to_patches(self, last_patch):
return []
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 3d0e7ff5..1f28cb45 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -790,7 +790,7 @@ class SatinColumn(EmbroideryElement):
sides = self.plot_points_on_rails(self.zigzag_spacing, self.pull_compensation)
# "left" and "right" here are kind of arbitrary designations meaning
- # a point from the first and second rail repectively
+ # a point from the first and second rail respectively
for left, right in zip(*sides):
patch.add_stitch(left)
patch.add_stitch(right)
diff --git a/lib/elements/stroke.py b/lib/elements/stroke.py
index edd5525a..76e80688 100644
--- a/lib/elements/stroke.py
+++ b/lib/elements/stroke.py
@@ -132,7 +132,7 @@ class Stroke(EmbroideryElement):
# want to see if they set a running stitch length at all, and the property will apply
# a default value.
#
- # Thsi is so tricky, and and intricate that's a major reason that we deprecated the
+ # This is so tricky, and and intricate that's a major reason that we deprecated the
# 0.5 units rule.
# Warn them the first time.
diff --git a/lib/elements/validation.py b/lib/elements/validation.py
index c14b634c..9ac8e745 100644
--- a/lib/elements/validation.py
+++ b/lib/elements/validation.py
@@ -25,11 +25,12 @@ class ValidationMessage(object):
description = None
steps_to_solve = []
- def __init__(self, position=None):
+ def __init__(self, position=None, label=""):
if isinstance(position, ShapelyPoint):
position = (position.x, position.y)
self.position = InkstitchPoint(*position)
+ self.label = label
class ValidationError(ValidationMessage):