diff options
| author | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
|---|---|---|
| committer | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
| commit | e7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch) | |
| tree | 9097520c54e355ded9bd0b4d6618af4e8dacdd91 /share/extensions | |
| parent | updated to latest trunk (diff) | |
| parent | [Bug #1695016] Xaml export misses some radialGradients. (diff) | |
| download | inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip | |
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'share/extensions')
76 files changed, 1359 insertions, 415 deletions
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/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/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/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 @@ <input> <extension>.ai</extension> <mimetype>image/x-adobe-illustrator</mimetype> - <_filetypename>Adobe Illustrator 8.0 and below (*.ai)</_filetypename> + <_filetypename>Adobe Illustrator 8.0 and below (UC) (*.ai)</_filetypename> <_filetypetooltip>Open files saved with Adobe Illustrator 8.0 or older</_filetypetooltip> </input> 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/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 @@ <input> <extension>.cgm</extension> <mimetype>application/x-xcgm</mimetype> - <_filetypename>Computer Graphics Metafile files (*.cgm)</_filetypename> + <_filetypename>Computer Graphics Metafile files (UC) (*.cgm)</_filetypename> <_filetypetooltip>Open Computer Graphics Metafile files</_filetypetooltip> </input> <script> 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 100755 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 74a58b863..fd966b1d1 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,24 @@ 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] ) )) - 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] ) )) + # TODO: unit identifier needs solution for arbitrary document scale + unit = Draw_From_Triangle.getDocumentUnit(e) + + 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): #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 diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index 525461bde..74b4ed465 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() @@ -338,9 +340,17 @@ 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() + # 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/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 @@ <item value="1920x1080">1920x1080 (FHD)</item> <item value="1920x1200">1920x1200 (WUXGA)</item> <item value="2560x1600">2560x1600 (WQXGA)</item> + <item value="3840x2160">3840x2160 (4K)</item> + <item value="5120x2880">5120x2880 (5K)</item> + <item value="7680x4320">7680x4320 (8K)</item> </param> <!-- Maximum size is '16k' --> 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): 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>Frame</_name> + <id>frame</id> + <dependency type="executable" location="extensions">frame.py</dependency> + <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="tab" type="notebook"> + <page name="stroke" gui-text="Stroke"> + <param name="stroke_color" type="color" gui-text="Stroke Color:">000000FF</param> + </page> + <page name="fill" gui-text="Fill"> + <param name="fill_color" type="color" gui-text="Fill Color:">00000000</param> + </page> + </param> + <param name="position" type="optiongroup" appearance="minimal" gui-text="Position"> + <option value="outside">Outside</option> + <option value="inside">Inside</option> + </param> + <param name="clip" type="boolean" gui-text="Clip"></param> + <param name="group" type="boolean" gui-text="Group"></param> + <param name="width" type="float" min="0" max="100" gui-text="Width(px)">2</param> + <param name="corner_radius" type="int" min="0" max="1000" gui-text="Corner Radius">0</param> + <effect> + <object-type>all</object-type> + <effects-menu> + <submenu _name="Render"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">frame.py</command> + </script> +</inkscape-extension>
\ No newline at end of file diff --git a/share/extensions/frame.py b/share/extensions/frame.py new file mode 100644 index 000000000..f6d54e180 --- /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 = '%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})() + + +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, (width/2)) + else: + box = size_box(box, -(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/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..4a1579181 100644 --- a/share/extensions/gcodetools_about.inx +++ b/share/extensions/gcodetools_about.inx @@ -8,9 +8,9 @@ <param name='active-tab' type="notebook"> <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. + <_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 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 @@ -22,7 +22,7 @@ To get more info visit developers page at http://www.cnc-club.ru/gcodetools</_pa </page> <page name='help' _gui-text='Help'> - <_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 b487f2c54..8dbcb1e1f 100644 --- a/share/extensions/gcodetools_area.inx +++ b/share/extensions/gcodetools_area.inx @@ -12,7 +12,7 @@ <param name="area-inkscape-radius" type="float" min="-1000" max="1000" _gui-text="Area width:">-10</param> <param name="area-tool-overlap" type="float" min="0" max="1" _gui-text="Area tool overlap (0..0.9):">0</param> - <_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> <_option value="delete">delete</_option> </param> - <_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) @@ -57,9 +57,9 @@ 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"> + <_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 </page> <page name='help' _gui-text='Help'> - <_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 @@ </page> <page name='help' _gui-text='Help'> - <_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='active-tab' type="notebook"> <page name='dxfpoints' _gui-text='DXF points'> - <_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 </page> <page name='help' _gui-text='Help'> - <_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 @@ <param name="engraving-newton-iterations" type="int" min="2" max="10" _gui-text="Accuracy factor (2 low to 10 high):">4</param> <param name="engraving-draw-calculation-paths" type="boolean" _gui-text="Draw additional graphics to see engraving path">false</param> - <_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> </page> <page name='help' _gui-text='Help'> - <_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)</_option> <_item value="G20 (All units in inches)">in</_item> </param> - <_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). </page> <page name='help' _gui-text='Help'> - <_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 c74ae267c..4bb9888a6 100644 --- a/share/extensions/gcodetools_lathe.inx +++ b/share/extensions/gcodetools_lathe.inx @@ -19,15 +19,15 @@ <param name="lathe-z-axis-remap" type="string" _gui-text="Lathe Z axis remap:">Z</param> </page> - <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. + <page name='lathe_modify_path' _gui-text='Lathe modify path'> + <_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. </_param> <param name="lathe-rectangular-cutter-width" type="float" precision="5" min="0" max="1000" _gui-text="Lathe width:">4</param> </page> - <page name='path-to-gcode' _gui-text='Path to Gcode'> + <page name='path-to-gcode' _gui-text='Path to Gcode'> <param name="biarc-tolerance" type='float' precision="5" _gui-text='Biarc interpolation tolerance:'>1</param> <param name="biarc-max-split-depth" type="int" _gui-text="Maximum splitting depth:">4</param> <param name="path-to-gcode-order" _gui-text="Cutting order:" type="optiongroup" appearance="minimal"> @@ -37,9 +37,9 @@ </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"> + <_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 </page> <page name='help' _gui-text='Help'> - <_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)</_option> <_item value="G20 (All units in inches)">in</_item> </param> - <_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). </page> <page name='help' _gui-text='Help'> - <_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 39cc6571b..6862a40a4 100644 --- a/share/extensions/gcodetools_path_to_gcode.inx +++ b/share/extensions/gcodetools_path_to_gcode.inx @@ -17,9 +17,9 @@ </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"> + <_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 </page> <page name='help' _gui-text='Help'> - <_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 ab054714e..c6d77e7db 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> @@ -30,7 +30,7 @@ </page> <page name='help' _gui-text='Help'> - <_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> - <_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. </page> <page name='help' _gui-text='Help'> - <_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/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() 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 @@ <id>grid.cartesian</id> <dependency type="executable" location="extensions">grid_cartesian.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="border_th" type="float" min="0" max="1000" _gui-text="Border Thickness (px):">3</param> - <_param name="x_axis" type="description" appearance="header">X Axis</_param> - <param name="x_divs" type="int" min="1" max="1000" _gui-text="Major X Divisions:">6</param> - <param name="dx" type="float" min="1" max="1000" _gui-text="Major X Division Spacing (px):">100.0</param> - <param name="x_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major X Division:">2</param> - <param name="x_log" type="boolean" _gui-text="Logarithmic X Subdiv. (Base given by entry above)">false</param> - <param name="x_subsubdivs" type="int" min="1" max="1000" _gui-text="Subsubdivs. per X Subdivision:">5</param> - <param name="x_half_freq" type="int" min="1" max="1000" _gui-text="Halve X Subsubdiv. Frequency after 'n' Subdivs. (log only):">4</param> - <param name="x_divs_th" type="float" min="0" max="1000" _gui-text="Major X Division Thickness (px):">2</param> - <param name="x_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor X Division Thickness (px):">1</param> - <param name="x_subsubdivs_th" type="float" min="0" max="1000" _gui-text="Subminor X Division Thickness (px):">0.3</param> - <_param name="y_axis" type="description" appearance="header">Y Axis</_param> - <param name="y_divs" type="int" min="1" max="1000" _gui-text="Major Y Divisions:">5</param> - <param name="dy" type="float" min="1" max="1000" _gui-text="Major Y Division Spacing (px):">100.0</param> - <param name="y_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Y Division:">1</param> - <param name="y_log" type="boolean" _gui-text="Logarithmic Y Subdiv. (Base given by entry above)">false</param> - <param name="y_subsubdivs" type="int" min="1" max="1000" _gui-text="Subsubdivs. per Y Subdivision:">5</param> - <param name="y_half_freq" type="int" min="1" max="1000" _gui-text="Halve Y Subsubdiv. Frequency after 'n' Subdivs. (log only):">4</param> - <param name="y_divs_th" type="float" min="0" max="1000" _gui-text="Major Y Division Thickness (px):">2</param> - <param name="y_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Y Division Thickness (px):">1</param> - <param name="y_subsubdivs_th" type="float" min="0" max="1000" _gui-text="Subminor Y Division Thickness (px):">0.3</param> + <param name="tab" type="notebook"> + <page name="x_tab" _gui-text="X Axis"> + <param name="x_divs" type="int" min="1" max="1000" _gui-text="Major X Divisions:">6</param> + <param name="dx" type="float" min="1" max="1000" _gui-text="Major X Division Spacing (px):">100.0</param> + <param name="x_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major X Division:">2</param> + <param name="x_log" type="boolean" _gui-text="Logarithmic X Subdiv. (Base given by entry above)">false</param> + <param name="x_subsubdivs" type="int" min="1" max="1000" _gui-text="Subsubdivs. per X Subdivision:">5</param> + <param name="x_half_freq" type="int" min="1" max="1000" _gui-text="Halve X Subsubdiv. Frequency after 'n' Subdivs. (log only):">4</param> + <param name="x_divs_th" type="float" min="0" max="1000" _gui-text="Major X Division Thickness (px):">2</param> + <param name="x_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor X Division Thickness (px):">1</param> + <param name="x_subsubdivs_th" type="float" min="0" max="1000" _gui-text="Subminor X Division Thickness (px):">0.3</param> + </page> + <page name="y_tab" _gui-text="Y Axis"> + <param name="y_divs" type="int" min="1" max="1000" _gui-text="Major Y Divisions:">5</param> + <param name="dy" type="float" min="1" max="1000" _gui-text="Major Y Division Spacing (px):">100.0</param> + <param name="y_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Y Division:">1</param> + <param name="y_log" type="boolean" _gui-text="Logarithmic Y Subdiv. (Base given by entry above)">false</param> + <param name="y_subsubdivs" type="int" min="1" max="1000" _gui-text="Subsubdivs. per Y Subdivision:">5</param> + <param name="y_half_freq" type="int" min="1" max="1000" _gui-text="Halve Y Subsubdiv. Frequency after 'n' Subdivs. (log only):">4</param> + <param name="y_divs_th" type="float" min="0" max="1000" _gui-text="Major Y Division Thickness (px):">2</param> + <param name="y_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Y Division Thickness (px):">1</param> + <param name="y_subsubdivs_th" type="float" min="0" max="1000" _gui-text="Subminor Y Division Thickness (px):">0.3</param> + </page> + </param> <effect> <object-type>all</object-type> 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, 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 @@ <id>grids.polar</id> <dependency type="executable" location="extensions">grid_polar.py</dependency> <dependency type="executable" location="extensions">inkex.py</dependency> + <param name="c_dot_dia" type="float" min="1" max="1000" _gui-text="Centre Dot Diameter (px):">5.0</param> <param name="a_labels" type="enum" _gui-text="Circumferential Labels:"> <_item msgctxt="Label" value="none">None</_item> @@ -11,20 +12,24 @@ </param> <param name="a_label_size" type="int" min="1" max="1000" _gui-text="Circumferential Label Size (px):">18</param> <param name="a_label_outset" type="float" min="0" max="1000" _gui-text="Circumferential Label Outset (px):">24</param> - <_param name="circ_divs_label" type="description" appearance="header">Circular Divisions</_param> - <param name="r_divs" type="int" min="1" max="1000" _gui-text="Major Circular Divisions:">5</param> - <param name="dr" type="float" min="1" max="1000" _gui-text="Major Circular Division Spacing (px):">50.0</param> - <param name="r_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Circular Division:">3</param> - <param name="r_log" type="boolean" _gui-text="Logarithmic Subdiv. (Base given by entry above)">false</param> - <param name="r_divs_th" type="float" min="0" max="1000" _gui-text="Major Circular Division Thickness (px):">2</param> - <param name="r_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Circular Division Thickness (px):">1</param> - <_param name="ang_divs_label" type="description" appearance="header">Angular Divisions</_param> - <param name="a_divs" type="int" min="1" max="1000" _gui-text="Angle Divisions:">24</param> - <param name="a_divs_cent" type="int" min="1" max="1000" _gui-text="Angle Divisions at Centre:">4</param> - <param name="a_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Angular Division:">1</param> - <param name="a_subdivs_cent" type="int" min="0" max="1000" _gui-text="Minor Angle Division End 'n' Divs. Before Centre:">2</param> - <param name="a_divs_th" type="float" min="0" max="1000" _gui-text="Major Angular Division Thickness (px):">2</param> - <param name="a_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Angular Division Thickness (px):">1</param> + <param name="tab" type="notebook"> + <page name="circular_div" _gui-text="Circular Divisions"> + <param name="r_divs" type="int" min="1" max="1000" _gui-text="Major Circular Divisions:">5</param> + <param name="dr" type="float" min="1" max="1000" _gui-text="Major Circular Division Spacing (px):">50.0</param> + <param name="r_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Circular Division:">3</param> + <param name="r_log" type="boolean" _gui-text="Logarithmic Subdiv. (Base given by entry above)">false</param> + <param name="r_divs_th" type="float" min="0" max="1000" _gui-text="Major Circular Division Thickness (px):">2</param> + <param name="r_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Circular Division Thickness (px):">1</param> + </page> + <page name="angular_div" _gui-text="Angular Divisions"> + <param name="a_divs" type="int" min="1" max="1000" _gui-text="Angle Divisions:">24</param> + <param name="a_divs_cent" type="int" min="1" max="1000" _gui-text="Angle Divisions at Centre:">4</param> + <param name="a_subdivs" type="int" min="1" max="1000" _gui-text="Subdivisions per Major Angular Division:">1</param> + <param name="a_subdivs_cent" type="int" min="0" max="1000" _gui-text="Minor Angle Division End 'n' Divs. Before Centre:">2</param> + <param name="a_divs_th" type="float" min="0" max="1000" _gui-text="Major Angular Division Thickness (px):">2</param> + <param name="a_subdivs_th" type="float" min="0" max="1000" _gui-text="Minor Angular Division Thickness (px):">1</param> + </page> + </param> <effect> <object-type>all</object-type> 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, 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/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/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/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 @@ <?xml version="1.0" encoding="UTF-8"?> <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> - <_name>Ask Us a Question</_name> - <id>org.inkscape.help.askaquestion</id> - <dependency type="executable" location="extensions">launch_webbrowser.py</dependency> - <param name="url" gui-hidden="true" type="string">http://answers.launchpad.net/inkscape/+addquestion</param> - <effect needs-document="false"> - <object-type>all</object-type> - <effects-menu hidden="true"/> - </effect> - <script> - <command reldir="extensions" interpreter="python">launch_webbrowser.py</command> - </script> + <_name>Ask Us a Question</_name> + <id>org.inkscape.help.askaquestion</id> + <dependency type="executable" location="extensions">launch_webbrowser.py</dependency> + <_param name="url" gui-hidden="true" type="string">https://inkscape.org/en/ask/</_param> + <effect needs-document="false"> + <object-type>all</object-type> + <effects-menu hidden="true"/> + </effect> + <script> + <command reldir="extensions" interpreter="python">launch_webbrowser.py</command> + </script> </inkscape-extension> diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 9dbb996e4..fd80ab412 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.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/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() 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..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 @@ -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 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: diff --git a/share/extensions/plt_input.inx b/share/extensions/plt_input.inx index ed3007fcd..743754469 100644 --- a/share/extensions/plt_input.inx +++ b/share/extensions/plt_input.inx @@ -6,7 +6,7 @@ <input> <extension>.plt</extension> <mimetype>image/x-plt</mimetype> - <_filetypename>HP Graphics Language Plot file [AutoCAD] (*.plt)</_filetypename> + <_filetypename>HP Graphics Language Plot file [AutoCAD] (UC) (*.plt)</_filetypename> <_filetypetooltip>Open HPGL plotter files</_filetypetooltip> <output_extension>org.inkscape.output.plt</output_extension> </input> diff --git a/share/extensions/plt_output.inx b/share/extensions/plt_output.inx index f7000cd79..8bbbaa1b8 100644 --- a/share/extensions/plt_output.inx +++ b/share/extensions/plt_output.inx @@ -6,7 +6,7 @@ <output> <extension>.plt</extension> <mimetype>image/x-plt</mimetype> - <_filetypename>HP Graphics Language Plot file [AutoCAD] (*.plt)</_filetypename> + <_filetypename>HP Graphics Language Plot file [AutoCAD] (UC) (*.plt)</_filetypename> <_filetypetooltip>Save a file for plotters</_filetypetooltip> </output> <script> 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/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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>Pre-Process File Save As...</_name> + <id>com.vaxxine.file.saveas.preprocess</id> + <dependency type="executable" location="extensions">prepare_file_save_as.py</dependency> + <dependency type="executable" location="extensions">inkex.py</dependency> + <effect> + <object-type>path</object-type> + <effects-menu> + <submenu _name="Export"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">prepare_file_save_as.py</command> + </script> +</inkscape-extension> diff --git a/share/extensions/prepare_file_save_as.py b/share/extensions/prepare_file_save_as.py new file mode 100755 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 <marenhachmannATyahoo.com> (refactoring, extend to multibool) + 2017 Alvin Penner <penner@vaxxine.com> (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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> + <_name>Pre-Process Win32 Vector Print</_name> + <id>com.vaxxine.print.win32.preprocess</id> + <dependency type="executable" location="extensions">prepare_print_win32_vector.py</dependency> + <dependency type="executable" location="extensions">inkex.py</dependency> + <effect> + <object-type>path</object-type> + <effects-menu> + <submenu _name="Export"/> + </effects-menu> + </effect> + <script> + <command reldir="extensions" interpreter="python">prepare_print_win32_vector.py</command> + </script> +</inkscape-extension> diff --git a/share/extensions/prepare_print_win32_vector.py b/share/extensions/prepare_print_win32_vector.py new file mode 100755 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 <marenhachmannATyahoo.com> (refactoring, extend to multibool) + 2017 Alvin Penner <penner@vaxxine.com> (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 diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py index 7151a3f88..99365fc5e 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,8 +199,17 @@ class MyEffect(inkex.Effect): exit() # user clicked Cancel self.scale = (ord(pDevMode[58]) + 256.0*ord(pDevMode[59]))/96 # use PrintQuality from DEVMODE - self.groupmat = [[[self.scale, 0.0, 0.0], [0.0, self.scale, 0.0]]] + self.scale /= self.unittouu('1px') + 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) 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/scour.inkscape.py b/share/extensions/scour.inkscape.py index eb31f308f..3d3f35bdb 100755 --- a/share/extensions/scour.inkscape.py +++ b/share/extensions/scour.inkscape.py @@ -1,10 +1,23 @@ #!/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 - 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)) @@ -17,10 +30,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 +62,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 +96,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 f7b8aedf7..7d7555664 100644 --- a/share/extensions/scour.inx +++ b/share/extensions/scour.inx @@ -92,6 +92,22 @@ _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> </page> + <page name="About" _gui-text="About"> + <param name="spacer" type="description"> </param> + <_param name="about_name_desc" type="description">Optimized SVG Output is provided by</_param> + <param name="about_name" type="description" appearance="header" indent="1">Scour - An SVG Scrubber</param> + <param name="spacer" type="description"> </param> + <_param name="about_link_desc" type="description">For details please refer to</_param> + <param name="about_link" type="description" appearance="url" indent="1">https://github.com/scour-project/scour</param> + <param name="spacer" type="description"> </param> + <param name="spacer" type="description"> </param> + <param name="spacer" type="description"> </param> + <_param name="about_version_desc" type="description">This version of the extension is designed for</_param> + <param name="about_version" type="description">Scour 0.31+</param> + <param name="scour-version" type="string" gui-hidden="true">0.31</param> <!-- this parameter is checked programatically in the extension to show a warning --> + <param _gui-text="Show warnings for older versions of Scour" + name="scour-version-warn-old" type="boolean">true</param> + </page> </param> <output> <extension>.svg</extension> diff --git a/share/extensions/sk1_input.inx b/share/extensions/sk1_input.inx index 64218b186..4483c2e13 100644 --- a/share/extensions/sk1_input.inx +++ b/share/extensions/sk1_input.inx @@ -6,7 +6,7 @@ <input> <extension>.sk1</extension> <mimetype>application/x-xsk1</mimetype> - <_filetypename>sK1 vector graphics files (*.sk1)</_filetypename> + <_filetypename>sK1 vector graphics files (UC) (*.sk1)</_filetypename> <_filetypetooltip>Open files saved in sK1 vector graphics editor</_filetypetooltip> </input> <script> diff --git a/share/extensions/sk1_output.inx b/share/extensions/sk1_output.inx index c6f021839..1aeedb6c7 100644 --- a/share/extensions/sk1_output.inx +++ b/share/extensions/sk1_output.inx @@ -6,7 +6,7 @@ <output> <extension>.sk1</extension> <mimetype>application/x-xsk1</mimetype> - <_filetypename>sK1 vector graphics files (*.sk1)</_filetypename> + <_filetypename>sK1 vector graphics files (UC) (*.sk1)</_filetypename> <_filetypetooltip>File format for use in sK1 vector graphics editor</_filetypetooltip> </output> <script> diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl index abc519065..e4a3ca3f1 100644 --- a/share/extensions/svg2xaml.xsl +++ b/share/extensions/svg2xaml.xsl @@ -765,7 +765,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt inkscape"> <xsl:choose> <xsl:when test="@xlink:href"> <xsl:variable name="reference_id" select="@xlink:href" /> - <xsl:apply-templates mode="forward" select="//*[name(.) = 'linearGradient' and $reference_id = concat('#', @id)]/*" /> + <xsl:apply-templates mode="forward" select="//*[name(.) = 'radialGradient' and $reference_id = concat('#', @id)]/*" /> </xsl:when> <xsl:otherwise> <xsl:apply-templates mode="forward" /> 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") diff --git a/share/extensions/synfig_output.py b/share/extensions/synfig_output.py index bcd1eeaf3..06a9c6e72 100755 --- a/share/extensions/synfig_output.py +++ b/share/extensions/synfig_output.py @@ -1051,7 +1051,6 @@ class SynfigExport(SynfigPrep): 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)) 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/test/frame_test.py b/share/extensions/test/frame_test.py new file mode 100755 index 000000000..3d686ab25 --- /dev/null +++ b/share/extensions/test/frame_test.py @@ -0,0 +1,120 @@ +#!/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) + 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 = [ + '--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/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/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 @@ +<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100"> + <g> + <defs> + <rect width="50" height="50" id="rect"/> + </defs> + <use xlink:href="#rect" transform="scale(.5)"/> + </g> +</svg>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="New document 1"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="375" + inkscape:cy="514.28571" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="479" + inkscape:window-height="379" + inkscape:window-x="1319" + inkscape:window-y="75" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <rect + style="opacity:0.5;fill:#6900ff;fill-opacity:0.36000001;stroke:#cae8ef;stroke-width:7.19999981;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect3006" + width="237.14285" + height="305.71429" + x="285.71429" + y="406.64789" /> + </g> +</svg> diff --git a/share/extensions/test/test_template.py.txt b/share/extensions/test/test_template.py.txt index 9a570cd6a..9a570cd6a 100644..100755 --- a/share/extensions/test/test_template.py.txt +++ b/share/extensions/test/test_template.py.txt 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] diff --git a/share/extensions/ungroup_deep.py b/share/extensions/ungroup_deep.py index d27bb8a69..359232007 100644..100755 --- 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 diff --git a/share/extensions/uniconv-ext.py b/share/extensions/uniconv-ext.py index c84ee2e0a..876cc4642 100755 --- a/share/extensions/uniconv-ext.py +++ b/share/extensions/uniconv-ext.py @@ -51,10 +51,11 @@ 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'+\ + '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 7815137b6..de6b6409f 100755 --- a/share/extensions/uniconv_output.py +++ b/share/extensions/uniconv_output.py @@ -118,10 +118,11 @@ 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'+\ + '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/voronoi.py b/share/extensions/voronoi.py index ac2c13f8f..ac2c13f8f 100644..100755 --- a/share/extensions/voronoi.py +++ b/share/extensions/voronoi.py diff --git a/share/extensions/voronoi2svg.py b/share/extensions/voronoi2svg.py index 5232fb81e..5232fb81e 100644..100755 --- a/share/extensions/voronoi2svg.py +++ b/share/extensions/voronoi2svg.py diff --git a/share/extensions/wmf_input.inx b/share/extensions/wmf_input.inx index 06c610d9e..db0f210e1 100644 --- a/share/extensions/wmf_input.inx +++ b/share/extensions/wmf_input.inx @@ -6,7 +6,7 @@ <input> <extension>.wmf</extension> <mimetype>application/x-wmf</mimetype> - <_filetypename>Windows Metafile (*.wmf)</_filetypename> + <_filetypename>Windows Metafile (UC) (*.wmf)</_filetypename> <_filetypetooltip>A popular graphics file format for clipart</_filetypetooltip> </input> <script> diff --git a/share/extensions/wmf_output.inx b/share/extensions/wmf_output.inx index e00721f0a..bc43a82a9 100644 --- a/share/extensions/wmf_output.inx +++ b/share/extensions/wmf_output.inx @@ -6,7 +6,7 @@ <output> <extension>.wmf</extension> <mimetype>application/x-wmf</mimetype> - <_filetypename>Windows Metafile (*.wmf)</_filetypename> + <_filetypename>Windows Metafile (UC) (*.wmf)</_filetypename> <_filetypetooltip>A popular graphics file format for clipart</_filetypetooltip> </output> <script> 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) - |
