jump to trim: add command option: trim or jump (#4038)

pull/4053/head
Kaalleen 2025-11-16 08:54:25 +01:00 zatwierdzone przez GitHub
rodzic 288e7a6e50
commit 27d6d090a8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 16 dodań i 5 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ class JumpToTrim(InkstitchExtension):
InkstitchExtension.__init__(self, *args, **kwargs)
self.arg_parser.add_argument("--tab")
self.arg_parser.add_argument("-c", "--command", type=str, default="trim", dest="command")
self.arg_parser.add_argument("-i", "--minimum-jump-length", type=float, default=3.0, dest="min_jump")
self.arg_parser.add_argument("-a", "--maximum-jump-length", type=float, default=0, dest="max_jump")
self.arg_parser.add_argument("-t", "--use-command-symbols", type=Boolean, default=False, dest="use_command_symbols")
@ -59,14 +60,20 @@ class JumpToTrim(InkstitchExtension):
self._add_trim(last)
def _add_trim(self, element):
command = "trim"
param = "trim_after"
if self.options.command == "stop":
command = "stop"
param = "stop_after"
# skip if the element already has a trim command in one way or the other
if element.has_command("trim") or element.trim_after:
if element.has_command(command) or element.trim_after:
return
if self.options.use_command_symbols:
add_commands(element, ["trim"])
add_commands(element, [command])
else:
element.node.set('inkstitch:trim_after', True)
element.node.set(f'inkstitch:{param}', True)
def _set_selection(self):
if not self.svg.selection:

Wyświetl plik

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension translationdomain="inkstitch" xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Jump Stitch to Trim Command</name>
<name>Jump Stitch to Trim/Stop Command</name>
<id>org.{{ id_inkstitch }}.jump_to_trim</id>
<param name="extension" type="string" gui-hidden="true">jump_to_trim</param>
<effect>
@ -15,6 +15,10 @@
</effect>
<param name="tab" type="notebook">
<page name="options" gui-text="Options">
<param name="command" type="optiongroup" appearance="combo" gui-text="Command">
<option value="trim">Trim</option>
<option value="stop">Stop</option>
</param>
<param name="minimum-jump-length" type="float" precision="2" min="0" max="100"
gui-text="Convert jumps not shorter than (mm)">3.0</param>
<param name="maximum-jump-length" type="float" precision="2" min="0" max="10000"
@ -25,7 +29,7 @@
<param name="use-command-symbol" type="boolean" indent="1" gui-text="Use command symbol">false</param>
</page>
<page name="info" gui-text="Help">
<label appearance="header">This extension inserts trim commands to avoid jump stitches.</label>
<label appearance="header">This extension inserts trim or stop commands to avoid jump stitches.</label>
<label>Get more information on our website</label>
<label appearance="url">https://inkstitch.org/docs/commands/#jump-to-trim</label>
</page>