small enhancements in travel moves

This commit is contained in:
Mario Voigt 2021-11-09 18:35:14 +01:00
parent 46f579af3d
commit ad73bd72a5
3 changed files with 33 additions and 9 deletions

View File

@ -4,6 +4,12 @@
<id>fablabchemnitz.de.draw_directions_tavel_moves</id>
<param name="nb_main" type="notebook">
<page name="tab_settings" gui-text="Settings">
<param name="order" type="optiongroup" appearance="combo" gui-text="Order">
<option value="separate_groups">To separate groups</option>
<option value="separate_layers">To separate layers</option>
<option value="element_index">At element's index</option>
</param>
<separator/>
<param name="draw_dots" type="bool" gui-text="Draw dots" gui-description="Start and end point of opened (red + blue) and closed paths (green + yellow)">true</param>
<param name="dotsize" type="int" min="1" max="9999" gui-text="Dot size (px)">10</param>
<separator/>

View File

@ -32,7 +32,7 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--nb_main")
pars.add_argument("--order", default="separate_groups")
pars.add_argument("--draw_dots", type=inkex.Boolean, default=True, help="Start and end point of opened (red + blue) and closed paths (green + yellow)")
pars.add_argument("--dotsize", type=int, default=10, help="Dot size (px)")
pars.add_argument("--draw_travel_moves", type=inkex.Boolean, default=False)
@ -45,6 +45,7 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
def effect(self):
global so
so = self.options
dotPrefix = "dots-"
linePrefix = "travelLine-"
groupPrefix = "travelLines-"
ignoreWord = "ignore"
@ -70,7 +71,14 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
for element in self.svg.selected.values():
parseChildren(element)
dot_group = self.svg.add(inkex.Group())
dotGroup = self.svg.add(inkex.Group(id=self.svg.get_unique_id(dotPrefix)))
if so.order == "separate_layers":
dotGroup.set("inkscape:groupmode", "layer")
dotGroup.set("inkscape:label", dotPrefix + "layer")
if so.order == "separate_groups":
dotGroup.pop("inkscape:groupmode")
dotGroup.pop("inkscape:label")
dotGroup.style.pop("display") #if the group previously has been a layer (which was hidden), a display:none will be added. we don't want that
if so.arrow_style is True:
markerId = "travel_move_arrow"
@ -112,11 +120,20 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
groupName = groupPrefix + strokeColor
travelGroup = self.find_group(groupName)
if travelGroup is None:
self.document.getroot().append(inkex.Group(id=groupName))
travelGroup = inkex.Group(id=groupName)
self.document.getroot().append(travelGroup)
else: #exists
self.document.getroot().append(travelGroup)
for child in travelGroup:
child.delete()
if so.order == "separate_layers":
travelGroup.set("inkscape:groupmode", "layer")
travelGroup.set("inkscape:label", groupName + "-layer")
if so.order == "separate_groups":
travelGroup.pop("inkscape:groupmode")
travelGroup.pop("inkscape:label")
travelGroup.style.pop("display")
p = element.path.transform(element.composed_transform())
points = list(p.end_points)
@ -127,11 +144,11 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
if so.draw_dots is True:
if start[0] == end[0] and start[1] == end[1]:
self.drawCircle(dot_group, '#00FF00', start)
self.drawCircle(dot_group, '#FFFF00', points[1]) #draw one point which gives direction of the path
self.drawCircle(dotGroup, '#00FF00', start)
self.drawCircle(dotGroup, '#FFFF00', points[1]) #draw one point which gives direction of the path
else: #open contour with start and end point
self.drawCircle(dot_group, '#FF0000', start)
self.drawCircle( dot_group, '#0000FF', end)
self.drawCircle(dotGroup, '#FF0000', start)
self.drawCircle( dotGroup, '#0000FF', end)
for strokeColor in strokeColors:
if strokeColor in strokeColorsAndCounts:
@ -203,8 +220,8 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
if so.debug is True: inkex.utils.debug("-"*40)
#cleanup empty groups
if len(dot_group) == 0:
dot_group.delete()
if len(dotGroup) == 0:
dotGroup.delete()
travelGroups = self.document.xpath("//svg:g[starts-with(@id, 'travelLines-')]", namespaces=inkex.NSS)
for travelGroup in travelGroups:
if len(travelGroup) == 0:

View File

@ -13,6 +13,7 @@ class LaserCheck(inkex.EffectExtension):
'''
ToDos:
- check for elements which have the attribute "display:none" (some groups have this)
- inx:
- set speed manually or pick machine (epilog) - travel and cut speed are prefilled then
- calculate cut estimation with linear or non-linear (epiloog) speeds > select formula or like this