From 36815f977d7236311e9b345c33fbc74390766385 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Wed, 21 Jul 2021 17:25:11 +0200 Subject: label hard to find troubleshoot objects (#1247) --- lib/elements/auto_fill.py | 4 +++- lib/elements/empty_d_object.py | 4 +++- lib/elements/validation.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/auto_fill.py b/lib/elements/auto_fill.py index 69533f62..cf7a44a7 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 Patch, 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/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/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): -- cgit v1.2.3 From 2f35a4a192eb6aa3b68b715da6c1ba984084e0e5 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 25 Jul 2021 07:24:34 +0200 Subject: Fix Style Issues (#1154) Co-authored-by: Lex Neva --- lib/elements/element.py | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/element.py b/lib/elements/element.py index 9b894d89..670b05d8 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -7,15 +7,13 @@ import sys from copy import deepcopy import inkex -import tinycss2 from inkex import bezier from ..commands import find_commands from ..i18n import _ 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 @@ -165,37 +163,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 -- cgit v1.2.3 From e6fad808e9459ed6211c5ee04f3f1a00b786fa7a Mon Sep 17 00:00:00 2001 From: luzpaz Date: Thu, 29 Jul 2021 14:52:44 -0400 Subject: Fix typos (#1291) --- lib/elements/element.py | 2 +- lib/elements/satin_column.py | 2 +- lib/elements/stroke.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/elements') diff --git a/lib/elements/element.py b/lib/elements/element.py index 670b05d8..0b001f0b 100644 --- a/lib/elements/element.py +++ b/lib/elements/element.py @@ -93,7 +93,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) diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index 778fc88a..d72680b7 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -779,7 +779,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 cf034d21..39a8f6e3 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. -- cgit v1.2.3