From 5cf5ebf8ef5cef77e0b491f52ac37e317b06279d Mon Sep 17 00:00:00 2001 From: Richard White Date: Fri, 26 Feb 2016 20:18:49 -0500 Subject: Added frame extension. (bzr r14668.1.1) --- share/extensions/frame.inx | 32 ++++++ share/extensions/frame.py | 175 +++++++++++++++++++++++++++++++ share/extensions/test/frame_test.py | 109 +++++++++++++++++++ share/extensions/test/svg/single_box.svg | 62 +++++++++++ 4 files changed, 378 insertions(+) create mode 100644 share/extensions/frame.inx create mode 100644 share/extensions/frame.py create mode 100755 share/extensions/test/frame_test.py create mode 100644 share/extensions/test/svg/single_box.svg (limited to 'share/extensions') diff --git a/share/extensions/frame.inx b/share/extensions/frame.inx new file mode 100644 index 000000000..a2b011430 --- /dev/null +++ b/share/extensions/frame.inx @@ -0,0 +1,32 @@ + + + <_name>Frame + frame + frame.py + inkex.py + + + 000000FF + + + 00000000 + + + + + + + + + 2 + 0 + + all + + + + + + \ No newline at end of file diff --git a/share/extensions/frame.py b/share/extensions/frame.py new file mode 100644 index 000000000..c63be52e5 --- /dev/null +++ b/share/extensions/frame.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python +""" +An Inkscape extension that creates a frame around a selected object. + +Copyright (C) 2016 Richard White, rwhite8282@gmail.com + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +# These two lines are only needed if you don't put the script directly into +# the installation directory +import sys +sys.path.append('/usr/share/inkscape/extensions') + +import inkex +import simplestyle +from simpletransform import * +from simplestyle import * + + +def get_picker_data(value): + """ Returns color data in style string format. + value -- The value returned from the color picker. + Returns an object with color and opacity properties. + """ + v = hex(value & 0xFFFFFFFF)[2:-1].rjust(8, '0').upper() + color = '#' + v[0:-2].rjust(6, '0') + opacity = '%1.2f' % (float(int(v[6:].rjust(2, '0'), 16))/255) + return type('', (object,), {'color':color, 'opacity':opacity})() + + +def size_box(box, delta): + """ Returns a box with an altered size. + delta -- The amount the box should grow. + Returns a box with an altered size. + """ + return ((box[0]-delta), (box[1]+delta), (box[2]-delta), (box[3]+delta)) + + +# Frame maker Inkscape effect extension +class Frame(inkex.Effect): + """ An Inkscape extension that creates a frame around a selected object. + """ + def __init__(self): + inkex.Effect.__init__(self) + self.defs = None + + # Parse the options. + self.OptionParser.add_option('--clip', + action='store', type='inkbool', + dest='clip', default=False) + self.OptionParser.add_option('--corner_radius', + action='store', type='int', + dest='corner_radius', default=0) + self.OptionParser.add_option('--fill_color', + action='store', type='int', + dest='fill_color', default='00000000') + self.OptionParser.add_option('--group', + action='store', type='inkbool', + dest='group', default=False) + self.OptionParser.add_option('--position', + action='store', type='string', + dest='position', default='outside') + self.OptionParser.add_option('--stroke_color', + action='store', type='int', + dest='stroke_color', default='00000000') + self.OptionParser.add_option('--tab', + action='store', type='string', + dest='tab', default='object') + self.OptionParser.add_option('--width', + action='store', type='float', + dest='width', default=2) + + + def add_clip(self, node, clip_path): + """ Adds a new clip path node to the defs and sets + the clip-path on the node. + node -- The node that will be clipped. + clip_path -- The clip path object. + """ + if self.defs is None: + defs_nodes = self.document.getroot().xpath('//svg:defs', namespaces=inkex.NSS) + if defs_nodes: + self.defs = defs_nodes[0] + else: + inkex.errormsg('Could not locate defs node for clip.') + return + clip = inkex.etree.SubElement(self.defs, inkex.addNS('clipPath','svg')) + clip.append(copy.deepcopy(clip_path)) + clip_id = self.uniqueId('clipPath') + clip.set('id', clip_id) + node.set('clip-path', 'url(#%s)' % str(clip_id)) + + + def add_frame(self, parent, name, box, style, radius=0): + """ Adds a new frame to the parent object. + parent -- The parent that the frame will be added to. + name -- The name of the new frame object. + box -- The boundary box of the node. + style -- The style used to draw the path. + radius -- The corner radius of the frame. + returns a new frame node. + """ + r = min([radius, (abs(box[1]-box[0])/2), (abs(box[3]-box[2])/2)]) + if (radius > 0): + d = ' '.join(str(x) for x in + ['M', box[0], (box[2]+r) + ,'A', r, r, '0 0 1', (box[0]+r), box[2] + ,'L', (box[1]-r), box[2] + ,'A', r, r, '0 0 1', box[1], (box[2]+r) + ,'L', box[1], (box[3]-r) + ,'A', r, r, '0 0 1', (box[1]-r), box[3] + ,'L', (box[0]+r), box[3] + ,'A', r, r, '0 0 1', box[0], (box[3]-r), 'Z']) + else: + d = ' '.join(str(x) for x in + ['M', box[0], box[2] + ,'L', box[1], box[2] + ,'L', box[1], box[3] + ,'L', box[0], box[3], 'Z']) + + attributes = {'style':style, inkex.addNS('label','inkscape'):name, 'd':d} + return inkex.etree.SubElement(parent, inkex.addNS('path','svg'), attributes ) + + + def effect(self): + """ Performs the effect. + """ + # Get the style values. + corner_radius = self.options.corner_radius + stroke_data = get_picker_data(self.options.stroke_color) + fill_data = get_picker_data(self.options.fill_color) + + # Determine common properties. + parent = self.current_layer + position = self.options.position + width = self.options.width + style = simplestyle.formatStyle({'stroke':stroke_data.color + , 'stroke-opacity':stroke_data.opacity + , 'stroke-width':str(width) + , 'fill':(fill_data.color if (fill_data.opacity > 0) else 'none') + , 'fill-opacity':fill_data.opacity}) + + for id, node in self.selected.iteritems(): + box = computeBBox([node]) + if 'outside' == position: + box = size_box(box, (3.5 + (width/2))) + else: + box = size_box(box, (3.5 - (width/2))) + name = 'Frame' + frame = self.add_frame(parent, name, box, style, corner_radius) + if self.options.clip: + self.add_clip(node, frame) + if self.options.group: + group = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg')) + group.append(node) + group.append(frame) + + +if __name__ == '__main__': #pragma: no cover + # Create effect instance and apply it. + effect = Frame() + effect.affect() \ No newline at end of file diff --git a/share/extensions/test/frame_test.py b/share/extensions/test/frame_test.py new file mode 100755 index 000000000..72c5b66e8 --- /dev/null +++ b/share/extensions/test/frame_test.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python + +""" +An Inkscape frame extension test class. + +Copyright (C) 2016 Richard White, rwhite8282@gmail.com + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +""" + +import sys +sys.path.append('/usr/share/inkscape/extensions') +sys.path.append('..') # this line allows to import the extension code + +import unittest +import inkex +from frame import * + + +class Frame_Test(unittest.TestCase): + + + def get_frame(self, document): + return document.xpath('//svg:g[@id="layer1"]//svg:path[@inkscape:label="Frame"]' + , namespaces=inkex.NSS)[0] + + + def test_empty_no_parameters(self): + args = [ 'svg/empty-SVG.svg' ] + uut = Frame() + uut.affect( args, False ) + + + def test_single_frame(self): + args = [ + '--corner_radius=20' + , '--fill_color=-16777124' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + + + def test_single_frame_grouped(self): + args = [ + '--corner_radius=20' + , '--fill_color=-16777124' + , '--group=True' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + group = new_frame.getparent() + self.assertEqual('{http://www.w3.org/2000/svg}g', group.tag) + self.assertEqual('{http://www.w3.org/2000/svg}rect', group[0].tag) + self.assertEqual('{http://www.w3.org/2000/svg}path', group[1].tag) + self.assertEqual("Frame", group[1].xpath('@inkscape:label', namespaces=inkex.NSS)[0]) + + + def test_single_frame_clipped(self): + args = [ + '--clip=True' + , '--corner_radius=20' + , '--fill_color=-16777124' + , '--id=rect3006' + , '--position=inside' + , '--stroke_color=255' + , '--tab="stroke"' + , '--width=10' + , 'svg/single_box.svg'] + uut = Frame() + uut.affect( args, False ) + new_frame = self.get_frame(uut.document) + self.assertIsNotNone(new_frame) + self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) + group = new_frame.getparent() + self.assertEqual('url(#clipPath)', group[0].get('clip-path')) + clip_path = uut.document.xpath('//svg:defs/svg:clipPath', namespaces=inkex.NSS)[0] + self.assertEqual('{http://www.w3.org/2000/svg}clipPath', clip_path.tag) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/share/extensions/test/svg/single_box.svg b/share/extensions/test/svg/single_box.svg new file mode 100644 index 000000000..094233d15 --- /dev/null +++ b/share/extensions/test/svg/single_box.svg @@ -0,0 +1,62 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + -- cgit v1.2.3 From 1c7b77f8b1c6a5f59384b54884229e88966fc1d4 Mon Sep 17 00:00:00 2001 From: Richard White Date: Wed, 18 May 2016 19:35:10 -0400 Subject: Corrected frame extension stroke and fill values on 64 bit machine. The lack of L suffix in the represented hex value caused an improper interpretation. (bzr r14668.1.2) --- share/extensions/frame.py | 6 +++--- share/extensions/test/frame_test.py | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/frame.py b/share/extensions/frame.py index c63be52e5..d0cafc37b 100644 --- a/share/extensions/frame.py +++ b/share/extensions/frame.py @@ -35,7 +35,7 @@ def get_picker_data(value): value -- The value returned from the color picker. Returns an object with color and opacity properties. """ - v = hex(value & 0xFFFFFFFF)[2:-1].rjust(8, '0').upper() + v = '%08X' % (value & 0xFFFFFFFF) color = '#' + v[0:-2].rjust(6, '0') opacity = '%1.2f' % (float(int(v[6:].rjust(2, '0'), 16))/255) return type('', (object,), {'color':color, 'opacity':opacity})() @@ -156,9 +156,9 @@ class Frame(inkex.Effect): for id, node in self.selected.iteritems(): box = computeBBox([node]) if 'outside' == position: - box = size_box(box, (3.5 + (width/2))) + box = size_box(box, (width/2)) else: - box = size_box(box, (3.5 - (width/2))) + box = size_box(box, (width/2)) name = 'Frame' frame = self.add_frame(parent, name, box, style, corner_radius) if self.options.clip: diff --git a/share/extensions/test/frame_test.py b/share/extensions/test/frame_test.py index 72c5b66e8..3d686ab25 100755 --- a/share/extensions/test/frame_test.py +++ b/share/extensions/test/frame_test.py @@ -58,7 +58,18 @@ class Frame_Test(unittest.TestCase): new_frame = self.get_frame(uut.document) self.assertIsNotNone(new_frame) self.assertEqual('{http://www.w3.org/2000/svg}path', new_frame.tag) - + new_frame_style = new_frame.attrib['style'].lower() + self.assertTrue('fill-opacity:0.36' in new_frame_style + , 'Invalid fill-opacity in "' + new_frame_style + '".') + self.assertTrue('stroke:#000000' in new_frame_style + , 'Invalid stroke in "' + new_frame_style + '".') + self.assertTrue('stroke-width:10.0' in new_frame_style + , 'Invalid stroke-width in "' + new_frame_style + '".') + self.assertTrue('stroke-opacity:1.00' in new_frame_style + , 'Invalid stroke-opacity in "' + new_frame_style + '".') + self.assertTrue('fill:#ff0000' in new_frame_style + , 'Invalid fill in "' + new_frame_style + '".') + def test_single_frame_grouped(self): args = [ -- cgit v1.2.3 From cf6e3cf5b4728951fafe742167e483d71fd0dba7 Mon Sep 17 00:00:00 2001 From: Richard White Date: Wed, 18 May 2016 22:06:38 -0400 Subject: Corrected frame extension inside option box size. (bzr r14668.1.4) --- share/extensions/frame.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/frame.py b/share/extensions/frame.py index d0cafc37b..f6d54e180 100644 --- a/share/extensions/frame.py +++ b/share/extensions/frame.py @@ -158,7 +158,7 @@ class Frame(inkex.Effect): if 'outside' == position: box = size_box(box, (width/2)) else: - box = size_box(box, (width/2)) + box = size_box(box, -(width/2)) name = 'Frame' frame = self.add_frame(parent, name, box, style, corner_radius) if self.options.clip: -- cgit v1.2.3 From 19f956f4e808c2c97dfeee599266c6d9680c2f3d Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 17 Jun 2016 08:44:20 +0200 Subject: [Bug #1454910] Compressed SVG with media error. Fixed bugs: - https://launchpad.net/bugs/1454910 (bzr r14995) --- share/extensions/svg_and_media_zip_output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/svg_and_media_zip_output.py b/share/extensions/svg_and_media_zip_output.py index fb1ddd823..e021bfd4e 100755 --- a/share/extensions/svg_and_media_zip_output.py +++ b/share/extensions/svg_and_media_zip_output.py @@ -111,7 +111,7 @@ class CompressedMediaOutput(inkex.Effect): url = urlparse.urlparse(xlink) href = urllib.url2pathname(url.path) - if (href != None): + if (href != None and os.path.isfile(href)): absref = os.path.realpath(href) absref = unicode(absref, "utf-8") -- cgit v1.2.3 From f0726870f87935e2081bfc08cafad3a6c82ac7ca Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 21 Jun 2016 13:22:57 +0200 Subject: [Bug #1594113] New extension Deep Ungroup includes hard-coded unit conversion based on 90dpi. Fixed bugs: - https://launchpad.net/bugs/1594113 (bzr r14998) --- share/extensions/ungroup_deep.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/ungroup_deep.py b/share/extensions/ungroup_deep.py index d27bb8a69..359232007 100644 --- a/share/extensions/ungroup_deep.py +++ b/share/extensions/ungroup_deep.py @@ -63,17 +63,17 @@ class Ungroup(inkex.Effect): elif s[-2:] == "px": return float(s[:-2]) elif s[-2:] == "pt": - return float(s[:-2]) * 1.25 + return float(s[:-2]) * 1.33 elif s[-2:] == "em": return float(s[:-2]) * 16 elif s[-2:] == "mm": - return float(s[:-2]) * 3.54 + return float(s[:-2]) * 3.779 elif s[-2:] == "pc": - return float(s[:-2]) * 15 + return float(s[:-2]) * 16 elif s[-2:] == "cm": - return float(s[:-2]) * 35.43 + return float(s[:-2]) * 37.79 elif s[-2:] == "in": - return float(s[:-2]) * 90 + return float(s[:-2]) * 96 else: return 1024 -- cgit v1.2.3 From 9f19c4dfa626ebdc49a4be26e52f42e155f310bd Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Thu, 23 Jun 2016 07:15:52 +0200 Subject: [Bug #1589792] Fix scaling for Draw From Triangle. Fixed bugs: - https://launchpad.net/bugs/1589792 (bzr r15000) --- share/extensions/draw_from_triangle.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/draw_from_triangle.py b/share/extensions/draw_from_triangle.py index 74a58b863..3146fe26e 100755 --- a/share/extensions/draw_from_triangle.py +++ b/share/extensions/draw_from_triangle.py @@ -147,8 +147,6 @@ def get_n_points_from_path( node, n):#returns a list of first n points (x,y) in if len(xi) == n and len(yi) == n: points = [] # returned pairs of points for i in range(n): - xi[i] = Draw_From_Triangle.unittouu(e, str(xi[i]) + 'px') - yi[i] = Draw_From_Triangle.unittouu(e, str(yi[i]) + 'px') points.append( [ xi[i], yi[i] ] ) else: #inkex.errormsg(_('Error: Not enough nodes to gather coordinates.')) #fail silently and exit, rather than invoke an error console @@ -176,21 +174,23 @@ def cot(x):#cotangent(x) return 1/tan(x) def report_properties( params ):#report to the Inkscape console using errormsg - inkex.errormsg(_("Side Length 'a' (px): " + str( params[0][0] ) )) - inkex.errormsg(_("Side Length 'b' (px): " + str( params[0][1] ) )) - inkex.errormsg(_("Side Length 'c' (px): " + str( params[0][2] ) )) + # TODO: unit identifier needs solution for arbitrary document scale + unit = Draw_From_Triangle.getDocumentUnit(e) + inkex.errormsg(_("Side Length 'a' (" + unit + "): " + str( params[0][0] ) )) + inkex.errormsg(_("Side Length 'b' (" + unit + "): " + str( params[0][1] ) )) + inkex.errormsg(_("Side Length 'c' (" + unit + "): " + str( params[0][2] ) )) inkex.errormsg(_("Angle 'A' (radians): " + str( params[1][0] ) )) inkex.errormsg(_("Angle 'B' (radians): " + str( params[1][1] ) )) inkex.errormsg(_("Angle 'C' (radians): " + str( params[1][2] ) )) inkex.errormsg(_("Semiperimeter (px): " + str( params[4][1] ) )) - inkex.errormsg(_("Area (px^2): " + str( params[4][0] ) )) + inkex.errormsg(_("Area ("+ unit + "^2): " + str( params[4][0] ) )) return class Style(object): #container for style information def __init__(self, options): #dot markers - self.d_rad = 4 #dot marker radius + self.d_rad = Draw_From_Triangle.unittouu(e, '4px') #dot marker radius self.d_th = Draw_From_Triangle.unittouu(e, '2px') #stroke width self.d_fill= '#aaaaaa' #fill colour self.d_col = '#000000' #stroke colour -- cgit v1.2.3 From e471a664f923f517b68071f2e33fbb6ce070f8b7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 8 Aug 2016 13:56:40 +0100 Subject: Remove deprecated Autotools and btool files. Please use CMake instead (bzr r15046) --- share/extensions/Barcode/Makefile.am | 23 --------- share/extensions/Makefile.am | 42 ---------------- share/extensions/Poly3DObjects/Makefile.am | 33 ------------- share/extensions/alphabet_soup/Makefile.am | 78 ------------------------------ share/extensions/ink2canvas/Makefile.am | 9 ---- share/extensions/test/Makefile.am | 60 ----------------------- share/extensions/xaml2svg/Makefile.am | 19 -------- 7 files changed, 264 deletions(-) delete mode 100644 share/extensions/Barcode/Makefile.am delete mode 100644 share/extensions/Makefile.am delete mode 100644 share/extensions/Poly3DObjects/Makefile.am delete mode 100644 share/extensions/alphabet_soup/Makefile.am delete mode 100644 share/extensions/ink2canvas/Makefile.am delete mode 100644 share/extensions/test/Makefile.am delete mode 100644 share/extensions/xaml2svg/Makefile.am (limited to 'share/extensions') diff --git a/share/extensions/Barcode/Makefile.am b/share/extensions/Barcode/Makefile.am deleted file mode 100644 index 08e2f58b4..000000000 --- a/share/extensions/Barcode/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ - -barcodedir = $(datadir)/inkscape/extensions/Barcode - -barcode_DATA = \ - Base.py \ - BaseEan.py \ - Code128.py \ - Code39Ext.py \ - Code39.py \ - Code25i.py \ - Code93.py \ - Ean13.py \ - Ean8.py \ - Ean5.py \ - Ean2.py \ - __init__.py \ - Rm4scc.py \ - Upca.py \ - Upce.py - -EXTRA_DIST = \ - $(barcode_DATA) - diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am deleted file mode 100644 index f247cd8bb..000000000 --- a/share/extensions/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ - -SUBDIRS = \ - alphabet_soup \ - Barcode \ - ink2canvas \ - Poly3DObjects \ - test \ - xaml2svg - -extensiondir = $(datadir)/inkscape/extensions - -otherstuffdir = $(datadir)/inkscape/extensions - -moduledir = $(datadir)/inkscape/extensions - -extension_SCRIPTS = \ - $(wildcard $(srcdir)/*.py) \ - $(wildcard $(srcdir)/*.pl) \ - $(wildcard $(srcdir)/*.sh) \ - $(wildcard $(srcdir)/*.rb) - -otherstuff_DATA = \ - fontfix.conf \ - inkweb.js \ - jessyInk.js \ - jessyInk_core_mouseHandler_noclick.js \ - jessyInk_core_mouseHandler_zoomControl.js \ - aisvg.xslt \ - colors.xml \ - jessyInk_video.svg \ - seamless_pattern.svg \ - svg2fxg.xsl \ - svg2xaml.xsl \ - xaml2svg.xsl \ - inkscape.extension.rng - -module_DATA = $(wildcard $(srcdir)/*.inx) - -EXTRA_DIST = \ - $(extension_SCRIPTS) $(otherstuff_DATA) $(module_DATA) - - diff --git a/share/extensions/Poly3DObjects/Makefile.am b/share/extensions/Poly3DObjects/Makefile.am deleted file mode 100644 index 82a81af42..000000000 --- a/share/extensions/Poly3DObjects/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ - -Poly3DObjectsdir = $(datadir)/inkscape/extensions/Poly3DObjects - -Poly3DObjects_DATA = \ - cube.obj \ - cuboct.obj \ - dodec.obj \ - great_dodec.obj \ - great_rhombicosidodec.obj \ - great_rhombicuboct.obj \ - great_stel_dodec.obj \ - icos.obj \ - icosidodec.obj \ - jessens_orthog_icos.obj \ - methane.obj \ - oct.obj \ - rhomb_dodec.obj \ - rhomb_triacont.obj \ - rh_axes.obj \ - small_rhombicosidodec.obj \ - small_rhombicuboct.obj \ - small_triam_icos.obj \ - snub_cube.obj \ - snub_dodec.obj \ - szilassi.obj \ - tet.obj \ - trunc_cube.obj \ - trunc_dodec.obj \ - trunc_icos.obj \ - trunc_oct.obj \ - trunc_tet.obj - -EXTRA_DIST = $(Poly3DObjects_DATA) diff --git a/share/extensions/alphabet_soup/Makefile.am b/share/extensions/alphabet_soup/Makefile.am deleted file mode 100644 index 004da4e8c..000000000 --- a/share/extensions/alphabet_soup/Makefile.am +++ /dev/null @@ -1,78 +0,0 @@ - -alphabet_soupdir = $(datadir)/inkscape/extensions/alphabet_soup - -alphabet_soup_DATA = \ - 2.svg \ - 3.svg \ - 6.svg \ - 7.svg \ - abase.svg \ - a.svg \ - acap.svg \ - bar2.svg \ - barcap.svg \ - bar.svg \ - b.svg \ - Cblob.svg \ - Chook.svg \ - cross.svg \ - cserif.svg \ - c.svg \ - Ctail.svg \ - Delta.svg \ - Eb.svg \ - epsilon.svg \ - Eserif.svg \ - e.svg \ - Et.svg \ - f.svg \ - gamma.svg \ - G.svg \ - h2.svg \ - hcap.svg \ - h.svg \ - IBSerif.svg \ - idot.svg \ - ITSerif.svg \ - j.svg \ - k.svg \ - Lb.svg \ - lserif.svg \ - l.svg \ - Lt.svg \ - mcap.svg \ - m.svg \ - n.svg \ - ocap.svg \ - Ocross.svg \ - o.svg \ - Oterm.svg \ - P.svg \ - Q.svg \ - question.svg \ - Rblock.svg \ - rcap.svg \ - r.svg \ - serif.svg \ - s.svg \ - Tb.svg \ - tserif.svg \ - t.svg \ - Tt.svg \ - U.svg \ - vcap.svg \ - vserl.svg \ - vserr.svg \ - Vser.svg \ - v.svg \ - Xh.svg \ - Xne.svg \ - Xnw.svg \ - x.svg \ - Xvb.svg \ - Xvt.svg \ - yogh.svg \ - y.svg \ - z.svg - -EXTRA_DIST = $(alphabet_soup_DATA) diff --git a/share/extensions/ink2canvas/Makefile.am b/share/extensions/ink2canvas/Makefile.am deleted file mode 100644 index ab6e7661d..000000000 --- a/share/extensions/ink2canvas/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ - -ink2canvasdir = $(datadir)/inkscape/extensions/ink2canvas - -ink2canvas_DATA = \ - __init__.py \ - canvas.py \ - svg.py - -EXTRA_DIST = $(ink2canvas_DATA) diff --git a/share/extensions/test/Makefile.am b/share/extensions/test/Makefile.am deleted file mode 100644 index cd1929a7f..000000000 --- a/share/extensions/test/Makefile.am +++ /dev/null @@ -1,60 +0,0 @@ - -# List of all tests to be run. -#TESTS = svgcalendar.test.py -# that is not working :-/ - -EXTRA_DIST = \ - addnodes.test.py \ - chardataeffect.test.py \ - color_randomize_test.py \ - coloreffect.test.py \ - create_test_from_template.sh \ - dots.test.py \ - draw_from_triangle.test.py \ - dxf_outlines.test.py \ - edge3d.test.py \ - embedimage.test.py \ - eqtexsvg.test.py \ - extractimage.test.py \ - extrude.test.py \ - flatten.test.py \ - foldablebox.test.py \ - fractalize.test.py \ - funcplot.test.py \ - gimp_xcf.test.py \ - grid_cartesian.test.py \ - grid_polar.test.py \ - guides_creator.test.py \ - handles.test.py \ - hpgl_output.test.py \ - inkweb-debug.js \ - inkwebeffect.test.py \ - inkwebjs-move.test.svg \ - interp_att_g.test.py \ - interp.test.py \ - lindenmayer.test.py \ - lorem_ipsum.test.py \ - markers_strokepaint.test.py \ - measure.test.py \ - minimal-blank.svg \ - motion.test.py \ - pathmodifier.test.py \ - perfectboundcover.test.py \ - perspective.test.py \ - polyhedron_3d.test.py \ - radiusrand.test.py \ - render_alphabetsoup.test.py \ - render_barcode.test.py \ - render_barcode.data \ - render_gears.test.py \ - restack.test.py \ - rtree.test.py \ - run-all-extension-tests \ - spirograph.test.py \ - straightseg.test.py \ - summersnight.test.py \ - svg_and_media_zip_output.test.py \ - svgcalendar.test.py \ - test_template.py.txt \ - triangle.test.py \ - whirl.test.py diff --git a/share/extensions/xaml2svg/Makefile.am b/share/extensions/xaml2svg/Makefile.am deleted file mode 100644 index 89a901fde..000000000 --- a/share/extensions/xaml2svg/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ - -xaml2svg_otherstuffdir = $(datadir)/inkscape/extensions/xaml2svg - -xaml2svg_otherstuff = \ - animation.xsl \ - brushes.xsl \ - canvas.xsl \ - geometry.xsl \ - Makefile.am \ - properties.xsl \ - shapes.xsl \ - transform.xsl - -xaml2svg_otherstuff_DATA = \ - $(xaml2svg_otherstuff) - -EXTRA_DIST = \ - $(xaml2svg_otherstuff_DATA) - -- cgit v1.2.3 From 53edbe953052913dbee444e4390c7612531f8043 Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Sat, 27 Aug 2016 15:31:36 +0200 Subject: [Bug #1586568] Interpolate extension creates wrong stroke width. Fixed bugs: - https://launchpad.net/bugs/1586568 (bzr r15081) --- share/extensions/interp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 9dbb996e4..a53ab07d9 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -109,8 +109,9 @@ class Interp(inkex.Effect): help="use z-order instead of selection order") def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' - sp = self.unittouu(start[property]) - ep = self.unittouu(end[property]) + scale = self.unittouu('1px') + sp = self.unittouu(start[property]) / scale + ep = self.unittouu(end[property]) / scale return str(sp + (time * (ep - sp))) def effect(self): -- cgit v1.2.3 From ac0e81e5f68f50a89d8fdc2f5401c205a42513a0 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 27 Aug 2016 23:45:38 -0400 Subject: Use new website link which allows us to control the answers provider (bzr r15082) --- share/extensions/inkscape_help_askaquestion.inx | 22 +++++++++++----------- share/extensions/launch_webbrowser.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/inkscape_help_askaquestion.inx b/share/extensions/inkscape_help_askaquestion.inx index 74462bf07..b093558cb 100644 --- a/share/extensions/inkscape_help_askaquestion.inx +++ b/share/extensions/inkscape_help_askaquestion.inx @@ -1,14 +1,14 @@ - <_name>Ask Us a Question - org.inkscape.help.askaquestion - launch_webbrowser.py - http://answers.launchpad.net/inkscape/+addquestion - - all - - + <_name>Ask Us a Question + org.inkscape.help.askaquestion + launch_webbrowser.py + <_param name="url" gui-hidden="true" type="string">https://inkscape.org/en/ask/ + + all + + diff --git a/share/extensions/launch_webbrowser.py b/share/extensions/launch_webbrowser.py index 225484393..fb2ccfd87 100755 --- a/share/extensions/launch_webbrowser.py +++ b/share/extensions/launch_webbrowser.py @@ -11,7 +11,7 @@ class VisitWebSiteWithoutLockingInkscape(threading.Thread): threading.Thread.__init__ (self) parser = OptionParser() parser.add_option("-u", "--url", action="store", type="string", - default="http://www.inkscape.org/", + default="https://www.inkscape.org/", dest="url", help="The URL to open in web browser") (self.options, args) = parser.parse_args() -- cgit v1.2.3 From f7169083307dd418bf8daf75036be1c3129e11e7 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 23 Sep 2016 16:03:34 +0300 Subject: Add missing space after a comma. (bzr r15100.1.21) --- share/extensions/text_sentencecase.py | 2 +- share/extensions/text_titlecase.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/text_sentencecase.py b/share/extensions/text_sentencecase.py index 43460efc5..e699a7efa 100755 --- a/share/extensions/text_sentencecase.py +++ b/share/extensions/text_sentencecase.py @@ -6,7 +6,7 @@ class C(chardataeffect.CharDataEffect): sentence_start = True was_punctuation = False - def process_chardata(self,text, line, par): + def process_chardata(self, text, line, par): r = "" #inkex.debug(text+str(line)+str(par)) for c in text: diff --git a/share/extensions/text_titlecase.py b/share/extensions/text_titlecase.py index 1af0db26b..533ab1a39 100755 --- a/share/extensions/text_titlecase.py +++ b/share/extensions/text_titlecase.py @@ -5,7 +5,7 @@ class C(chardataeffect.CharDataEffect): word_ended = True - def process_chardata(self,text, line, par): + def process_chardata(self, text, line, par): r = "" for i in range(len(text)): c = text[i] -- cgit v1.2.3 From cb93d88bd2110970609f05b1ab4cd58581ded4dd Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 18 Oct 2016 06:41:23 +0200 Subject: [Bug #1633999] xcf export fails if layer names contain non-ASCII characters. Fixed bugs: - https://launchpad.net/bugs/1633999 (bzr r15174) --- share/extensions/gimp_xcf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/gimp_xcf.py b/share/extensions/gimp_xcf.py index 7dfdc0cc8..d79717828 100755 --- a/share/extensions/gimp_xcf.py +++ b/share/extensions/gimp_xcf.py @@ -176,7 +176,7 @@ class MyEffect(inkex.Effect): if os.name == 'nt': filename = filename.replace("\\", "/") pngs.append(filename) - names.append(name.encode('utf-8')) + names.append(name) if (self.valid == 0): self.clear_tmp() -- cgit v1.2.3 From 647b3ccad1fd3b178e92341fdc92fd276a234dff Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Nov 2016 22:29:03 +0100 Subject: Add exporters (bzr r15142.1.32) --- share/extensions/hpgl_output.py | 14 ++++++++++++++ share/extensions/synfig_output.py | 9 +++++++++ 2 files changed, 23 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 58f82da71..367a9addd 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # standard library import sys +from inkex import NSS # local libraries import hpgl_encoder import inkex @@ -48,6 +49,13 @@ class HpglOutput(inkex.Effect): def effect(self): self.options.debug = False # get hpgl data + svg = self.document.getroot() + xpathStr = '//sodipodi:namedview' + nv = svg.xpath(xpathStr, namespaces=NSS) + document_rotate = "0" + if nv != []: + document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation") + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -56,9 +64,13 @@ class HpglOutput(inkex.Effect): # issue error if no paths found inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -67,6 +79,8 @@ class HpglOutput(inkex.Effect): if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' + if nv != [] and document_rotate: + nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) def output(self): # print to file diff --git a/share/extensions/synfig_output.py b/share/extensions/synfig_output.py index bcd1eeaf3..461078951 100755 --- a/share/extensions/synfig_output.py +++ b/share/extensions/synfig_output.py @@ -1046,6 +1046,11 @@ def extract_width(style, width_attrib, mtx): ###### Main Class ######################################### class SynfigExport(SynfigPrep): def __init__(self): + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + self.document_rotate = res[0].get("inkscape:document_rotation") + res[0].set("inkscape:document_rotation","0") SynfigPrep.__init__(self) def effect(self): @@ -1073,6 +1078,10 @@ class SynfigExport(SynfigPrep): root_canvas.append(layer) d.get_root_tree().write(sys.stdout) + svg = self.document.getroot() + xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' + res = svg.xpath(xpathStr, namespaces=inkex.NSS) + res[0].set("inkscape:document_rotation",self.document_rotate) def convert_node(self, node, d): """Convert an SVG node to a list of Synfig layers""" -- cgit v1.2.3 From 61b1ddd0599ee54f76494888524b156859134e85 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 26 Nov 2016 17:15:27 +0100 Subject: CMake: Add ${INKSCAPE_SHARE_INSTALL} This is set to "share/inkscape" by default, on Windows we need to be able to install directly into "share" however (bzr r15278) --- share/extensions/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/CMakeLists.txt b/share/extensions/CMakeLists.txt index 74819309d..b311c6cbf 100644 --- a/share/extensions/CMakeLists.txt +++ b/share/extensions/CMakeLists.txt @@ -17,7 +17,7 @@ file(GLOB _FILES "*.inx" ) -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions) # Install the executable scripts file(GLOB _SCRIPTS @@ -27,16 +27,16 @@ file(GLOB _SCRIPTS "*.rb" ) -install(PROGRAMS ${_SCRIPTS} DESTINATION ${SHARE_INSTALL}/inkscape/extensions) +install(PROGRAMS ${_SCRIPTS} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions) file(GLOB _FILES "alphabet_soup/*.svg") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/alphabet_soup) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/alphabet_soup) file(GLOB _FILES "Barcode/*.py") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Barcode) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/Barcode) file(GLOB _FILES "Poly3DObjects/*.obj") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Poly3DObjects) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/Poly3DObjects) # file(GLOB _FILES # "test/*.svg" @@ -45,10 +45,10 @@ install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Poly3DO # "test/*.js" # "test/run-all-extension-tests" # ) -# install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/test) +# install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/test) file(GLOB _FILES "ink2canvas/*.py") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/ink2canvas) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/ink2canvas) file(GLOB _FILES "xaml2svg/*.xsl") -install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/xaml2svg) +install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/xaml2svg) -- cgit v1.2.3 From 35d3eeae3779e4b48e0484ca23d5254786aae588 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 27 Nov 2016 21:44:30 +0100 Subject: [Bug #1641111] extension Visualize Path/Measure path... fails Fixed bugs: - https://launchpad.net/bugs/1641111 (bzr r15281) --- share/extensions/measure.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/measure.py b/share/extensions/measure.py index 2711727cf..b605ffe93 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -34,6 +34,7 @@ TODO: ''' # standard library import locale +import re # local library import inkex import simplestyle @@ -211,7 +212,7 @@ class Length(inkex.Effect): factor = 1.0 doc = self.document.getroot() if doc.get('viewBox'): - [viewx, viewy, vieww, viewh] = doc.get('viewBox').split(' ') + (viewx, viewy, vieww, viewh) = re.sub(' +|, +|,',' ',doc.get('viewBox')).strip().split(' ', 4) factor = self.unittouu(doc.get('width'))/float(vieww) if self.unittouu(doc.get('height'))/float(viewh) < factor: factor = self.unittouu(doc.get('height'))/float(viewh) -- cgit v1.2.3 From 02e09f2b868edcfce47a53bf6bc556df6e5515bc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 6 Dec 2016 13:27:53 +0100 Subject: Add dpiswitcher extension and option to scale legacy documents with it. (bzr r15301) --- share/extensions/docinfo.inx | 21 ++++ share/extensions/dpi90to96.inx | 23 +++++ share/extensions/dpi96to90.inx | 23 +++++ share/extensions/dpiswitcher.py | 219 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 286 insertions(+) create mode 100644 share/extensions/docinfo.inx create mode 100644 share/extensions/dpi90to96.inx create mode 100644 share/extensions/dpi96to90.inx create mode 100644 share/extensions/dpiswitcher.py (limited to 'share/extensions') diff --git a/share/extensions/docinfo.inx b/share/extensions/docinfo.inx new file mode 100644 index 000000000..c3d76a960 --- /dev/null +++ b/share/extensions/docinfo.inx @@ -0,0 +1,21 @@ + + + <_name>DOC Info + org.inkscape.docinfo + dpiswitcher.py + inkex.py + + + <_param name="d" type="description">Choose this tab if you would like to see page info previously to apply DPI Switcher. + + + + all + + + + + + diff --git a/share/extensions/dpi90to96.inx b/share/extensions/dpi90to96.inx new file mode 100644 index 000000000..e7ad4a895 --- /dev/null +++ b/share/extensions/dpi90to96.inx @@ -0,0 +1,23 @@ + + + <_name>DPI 90 to 96 + org.inkscape.dpi90to96 + dpiswitcher.py + inkex.py + + + + DPI Switch from 90 to 96 + + + + + all + + + + + + diff --git a/share/extensions/dpi96to90.inx b/share/extensions/dpi96to90.inx new file mode 100644 index 000000000..11d1cb40b --- /dev/null +++ b/share/extensions/dpi96to90.inx @@ -0,0 +1,23 @@ + + + <_name>DPI 96 to 90 + org.inkscape.dpi96to90 + dpiswitcher.py + inkex.py + + + + DPI Switch from 96 to 90 + + + + + all + + + + + + diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py new file mode 100644 index 000000000..e7adbc0cf --- /dev/null +++ b/share/extensions/dpiswitcher.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python +''' +This extension scale or reduce a document to fit diferent SVG DPI -90/96- + +Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es + +Version 0.5 - DPI Switcher + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' + +import inkex, sys, re, string +from lxml import etree + +class DPISwitcher(inkex.Effect): + + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("--switcher", action="store", + type="string", dest="switcher", default="0", + help="Select the DPI switch you want") + self.OptionParser.add_option("--action", action="store", + type="string", dest="action", + default=None, help="") + self.factor_a = 90.0/96.0 + self.factor_b = 96.0/90.0 + self.units = "px" + self.unitExponent = 1.0 + + def scaleRoot(self, svg): + widthNumber = re.sub("[a-zA-Z]", "", svg.get('width')) + heightNumber = re.sub("[a-zA-Z]", "", svg.get('height')) + widthDoc = str(float(widthNumber) * self.factor_a * self.unitExponent) + heightDoc = str(float(heightNumber) * self.factor_a * self.unitExponent) + if svg.get('viewBox'): + widthNumber = svg.get('viewBox').split(" ")[2] + heightNumber = svg.get('viewBox').split(" ")[3] + if svg.get('height'): + svg.set('height', heightDoc) + if svg.get('width'): + svg.set('width', widthDoc) + if svg.get('viewBox'): + svg.set('viewBox',"0 0 " + str(float(widthNumber) * self.factor_a) + " " + str(float(heightNumber) * self.factor_a)) + if self.options.switcher == "1": + self.scaleGuides(svg) + self.scaleGrid(svg) + for element in svg: + box3DSide = element.get(inkex.addNS('box3dsidetype', 'inkscape')) + if box3DSide: + continue + uri, tag = element.tag.split("}") + width_scale = self.factor_a + height_scale = self.factor_a + if tag == "rect" or tag == "image" or tag == "path" or tag == "circle" or tag == "ellipse" or tag == "text": + if element.get('width') is not None and \ + (re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "%" or \ + re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "px"): + width_scale = 1.0; + if element.get('height') is not None and \ + (re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "%" or \ + re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "px"): + height_scale = 1.0; + if element.get('x') is not None and \ + re.sub("[0-9]*\.?[0-9]", "", element.get('x')) == "%": + xpos = str(float(element.get('x').replace('%','')) * self.factor_b) + '%' + element.set('x', xpos) + if element.get('y') is not None and \ + re.sub("[0-9]*\.?[0-9]", "", element.get('y')) == "%": + ypos = str(float(element.get('y').replace('%','')) * self.factor_b) + '%' + element.set('y', ypos) + if element.get('transform'): + if "matrix" in str(element.get('transform')) and width_scale != 1.0: + result = re.sub(r".*?matrix( \(|\()(.*?)\)", self.matrixElement, str(element.get('transform'))) + element.set('transform', result) + if "scale" in str(element.get('transform')) and width_scale != 1.0: + result = re.sub(r".*?scale( \(|\()(.*?)\)", self.scaleElement, str(element.get('transform'))) + element.set('transform', result) + if "translate" in str(element.get('transform')) and width_scale != 1.0: + result = re.sub(r".*?translate( \(|\()(.*?)\)", self.translateElement, str(element.get('transform'))) + element.set('transform', result) + if "skew" in str(element.get('transform')) and width_scale != 1.0: + result = re.sub(r".*?skew( \(|\()(.*?)\)", self.skewElement, str(element.get('transform'))) + element.set('transform', result) + if "scale" not in str(element.get('transform')) and "matrix" not in str(element.get('transform')): + element.set('transform', str(element.get('transform')) + "scale(" + str( width_scale) + ", " + str(height_scale) + ")") + else: + element.set('transform', "scale(" + str(width_scale) + ", " + str(height_scale) + ")") + + #a dictionary of unit to user unit conversion factors + __uuconv = {'in':96.0, 'pt':1.33333333333, 'px':1.0, 'mm':3.77952755913, 'cm':37.7952755913, + 'm':3779.52755913, 'km':3779527.55913, 'pc':16.0, 'yd':3456.0 , 'ft':1152.0} + + __uuconvLegazy = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, + 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} + + def scaleElement(self, m): + scaleVal = m.group(2).replace(" ","") + total = scaleVal.count(',') + if total == 1: + scaleVal = scaleVal.split(",") + return "matrix(" + str(float(scaleVal[0]) * self.factor_a) + ",0,0," + str(float(scaleVal[1]) * self.factor_a) + ",0,0)" + else: + return "matrix(" + str(float(scaleVal) * self.factor_a) + ",0,0," + str(float(scaleVal) * self.factor_a) + ",0,0)" + + + def translateElement(self, m): + translateVal = m.group(2).replace(" ","") + total = translateVal.count(',') + if total == 1: + translateVal = translateVal.split(",") + return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal[0]) * self.factor_a) + "," + str(float(translateVal[1]) * self.factor_a) + ")" + else: + return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal) * self.factor_a) + "," + str(float(translateVal) * self.factor_a) + ")" + + def skewElement(self, m): + skeweVal = m.group(2).replace(" ","") + total = skewVal.count(',') + if total == 1: + skeweVal = skewVal.split(",") + return "skew(" + str(float(skewVal[0]) * self.factor_a) + "," + str(float(skewVal[1]) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)" + else: + return "skew(" + str(float(skewVal) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)" + + def matrixElement(self, m): + matrixVal = m.group(2).replace(" ","") + total = matrixVal.count(',') + matrixVal = matrixVal.split(",") + if total == 5: + return "matrix(" + str(float(matrixVal[0]) * self.factor_a) + "," + matrixVal[1] + "," + matrixVal[2] + "," + str(float(matrixVal[3]) * self.factor_a) + "," + str(float(matrixVal[4]) * self.factor_a) + "," + str(float(matrixVal[5]) * self.factor_a) + ")" + + def scaleGuides(self, svg): + xpathStr = '//sodipodi:guide' + guides = svg.xpath(xpathStr, namespaces=inkex.NSS) + for guide in guides: + point = string.split(guide.get("position"), ",") + guide.set("position", str(float(point[0].strip()) * self.factor_a ) + "," + str(float(point[1].strip()) * self.factor_a )) + + def scaleGrid(self, svg): + xpathStr = '//inkscape:grid' + grids = svg.xpath(xpathStr, namespaces=inkex.NSS) + for grid in grids: + grid.set("units", "px") + if grid.get("spacingx"): + spacingx = str(float(re.sub("[a-zA-Z]", "", grid.get("spacingx"))) * self.factor_a) + "px" + grid.set("spacingx", str(spacingx)) + if grid.get("spacingy"): + spacingy = str(float(re.sub("[a-zA-Z]", "", grid.get("spacingy"))) * self.factor_a) + "px" + grid.set("spacingy", str(spacingy)) + if grid.get("originx"): + originx = str(float(re.sub("[a-zA-Z]", "", grid.get("originx"))) * self.factor_a) + "px" + grid.set("originx", str(originx)) + if grid.get("originy"): + originy = str(float(re.sub("[a-zA-Z]", "", grid.get("originy"))) * self.factor_a) + "px" + grid.set("originy", str(originy)) + + def effect(self): + action = self.options.action.strip("\"") # TODO Is this a bug? (Extra " characters) + saveout = sys.stdout + sys.stdout = sys.stderr + svg = self.document.getroot() + if action == "page_info": + print ":::SVG document related info:::" + print "version: " + str(svg.get(inkex.addNS('version',u'inkscape'))) + width = svg.get('width') + if width: + print "width: " + width + height = svg.get('height') + if height: + print "height: " + height + viewBox = svg.get('viewBox') + if viewBox: + print "viewBox: " + viewBox + namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) + docunits= namedview.get(inkex.addNS('document-units', 'inkscape')) + if docunits: + print "document-units: " + docunits + units = namedview.get('units') + if units: + print "units: " + units + xpathStr = '//sodipodi:guide' + guides = svg.xpath(xpathStr, namespaces=inkex.NSS) + xpathStr = '//inkscape:grid' + if guides: + numberGuides = len(guides) + print "Document has " + str(numberGuides) + " guides" + grids = svg.xpath(xpathStr, namespaces=inkex.NSS) + i = 1 + for grid in grids: + print "Grid number " + str(i) + ": Units: " + grid.get("units") + i = i+1 + else: + if self.options.switcher == "0": + self.factor_a = 96.0/90.0 + self.factor_b = 90.0/96.0 + namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) + namedview.set(inkex.addNS('document-units', 'inkscape'), "px") + self.units = re.sub("[0-9]*\.?[0-9]", "", svg.get('width')) + if self.units and self.units <> "px" and self.units <> "" and self.units <> "%": + if self.options.switcher == "0": + self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units]) + else: + self.unitExponent = 1.0/(self.factor_a/self.__uuconvLegazy[self.units]) + self.scaleRoot(svg); + sys.stdout = saveout + +effect = DPISwitcher() +effect.affect() -- cgit v1.2.3 From 91b11b81c382a3822cd1dbaeadf331469bf0665c Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 10 Dec 2016 19:23:01 +0100 Subject: Apply suv patch to handle containers https://bugs.launchpad.net/inkscape/+bug/1389723/comments/95 (bzr r15320) --- share/extensions/dpiswitcher.py | 65 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 8 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py index e7adbc0cf..46dad5ee5 100644 --- a/share/extensions/dpiswitcher.py +++ b/share/extensions/dpiswitcher.py @@ -20,9 +20,59 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -import inkex, sys, re, string +# standard libraries +import sys +import re +import string from lxml import etree +# local libraries +import inkex + + +# globals +REFERENCED_CONTAINERS = [ + # These container elements - which may be referenced by other + # elements - do not need to be scaled directly. The referencing + # elements will be either insided scaled containers or scaled + # directly as graphics elements in SVG root. + 'defs', + 'glyph', + 'marker', + 'mask', + 'missing-glyph', + 'pattern', + 'symbol', +] +CONTAINER_ELEMENTS = [ + # These element types have graphics elements and other container + # elements as child elements. They need to be scaled if in SVG root. + 'a', + 'g', + 'switch', +] +GRAPHICS_ELEMENTS = [ + # These element types cause graphics to be drawn. They need to be + # scaled if in SVG root. + 'circle', + 'ellipse', + 'image', + 'line', + 'path', + 'polygon', + 'polyline', + 'rect', + 'text', + 'use', +] +# FIXME: instances and referenced elements +# If for example a referenced element in SVG root is directly scaled, +# and its instance (referencing element e.g. ) is inside a scaled +# top-level container, the instance in the end will be rendered at an +# incorrect scale relative to the viewport (page area) and the other +# drawing content. Another unsupported case is both the referenced +# element and the instance in SVG root: the clone will in the end be +# rendered with the scale factor applied twice. + class DPISwitcher(inkex.Effect): @@ -56,14 +106,14 @@ class DPISwitcher(inkex.Effect): if self.options.switcher == "1": self.scaleGuides(svg) self.scaleGrid(svg) - for element in svg: + for element in svg: # iterate all top-level elements of SVGRoot box3DSide = element.get(inkex.addNS('box3dsidetype', 'inkscape')) if box3DSide: continue uri, tag = element.tag.split("}") width_scale = self.factor_a height_scale = self.factor_a - if tag == "rect" or tag == "image" or tag == "path" or tag == "circle" or tag == "ellipse" or tag == "text": + if tag in GRAPHICS_ELEMENTS or tag in CONTAINER_ELEMENTS: if element.get('width') is not None and \ (re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "%" or \ re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "px"): @@ -102,7 +152,7 @@ class DPISwitcher(inkex.Effect): __uuconv = {'in':96.0, 'pt':1.33333333333, 'px':1.0, 'mm':3.77952755913, 'cm':37.7952755913, 'm':3779.52755913, 'km':3779527.55913, 'pc':16.0, 'yd':3456.0 , 'ft':1152.0} - __uuconvLegazy = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, + __uuconvLegacy = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} def scaleElement(self, m): @@ -166,11 +216,10 @@ class DPISwitcher(inkex.Effect): grid.set("originy", str(originy)) def effect(self): - action = self.options.action.strip("\"") # TODO Is this a bug? (Extra " characters) saveout = sys.stdout sys.stdout = sys.stderr svg = self.document.getroot() - if action == "page_info": + if self.options.action == '"page_info"': print ":::SVG document related info:::" print "version: " + str(svg.get(inkex.addNS('version',u'inkscape'))) width = svg.get('width') @@ -211,7 +260,7 @@ class DPISwitcher(inkex.Effect): if self.options.switcher == "0": self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units]) else: - self.unitExponent = 1.0/(self.factor_a/self.__uuconvLegazy[self.units]) + self.unitExponent = 1.0/(self.factor_a/self.__uuconvLegacy[self.units]) self.scaleRoot(svg); sys.stdout = saveout -- cgit v1.2.3 From 12b1d911cfc7ac4fb0e9b1c8ef49321068ea14a9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 13 Dec 2016 10:13:01 +0100 Subject: Apply su_v patch to DPISwitcher: https://launchpadlibrarian.net/297886893/0000-fix-dpiswitcher-scaling-v1.diff (bzr r15323) --- share/extensions/dpiswitcher.py | 371 ++++++++++++++++++++++++++++------------ 1 file changed, 264 insertions(+), 107 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py index 46dad5ee5..317616db5 100644 --- a/share/extensions/dpiswitcher.py +++ b/share/extensions/dpiswitcher.py @@ -1,10 +1,11 @@ #!/usr/bin/env python ''' -This extension scale or reduce a document to fit diferent SVG DPI -90/96- +This extension scales a document to fit different SVG DPI -90/96- Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es +Copyright (C) 2016 su_v, -Version 0.5 - DPI Switcher +Version 0.6 - DPI Switcher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,22 +20,40 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Changes since v0.5: + - transform all top-level containers and graphics elements + - support scientific notation in SVG lengths + - fix scaling with existing matrix() (use functions from simpletransform.py) + - support different units for document width, height attributes + - improve viewBox support (syntax, offset) + - support common cases of text-put-on-path in SVG root + - support common cases of references in SVG root + - examples from http://tavmjong.free.fr/INKSCAPE/UNITS/ tested + +TODO: + - check grids/guides created with 0.91: + http://tavmjong.free.fr/INKSCAPE/UNITS/units_mm_nv_90dpi.svg + - check instances + - check more and text-on-path cases (reverse scaling needed?) + - scale perspective of 3dboxes + ''' # standard libraries import sys import re import string +import math from lxml import etree # local libraries import inkex +import simpletransform +import simplestyle # globals -REFERENCED_CONTAINERS = [ - # These container elements - which may be referenced by other - # elements - do not need to be scaled directly. The referencing - # elements will be either insided scaled containers or scaled - # directly as graphics elements in SVG root. +SKIP_CONTAINERS = [ 'defs', 'glyph', 'marker', @@ -44,15 +63,11 @@ REFERENCED_CONTAINERS = [ 'symbol', ] CONTAINER_ELEMENTS = [ - # These element types have graphics elements and other container - # elements as child elements. They need to be scaled if in SVG root. 'a', 'g', 'switch', ] GRAPHICS_ELEMENTS = [ - # These element types cause graphics to be drawn. They need to be - # scaled if in SVG root. 'circle', 'ellipse', 'image', @@ -64,14 +79,118 @@ GRAPHICS_ELEMENTS = [ 'text', 'use', ] -# FIXME: instances and referenced elements -# If for example a referenced element in SVG root is directly scaled, -# and its instance (referencing element e.g. ) is inside a scaled -# top-level container, the instance in the end will be rendered at an -# incorrect scale relative to the viewport (page area) and the other -# drawing content. Another unsupported case is both the referenced -# element and the instance in SVG root: the clone will in the end be -# rendered with the scale factor applied twice. + +def is_3dbox(element): + """Check whether element is an Inkscape 3dbox type.""" + return element.get(inkex.addNS('type', 'sodipodi')) == 'inkscape:box3d' + + +def is_use(element): + """Check whether element is of type .""" + return element.tag == inkex.addNS('use', 'svg') + + +def is_text(element): + """Check whether element is of type .""" + return element.tag == inkex.addNS('text', 'svg') + + +def is_text_on_path(element): + """Check whether text element is put on a path.""" + if is_text(element): + text_path = element.find(inkex.addNS('textPath', 'svg')) + if text_path is not None and len(text_path): + return True + return False + + +def is_sibling(element1, element2): + """Check whether element1 and element2 are siblings of same parent.""" + return element2 in element1.getparent() + + +def is_in_defs(doc, element): + """Check whether element is in defs.""" + if element is not None: + defs = doc.find('defs', namespaces=inkex.NSS) + if defs is not None: + return linked_node in defs.iterdescendants() + return False + + +def get_linked(doc, element): + """Return linked element or None.""" + if element is not None: + href = element.get(inkex.addNS('href', 'xlink'), None) + if href is not None: + linked_id = href[href.find('#')+1:] + path = '//*[@id="%s"]' % linked_id + el_list = doc.xpath(path, namespaces=inkex.NSS) + if isinstance(el_list, list) and len(el_list): + return el_list[0] + else: + return None + + +def check_3dbox(svg, element, scale_x, scale_y): + """Check transformation for 3dbox element.""" + skip = False + if skip: + # 3dbox elements ignore preserved transforms + # FIXME: manually update geometry of 3dbox? + pass + return skip + + +def check_text_on_path(svg, element, scale_x, scale_y): + """Check whether to skip scaling a text put on a path.""" + skip = False + path = get_linked(svg, element.find(inkex.addNS('textPath', 'svg'))) + if not is_in_defs(svg, path): + if is_sibling(element, path): + # skip common element scaling if both text and path are siblings + skip = True + # scale offset + if 'transform' in element.attrib: + mat = simpletransform.parseTransform(element.get('transform')) + mat[0][2] *= scale_x + mat[1][2] *= scale_y + element.set('transform', simpletransform.formatTransform(mat)) + # scale font size + mat = simpletransform.parseTransform( + 'scale({},{})'.format(scale_x, scale_y)) + det = abs(mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0]) + descrim = math.sqrt(abs(det)) + prop = 'font-size' + # outer text + sdict = simplestyle.parseStyle(element.get('style')) + if prop in sdict: + sdict[prop] = float(sdict[prop]) * descrim + element.set('style', simplestyle.formatStyle(sdict)) + # inner tspans + for child in element.iterdescendants(): + if child.tag == inkex.addNS('tspan', 'svg'): + sdict = simplestyle.parseStyle(child.get('style')) + if prop in sdict: + sdict[prop] = float(sdict[prop]) * descrim + child.set('style', simplestyle.formatStyle(sdict)) + return skip + + +def check_use(svg, element, scale_x, scale_y): + """Check whether to skip scaling an instanciated element ().""" + skip = False + path = get_linked(svg, element) + if not is_in_defs(svg, path): + if is_sibling(element, path): + skip = True + # scale offset + if 'transform' in element.attrib: + mat = simpletransform.parseTransform(element.get('transform')) + mat[0][2] *= scale_x + mat[1][2] *= scale_y + element.set('transform', simpletransform.formatTransform(mat)) + return skip class DPISwitcher(inkex.Effect): @@ -89,106 +208,140 @@ class DPISwitcher(inkex.Effect): self.units = "px" self.unitExponent = 1.0 + # dictionaries of unit to user unit conversion factors + __uuconvLegacy = { + 'in': 90.0, + 'pt': 1.25, + 'px': 1.0, + 'mm': 3.5433070866, + 'cm': 35.433070866, + 'm': 3543.3070866, + 'km': 3543307.0866, + 'pc': 15.0, + 'yd': 3240.0, + 'ft': 1080.0, + } + __uuconv = { + 'in': 96.0, + 'pt': 1.33333333333, + 'px': 1.0, + 'mm': 3.77952755913, + 'cm': 37.7952755913, + 'm': 3779.52755913, + 'km': 3779527.55913, + 'pc': 16.0, + 'yd': 3456.0, + 'ft': 1152.0, + } + + def parse_length(self, length, percent=False): + """Parse SVG length.""" + if self.options.switcher == "0": # dpi90to96 + known_units = self.__uuconvLegacy.keys() + else: # dpi96to90 + known_units = self.__uuconv.keys() + if percent: + unitmatch = re.compile('(%s)$' % '|'.join(known_units + ['%'])) + else: + unitmatch = re.compile('(%s)$' % '|'.join(known_units)) + param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)') + p = param.match(length) + u = unitmatch.search(length) + val = 100 # fallback: assume default length of 100 + unit = 'px' # fallback: assume 'px' unit + if p: + val = float(p.string[p.start():p.end()]) + if u: + unit = u.string[u.start():u.end()] + return (val, unit) + + def convert_length(self, val, unit): + """Convert length to self.units if unit differs.""" + doc_unit = self.units or 'px' + if unit != doc_unit: + if self.options.switcher == "0": # dpi90to96 + val_px = val * self.__uuconvLegacy[unit] + val = val_px / (self.__uuconvLegacy[doc_unit] / self.__uuconvLegacy['px']) + unit = doc_unit + else: # dpi96to90 + val_px = val * self.__uuconv[unit] + val = val_px / (self.__uuconv[doc_unit] / self.__uuconv['px']) + unit = doc_unit + return (val, unit) + + def check_attr_unit(self, element, attr, unit_list): + """Check unit of attribute value, match to units in *unit_list*.""" + if attr in element.attrib: + unit = self.parse_length(element.get(attr), percent=True)[1] + return unit in unit_list + + def scale_attr_val(self, element, attr, unit_list, factor): + """Scale attribute value if unit matches one in *unit_list*.""" + if attr in element.attrib: + val, unit = self.parse_length(element.get(attr), percent=True) + if unit in unit_list: + element.set(attr, '{}{}'.format(val * factor, unit)) + def scaleRoot(self, svg): - widthNumber = re.sub("[a-zA-Z]", "", svg.get('width')) - heightNumber = re.sub("[a-zA-Z]", "", svg.get('height')) - widthDoc = str(float(widthNumber) * self.factor_a * self.unitExponent) - heightDoc = str(float(heightNumber) * self.factor_a * self.unitExponent) - if svg.get('viewBox'): - widthNumber = svg.get('viewBox').split(" ")[2] - heightNumber = svg.get('viewBox').split(" ")[3] + """Scale all top-level elements in SVG root.""" + + # update viewport + widthNumber = self.parse_length(svg.get('width'))[0] + heightNumber = self.convert_length(*self.parse_length(svg.get('height')))[0] + widthDoc = widthNumber * self.factor_a * self.unitExponent + heightDoc = heightNumber * self.factor_a * self.unitExponent + if svg.get('height'): - svg.set('height', heightDoc) + svg.set('height', str(heightDoc)) if svg.get('width'): - svg.set('width', widthDoc) + svg.set('width', str(widthDoc)) + + # update viewBox if svg.get('viewBox'): - svg.set('viewBox',"0 0 " + str(float(widthNumber) * self.factor_a) + " " + str(float(heightNumber) * self.factor_a)) + viewboxstring = re.sub(' +|, +|,',' ', svg.get('viewBox')) + viewboxlist = [float(i) for i in viewboxstring.strip().split(' ', 4)] + svg.set('viewBox','{} {} {} {}'.format(*[(val * self.factor_a) for val in viewboxlist])) + + # update guides, grids if self.options.switcher == "1": + # FIXME: dpi96to90 only? self.scaleGuides(svg) self.scaleGrid(svg) + for element in svg: # iterate all top-level elements of SVGRoot - box3DSide = element.get(inkex.addNS('box3dsidetype', 'inkscape')) - if box3DSide: - continue - uri, tag = element.tag.split("}") + + # init variables + tag = etree.QName(element).localname width_scale = self.factor_a height_scale = self.factor_a - if tag in GRAPHICS_ELEMENTS or tag in CONTAINER_ELEMENTS: - if element.get('width') is not None and \ - (re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "%" or \ - re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "px"): - width_scale = 1.0; - if element.get('height') is not None and \ - (re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "%" or \ - re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "px"): - height_scale = 1.0; - if element.get('x') is not None and \ - re.sub("[0-9]*\.?[0-9]", "", element.get('x')) == "%": - xpos = str(float(element.get('x').replace('%','')) * self.factor_b) + '%' - element.set('x', xpos) - if element.get('y') is not None and \ - re.sub("[0-9]*\.?[0-9]", "", element.get('y')) == "%": - ypos = str(float(element.get('y').replace('%','')) * self.factor_b) + '%' - element.set('y', ypos) - if element.get('transform'): - if "matrix" in str(element.get('transform')) and width_scale != 1.0: - result = re.sub(r".*?matrix( \(|\()(.*?)\)", self.matrixElement, str(element.get('transform'))) - element.set('transform', result) - if "scale" in str(element.get('transform')) and width_scale != 1.0: - result = re.sub(r".*?scale( \(|\()(.*?)\)", self.scaleElement, str(element.get('transform'))) - element.set('transform', result) - if "translate" in str(element.get('transform')) and width_scale != 1.0: - result = re.sub(r".*?translate( \(|\()(.*?)\)", self.translateElement, str(element.get('transform'))) - element.set('transform', result) - if "skew" in str(element.get('transform')) and width_scale != 1.0: - result = re.sub(r".*?skew( \(|\()(.*?)\)", self.skewElement, str(element.get('transform'))) - element.set('transform', result) - if "scale" not in str(element.get('transform')) and "matrix" not in str(element.get('transform')): - element.set('transform', str(element.get('transform')) + "scale(" + str( width_scale) + ", " + str(height_scale) + ")") - else: - element.set('transform', "scale(" + str(width_scale) + ", " + str(height_scale) + ")") - #a dictionary of unit to user unit conversion factors - __uuconv = {'in':96.0, 'pt':1.33333333333, 'px':1.0, 'mm':3.77952755913, 'cm':37.7952755913, - 'm':3779.52755913, 'km':3779527.55913, 'pc':16.0, 'yd':3456.0 , 'ft':1152.0} - - __uuconvLegacy = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866, - 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080} + if tag in GRAPHICS_ELEMENTS or tag in CONTAINER_ELEMENTS: - def scaleElement(self, m): - scaleVal = m.group(2).replace(" ","") - total = scaleVal.count(',') - if total == 1: - scaleVal = scaleVal.split(",") - return "matrix(" + str(float(scaleVal[0]) * self.factor_a) + ",0,0," + str(float(scaleVal[1]) * self.factor_a) + ",0,0)" - else: - return "matrix(" + str(float(scaleVal) * self.factor_a) + ",0,0," + str(float(scaleVal) * self.factor_a) + ",0,0)" + # test for specific elements to skip from scaling + if is_3dbox(element): + if check_3dbox(svg, element, width_scale, height_scale): + continue + if is_text_on_path(element): + if check_text_on_path(svg, element, width_scale, height_scale): + continue + if is_use(element): + if check_use(svg, element, width_scale, height_scale): + continue + # relative units ('%') in presentation attributes + for attr in ['width', 'height']: + self.scale_attr_val(element, attr, ['%'], 1.0 / self.factor_a) + for attr in ['x', 'y']: + self.scale_attr_val(element, attr, ['%'], 1.0 / self.factor_a) - def translateElement(self, m): - translateVal = m.group(2).replace(" ","") - total = translateVal.count(',') - if total == 1: - translateVal = translateVal.split(",") - return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal[0]) * self.factor_a) + "," + str(float(translateVal[1]) * self.factor_a) + ")" - else: - return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal) * self.factor_a) + "," + str(float(translateVal) * self.factor_a) + ")" - - def skewElement(self, m): - skeweVal = m.group(2).replace(" ","") - total = skewVal.count(',') - if total == 1: - skeweVal = skewVal.split(",") - return "skew(" + str(float(skewVal[0]) * self.factor_a) + "," + str(float(skewVal[1]) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)" - else: - return "skew(" + str(float(skewVal) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)" + # set preserved transforms on top-level elements + if width_scale != 1.0 and height_scale != 1.0: + mat = simpletransform.parseTransform( + 'scale({},{})'.format(width_scale, height_scale)) + simpletransform.applyTransformToNode(mat, element) - def matrixElement(self, m): - matrixVal = m.group(2).replace(" ","") - total = matrixVal.count(',') - matrixVal = matrixVal.split(",") - if total == 5: - return "matrix(" + str(float(matrixVal[0]) * self.factor_a) + "," + matrixVal[1] + "," + matrixVal[2] + "," + str(float(matrixVal[3]) * self.factor_a) + "," + str(float(matrixVal[4]) * self.factor_a) + "," + str(float(matrixVal[5]) * self.factor_a) + ")" + def scaleElement(self, m): + pass # TODO: optionally scale graphics elements only? def scaleGuides(self, svg): xpathStr = '//sodipodi:guide' @@ -255,7 +408,7 @@ class DPISwitcher(inkex.Effect): self.factor_b = 90.0/96.0 namedview = svg.find(inkex.addNS('namedview', 'sodipodi')) namedview.set(inkex.addNS('document-units', 'inkscape'), "px") - self.units = re.sub("[0-9]*\.?[0-9]", "", svg.get('width')) + self.units = self.parse_length(svg.get('width'))[1] if self.units and self.units <> "px" and self.units <> "" and self.units <> "%": if self.options.switcher == "0": self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units]) @@ -264,5 +417,9 @@ class DPISwitcher(inkex.Effect): self.scaleRoot(svg); sys.stdout = saveout -effect = DPISwitcher() -effect.affect() + +if __name__ == '__main__': + effect = DPISwitcher() + effect.affect() + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 -- cgit v1.2.3 From 1718bfb10a12c22b9f4a9d502e715634c2cc153c Mon Sep 17 00:00:00 2001 From: Ivan Mas??r Date: Fri, 30 Dec 2016 17:11:45 +0100 Subject: fix typos, add translator comment (bzr r15373) --- share/extensions/gcodetools.py | 4 ++-- share/extensions/gcodetools_about.inx | 2 +- share/extensions/gcodetools_area.inx | 2 +- share/extensions/gcodetools_lathe.inx | 4 ++-- share/extensions/gcodetools_path_to_gcode.inx | 2 +- share/extensions/gcodetools_prepare_path_for_plasma.inx | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/gcodetools.py b/share/extensions/gcodetools.py index dab0312af..23a3e1a1c 100755 --- a/share/extensions/gcodetools.py +++ b/share/extensions/gcodetools.py @@ -3433,7 +3433,7 @@ class Gcodetools(inkex.Effect): for subpath in csp : for sp1, sp2 in zip(subpath,subpath[1:]) : polygon.add([csp_segment_convex_hull(sp1,sp2)]) - #print_("Redused edges count from", sum([len(poly) for poly in polygon.polygon ]) ) + #print_("Reduced edges count from", sum([len(poly) for poly in polygon.polygon ]) ) polygon.hull() original_paths += [path] polygons += [polygon] @@ -3574,7 +3574,7 @@ class Gcodetools(inkex.Effect): self.OptionParser.add_option("", "--biarc-max-split-depth", action="store", type="int", dest="biarc_max_split_depth", default="4", help="Defines maximum depth of splitting while approximating using biarcs.") self.OptionParser.add_option("", "--path-to-gcode-order", action="store", type="string", dest="path_to_gcode_order", default="path by path", help="Defines cutting order path by path or layer by layer.") self.OptionParser.add_option("", "--path-to-gcode-depth-function",action="store", type="string", dest="path_to_gcode_depth_function", default="zd", help="Path to gcode depth function.") - self.OptionParser.add_option("", "--path-to-gcode-sort-paths", action="store", type="inkbool", dest="path_to_gcode_sort_paths", default=True, help="Sort paths to reduse rapid distance.") + self.OptionParser.add_option("", "--path-to-gcode-sort-paths", action="store", type="inkbool", dest="path_to_gcode_sort_paths", default=True, help="Sort paths to reduce rapid distance.") self.OptionParser.add_option("", "--comment-gcode", action="store", type="string", dest="comment_gcode", default="", help="Comment Gcode") self.OptionParser.add_option("", "--comment-gcode-from-properties",action="store", type="inkbool", dest="comment_gcode_from_properties", default=False,help="Get additional comments from Object Properties") diff --git a/share/extensions/gcodetools_about.inx b/share/extensions/gcodetools_about.inx index c1016477d..385a38244 100644 --- a/share/extensions/gcodetools_about.inx +++ b/share/extensions/gcodetools_about.inx @@ -10,7 +10,7 @@ <_param name="help" type="description">Gcodetools was developed to make simple Gcode from Inkscape's paths. Gcode is a special format which is used in most of CNC machines. So Gcodetools allows you to use Inkscape as CAM program. -It can be use with a lot of machine types: +It can be used with a lot of machine types: Mills Lathes Laser and Plasma cutters and engravers diff --git a/share/extensions/gcodetools_area.inx b/share/extensions/gcodetools_area.inx index b487f2c54..23efdf8b6 100644 --- a/share/extensions/gcodetools_area.inx +++ b/share/extensions/gcodetools_area.inx @@ -57,7 +57,7 @@ Suspected small objects will be marked out by colored arrows. d - True + True <_param name="help" type="description"> Biarc interpolation tolerance is the maximum distance between path and its approximation. diff --git a/share/extensions/gcodetools_lathe.inx b/share/extensions/gcodetools_lathe.inx index c74ae267c..7483ac2b9 100644 --- a/share/extensions/gcodetools_lathe.inx +++ b/share/extensions/gcodetools_lathe.inx @@ -21,7 +21,7 @@ <_param name="help" type="description"> - This function modifies path so it will be able to be cut with the rectangular cutter. + This function modifies path so it will be possible to be cut it with a rectangular cutter. 4 @@ -37,7 +37,7 @@ d - True + True <_param name="help" type="description"> Biarc interpolation tolerance is the maximum distance between path and its approximation. diff --git a/share/extensions/gcodetools_path_to_gcode.inx b/share/extensions/gcodetools_path_to_gcode.inx index 39cc6571b..b1664a70e 100644 --- a/share/extensions/gcodetools_path_to_gcode.inx +++ b/share/extensions/gcodetools_path_to_gcode.inx @@ -17,7 +17,7 @@ d - True + True <_param name="help" type="description"> Biarc interpolation tolerance is the maximum distance between path and its approximation. diff --git a/share/extensions/gcodetools_prepare_path_for_plasma.inx b/share/extensions/gcodetools_prepare_path_for_plasma.inx index ab054714e..805a3a2b2 100644 --- a/share/extensions/gcodetools_prepare_path_for_plasma.inx +++ b/share/extensions/gcodetools_prepare_path_for_plasma.inx @@ -7,7 +7,7 @@ inkex.py - + True 10 10 -- cgit v1.2.3 From 5bb29138e26fab00159edda73dc51c9e7d483148 Mon Sep 17 00:00:00 2001 From: "mattia@debian.org" <> Date: Sat, 7 Jan 2017 12:24:29 +0100 Subject: Don't install python modules with the executable bit (bzr r15395.1.1) --- share/extensions/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/CMakeLists.txt b/share/extensions/CMakeLists.txt index b311c6cbf..47dfbe0a0 100644 --- a/share/extensions/CMakeLists.txt +++ b/share/extensions/CMakeLists.txt @@ -26,8 +26,18 @@ file(GLOB _SCRIPTS "*.sh" "*.rb" ) - +# These files don't need the +x bit +set(_SCRIPTS_NOEXEC + "hersheydata.py" + "hpgl_decoder.py" + "hpgl_encoder.py" + "simplepath.py" + "simplestyle.py" + "simpletransform.py" +) +list(REMOVE_ITEM _SCRIPTS ${_SCRIPTS_NOEXEC}) install(PROGRAMS ${_SCRIPTS} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions) +install(FILES ${_SCRIPTS_NOEXEC} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions) file(GLOB _FILES "alphabet_soup/*.svg") install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/extensions/alphabet_soup) -- cgit v1.2.3 From 62ef7c9d8c78ec40d5eab013246bfd204709b605 Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Sun, 8 Jan 2017 08:55:53 +0100 Subject: [Bug #1654743] Interpolate extension fails if end path has no 'stroke-width' attribute (0.91, 0.92). Fixed bugs: - https://launchpad.net/bugs/1654743 (bzr r15401) --- share/extensions/interp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/interp.py b/share/extensions/interp.py index a53ab07d9..fd80ab412 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -110,8 +110,8 @@ class Interp(inkex.Effect): def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' scale = self.unittouu('1px') - sp = self.unittouu(start[property]) / scale - ep = self.unittouu(end[property]) / scale + sp = self.unittouu(start.get(property, '1px')) / scale + ep = self.unittouu(end.get(property, '1px')) / scale return str(sp + (time * (ep - sp))) def effect(self): -- cgit v1.2.3 From e1e535998b740ea79b0bdcd5b09a855e13af397f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 10 Jan 2017 09:58:25 +0100 Subject: [Bug #1651334] Strings untranslatable due to word puzzles. Fixed bugs: - https://launchpad.net/bugs/1651334 (bzr r15405) --- share/extensions/draw_from_triangle.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/draw_from_triangle.py b/share/extensions/draw_from_triangle.py index 3146fe26e..fd966b1d1 100755 --- a/share/extensions/draw_from_triangle.py +++ b/share/extensions/draw_from_triangle.py @@ -176,16 +176,17 @@ def cot(x):#cotangent(x) def report_properties( params ):#report to the Inkscape console using errormsg # TODO: unit identifier needs solution for arbitrary document scale unit = Draw_From_Triangle.getDocumentUnit(e) - inkex.errormsg(_("Side Length 'a' (" + unit + "): " + str( params[0][0] ) )) - inkex.errormsg(_("Side Length 'b' (" + unit + "): " + str( params[0][1] ) )) - inkex.errormsg(_("Side Length 'c' (" + unit + "): " + str( params[0][2] ) )) - inkex.errormsg(_("Angle 'A' (radians): " + str( params[1][0] ) )) - inkex.errormsg(_("Angle 'B' (radians): " + str( params[1][1] ) )) - inkex.errormsg(_("Angle 'C' (radians): " + str( params[1][2] ) )) - inkex.errormsg(_("Semiperimeter (px): " + str( params[4][1] ) )) - inkex.errormsg(_("Area ("+ unit + "^2): " + str( params[4][0] ) )) + + inkex.errormsg(_("Side Length 'a' ({0}): {1}").format(unit, str(params[0][0])) ) + inkex.errormsg(_("Side Length 'b' ({0}): {1}").format(unit, str(params[0][1])) ) + inkex.errormsg(_("Side Length 'c' ({0}): {1}").format(unit, str(params[0][2])) ) + inkex.errormsg(_("Angle 'A' (radians): {}").format(str(params[1][0])) ) + inkex.errormsg(_("Angle 'B' (radians): {}").format(str(params[1][1])) ) + inkex.errormsg(_("Angle 'C' (radians): {}").format(params[1][2]) ) + inkex.errormsg(_("Semiperimeter (px): {}").format(params[4][1]) ) + inkex.errormsg(_("Area ({0}^2): {1}").format(unit, str(params[4][0])) ) return - + class Style(object): #container for style information def __init__(self, options): -- cgit v1.2.3 From 0e4fb2baf3e4a0a17247df6d46f04c0b504ae4bd Mon Sep 17 00:00:00 2001 From: seahawk1986-hotmail <> Date: Thu, 12 Jan 2017 11:49:13 +0100 Subject: [Bug #1650480] pyserial errorhandling in plotter.py tries to iterate over wrong Exception attribute. Fixed bugs: - https://launchpad.net/bugs/1650480 (bzr r15413) --- share/extensions/plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index 8a14d55bc..800142bb2 100755 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -196,7 +196,7 @@ class Plot(inkex.Effect): try: mySerial.open() except Exception as inst: - if 'ould not open port' in inst.args[0]: + if 'ould not open port' in inst.strerror: inkex.errormsg(_("Could not open port. Please check that your plotter is running, connected and the settings are correct.")) return else: -- cgit v1.2.3 From c4058f9f1ccd9c3bb2eecbb781cc1fee7001a9ac Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 15 Jan 2017 03:09:19 +0100 Subject: Extensions: run_command.py - inform user about output to stderr even if error code is zero (bzr r15417) --- share/extensions/run_command.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/run_command.py b/share/extensions/run_command.py index 7012c4274..950e9ed7c 100755 --- a/share/extensions/run_command.py +++ b/share/extensions/run_command.py @@ -61,8 +61,11 @@ def run(command_format, prog_name): except ImportError: # shouldn't happen... msg = "Neither subprocess.Popen nor popen2.Popen3 is available" - if rc and msg is None: - msg = "%s failed:\n%s\n%s\n" % (prog_name, out, err) + if msg is None: + if rc: + msg = "%s failed:\n%s\n%s\n" % (prog_name, out, err) + elif err: + sys.stderr.write("%s executed but logged the following error:\n%s\n%s\n" % (prog_name, out, err)) except Exception, inst: msg = "Error attempting to run %s: %s" % (prog_name, str(inst)) -- cgit v1.2.3 From 10141c4f5a78c99811a52ace4ee9b46ad5cbc3b5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 22 Jan 2017 16:37:47 +0100 Subject: i18n. Fixing gettext initialization in the Uniconvertor related extensions. (bzr r15430) --- share/extensions/uniconv-ext.py | 3 ++- share/extensions/uniconv_output.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/uniconv-ext.py b/share/extensions/uniconv-ext.py index c84ee2e0a..6ce0d7fab 100755 --- a/share/extensions/uniconv-ext.py +++ b/share/extensions/uniconv-ext.py @@ -51,7 +51,8 @@ if cmd == None: import imp imp.find_module("uniconvertor") except ImportError: - sys.stderr.write(_('You need to install the UniConvertor software.\n'+\ + inkex.localize() + inkex.errormsg(_('You need to install the UniConvertor software.\n'+\ 'For GNU/Linux: install the package python-uniconvertor.\n'+\ 'For Windows: download it from\n'+\ 'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n'+\ diff --git a/share/extensions/uniconv_output.py b/share/extensions/uniconv_output.py index 7815137b6..a02a16d95 100755 --- a/share/extensions/uniconv_output.py +++ b/share/extensions/uniconv_output.py @@ -118,7 +118,8 @@ def get_command(): import imp imp.find_module("uniconvertor") except ImportError: - sys.stderr.write(_('You need to install the UniConvertor software.\n'+\ + inkex.localize() + inkex.errormsg(_('You need to install the UniConvertor software.\n'+\ 'For GNU/Linux: install the package python-uniconvertor.\n'+\ 'For Windows: download it from\n'+\ 'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n'+\ -- cgit v1.2.3 From 2975cae69ee6b1b35dc586e908fc6679ce165938 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 22 Jan 2017 18:23:34 +0100 Subject: i18n. Fixing gettext initialization in the HPGL related extensions. (bzr r15431) --- share/extensions/hpgl_input.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_input.py b/share/extensions/hpgl_input.py index 2b275cbf8..13d6d00ec 100755 --- a/share/extensions/hpgl_input.py +++ b/share/extensions/hpgl_input.py @@ -26,6 +26,8 @@ import hpgl_decoder import inkex import sys +inkex.localize() + # parse options parser = inkex.optparse.OptionParser(usage='usage: %prog [options] HPGLfile', option_class=inkex.InkOption) parser.add_option('--resolutionX', action='store', type='float', dest='resolutionX', default=1016.0, help='Resolution X (dpi)') -- cgit v1.2.3 From 22f70b86b718287ab031db355f5b0c19e31c9fd7 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 23 Jan 2017 11:27:07 +0100 Subject: Extensions. Improve run-all-extension-tests script for Windows users. (bzr r15432) --- share/extensions/test/run-all-extension-tests | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/test/run-all-extension-tests b/share/extensions/test/run-all-extension-tests index e7faf672a..ff739c311 100755 --- a/share/extensions/test/run-all-extension-tests +++ b/share/extensions/test/run-all-extension-tests @@ -38,20 +38,25 @@ failed_tests=$( $MKTEMP ) if coverage.py erase >/dev/null 2>/dev/null; then has_py_coverage=true cover_py_cmd=coverage.py -else - if coverage erase >/dev/null 2>/dev/null; then - has_py_coverage=true - cover_py_cmd=coverage - else - if python-coverage erase >/dev/null 2>/dev/null; then - has_py_coverage=true - cover_py_cmd=python-coverage - fi - fi + else + if coverage erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=coverage + else + if python-coverage erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=python-coverage + else + if coverage-script.py erase >/dev/null 2>/dev/null; then + has_py_coverage=true + cover_py_cmd=coverage-script.py + fi + fi + fi fi if $has_py_coverage; then - echo -e "\nRunning tests with coverage" + echo -e "\nRunning tests with coverage (${cover_py_cmd})" fi #if $has_py_coverage; then # $cover_py_cmd -e -- cgit v1.2.3 From cb1e1ed0e7eab8865a1f3a5925688cea5f63a140 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 23 Jan 2017 11:32:56 +0100 Subject: i18n. Fixing gettext initialization in some more extensions. (bzr r15433) --- share/extensions/dxf_outlines.py | 2 ++ share/extensions/measure.py | 3 +++ share/extensions/perspective.py | 2 ++ share/extensions/polyhedron_3d.py | 3 +++ 4 files changed, 10 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index 525461bde..a387df4a1 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -44,6 +44,8 @@ try: from numpy import * from numpy.linalg import solve except: + # Initialize gettext for messages outside an inkex derived class + inkex.localize() inkex.errormsg(_("Failed to import the numpy or numpy.linalg modules. These modules are required by this extension. Please install them and try again.")) inkex.sys.exit() diff --git a/share/extensions/measure.py b/share/extensions/measure.py index b605ffe93..d025f142c 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -51,6 +51,9 @@ try: except locale.Error: locale.setlocale(locale.LC_ALL, 'C') +# Initialize gettext for messages outside an inkex derived class +inkex.localize() + # third party try: import numpy diff --git a/share/extensions/perspective.py b/share/extensions/perspective.py index ea08b98dc..f15deaad5 100755 --- a/share/extensions/perspective.py +++ b/share/extensions/perspective.py @@ -39,6 +39,8 @@ try: from numpy import * from numpy.linalg import * except: + # Initialize gettext for messages outside an inkex derived class + inkex.localize() inkex.errormsg(_("Failed to import the numpy or numpy.linalg modules. These modules are required by this extension. Please install them and try again. On a Debian-like system this can be done with the command, sudo apt-get install python-numpy.")) exit() diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py index 86203d4bc..a74a64e69 100755 --- a/share/extensions/polyhedron_3d.py +++ b/share/extensions/polyhedron_3d.py @@ -57,6 +57,9 @@ import inkex import simplestyle from simpletransform import computePointInNode +# Initialize gettext for messages outside an inkex derived class +inkex.localize() + # third party try: from numpy import * -- cgit v1.2.3 From fac56d4edde603933e315d147d333764c51e9694 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 24 Jan 2017 10:13:28 +0100 Subject: [Bug #1658925] Incorrect SK1 link in Uniconvertor error messages. Fixed bugs: - https://launchpad.net/bugs/1658925 (bzr r15439) --- share/extensions/uniconv-ext.py | 2 +- share/extensions/uniconv_output.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/uniconv-ext.py b/share/extensions/uniconv-ext.py index 6ce0d7fab..876cc4642 100755 --- a/share/extensions/uniconv-ext.py +++ b/share/extensions/uniconv-ext.py @@ -55,7 +55,7 @@ if cmd == None: inkex.errormsg(_('You need to install the UniConvertor software.\n'+\ 'For GNU/Linux: install the package python-uniconvertor.\n'+\ 'For Windows: download it from\n'+\ - 'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n'+\ + 'https://sk1project.net/modules.php?name=Products&product=uniconvertor&op=download\n'+\ 'and install into your Inkscape\'s Python location\n')) sys.exit(1) cmd = 'python -c "import uniconvertor; uniconvertor.uniconv_run()"' diff --git a/share/extensions/uniconv_output.py b/share/extensions/uniconv_output.py index a02a16d95..de6b6409f 100755 --- a/share/extensions/uniconv_output.py +++ b/share/extensions/uniconv_output.py @@ -122,7 +122,7 @@ def get_command(): inkex.errormsg(_('You need to install the UniConvertor software.\n'+\ 'For GNU/Linux: install the package python-uniconvertor.\n'+\ 'For Windows: download it from\n'+\ - 'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n'+\ + 'https://sk1project.net/modules.php?name=Products&product=uniconvertor&op=download\n'+\ 'and install into your Inkscape\'s Python location\n')) sys.exit(1) cmd = 'python -c "import uniconvertor; uniconvertor.uniconv_run();"' -- cgit v1.2.3 From 1877acd7dc37abe559c94d3abea5e9148fce8fab Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 24 Jan 2017 18:52:08 +0100 Subject: Put namespace as constant (bzr r15142.1.40) --- share/extensions/hpgl_output.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 367a9addd..f31c3fc2d 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -45,6 +45,7 @@ class HpglOutput(inkex.Effect): self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') + self.DOCROTATE = "{http://www.inkscape.org/namespaces/inkscape}document_rotation" def effect(self): self.options.debug = False @@ -54,8 +55,8 @@ class HpglOutput(inkex.Effect): nv = svg.xpath(xpathStr, namespaces=NSS) document_rotate = "0" if nv != []: - document_rotate = nv[0].get("{http://www.inkscape.org/namespaces/inkscape}document-rotation") - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document-rotation","0") + document_rotate = nv[0].get(self.DOCROTATE) + nv[0].set(self.DOCROTATE,"0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -65,12 +66,12 @@ class HpglOutput(inkex.Effect): inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -80,7 +81,7 @@ class HpglOutput(inkex.Effect): hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' if nv != [] and document_rotate: - nv[0].set("{http://www.inkscape.org/namespaces/inkscape}document_rotation",document_rotate) + nv[0].set("inkscape:document_rotation",document_rotate) def output(self): # print to file -- cgit v1.2.3 From b1597f9bc8bb99fabeaaf4237bff8c24e7062df7 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 25 Jan 2017 18:32:38 +0100 Subject: Extensions. Basic tests for the simpletransform.py file. (bzr r15450) --- share/extensions/test/simpletransform.test.py | 28 ++++++++++++++++++++++ share/extensions/test/svg/simpletransform.test.svg | 8 +++++++ 2 files changed, 36 insertions(+) create mode 100755 share/extensions/test/simpletransform.test.py create mode 100644 share/extensions/test/svg/simpletransform.test.svg (limited to 'share/extensions') diff --git a/share/extensions/test/simpletransform.test.py b/share/extensions/test/simpletransform.test.py new file mode 100755 index 000000000..9e5dbc3b2 --- /dev/null +++ b/share/extensions/test/simpletransform.test.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import os +import sys +import unittest + +sys.path.append('..') # this line allows to import the extension code + +import inkex +from simpletransform import * + +class ComputeBBoxTest(unittest.TestCase): + def setUp(self): + args = [ 'svg/simpletransform.test.svg' ] + self.e = inkex.Effect() + self.e.affect(args, False) + + def test_scaled_object(self): + "Object in the defs with 50,50 scaled by 0.5 when used" + bbox = computeBBox(self.e.document.xpath("//svg:g", namespaces=inkex.NSS)) + text_bbox = "{} {} {} {}".format(bbox[0], bbox[1], bbox[2], bbox[3]) + self.assertEqual(text_bbox, "0.0 25.0 0.0 25.0") + + + +if __name__ == '__main__': + suite = unittest.TestLoader().loadTestsFromTestCase(ComputeBBoxTest) + unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/share/extensions/test/svg/simpletransform.test.svg b/share/extensions/test/svg/simpletransform.test.svg new file mode 100644 index 000000000..62876eea7 --- /dev/null +++ b/share/extensions/test/svg/simpletransform.test.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From ed1a122295c24cd0bdec973d0e6f36bc2e284877 Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Thu, 26 Jan 2017 17:38:02 +0100 Subject: [Bug #1659446] Cartesian Grid dialogue box bottom under dock. Fixed bugs: - https://launchpad.net/bugs/1659446 (bzr r15457) --- share/extensions/grid_cartesian.inx | 45 ++++++++++++++++++++----------------- share/extensions/grid_cartesian.py | 3 +++ 2 files changed, 28 insertions(+), 20 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/grid_cartesian.inx b/share/extensions/grid_cartesian.inx index 494aabf76..f053d80bb 100644 --- a/share/extensions/grid_cartesian.inx +++ b/share/extensions/grid_cartesian.inx @@ -4,27 +4,32 @@ grid.cartesian grid_cartesian.py inkex.py + 3 - <_param name="x_axis" type="description" appearance="header">X Axis - 6 - 100.0 - 2 - false - 5 - 4 - 2 - 1 - 0.3 - <_param name="y_axis" type="description" appearance="header">Y Axis - 5 - 100.0 - 1 - false - 5 - 4 - 2 - 1 - 0.3 + + + 6 + 100.0 + 2 + false + 5 + 4 + 2 + 1 + 0.3 + + + 5 + 100.0 + 1 + false + 5 + 4 + 2 + 1 + 0.3 + + all diff --git a/share/extensions/grid_cartesian.py b/share/extensions/grid_cartesian.py index 26270002d..e92509505 100755 --- a/share/extensions/grid_cartesian.py +++ b/share/extensions/grid_cartesian.py @@ -44,6 +44,9 @@ def draw_SVG_rect(x,y,w,h, width, fill, name, parent): class Grid_Polar(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", default="x_tab") self.OptionParser.add_option("--x_divs", action="store", type="int", dest="x_divs", default=5, -- cgit v1.2.3 From 8ab9f35a289571d5ebf8954abe037d913fa4e002 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 3 Feb 2017 06:46:32 -0500 Subject: extensions.export.win32vectorprint. compensate for svg document units (Bug 1660474) Fixed bugs: - https://launchpad.net/bugs/1660474 (bzr r15468) --- share/extensions/print_win32_vector.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index 7151a3f88..984a10eed 100755 --- a/share/extensions/print_win32_vector.py +++ b/share/extensions/print_win32_vector.py @@ -35,6 +35,7 @@ import simplestyle import simpletransform import cubicsuperpath +inkex.localize() # Initialize gettext if not inkex.sys.platform.startswith('win'): exit(_("sorry, this will run only on Windows, exiting...")) @@ -61,7 +62,7 @@ class MyEffect(inkex.Effect): if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url': rgb = simplestyle.parseColor(style['stroke']) if style.has_key('stroke-width'): - stroke = self.unittouu(style['stroke-width']) + stroke = self.unittouu(style['stroke-width'])/self.unittouu('1px') stroke = int(stroke*self.scale) if style.has_key('fill'): if style['fill'] and style['fill'] != 'none' and style['fill'][0:3] != 'url': @@ -198,6 +199,7 @@ class MyEffect(inkex.Effect): exit() # user clicked Cancel self.scale = (ord(pDevMode[58]) + 256.0*ord(pDevMode[59]))/96 # use PrintQuality from DEVMODE + self.scale /= self.unittouu('1px') self.groupmat = [[[self.scale, 0.0, 0.0], [0.0, self.scale, 0.0]]] doc = self.document.getroot() self.process_group(doc) -- cgit v1.2.3 From f5b7d15f1d7b97f785486cf05f6cf0043245bba8 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 3 Feb 2017 07:00:22 -0500 Subject: save as desktop cutting plotter dxf. compensate for svg document units (Bug 1660967) Fixed bugs: - https://launchpad.net/bugs/1660967 (bzr r15469) --- share/extensions/dxf_outlines.py | 1 + 1 file changed, 1 insertion(+) (limited to 'share/extensions') diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index a387df4a1..e30637f55 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -340,6 +340,7 @@ class MyEffect(inkex.Effect): scale = eval(self.options.units) if not scale: scale = 25.4/96 # if no scale is specified, assume inch as baseunit + scale /= self.unittouu('1px') h = self.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0]) self.groupmat = [[[scale, 0.0, 0.0], [0.0, -scale, h*scale]]] doc = self.document.getroot() -- cgit v1.2.3 From c5a7dd71d1b0489364277a59204f2e75e40a6441 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 5 Feb 2017 22:05:13 +0100 Subject: Extensions: Add about screen for Scour extension (aka "optimized SVG output") (bzr r15482) --- share/extensions/scour.inx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx index f7b8aedf7..a797f7ac3 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -92,6 +92,14 @@ _gui-description="Preserve all IDs that start with the specified prefix (e.g. specify "flag" to preserve "flag-mx", "flag-pt", etc.)." name="protect-ids-prefix" type="string"> + +   + <_param name="about_name_desc" type="description">Optimized SVG Output is provided by + Scour - An SVG Scrubber +   + <_param name="about_link_desc" type="description">For details please refer to + https://github.com/scour-project/scour + .svg -- cgit v1.2.3 From 34ee2e37ef6e6163d65f60299e639a1e60f7cf4e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 5 Feb 2017 23:59:18 +0100 Subject: Extensions: Add a version check for Scour If an older version of Scour is installed on the system notify the user that not all options in the extensions Window might be available (can optionally be turned off) (bzr r15483) --- share/extensions/scour.inkscape.py | 31 ++++++++++++++++++++++++++++++- share/extensions/scour.inx | 8 ++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour.inkscape.py index eb31f308f..0bc1435c5 100755 --- a/share/extensions/scour.inkscape.py +++ b/share/extensions/scour.inkscape.py @@ -1,6 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import sys, platform, inkex + +import platform +import sys + +from distutils.version import StrictVersion + +import inkex try: import scour @@ -17,10 +23,13 @@ except Exception as e: inkex.errormsg("\nDetails:\n" + str(e)) sys.exit() + class ScourInkscape (inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + + # Scour options self.OptionParser.add_option("--tab", type="string", action="store", dest="tab") self.OptionParser.add_option("--simplify-colors", type="inkbool", action="store", dest="simple_colors") self.OptionParser.add_option("--style-to-xml", type="inkbool", action="store", dest="style_to_xml") @@ -46,7 +55,26 @@ class ScourInkscape (inkex.Effect): self.OptionParser.add_option("--enable-comment-stripping", type="inkbool", action="store", dest="strip_comments") self.OptionParser.add_option("--renderer-workaround", type="inkbool", action="store", dest="renderer_workaround") + # options for internal use of the extension + self.OptionParser.add_option("--scour-version", type="string", action="store", dest="scour_version") + self.OptionParser.add_option("--scour-version-warn-old", type="inkbool", action="store", dest="scour_version_warn_old") + def effect(self): + # version check if enabled in options + if (self.options.scour_version_warn_old): + scour_version = scour.__version__ + scour_version_min = self.options.scour_version + if (StrictVersion(scour_version) < StrictVersion(scour_version_min)): + inkex.errormsg("The extension 'Optimized SVG Output' is designed for Scour " + scour_version_min + " and later " + "but you're using the older version Scour " + scour_version + ".") + inkex.errormsg("This usually works just fine but not all options available in the UI might be supported " + "by the version of Scour installed on your system " + "(see https://github.com/scour-project/scour/blob/master/HISTORY.md for release notes of Scour).") + inkex.errormsg("Note: You can permanently disable this message on the 'About' tab of the extension window.") + del self.options.scour_version + del self.options.scour_version_warn_old + + # do the scouring try: input = file(self.args[0], "r") self.options.infilename = self.args[0] @@ -61,6 +89,7 @@ class ScourInkscape (inkex.Effect): inkex.errormsg("Scour version: " + scour.__version__) sys.exit() + if __name__ == '__main__': e = ScourInkscape() e.affect(output=False) diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx index a797f7ac3..5cad00780 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -99,6 +99,14 @@   <_param name="about_link_desc" type="description">For details please refer to https://github.com/scour-project/scour +   +   +   + <_param name="about_version_desc" type="description">This version of the extension is designed for + Scour 0.31+ + 0.31 + true -- cgit v1.2.3 From 9a9968dc8129baa60b79df5137c258f3614e3a97 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 6 Feb 2017 00:04:32 +0100 Subject: Extensions: Support for very old versions of Scour (<= 0.26) We do not really want to support them anymore, but some distros are stuck with it (see https://code.launchpad.net/~mapreri/inkscape/support-scour-0.26/+merge/315348) (bzr r15484) --- share/extensions/scour.inkscape.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour.inkscape.py index 0bc1435c5..3d3f35bdb 100755 --- a/share/extensions/scour.inkscape.py +++ b/share/extensions/scour.inkscape.py @@ -10,7 +10,14 @@ import inkex try: import scour - from scour.scour import scourString + try: + from scour.scour import scourString + except ImportError: # compatibility for very old Scour (<= 0.26) - deprecated! + try: + from scour import scourString + scour.__version__ = scour.VER + except: + raise except Exception as e: inkex.errormsg("Failed to import Python module 'scour'.\nPlease make sure it is installed (e.g. using 'pip install scour' or 'sudo apt-get install python-scour') and try again.") inkex.errormsg("\nDetails:\n" + str(e)) -- cgit v1.2.3 From 5235891060a1950b0dff3b7a09df8c26bf854a9a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 10 Feb 2017 05:36:17 +0100 Subject: Extensions: Fix for r15483 (accidentally commited the wrong file version of scour.inx) (bzr r15499) --- share/extensions/scour.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx index 5cad00780..e5a34188c 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -104,9 +104,9 @@   <_param name="about_version_desc" type="description">This version of the extension is designed for Scour 0.31+ - 0.31 + 0.31 true + name="scour-version-warn-old" type="boolean" indent="1">true -- cgit v1.2.3 From 24d66b5173963dcb69545614449de91da5397db6 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 14 Feb 2017 00:42:11 +0100 Subject: Extensions: Add 'appearance="url"' to desccription parameters. It allows to create and add a clickable plain text link to extensions The description parameter's text is escaped and converted to a URL as-is preventing potential security issues The Scour extension shows a first example implementation (bzr r15519) --- share/extensions/scour.inx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx index e5a34188c..7d7555664 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -95,10 +95,10 @@   <_param name="about_name_desc" type="description">Optimized SVG Output is provided by - Scour - An SVG Scrubber + Scour - An SVG Scrubber   <_param name="about_link_desc" type="description">For details please refer to - https://github.com/scour-project/scour + https://github.com/scour-project/scour       @@ -106,7 +106,7 @@ Scour 0.31+ 0.31 true + name="scour-version-warn-old" type="boolean">true -- cgit v1.2.3 From 52cfe4a497e8775f61dfd58be5095d0439afecb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Sun, 19 Feb 2017 18:14:13 +0100 Subject: Extensions: prevent exception when inst.strerror is None (bzr r15534) --- share/extensions/plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index 800142bb2..965fbf6d9 100755 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -196,7 +196,7 @@ class Plot(inkex.Effect): try: mySerial.open() except Exception as inst: - if 'ould not open port' in inst.strerror: + if inst.strerror is not None and 'ould not open port' in inst.strerror: inkex.errormsg(_("Could not open port. Please check that your plotter is running, connected and the settings are correct.")) return else: -- cgit v1.2.3 From 60bb9a9350633076cf2d83054e09e44beaf48392 Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Thu, 23 Feb 2017 09:22:00 +0100 Subject: [Bug #1666939] Polar grid: reduce height of options dialog. Fixed bugs: - https://launchpad.net/bugs/1666939 (bzr r15541) --- share/extensions/grid_polar.inx | 33 +++++++++++++++++++-------------- share/extensions/grid_polar.py | 3 +++ 2 files changed, 22 insertions(+), 14 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/grid_polar.inx b/share/extensions/grid_polar.inx index ffc64a3d5..2fbd190e5 100644 --- a/share/extensions/grid_polar.inx +++ b/share/extensions/grid_polar.inx @@ -4,6 +4,7 @@ grids.polar grid_polar.py inkex.py + 5.0 <_item msgctxt="Label" value="none">None @@ -11,20 +12,24 @@ 18 24 - <_param name="circ_divs_label" type="description" appearance="header">Circular Divisions - 5 - 50.0 - 3 - false - 2 - 1 - <_param name="ang_divs_label" type="description" appearance="header">Angular Divisions - 24 - 4 - 1 - 2 - 2 - 1 + + + 5 + 50.0 + 3 + false + 2 + 1 + + + 24 + 4 + 1 + 2 + 2 + 1 + + all diff --git a/share/extensions/grid_polar.py b/share/extensions/grid_polar.py index f3d5dbf41..c5a7e7062 100755 --- a/share/extensions/grid_polar.py +++ b/share/extensions/grid_polar.py @@ -54,6 +54,9 @@ def draw_SVG_label_centred(x, y, string, font_size, name, parent): class Grid_Polar(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", default="circular_div") self.OptionParser.add_option("--r_divs", action="store", type="int", dest="r_divs", default=5, -- cgit v1.2.3 From e6fa028cd4ccc870664dae669c17f0528ed9f676 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 24 Feb 2017 10:04:32 +0100 Subject: [Bug #980527] Gcodetools: Unlocalized messages. Fixed bugs: - https://launchpad.net/bugs/980527 (bzr r15543) --- share/extensions/gcodetools_about.inx | 4 ++-- share/extensions/gcodetools_area.inx | 8 ++++---- share/extensions/gcodetools_check_for_updates.inx | 2 +- share/extensions/gcodetools_dxf_points.inx | 4 ++-- share/extensions/gcodetools_engraving.inx | 4 ++-- share/extensions/gcodetools_graffiti.inx | 4 ++-- share/extensions/gcodetools_lathe.inx | 10 +++++----- share/extensions/gcodetools_orientation_points.inx | 4 ++-- share/extensions/gcodetools_path_to_gcode.inx | 4 ++-- share/extensions/gcodetools_prepare_path_for_plasma.inx | 2 +- share/extensions/gcodetools_tools_library.inx | 4 ++-- 11 files changed, 25 insertions(+), 25 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/gcodetools_about.inx b/share/extensions/gcodetools_about.inx index 385a38244..4a1579181 100644 --- a/share/extensions/gcodetools_about.inx +++ b/share/extensions/gcodetools_about.inx @@ -8,7 +8,7 @@ - <_param name="help" type="description">Gcodetools was developed to make simple Gcode from Inkscape's paths. Gcode is a special format which is used in most of CNC machines. So Gcodetools allows you to use Inkscape as CAM program. + <_param name="help" type="description" xml:space="preserve">Gcodetools was developed to make simple Gcode from Inkscape's paths. Gcode is a special format which is used in most of CNC machines. So Gcodetools allows you to use Inkscape as CAM program. It can be used with a lot of machine types: Mills @@ -22,7 +22,7 @@ To get more info visit developers page at http://www.cnc-club.ru/gcodetools - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_area.inx b/share/extensions/gcodetools_area.inx index 23efdf8b6..8dbcb1e1f 100644 --- a/share/extensions/gcodetools_area.inx +++ b/share/extensions/gcodetools_area.inx @@ -12,7 +12,7 @@ -10 0 - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> "Create area offset": creates several Inkscape path offsets to fill original path's area up to "Area radius" value. Outlines start from "1/2 D" up to "Area width" total width with "D" steps where D is taken from the nearest tool definition ("Tool diameter" value). @@ -37,7 +37,7 @@ Only one offset will be created if the "Area width" is equal to "1/2 D". <_option value="mark with style">mark with style <_option value="delete">delete - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Usage: 1. Select all Area Offsets (gray outlines) 2. Object/Ungroup (Shift+Ctrl+G) @@ -59,7 +59,7 @@ Suspected small objects will be marked out by colored arrows. d True - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Biarc interpolation tolerance is the maximum distance between path and its approximation. The segment will be split into two segments if the distance between path's segment and its approximation exceeds biarc interpolation tolerance. For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the depth defined by orientation points, s - surface defined by orientation points. @@ -103,7 +103,7 @@ For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the d - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_check_for_updates.inx b/share/extensions/gcodetools_check_for_updates.inx index 6eaa098a5..05cc97b1d 100644 --- a/share/extensions/gcodetools_check_for_updates.inx +++ b/share/extensions/gcodetools_check_for_updates.inx @@ -12,7 +12,7 @@ - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_dxf_points.inx b/share/extensions/gcodetools_dxf_points.inx index 4367353b9..06d655624 100644 --- a/share/extensions/gcodetools_dxf_points.inx +++ b/share/extensions/gcodetools_dxf_points.inx @@ -8,7 +8,7 @@ - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Convert selected objects to drill points (as dxf_import plugin does). Also you can save original shape. Only the start point of each curve will be used. @@ -49,7 +49,7 @@ Also you can manually select object, open XML editor (Shift+Ctrl+X) and add or r - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_engraving.inx b/share/extensions/gcodetools_engraving.inx index a488f45a1..6dd1a3c73 100644 --- a/share/extensions/gcodetools_engraving.inx +++ b/share/extensions/gcodetools_engraving.inx @@ -13,7 +13,7 @@ 4 false - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> This function creates path to engrave letters or any shape with sharp angles. Cutter's depth as a function of radius is defined by the tool. Depth may be any Python expression. For instance: @@ -61,7 +61,7 @@ ellipse.(minor axis r, major 4r).....: math.sqrt(max(0,r**2-w**2))*4 - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_graffiti.inx b/share/extensions/gcodetools_graffiti.inx index bcaec76d4..c2ea161d9 100644 --- a/share/extensions/gcodetools_graffiti.inx +++ b/share/extensions/gcodetools_graffiti.inx @@ -37,7 +37,7 @@ different X/Y scale) <_item value="G20 (All units in inches)">in - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Orientation points are used to calculate transformation (offset,scale,mirror,rotation in XY plane) of the path. 3-points mode only: do not put all three into one line (use 2-points mode instead). @@ -88,7 +88,7 @@ Now press apply to create control points (independent set for each layer). - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_lathe.inx b/share/extensions/gcodetools_lathe.inx index 7483ac2b9..4bb9888a6 100644 --- a/share/extensions/gcodetools_lathe.inx +++ b/share/extensions/gcodetools_lathe.inx @@ -19,15 +19,15 @@ Z - - <_param name="help" type="description"> + + <_param name="help" type="description" xml:space="preserve"> This function modifies path so it will be possible to be cut it with a rectangular cutter. 4 - + 1 4 @@ -39,7 +39,7 @@ d True - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Biarc interpolation tolerance is the maximum distance between path and its approximation. The segment will be split into two segments if the distance between path's segment and its approximation exceeds biarc interpolation tolerance. For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the depth defined by orientation points, s - surface defined by orientation points. @@ -83,7 +83,7 @@ For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the d - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_orientation_points.inx b/share/extensions/gcodetools_orientation_points.inx index 604369881..9f07ff219 100644 --- a/share/extensions/gcodetools_orientation_points.inx +++ b/share/extensions/gcodetools_orientation_points.inx @@ -27,7 +27,7 @@ different X/Y scale) <_item value="G20 (All units in inches)">in - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Orientation points are used to calculate transformation (offset,scale,mirror,rotation in XY plane) of the path. 3-points mode only: do not put all three into one line (use 2-points mode instead). @@ -42,7 +42,7 @@ Now press apply to create control points (independent set for each layer). - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_path_to_gcode.inx b/share/extensions/gcodetools_path_to_gcode.inx index b1664a70e..6862a40a4 100644 --- a/share/extensions/gcodetools_path_to_gcode.inx +++ b/share/extensions/gcodetools_path_to_gcode.inx @@ -19,7 +19,7 @@ d True - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Biarc interpolation tolerance is the maximum distance between path and its approximation. The segment will be split into two segments if the distance between path's segment and its approximation exceeds biarc interpolation tolerance. For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the depth defined by orientation points, s - surface defined by orientation points. @@ -63,7 +63,7 @@ For depth function c=color intensity from 0.0 (white) to 1.0 (black), d is the d - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_prepare_path_for_plasma.inx b/share/extensions/gcodetools_prepare_path_for_plasma.inx index 805a3a2b2..c6d77e7db 100644 --- a/share/extensions/gcodetools_prepare_path_for_plasma.inx +++ b/share/extensions/gcodetools_prepare_path_for_plasma.inx @@ -30,7 +30,7 @@ - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. diff --git a/share/extensions/gcodetools_tools_library.inx b/share/extensions/gcodetools_tools_library.inx index e7be0d996..7841c3130 100644 --- a/share/extensions/gcodetools_tools_library.inx +++ b/share/extensions/gcodetools_tools_library.inx @@ -23,7 +23,7 @@ - <_param name="help" type="description"> + <_param name="help" type="description" xml:space="preserve"> Selected tool type fills appropriate default values. You can change these values using the Text tool later on. The topmost (z order) tool in the active layer is used. If there is no tool inside the current layer it is taken from the upper layer. @@ -33,7 +33,7 @@ Press Apply to create new tool. - <_param name="fullhelp" type="description"> + <_param name="fullhelp" type="description" xml:space="preserve"> Gcodetools plug-in: converts paths to Gcode (using circular interpolation), makes offset paths and engraves sharp corners using cone cutters. This plug-in calculates Gcode for paths using circular interpolation or linear motion when needed. -- cgit v1.2.3 From 677ee6d0e188fd994975b9295a4069db8918a73e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 5 Mar 2017 16:06:23 +0100 Subject: Fix ACLs (bzr r15567) --- share/extensions/dpiswitcher.py | 0 share/extensions/test/test_template.py.txt | 0 share/extensions/ungroup_deep.py | 0 share/extensions/voronoi.py | 0 share/extensions/voronoi2svg.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/extensions/dpiswitcher.py mode change 100644 => 100755 share/extensions/test/test_template.py.txt mode change 100644 => 100755 share/extensions/ungroup_deep.py mode change 100644 => 100755 share/extensions/voronoi.py mode change 100644 => 100755 share/extensions/voronoi2svg.py (limited to 'share/extensions') diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py old mode 100644 new mode 100755 diff --git a/share/extensions/test/test_template.py.txt b/share/extensions/test/test_template.py.txt old mode 100644 new mode 100755 diff --git a/share/extensions/ungroup_deep.py b/share/extensions/ungroup_deep.py old mode 100644 new mode 100755 diff --git a/share/extensions/voronoi.py b/share/extensions/voronoi.py old mode 100644 new mode 100755 diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py old mode 100644 new mode 100755 -- cgit v1.2.3 From 4cd89565f68a984b3c52ae5a677f0a3f4427abba Mon Sep 17 00:00:00 2001 From: Alvin Penner <> Date: Wed, 8 Mar 2017 20:11:01 +0100 Subject: Apply the Albin Penner fix for bug 1663362 Fixed bugs: - https://launchpad.net/bugs/1663362 (bzr r15578) --- share/extensions/hpgl_output.py | 15 --------------- share/extensions/synfig_output.py | 10 ---------- 2 files changed, 25 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index f31c3fc2d..58f82da71 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # standard library import sys -from inkex import NSS # local libraries import hpgl_encoder import inkex @@ -45,18 +44,10 @@ class HpglOutput(inkex.Effect): self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut') self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness') self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align') - self.DOCROTATE = "{http://www.inkscape.org/namespaces/inkscape}document_rotation" def effect(self): self.options.debug = False # get hpgl data - svg = self.document.getroot() - xpathStr = '//sodipodi:namedview' - nv = svg.xpath(xpathStr, namespaces=NSS) - document_rotate = "0" - if nv != []: - document_rotate = nv[0].get(self.DOCROTATE) - nv[0].set(self.DOCROTATE,"0") myHpglEncoder = hpgl_encoder.hpglEncoder(self) try: self.hpgl, debugObject = myHpglEncoder.getHpgl() @@ -65,13 +56,9 @@ class HpglOutput(inkex.Effect): # issue error if no paths found inkex.errormsg(_("No paths where found. Please convert all objects you want to save into paths.")) self.hpgl = '' - if nv != [] and document_rotate: - nv[0].set("inkscape:document_rotation",document_rotate) return else: type, value, traceback = sys.exc_info() - if nv != [] and document_rotate: - nv[0].set("inkscape:document_rotation",document_rotate) raise ValueError, ("", type, value), traceback # convert raw HPGL to HPGL hpglInit = 'IN' @@ -80,8 +67,6 @@ class HpglOutput(inkex.Effect): if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' - if nv != [] and document_rotate: - nv[0].set("inkscape:document_rotation",document_rotate) def output(self): # print to file diff --git a/share/extensions/synfig_output.py b/share/extensions/synfig_output.py index 461078951..06a9c6e72 100755 --- a/share/extensions/synfig_output.py +++ b/share/extensions/synfig_output.py @@ -1046,17 +1046,11 @@ def extract_width(style, width_attrib, mtx): ###### Main Class ######################################### class SynfigExport(SynfigPrep): def __init__(self): - svg = self.document.getroot() - xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' - res = svg.xpath(xpathStr, namespaces=inkex.NSS) - self.document_rotate = res[0].get("inkscape:document_rotation") - res[0].set("inkscape:document_rotation","0") SynfigPrep.__init__(self) def effect(self): # Prepare the document for exporting SynfigPrep.effect(self) - svg = self.document.getroot() width = get_dimension(svg.get("width", 1024)) height = get_dimension(svg.get("height", 768)) @@ -1078,10 +1072,6 @@ class SynfigExport(SynfigPrep): root_canvas.append(layer) d.get_root_tree().write(sys.stdout) - svg = self.document.getroot() - xpathStr = '//http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}:namedview' - res = svg.xpath(xpathStr, namespaces=inkex.NSS) - res[0].set("inkscape:document_rotation",self.document_rotate) def convert_node(self, node, d): """Convert an SVG node to a list of Synfig layers""" -- cgit v1.2.3 From 4aacbb7d40826888f18238ce8cad134b5dbed934 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 12 Mar 2017 19:12:23 -0400 Subject: extensions. dxf output & print_win32_vector. compensate for viewbox. (Bug 1672066) Fixed bugs: - https://launchpad.net/bugs/1672066 (bzr r15590) --- share/extensions/dxf_outlines.py | 9 ++++++++- share/extensions/print_win32_vector.py | 10 +++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index e30637f55..74b4ed465 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -342,8 +342,15 @@ class MyEffect(inkex.Effect): scale = 25.4/96 # if no scale is specified, assume inch as baseunit scale /= self.unittouu('1px') h = self.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0]) - self.groupmat = [[[scale, 0.0, 0.0], [0.0, -scale, h*scale]]] doc = self.document.getroot() + # process viewBox height attribute to correct page scaling + viewBox = doc.get('viewBox') + if viewBox: + viewBox2 = viewBox.split(',') + if len(viewBox2) < 4: + viewBox2 = viewBox.split(' ') + scale *= h / self.unittouu(self.addDocumentUnit(viewBox2[3])) + self.groupmat = [[[scale, 0.0, 0.0], [0.0, -scale, h*scale]]] self.process_group(doc) if self.options.ROBO == 'true': self.ROBO_output() diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index 984a10eed..99365fc5e 100755 --- a/share/extensions/print_win32_vector.py +++ b/share/extensions/print_win32_vector.py @@ -200,8 +200,16 @@ class MyEffect(inkex.Effect): self.scale = (ord(pDevMode[58]) + 256.0*ord(pDevMode[59]))/96 # use PrintQuality from DEVMODE self.scale /= self.unittouu('1px') - self.groupmat = [[[self.scale, 0.0, 0.0], [0.0, self.scale, 0.0]]] + h = self.unittouu(self.document.getroot().xpath('@height', namespaces=inkex.NSS)[0]) doc = self.document.getroot() + # process viewBox height attribute to correct page scaling + viewBox = doc.get('viewBox') + if viewBox: + viewBox2 = viewBox.split(',') + if len(viewBox2) < 4: + viewBox2 = viewBox.split(' ') + self.scale *= h / self.unittouu(self.addDocumentUnit(viewBox2[3])) + self.groupmat = [[[self.scale, 0.0, 0.0], [0.0, self.scale, 0.0]]] self.process_group(doc) mygdi.EndDoc(self.hDC) -- cgit v1.2.3 From 18b79811a187ecb630f11a841ffa686936f12614 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 13 Mar 2017 08:41:58 -0400 Subject: Two Extensions for converting objects to paths before exporting. (Bug 1662531) Fixed bugs: - https://launchpad.net/bugs/1662531 (bzr r15591) --- share/extensions/prepare_file_save_as.inx | 16 +++++++ share/extensions/prepare_file_save_as.py | 58 ++++++++++++++++++++++ share/extensions/prepare_print_win32_vector.inx | 16 +++++++ share/extensions/prepare_print_win32_vector.py | 64 +++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 share/extensions/prepare_file_save_as.inx create mode 100644 share/extensions/prepare_file_save_as.py create mode 100644 share/extensions/prepare_print_win32_vector.inx create mode 100644 share/extensions/prepare_print_win32_vector.py (limited to 'share/extensions') diff --git a/share/extensions/prepare_file_save_as.inx b/share/extensions/prepare_file_save_as.inx new file mode 100644 index 000000000..1556713aa --- /dev/null +++ b/share/extensions/prepare_file_save_as.inx @@ -0,0 +1,16 @@ + + + <_name>Pre-Process File Save As... + com.vaxxine.file.saveas.preprocess + prepare_file_save_as.py + inkex.py + + path + + + + + + diff --git a/share/extensions/prepare_file_save_as.py b/share/extensions/prepare_file_save_as.py new file mode 100644 index 000000000..d0c660fcf --- /dev/null +++ b/share/extensions/prepare_file_save_as.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +''' +file: prepare_file_save_as.py + +This extension will pre-process a vector image by applying the operations: +'EditSelectAllInAllLayers' and 'ObjectToPath' +before calling the dialog File->Save As.... + +Copyright (C) 2014 Ryan Lerch (multiple difference) + 2016 Maren Hachmann (refactoring, extend to multibool) + 2017 Alvin Penner (apply to 'File Save As...') + +This code is based on 'inkscape-extension-multiple-difference' by Ryan Lerch +see : https://github.com/ryanlerch/inkscape-extension-multiple-difference +also: https://github.com/Moini/inkscape-extensions-multi-bool +It will call up a new instance of Inkscape and process the image there, +so that the original file is left intact. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' +# standard library +from subprocess import Popen, PIPE +from shutil import copy2 +# local library +import inkex + +class MyEffect(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + file = self.args[-1] + tempfile = inkex.os.path.splitext(file)[0] + "-prepare.svg" + # tempfile is needed here only because we want to force the extension to be .svg + # so that we can open and close it silently + copy2(file, tempfile) + p = Popen('inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=FileSaveACopy --verb=FileSave --verb=FileQuit '+tempfile, shell=True, stdout=PIPE, stderr=PIPE) + err = p.stderr + f = p.communicate()[0] + err.close() + +if __name__ == '__main__': + e = MyEffect() + e.affect() + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/prepare_print_win32_vector.inx b/share/extensions/prepare_print_win32_vector.inx new file mode 100644 index 000000000..b8d87cec8 --- /dev/null +++ b/share/extensions/prepare_print_win32_vector.inx @@ -0,0 +1,16 @@ + + + <_name>Pre-Process Win32 Vector Print + com.vaxxine.print.win32.preprocess + prepare_print_win32_vector.py + inkex.py + + path + + + + + + diff --git a/share/extensions/prepare_print_win32_vector.py b/share/extensions/prepare_print_win32_vector.py new file mode 100644 index 000000000..e13670931 --- /dev/null +++ b/share/extensions/prepare_print_win32_vector.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +''' +file: prepare_print_win32_vector.py + +This extension will pre-process a vector image by applying the operations: +'EditSelectAllInAllLayers' and 'ObjectToPath' +before applying the extension: 'Win32 Vector Print'. + +Generate vector graphics printout, specifically for Windows GDI32. + +Copyright (C) 2014 Ryan Lerch (multiple difference) + 2016 Maren Hachmann (refactoring, extend to multibool) + 2017 Alvin Penner (apply to 'Win32 Vector Print') + +This code is based on 'inkscape-extension-multiple-difference' by Ryan Lerch +see : https://github.com/ryanlerch/inkscape-extension-multiple-difference +also: https://github.com/Moini/inkscape-extensions-multi-bool +It will call up a new instance of Inkscape and process the image there, +so that the original file is left intact. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +''' +# standard library +from subprocess import Popen, PIPE +from shutil import copy2 +# local library +import inkex + +inkex.localize() # Initialize gettext +if not inkex.sys.platform.startswith('win'): + exit(_("sorry, this will run only on Windows, exiting...")) + +class MyEffect(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + + def effect(self): + file = self.args[-1] + tempfile = inkex.os.path.splitext(file)[0] + "-prepare.svg" + # tempfile is needed here only because we want to force the extension to be .svg + # so that we can open and close it silently + copy2(file, tempfile) + p = Popen('inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=com.vaxxine.print.win32 --verb=FileSave --verb=FileQuit '+tempfile, shell=True, stdout=PIPE, stderr=PIPE) + err = p.stderr + f = p.communicate()[0] + err.close() + +if __name__ == '__main__': + e = MyEffect() + e.affect() + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 -- cgit v1.2.3 From d3c760ca97323625ad78234ae76521096b6008ed Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 8 Apr 2017 12:41:15 +0200 Subject: cmake/MSYS2: Spell checking via gtkspell now working * the Aspell backend for Enchant was missing (now available [1]) * actually install the backend * install translations required by gtkspell Also re-enable installation of gtk3 translations after r15583 as we still need them in the context menu of native gtk inputs [1] https://github.com/Alexpux/MINGW-packages/pull/2369 (bzr r15618) --- share/extensions/prepare_file_save_as.py | 0 share/extensions/prepare_print_win32_vector.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/extensions/prepare_file_save_as.py mode change 100644 => 100755 share/extensions/prepare_print_win32_vector.py (limited to 'share/extensions') diff --git a/share/extensions/prepare_file_save_as.py b/share/extensions/prepare_file_save_as.py old mode 100644 new mode 100755 diff --git a/share/extensions/prepare_print_win32_vector.py b/share/extensions/prepare_print_win32_vector.py old mode 100644 new mode 100755 -- cgit v1.2.3 From 20978fe6b2d1053ab0106329a900b7bdcebc44a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Mon, 17 Apr 2017 22:04:40 +0200 Subject: Extensions: HPGL: changed command order of cleanup commands so pen plotters react correctly (bzr r15625) --- share/extensions/hpgl_output.py | 2 +- share/extensions/plotter.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 58f82da71..d4a23743f 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -66,7 +66,7 @@ class HpglOutput(inkex.Effect): hpglInit += ';FS%d' % self.options.force if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed - self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' + self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN; ' def output(self): # print to file diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index 965fbf6d9..1d8e8f79e 100755 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -104,7 +104,7 @@ class Plot(inkex.Effect): hpglInit += ';FS%d' % self.options.force if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed - self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; ' + self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN; ' def convertToDmpl(self): # convert HPGL to DMPL @@ -127,7 +127,7 @@ class Plot(inkex.Effect): if self.options.speed > 0: dmplInit += 'V%d' % self.options.speed dmplInit += 'EC1' - self.hpgl = dmplInit + self.hpgl[1:] + ',P0,U0,0,Z ' + self.hpgl = dmplInit + self.hpgl[1:] + ',U0,0,P0,Z ' def convertToKNK(self): # convert HPGL to KNK Plotter Language @@ -136,7 +136,7 @@ class Plot(inkex.Effect): hpglInit += ';FS%d' % self.options.force if self.options.speed > 0: hpglInit += ';VS%d' % self.options.speed - self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;@ ' + self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;@ ' def sendHpglToSerial(self): # gracefully exit script when pySerial is missing -- cgit v1.2.3 From bab6dfe02bd9556c931973a272e154251764e88e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 24 Apr 2017 20:59:06 +0200 Subject: Restore r14955 which was reverted in r15047 due to messed up merge http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/14955 http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15047 Fixed bugs: - https://launchpad.net/bugs/1669951 (bzr r15633) --- share/extensions/restack.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/restack.inx b/share/extensions/restack.inx index 4f5f577cb..e14d2d5d5 100644 --- a/share/extensions/restack.inx +++ b/share/extensions/restack.inx @@ -9,7 +9,7 @@ <_param name="desc_dir" type="description" appearance="header">Restack Direction - + <_item value="lr">Left to Right (0) <_item value="bt">Bottom to Top (90) <_item value="rl">Right to Left (180) @@ -36,7 +36,7 @@ <_param name="desc_zsort" type="description" appearance="header">Restack Mode - + <_item value="rev">Reverse Z-Order <_item value="rand">Shuffle Z-Order -- cgit v1.2.3 From dc0b8a1b7c8a4215335b2b52bf101fcec8bfca03 Mon Sep 17 00:00:00 2001 From: suv-lp <> Date: Mon, 1 May 2017 09:38:02 +0200 Subject: [Bug #1680833] Extrude extension changes edge width thickness. Fixed bugs: - https://launchpad.net/bugs/1680833 (bzr r15657) --- share/extensions/extrude.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/extrude.py b/share/extensions/extrude.py index 88ae3994a..b11d0d36c 100755 --- a/share/extensions/extrude.py +++ b/share/extensions/extrude.py @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # local library import inkex import simplepath +import simplestyle import simpletransform import cubicsuperpath @@ -68,10 +69,23 @@ class Extrude(inkex.Effect): ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path') paths[0].xpath('..')[0].append(ele) ele.set('d', simplepath.formatPath(line)) - ele.set('style', 'fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;') + style = { + 'fill': 'none', + 'stroke': '#000000', + 'stroke-opacity': 1, + 'stroke-width': self.unittouu('1px'), + } + ele.set('style', simplestyle.formatStyle(style)) elif self.options.mode.lower() == 'polygons': g = inkex.etree.Element('{http://www.w3.org/2000/svg}g') - g.set('style', 'fill:#000000;stroke:#000000;fill-opacity:0.3;stroke-width:2;stroke-opacity:0.6;') + style = { + 'fill': '#000000', + 'fill-opacity': 0.3, + 'stroke': '#000000', + 'stroke-opacity': 0.6, + 'stroke-width': self.unittouu('2px'), + } + g.set('style', simplestyle.formatStyle(style)) paths[0].xpath('..')[0].append(g) for comp in verts: for n,v in enumerate(comp): -- cgit v1.2.3 From b03e17f96ab99ae39bbd3268ab2f3a6d080dbd84 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 31 May 2017 14:01:07 +0200 Subject: Add 4k, 5k, and 8k screen sizes. (bzr r15721) --- share/extensions/empty_desktop.inx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'share/extensions') diff --git a/share/extensions/empty_desktop.inx b/share/extensions/empty_desktop.inx index 75762b660..449f2ec66 100644 --- a/share/extensions/empty_desktop.inx +++ b/share/extensions/empty_desktop.inx @@ -16,6 +16,9 @@ 1920x1080 (FHD) 1920x1200 (WUXGA) 2560x1600 (WQXGA) + 3840x2160 (4K) + 5120x2880 (5K) + 7680x4320 (8K) -- cgit v1.2.3 From 23f636996a0326b9b14a54610d682c7d54310752 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 1 Jun 2017 10:34:08 +0200 Subject: Explicitly mark input/output via UniConvertor. Helps keep track of which input/output method is being used when multiple options are available. (bzr r15722) --- share/extensions/ai_input.inx | 2 +- share/extensions/cgm_input.inx | 2 +- share/extensions/plt_input.inx | 2 +- share/extensions/plt_output.inx | 2 +- share/extensions/sk1_input.inx | 2 +- share/extensions/sk1_output.inx | 2 +- share/extensions/wmf_input.inx | 2 +- share/extensions/wmf_output.inx | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/ai_input.inx b/share/extensions/ai_input.inx index a48825840..bc4919500 100644 --- a/share/extensions/ai_input.inx +++ b/share/extensions/ai_input.inx @@ -6,7 +6,7 @@ .ai image/x-adobe-illustrator - <_filetypename>Adobe Illustrator 8.0 and below (*.ai) + <_filetypename>Adobe Illustrator 8.0 and below (UC) (*.ai) <_filetypetooltip>Open files saved with Adobe Illustrator 8.0 or older diff --git a/share/extensions/cgm_input.inx b/share/extensions/cgm_input.inx index e6fee4860..5c1ccd937 100644 --- a/share/extensions/cgm_input.inx +++ b/share/extensions/cgm_input.inx @@ -6,7 +6,7 @@ .cgm application/x-xcgm - <_filetypename>Computer Graphics Metafile files (*.cgm) + <_filetypename>Computer Graphics Metafile files (UC) (*.cgm) <_filetypetooltip>Open Computer Graphics Metafile files