From ad73bd72a53119c8a50290b513d8c3f3968aac1e Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Tue, 9 Nov 2021 18:35:14 +0100 Subject: [PATCH] small enhancements in travel moves --- .../draw_directions_tavel_moves.inx | 6 ++++ .../draw_directions_tavel_moves.py | 35 ++++++++++++++----- .../fablabchemnitz/laser_check/laser_check.py | 1 + 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.inx b/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.inx index 7a8c7da1..84d27f4c 100644 --- a/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.inx +++ b/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.inx @@ -4,6 +4,12 @@ fablabchemnitz.de.draw_directions_tavel_moves + + + + + + true 10 diff --git a/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.py b/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.py index 1df581e5..7923961b 100644 --- a/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.py +++ b/extensions/fablabchemnitz/draw_directions_tavel_moves/draw_directions_tavel_moves.py @@ -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: diff --git a/extensions/fablabchemnitz/laser_check/laser_check.py b/extensions/fablabchemnitz/laser_check/laser_check.py index 70ee7616..dd343959 100644 --- a/extensions/fablabchemnitz/laser_check/laser_check.py +++ b/extensions/fablabchemnitz/laser_check/laser_check.py @@ -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