small enhancements in travel moves
This commit is contained in:
parent
46f579af3d
commit
ad73bd72a5
@ -4,6 +4,12 @@
|
|||||||
<id>fablabchemnitz.de.draw_directions_tavel_moves</id>
|
<id>fablabchemnitz.de.draw_directions_tavel_moves</id>
|
||||||
<param name="nb_main" type="notebook">
|
<param name="nb_main" type="notebook">
|
||||||
<page name="tab_settings" gui-text="Settings">
|
<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="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>
|
<param name="dotsize" type="int" min="1" max="9999" gui-text="Dot size (px)">10</param>
|
||||||
<separator/>
|
<separator/>
|
||||||
|
@ -32,7 +32,7 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
|
|
||||||
def add_arguments(self, pars):
|
def add_arguments(self, pars):
|
||||||
pars.add_argument("--nb_main")
|
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("--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("--dotsize", type=int, default=10, help="Dot size (px)")
|
||||||
pars.add_argument("--draw_travel_moves", type=inkex.Boolean, default=False)
|
pars.add_argument("--draw_travel_moves", type=inkex.Boolean, default=False)
|
||||||
@ -45,6 +45,7 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
def effect(self):
|
def effect(self):
|
||||||
global so
|
global so
|
||||||
so = self.options
|
so = self.options
|
||||||
|
dotPrefix = "dots-"
|
||||||
linePrefix = "travelLine-"
|
linePrefix = "travelLine-"
|
||||||
groupPrefix = "travelLines-"
|
groupPrefix = "travelLines-"
|
||||||
ignoreWord = "ignore"
|
ignoreWord = "ignore"
|
||||||
@ -70,7 +71,14 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
for element in self.svg.selected.values():
|
for element in self.svg.selected.values():
|
||||||
parseChildren(element)
|
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:
|
if so.arrow_style is True:
|
||||||
markerId = "travel_move_arrow"
|
markerId = "travel_move_arrow"
|
||||||
@ -112,11 +120,20 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
groupName = groupPrefix + strokeColor
|
groupName = groupPrefix + strokeColor
|
||||||
travelGroup = self.find_group(groupName)
|
travelGroup = self.find_group(groupName)
|
||||||
if travelGroup is None:
|
if travelGroup is None:
|
||||||
self.document.getroot().append(inkex.Group(id=groupName))
|
travelGroup = inkex.Group(id=groupName)
|
||||||
|
self.document.getroot().append(travelGroup)
|
||||||
else: #exists
|
else: #exists
|
||||||
self.document.getroot().append(travelGroup)
|
self.document.getroot().append(travelGroup)
|
||||||
for child in travelGroup:
|
for child in travelGroup:
|
||||||
child.delete()
|
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())
|
p = element.path.transform(element.composed_transform())
|
||||||
points = list(p.end_points)
|
points = list(p.end_points)
|
||||||
@ -127,11 +144,11 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
|
|
||||||
if so.draw_dots is True:
|
if so.draw_dots is True:
|
||||||
if start[0] == end[0] and start[1] == end[1]:
|
if start[0] == end[0] and start[1] == end[1]:
|
||||||
self.drawCircle(dot_group, '#00FF00', start)
|
self.drawCircle(dotGroup, '#00FF00', start)
|
||||||
self.drawCircle(dot_group, '#FFFF00', points[1]) #draw one point which gives direction of the path
|
self.drawCircle(dotGroup, '#FFFF00', points[1]) #draw one point which gives direction of the path
|
||||||
else: #open contour with start and end point
|
else: #open contour with start and end point
|
||||||
self.drawCircle(dot_group, '#FF0000', start)
|
self.drawCircle(dotGroup, '#FF0000', start)
|
||||||
self.drawCircle( dot_group, '#0000FF', end)
|
self.drawCircle( dotGroup, '#0000FF', end)
|
||||||
|
|
||||||
for strokeColor in strokeColors:
|
for strokeColor in strokeColors:
|
||||||
if strokeColor in strokeColorsAndCounts:
|
if strokeColor in strokeColorsAndCounts:
|
||||||
@ -203,8 +220,8 @@ class DrawDirectionsTravelMoves(inkex.EffectExtension):
|
|||||||
if so.debug is True: inkex.utils.debug("-"*40)
|
if so.debug is True: inkex.utils.debug("-"*40)
|
||||||
|
|
||||||
#cleanup empty groups
|
#cleanup empty groups
|
||||||
if len(dot_group) == 0:
|
if len(dotGroup) == 0:
|
||||||
dot_group.delete()
|
dotGroup.delete()
|
||||||
travelGroups = self.document.xpath("//svg:g[starts-with(@id, 'travelLines-')]", namespaces=inkex.NSS)
|
travelGroups = self.document.xpath("//svg:g[starts-with(@id, 'travelLines-')]", namespaces=inkex.NSS)
|
||||||
for travelGroup in travelGroups:
|
for travelGroup in travelGroups:
|
||||||
if len(travelGroup) == 0:
|
if len(travelGroup) == 0:
|
||||||
|
@ -13,6 +13,7 @@ class LaserCheck(inkex.EffectExtension):
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
ToDos:
|
ToDos:
|
||||||
|
- check for elements which have the attribute "display:none" (some groups have this)
|
||||||
- inx:
|
- inx:
|
||||||
- set speed manually or pick machine (epilog) - travel and cut speed are prefilled then
|
- 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
|
- calculate cut estimation with linear or non-linear (epiloog) speeds > select formula or like this
|
||||||
|
Reference in New Issue
Block a user