summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
Diffstat (limited to 'lib/elements')
-rw-r--r--lib/elements/pattern.py4
-rw-r--r--lib/elements/satin_column.py7
-rw-r--r--lib/elements/utils.py11
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/elements/pattern.py b/lib/elements/pattern.py
index 98f29456..c66ffbdc 100644
--- a/lib/elements/pattern.py
+++ b/lib/elements/pattern.py
@@ -30,3 +30,7 @@ class PatternObject(EmbroideryElement):
def to_patches(self, last_patch):
return []
+
+
+def is_pattern(node):
+ return "marker-start:url(#inkstitch-pattern-marker)" in node.get('style', '')
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py
index 65e523d4..77cb7d22 100644
--- a/lib/elements/satin_column.py
+++ b/lib/elements/satin_column.py
@@ -578,11 +578,14 @@ class SatinColumn(EmbroideryElement):
return SatinColumn(node)
def get_patterns(self):
- xpath = "./ancestor::svg:g[svg:use[@xlink:href='#inkstitch_pattern_group']]//*[not(@inkstitch:satin_column='true')]"
+ # TODO: which one is better?!?
+ # All child groups of pattern
+ # xpath = "./ancestor::svg:g//*[contains(@style, 'marker-start:url(#inkstitch-pattern-marker)')]"
+ # Only direct siblings of pattern
+ xpath = "./parent::svg:g/*[contains(@style, 'marker-start:url(#inkstitch-pattern-marker)')]"
patterns = self.node.xpath(xpath, namespaces=NSS)
line_strings = []
for pattern in patterns:
- # TODO: exclude fills in case we will want to use them with the pattern too
if pattern.tag not in EMBROIDERABLE_TAGS:
continue
d = pattern.get_path()
diff --git a/lib/elements/utils.py b/lib/elements/utils.py
index 78dace6a..cd87cec8 100644
--- a/lib/elements/utils.py
+++ b/lib/elements/utils.py
@@ -3,16 +3,16 @@
# Copyright (c) 2010 Authors
# Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details.
-from ..commands import group_commands, is_command
-from ..svg.tags import (EMBROIDERABLE_TAGS, INKSTITCH_ATTRIBS, SVG_IMAGE_TAG,
- SVG_PATH_TAG, SVG_POLYLINE_TAG, SVG_TEXT_TAG)
+from ..commands import is_command
+from ..svg.tags import (EMBROIDERABLE_TAGS, SVG_IMAGE_TAG, SVG_PATH_TAG,
+ SVG_POLYLINE_TAG, SVG_TEXT_TAG)
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 .pattern import PatternObject, is_pattern
from .polyline import Polyline
from .satin_column import SatinColumn
from .stroke import Stroke
@@ -29,8 +29,7 @@ def node_to_elements(node): # noqa: C901
elif node.tag == SVG_PATH_TAG and not node.get('d', ''):
return [EmptyDObject(node)]
- # TODO: exclude fills
- elif group_commands(node, 'pattern_group') and not node.get(INKSTITCH_ATTRIBS['satin_column']):
+ elif is_pattern(node):
return [PatternObject(node)]
elif node.tag in EMBROIDERABLE_TAGS: