summaryrefslogtreecommitdiff
path: root/lib/extensions/troubleshoot.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-04-01 15:30:13 +0200
committerGitHub <noreply@github.com>2023-04-01 15:30:13 +0200
commitacdb911145972012cf8055c9accd31a235214ca7 (patch)
tree769db756139556d696b131d31c090a9aae815e30 /lib/extensions/troubleshoot.py
parentb289c4a633b4fcce581a9edd8f1ded16be28eb5a (diff)
troubleshoot: size options (#2186)
Diffstat (limited to 'lib/extensions/troubleshoot.py')
-rw-r--r--lib/extensions/troubleshoot.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/extensions/troubleshoot.py b/lib/extensions/troubleshoot.py
index f7d979e7..fdc7fa9e 100644
--- a/lib/extensions/troubleshoot.py
+++ b/lib/extensions/troubleshoot.py
@@ -7,21 +7,25 @@ import textwrap
import inkex
-from .base import InkstitchExtension
from ..commands import add_layer_commands
from ..elements.validation import (ObjectTypeWarning, ValidationError,
ValidationWarning)
from ..i18n import _
+from ..svg import PIXELS_PER_MM
from ..svg.path import get_correction_transform
-from ..svg.tags import (INKSCAPE_GROUPMODE, INKSCAPE_LABEL, SODIPODI_ROLE)
+from ..svg.tags import INKSCAPE_GROUPMODE, INKSCAPE_LABEL, SODIPODI_ROLE
+from .base import InkstitchExtension
class Troubleshoot(InkstitchExtension):
- def effect(self):
+ def __init__(self, *args, **kwargs):
+ InkstitchExtension.__init__(self, *args, **kwargs)
+ self.arg_parser.add_argument("-p", "--pointer-size", type=float, default=5, dest="pointer_size_mm")
+ self.arg_parser.add_argument("-f", "--font-size", type=float, default=2, dest="font_size_mm")
+ def effect(self):
self.create_troubleshoot_layer()
-
problem_types = {'error': set(), 'warning': set(), 'type_warning': set()}
if self.get_elements(True):
@@ -50,6 +54,8 @@ class Troubleshoot(InkstitchExtension):
def insert_pointer(self, problem):
correction_transform = get_correction_transform(self.troubleshoot_layer)
+ pointer_size = self.options.pointer_size_mm * PIXELS_PER_MM
+ font_size = self.options.font_size_mm * PIXELS_PER_MM
if isinstance(problem, ValidationWarning):
fill_color = "#ffdd00"
@@ -61,12 +67,14 @@ class Troubleshoot(InkstitchExtension):
fill_color = "#ff9900"
layer = self.type_warning_group
- pointer_style = "stroke:#000000;stroke-width:0.2;fill:%s;" % (fill_color)
- text_style = "fill:%s;stroke:#000000;stroke-width:0.2;font-size:8px;text-align:center;text-anchor:middle" % (fill_color)
+ pointer_style = f'stroke:#000000;stroke-width:0.1;fill:{ fill_color }'
+ text_style = f'fill:{ fill_color };stroke:#000000;stroke-width:0.1;font-size:{ font_size }px;text-align:center;text-anchor:middle'
+ pointer_path = f'm {problem.position.x},{problem.position.y} {pointer_size / 5},{pointer_size} ' \
+ f'h -{pointer_size / 2.5} l {pointer_size / 5},-{pointer_size}'
path = inkex.PathElement(attrib={
"id": self.uniqueId("inkstitch__invalid_pointer__"),
- "d": "m %s,%s 4,20 h -8 l 4,-20" % (problem.position.x, problem.position.y),
+ "d": pointer_path,
"style": pointer_style,
INKSCAPE_LABEL: _('Invalid Pointer'),
"transform": correction_transform
@@ -76,7 +84,7 @@ class Troubleshoot(InkstitchExtension):
text = inkex.TextElement(attrib={
INKSCAPE_LABEL: _('Description'),
"x": str(problem.position.x),
- "y": str(float(problem.position.y) + 30),
+ "y": str(float(problem.position.y) + pointer_size + font_size),
"transform": correction_transform,
"style": text_style
})