fixes in filter layer, added guide support for migrategroups

This commit is contained in:
Mario Voigt 2021-04-19 22:07:01 +02:00
parent db8f6be2a5
commit 70ffb2b72f
6 changed files with 51 additions and 47 deletions

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding//extensions/fablabchemnitz/create_links.py=utf-8

View File

@ -55,8 +55,8 @@ class Cleanup(inkex.EffectExtension):
if len(self.svg.selected) == 0: if len(self.svg.selected) == 0:
self.getAttribs(self.document.getroot()) self.getAttribs(self.document.getroot())
else: else:
for id, node in self.svg.selected.items(): for element in self.svg.selected.values():
self.getAttribs(node) self.getAttribs(element)
#finally remove the styles from collected groups (if enabled) #finally remove the styles from collected groups (if enabled)
if self.options.remove_group_styles is True: if self.options.remove_group_styles is True:
for group in self.groups: for group in self.groups:

View File

@ -289,16 +289,16 @@ class ContourScanner(inkex.EffectExtension):
self.scanContours(self.document.getroot()) self.scanContours(self.document.getroot())
else: else:
newContourSet = [] newContourSet = []
for id, item in self.svg.selected.items(): for element in self.svg.selected.items():
self.breakContours(item) self.breakContours(element)
for newContours in self.replacedNodes: for newContours in self.replacedNodes:
self.scanContours(newContours) self.scanContours(newContours)
else: else:
if len(self.svg.selected) == 0: if len(self.svg.selected) == 0:
self.scanContours(self.document.getroot()) self.scanContours(self.document.getroot())
else: else:
for id, item in self.svg.selected.items(): for element in self.svg.selected.values():
self.scanContours(item) self.scanContours(element)
if __name__ == '__main__': if __name__ == '__main__':
ContourScanner().run() ContourScanner().run()

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
''' '''
This extension adds or removes filters to current layer This extension adds filters to current layer or removes filters from current layer
Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es
@ -37,15 +37,11 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
pars.add_argument('--type', default = 'Add', help = 'Add or remove filters to current layer') pars.add_argument('--type', default = 'Add', help = 'Add or remove filters to current layer')
def selectTop(self): def selectTop(self):
selected = []
selectedSorted = None selectedSorted = None
if self.svg.selected is not None: if self.svg.selected is not None:
for id, node in self.svg.selected.items(): for element in self.document.getroot().iter():
selected.append(id) if element.get("id") in self.svg.selection:
for node in self.document.getroot().iter(): selectedSorted = element
idNode = node.get("id")
if idNode in selected:
selectedSorted = node
return selectedSorted return selectedSorted
def effect(self): def effect(self):
@ -56,7 +52,8 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
idLayer = namedview[0].get('{http://www.inkscape.org/namespaces/inkscape}current-layer'); idLayer = namedview[0].get('{http://www.inkscape.org/namespaces/inkscape}current-layer');
xpathStr = '//svg:g[@id="'+idLayer+'"]' xpathStr = '//svg:g[@id="'+idLayer+'"]'
layer = svg.xpath(xpathStr, namespaces=inkex.NSS) layer = svg.xpath(xpathStr, namespaces=inkex.NSS)
if typeOperation == "Add":
if typeOperation == "Add": #Add action
element = self.selectTop() element = self.selectTop()
if element is not None: if element is not None:
if element.get('style'): if element.get('style'):
@ -74,6 +71,7 @@ class FilterAndLiveEffectsLayer(inkex.EffectExtension):
layer[0].set('style',filter) layer[0].set('style',filter)
else: else:
inkex.utils.debug("Nothing selected") inkex.utils.debug("Nothing selected")
else: #Remove action else: #Remove action
if layer[0].get('style'): if layer[0].get('style'):
matchObj = re.search( r'filter:url\(#.*?[^\)]\)', layer[0].get('style'), re.M|re.I) matchObj = re.search( r'filter:url\(#.*?[^\)]\)', layer[0].get('style'), re.M|re.I)

View File

@ -45,12 +45,13 @@
<param name="clipPath" type="bool" gui-text="clipPath">true</param> <param name="clipPath" type="bool" gui-text="clipPath">true</param>
<param name="defs" type="bool" gui-text="defs">true</param> <param name="defs" type="bool" gui-text="defs">true</param>
<param name="image" type="bool" gui-text="image">true</param> <param name="image" type="bool" gui-text="image">true</param>
<param name="guide" type="bool" gui-text="guide">true</param>
<param name="mask" type="bool" gui-text="mask">true</param> <param name="mask" type="bool" gui-text="mask">true</param>
<param name="marker" type="bool" gui-text="marker">true</param> <param name="marker" type="bool" gui-text="marker">true</param>
<param name="metadata" type="bool" gui-text="metadata">true</param>
</vbox> </vbox>
<spacer/> <spacer/>
<vbox> <vbox>
<param name="metadata" type="bool" gui-text="metadata">true</param>
<param name="pattern" type="bool" gui-text="pattern">true</param> <param name="pattern" type="bool" gui-text="pattern">true</param>
<param name="script" type="bool" gui-text="script">true</param> <param name="script" type="bool" gui-text="script">true</param>
<param name="switch" type="bool" gui-text="switch">true</param> <param name="switch" type="bool" gui-text="switch">true</param>

View File

@ -39,6 +39,7 @@ class MigrateGroups(inkex.EffectExtension):
pars.add_argument("--defs", type=inkex.Boolean, default=True) pars.add_argument("--defs", type=inkex.Boolean, default=True)
pars.add_argument("--ellipse", type=inkex.Boolean, default=True) pars.add_argument("--ellipse", type=inkex.Boolean, default=True)
pars.add_argument("--image", type=inkex.Boolean, default=True) pars.add_argument("--image", type=inkex.Boolean, default=True)
pars.add_argument("--guide", type=inkex.Boolean, default=True)
pars.add_argument("--line", type=inkex.Boolean, default=True) pars.add_argument("--line", type=inkex.Boolean, default=True)
pars.add_argument("--path", type=inkex.Boolean, default=True) pars.add_argument("--path", type=inkex.Boolean, default=True)
pars.add_argument("--polyline", type=inkex.Boolean, default=True) pars.add_argument("--polyline", type=inkex.Boolean, default=True)
@ -98,6 +99,8 @@ class MigrateGroups(inkex.EffectExtension):
namespace.append("{http://www.w3.org/2000/svg}flowPara") if self.options.flowPara else "" namespace.append("{http://www.w3.org/2000/svg}flowPara") if self.options.flowPara else ""
namespace.append("{http://www.w3.org/2000/svg}marker") if self.options.marker else "" namespace.append("{http://www.w3.org/2000/svg}marker") if self.options.marker else ""
namespace.append("{http://www.w3.org/2000/svg}pattern") if self.options.pattern else "" namespace.append("{http://www.w3.org/2000/svg}pattern") if self.options.pattern else ""
namespace.append("{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}guide") if self.options.guide else ""
#self.msg(namespace) #self.msg(namespace)
#in case the user made a manual selection instead of whole document parsing, we need to collect all required elements first #in case the user made a manual selection instead of whole document parsing, we need to collect all required elements first