summaryrefslogtreecommitdiffstats
path: root/share/extensions
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2017-01-24 14:16:06 +0000
committerJabiertxof <jtx@jtx>2017-01-24 14:16:06 +0000
commitb25ebda10578c5d697db9716e3c2b70950d33e45 (patch)
tree4635b8b3f65600cfd54b5465b906ae42165b0674 /share/extensions
parentFix some bugs (diff)
parentfix nodes reverting back during editing (diff)
downloadinkscape-b25ebda10578c5d697db9716e3c2b70950d33e45.tar.gz
inkscape-b25ebda10578c5d697db9716e3c2b70950d33e45.zip
fixing to new trunk
(bzr r15142.1.38)
Diffstat (limited to 'share/extensions')
-rw-r--r--share/extensions/CMakeLists.txt28
-rw-r--r--share/extensions/docinfo.inx21
-rw-r--r--share/extensions/dpi90to96.inx23
-rw-r--r--share/extensions/dpi96to90.inx23
-rw-r--r--share/extensions/dpiswitcher.py425
-rwxr-xr-xshare/extensions/draw_from_triangle.py19
-rwxr-xr-xshare/extensions/dxf_outlines.py2
-rwxr-xr-xshare/extensions/gcodetools.py4
-rw-r--r--share/extensions/gcodetools_about.inx2
-rw-r--r--share/extensions/gcodetools_area.inx2
-rw-r--r--share/extensions/gcodetools_lathe.inx4
-rw-r--r--share/extensions/gcodetools_path_to_gcode.inx2
-rw-r--r--share/extensions/gcodetools_prepare_path_for_plasma.inx2
-rwxr-xr-xshare/extensions/hpgl_input.py2
-rwxr-xr-xshare/extensions/interp.py4
-rwxr-xr-xshare/extensions/measure.py6
-rwxr-xr-xshare/extensions/perspective.py2
-rwxr-xr-xshare/extensions/plotter.py2
-rwxr-xr-xshare/extensions/polyhedron_3d.py3
-rwxr-xr-xshare/extensions/run_command.py7
-rwxr-xr-xshare/extensions/test/run-all-extension-tests27
-rwxr-xr-xshare/extensions/uniconv-ext.py3
-rwxr-xr-xshare/extensions/uniconv_output.py3
23 files changed, 571 insertions, 45 deletions
diff --git a/share/extensions/CMakeLists.txt b/share/extensions/CMakeLists.txt
index 74819309d..47dfbe0a0 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
@@ -26,17 +26,27 @@ file(GLOB _SCRIPTS
"*.sh"
"*.rb"
)
-
-install(PROGRAMS ${_SCRIPTS} DESTINATION ${SHARE_INSTALL}/inkscape/extensions)
+# 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 ${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 +55,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)
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DOC Info</_name>
+ <id>org.inkscape.docinfo</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="page_info" _gui-text="Show page info">
+ <_param name="d" type="description">Choose this tab if you would like to see page info previously to apply DPI Switcher.</_param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DPI 90 to 96</_name>
+ <id>org.inkscape.dpi90to96</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="dpi_swicher" >
+ <param name="switcher" type="enum" gui-hidden="true">
+ <item value="0">DPI Switch from 90 to 96</item>
+ </param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DPI 96 to 90</_name>
+ <id>org.inkscape.dpi96to90</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="dpi_swicher" >
+ <param name="switcher" type="enum" gui-hidden="true">
+ <item value="1">DPI Switch from 96 to 90</item>
+ </param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py
new file mode 100644
index 000000000..317616db5
--- /dev/null
+++ b/share/extensions/dpiswitcher.py
@@ -0,0 +1,425 @@
+#!/usr/bin/env python
+'''
+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, <suv-sf@users.sf.net>
+
+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
+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
+
+
+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 <use> 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 <symbol> instances
+ - check more <use> 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
+SKIP_CONTAINERS = [
+ 'defs',
+ 'glyph',
+ 'marker',
+ 'mask',
+ 'missing-glyph',
+ 'pattern',
+ 'symbol',
+]
+CONTAINER_ELEMENTS = [
+ 'a',
+ 'g',
+ 'switch',
+]
+GRAPHICS_ELEMENTS = [
+ 'circle',
+ 'ellipse',
+ 'image',
+ 'line',
+ 'path',
+ 'polygon',
+ 'polyline',
+ 'rect',
+ 'text',
+ 'use',
+]
+
+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 <text>."""
+ return element.tag == inkex.addNS('use', 'svg')
+
+
+def is_text(element):
+ """Check whether element is of type <text>."""
+ 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 (<use>)."""
+ 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):
+
+ 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
+
+ # 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):
+ """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', str(heightDoc))
+ if svg.get('width'):
+ svg.set('width', str(widthDoc))
+
+ # update viewBox
+ if svg.get('viewBox'):
+ 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
+
+ # 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:
+
+ # 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)
+
+ # 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 scaleElement(self, m):
+ pass # TODO: optionally scale graphics elements only?
+
+ 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):
+ saveout = sys.stdout
+ sys.stdout = sys.stderr
+ svg = self.document.getroot()
+ 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')
+ 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 = 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])
+ else:
+ self.unitExponent = 1.0/(self.factor_a/self.__uuconvLegacy[self.units])
+ self.scaleRoot(svg);
+ sys.stdout = saveout
+
+
+if __name__ == '__main__':
+ effect = DPISwitcher()
+ effect.affect()
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
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):
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/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 @@
<page name='about' _gui-text='About'>
<_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.
</param>
<param name="path-to-gcode-depth-function" type="string" _gui-text="Depth function:">d</param>
- <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduse rapid distance">True</param>
+ <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduce rapid distance">True</param>
<_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 @@
<page name='lathe_modify_path' _gui-text='Lathe modify path'>
<_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.
</_param>
<param name="lathe-rectangular-cutter-width" type="float" precision="5" min="0" max="1000" _gui-text="Lathe width:">4</param>
</page>
@@ -37,7 +37,7 @@
</param>
<param name="path-to-gcode-depth-function" type="string" _gui-text="Depth function:">d</param>
- <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduse rapid distance">True</param>
+ <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduce rapid distance">True</param>
<_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 @@
</param>
<param name="path-to-gcode-depth-function" type="string" _gui-text="Depth function:">d</param>
- <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduse rapid distance">True</param>
+ <param name="path-to-gcode-sort-paths" type="boolean" _gui-text="Sort paths to reduce rapid distance">True</param>
<_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 @@
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name='active-tab' type="notebook">
- <page name='plasma-prepare-path' _gui-text='Prepare path for plasma or laser cuters'>
+ <page name='plasma-prepare-path' _gui-text='Prepare path for plasma or laser cutters'>
<param name='in-out-path' type="boolean" _gui-text="Create in-out paths" >True</param>
<param name='in-out-path-len' type="float" precision="5" min="0" max="1000000" _gui-text='In-out path length:'>10</param>
<param name='in-out-path-point-max-dist' type="float" precision="5" min="0" max="1000000" _gui-text='In-out path max distance to reference point:'>10</param>
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)')
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):
diff --git a/share/extensions/measure.py b/share/extensions/measure.py
index 2711727cf..d025f142c 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
@@ -50,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
@@ -211,7 +215,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)
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/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:
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 *
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))
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
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'+\