Code

adjustable hpgl scaling and pen number
authorAlvin Penner <penner@vaxxine.com>
Tue, 30 Mar 2010 22:23:12 +0000 (18:23 -0400)
committerAlvin Penner <penner@vaxxine.com>
Tue, 30 Mar 2010 22:23:12 +0000 (18:23 -0400)
share/extensions/hpgl_output.inx
share/extensions/hpgl_output.py

index f5cb9b7f8f634aef0f17bba5a14c399519246d28..fc65e70704977aec75d2986df195055be829bbf9 100644 (file)
@@ -9,6 +9,8 @@
        <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="resolution" type="int" min="90" max="2048" _gui-text="Resolution (dpi)">1016</param>
+       <param name="pen" type="int" min="1" max="10" _gui-text="Pen number">1</param>
        <param name="plotInvisibleLayers" type="boolean" _gui-text="Plot invisible layers">FALSE</param>
        <output>
                <extension>.hpgl</extension>
index 8c6eaa1684d6e1ecb26af9c1eb09e09ba5e90d42..28e1234980a0c2d19af2908a2c43c70b14d386f5 100644 (file)
@@ -37,18 +37,26 @@ class MyEffect(inkex.Effect):
                         action="store", type="float", 
                         dest="yOrigin", default=0.0,
                         help="Y Origin (pixels)")
+        self.OptionParser.add_option("-r", "--resolution",
+                        action="store", type="int", 
+                        dest="resolution", default=1016,
+                        help="Resolution (dpi)")
+        self.OptionParser.add_option("-n", "--pen",
+                        action="store", type="int",
+                        dest="pen", default=1,
+                        help="Pen number")
         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):
+        self.hpgl = ['IN;SP%d;' % self.options.pen]
         x0 = self.options.xOrigin
         y0 = self.options.yOrigin
-        scale = 1016.0/90
+        scale = float(self.options.resolution)/90
         mirror = 1.0
         if self.options.mirror:
             mirror = -1.0
@@ -78,6 +86,7 @@ class MyEffect(inkex.Effect):
                                 cmd = 'PU'
                             first = False
                             self.hpgl.append('%s%d,%d;' % (cmd,(csp[1][0] - x0)*scale,(csp[1][1]*mirror - y0)*scale))
+        self.hpgl.append('PU;')
 
 if __name__ == '__main__':   #pragma: no cover
     e = MyEffect()