summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 498a0da)
raw | patch | inline | side by side (parent: 498a0da)
author | alvinpenner <alvinpenner@users.sourceforge.net> | |
Wed, 1 Jul 2009 23:35:57 +0000 (23:35 +0000) | ||
committer | alvinpenner <alvinpenner@users.sourceforge.net> | |
Wed, 1 Jul 2009 23:35:57 +0000 (23:35 +0000) |
share/extensions/hpgl_output.inx | patch | blob | history | |
share/extensions/hpgl_output.py | patch | blob | history |
index 8b06a11c28fba52621270a395bc04a8900c5ec42..f5cb9b7f8f634aef0f17bba5a14c399519246d28 100644 (file)
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
- <_name>HPGL Output</_name>
- <id>org.ekips.output.hpgl</id>
- <dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
- <dependency type="executable" location="extensions">hpgl_output.py</dependency>
- <dependency type="executable" location="extensions">inkex.py</dependency>
- <param name="flat" type="float" min="0.001" max="1000" _gui-text="hpgl output flatness">10</param>
- <output>
- <extension>.hpgl</extension>
- <mimetype>image/hpgl</mimetype>
- <_filetypename>HP Graphics Language file (*.hpgl)</_filetypename>
- <_filetypetooltip>Export to an HP Graphics Language file</_filetypetooltip>
- <dataloss>true</dataloss>
- </output>
- <script>
- <command reldir="extensions" interpreter="python">hpgl_output.py</command>
- <helper_extension>org.inkscape.output.svg.inkscape</helper_extension>
- </script>
+ <_name>HPGL Output</_name>
+ <id>org.ekips.output.hpgl</id>
+ <dependency type="extension">org.inkscape.output.svg.inkscape</dependency>
+ <dependency type="executable" location="extensions">hpgl_output.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="flat" type="float" min="0.001" max="1000" _gui-text="hpgl output flatness">0.2</param>
+ <param name="mirror" type="boolean" _gui-text="Mirror Y-axis">FALSE</param>
+ <param name="xOrigin" type="float" min="-100000" max="100000" _gui-text="X-origin (px)">0.0</param>
+ <param name="yOrigin" type="float" min="-100000" max="100000" _gui-text="Y-origin (px)">0.0</param>
+ <param name="plotInvisibleLayers" type="boolean" _gui-text="Plot invisible layers">FALSE</param>
+ <output>
+ <extension>.hpgl</extension>
+ <mimetype>image/hpgl</mimetype>
+ <_filetypename>HP Graphics Language file (*.hpgl)</_filetypename>
+ <_filetypetooltip>Export to an HP Graphics Language file</_filetypetooltip>
+ <dataloss>true</dataloss>
+ </output>
+ <script>
+ <command reldir="extensions" interpreter="python">hpgl_output.py</command>
+ <helper_extension>org.inkscape.output.svg.inkscape</helper_extension>
+ </script>
</inkscape-extension>
index 606718995af2afe05d4a4ee3446e7ffaee8b46ac..7e2dbc8acc749fcc04e59ffe3ca04115cc466a3b 100644 (file)
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
-import inkex, cubicsuperpath, simplepath, cspsubdiv
+import inkex, cubicsuperpath, simplepath, simplestyle, cspsubdiv
class MyEffect(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("-f", "--flatness",
action="store", type="float",
- dest="flat", default=10.0,
+ dest="flat", default=0.2,
help="Minimum flatness of the subdivided curves")
+ self.OptionParser.add_option("-m", "--mirror",
+ action="store", type="inkbool",
+ dest="mirror", default="FALSE",
+ help="Mirror Y-Axis")
+ self.OptionParser.add_option("-x", "--xOrigin",
+ action="store", type="float",
+ dest="xOrigin", default=0.0,
+ help="X Origin (pixels)")
+ self.OptionParser.add_option("-y", "--yOrigin",
+ action="store", type="float",
+ dest="yOrigin", default=0.0,
+ help="Y Origin (pixels)")
+ self.OptionParser.add_option("-p", "--plotInvisibleLayers",
+ action="store", type="inkbool",
+ dest="plotInvisibleLayers", default="FALSE",
+ help="Plot invisible layers")
+
self.hpgl = ['IN;SP1;']
def output(self):
print ''.join(self.hpgl)
def effect(self):
- path = '//svg:path'
- for node in self.document.getroot().xpath(path, namespaces=inkex.NSS):
- d = node.get('d')
- if len(simplepath.parsePath(d)):
- p = cubicsuperpath.parsePath(d)
- cspsubdiv.cspsubdiv(p, self.options.flat)
- for sp in p:
- first = True
- for csp in sp:
- cmd = 'PD'
- if first:
- cmd = 'PU'
- first = False
- self.hpgl.append('%s%s,%s;' % (cmd,csp[1][0],csp[1][1]))
+ mirror = 1.0
+ if self.options.mirror:
+ mirror = -1.0
+ x0 = self.options.xOrigin
+ y0 = self.options.yOrigin
+ scale = 1016.0/90
+ i = 0
+ layerPath = '//svg:g[@inkscape:groupmode="layer"]'
+ for layer in self.document.getroot().xpath(layerPath, namespaces=inkex.NSS):
+ i += 1
+ style = layer.get('style')
+ if style:
+ style = simplestyle.parseStyle(style)
+ if style['display']=='none':
+ if not self.options.plotInvisibleLayers:
+ continue
+ nodePath = ('//svg:g[@inkscape:groupmode="layer"][%d]/descendant::svg:path') % i
+ for node in self.document.getroot().xpath(nodePath, namespaces=inkex.NSS):
+ d = node.get('d')
+ if len(simplepath.parsePath(d)):
+ p = cubicsuperpath.parsePath(d)
+ cspsubdiv.cspsubdiv(p, self.options.flat)
+ for sp in p:
+ first = True
+ for csp in sp:
+ cmd = 'PD'
+ if first:
+ cmd = 'PU'
+ first = False
+ self.hpgl.append('%s%d,%d;' % (cmd,(csp[1][0] - x0)*scale,(csp[1][1] - y0)*scale*mirror))
if __name__ == '__main__': #pragma: no cover
e = MyEffect()
e.affect()
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99