summaryrefslogtreecommitdiffstats
path: root/share/extensions
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-11-15 21:45:55 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-11-15 21:45:55 +0000
commitec2f5449d635a301b82c84d5f1a031fef62b34af (patch)
tree70be27a769645e9733b50192121ea4e577cc49fc /share/extensions
parentUpdate to trunk (diff)
parentfix typo in rev 12797 (diff)
downloadinkscape-ec2f5449d635a301b82c84d5f1a031fef62b34af.tar.gz
inkscape-ec2f5449d635a301b82c84d5f1a031fef62b34af.zip
Update to trunk
(bzr r11950.1.200)
Diffstat (limited to 'share/extensions')
-rw-r--r--share/extensions/hpgl_encoder.py33
-rw-r--r--share/extensions/plotter.inx5
-rw-r--r--share/extensions/plotter.py20
3 files changed, 26 insertions, 32 deletions
diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py
index f6ad13f60..b4191e7c0 100644
--- a/share/extensions/hpgl_encoder.py
+++ b/share/extensions/hpgl_encoder.py
@@ -91,7 +91,7 @@ class hpglEncoder:
groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, 0.0], [0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, 0.0]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
- self.process_groups(self.doc, groupmat)
+ self.processGroups(self.doc, groupmat)
if self.divergenceX == 'False' or self.divergenceY == 'False' or self.sizeX == 'False' or self.sizeY == 'False':
raise Exception('NO_PATHS')
# live run
@@ -110,17 +110,17 @@ class hpglEncoder:
self.hpgl = 'IN;SP%d' % self.options.pen
# add precut
if self.options.useToolOffset and self.options.precut:
- self.calcOffset('PU', 0, 0)
- self.calcOffset('PD', 0, self.options.toolOffset * 8)
+ self.processOffset('PU', 0, 0)
+ self.processOffset('PD', 0, self.options.toolOffset * 8)
# start conversion
- self.process_groups(self.doc, groupmat)
+ self.processGroups(self.doc, groupmat)
# shift an empty node in in order to process last node in cache
- self.calcOffset('PU', 0, 0)
+ self.processOffset('PU', 0, 0)
# add return to zero point
self.hpgl += ';PU0,0;'
return self.hpgl
- def process_groups(self, doc, groupmat):
+ def processGroups(self, doc, groupmat):
# flatten groups to avoid recursion
paths = []
for node in doc:
@@ -139,7 +139,7 @@ class hpglEncoder:
paths[i][0] = ''
for node in paths:
if node[0] == inkex.addNS('path', 'svg'):
- self.process_path(node[1], node[2])
+ self.processPath(node[1], node[2])
def mergeTransform(self, doc, matrix):
# get and merge two matrixes into one
@@ -157,7 +157,7 @@ class hpglEncoder:
return False
return True
- def process_path(self, node, mat):
+ def processPath(self, node, mat):
# process path
paths = node.get('d')
if paths:
@@ -166,21 +166,20 @@ class hpglEncoder:
simpletransform.applyTransformToPath(mat, paths)
cspsubdiv.cspsubdiv(paths, self.options.flat)
# path to HPGL commands
- oldPosX = ''
- oldPosY = ''
+ oldPosX = 0.0
+ oldPosY = 0.0
# TODO: Plot smallest parts first to avid plotter dragging parts of foil around (on text)
for singlePath in paths:
cmd = 'PU'
for singlePathPoint in singlePath:
posX, posY = singlePathPoint[1]
# check if point is repeating, if so, ignore
- if posX != oldPosX or posY != oldPosY:
- self.calcOffset(cmd, posX, posY)
+ if int(round(posX)) != int(round(oldPosX)) or int(round(posY)) != int(round(oldPosY)):
+ self.processOffset(cmd, posX, posY)
cmd = 'PD'
oldPosX = posX
oldPosY = posY
# perform overcut
- # TODO: Find that evasive bug that produces an extra point between the end of the path and the overcut
if self.options.useOvercut and not self.dryRun:
# check if last and first points are the same, otherwise the path is not closed and no overcut can be performed
if int(round(oldPosX)) == int(round(singlePath[0][1][0])) and int(round(oldPosY)) == int(round(singlePath[0][1][1])):
@@ -188,14 +187,14 @@ class hpglEncoder:
for singlePathPoint in singlePath:
posX, posY = singlePathPoint[1]
# check if point is repeating, if so, ignore
- if posX != oldPosX or posY != oldPosY:
+ if int(round(posX)) != int(round(oldPosX)) or int(round(posY)) != int(round(oldPosY)):
overcutLength += self.getLength(oldPosX, oldPosY, posX, posY)
if overcutLength >= self.options.overcut:
newLength = self.changeLength(oldPosX, oldPosY, posX, posY, - (overcutLength - self.options.overcut))
- self.calcOffset(cmd, newLength[0], newLength[1])
+ self.processOffset(cmd, newLength[0], newLength[1])
break
else:
- self.calcOffset(cmd, posX, posY)
+ self.processOffset(cmd, posX, posY)
oldPosX = posX
oldPosY = posY
@@ -220,7 +219,7 @@ class hpglEncoder:
temp2 = 2 * math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2) * math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
return math.acos(max(min(temp1 / temp2, 1.0), -1.0))
- def calcOffset(self, cmd, posX, posY):
+ def processOffset(self, cmd, posX, posY):
# calculate offset correction (or dont)
if not self.options.useToolOffset or self.dryRun:
self.storePoint(cmd, posX, posY)
diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx
index 49bcf837e..7cc9f1c94 100644
--- a/share/extensions/plotter.inx
+++ b/share/extensions/plotter.inx
@@ -11,6 +11,7 @@
<page name="misc" _gui-text="Connection">
<param name="serialPort" type="string" _gui-text="Serial Port" _gui-description="The port of your serial connection, on Windows something like 'COM1', on Linux something like: '/dev/ttyUSB0' (Default: COM1)">COM1</param>
<param name="serialBaudRate" type="optiongroup" appearance="minimal" _gui-text="Serial Baud rate" _gui-description="The Baud rate of your serial connection (Default: 9600)">
+ <option value="9600">9600</option>
<option value="110">110</option>
<option value="300">300</option>
<option value="600">600</option>
@@ -38,8 +39,8 @@
</param>
<param name="space" type="description">&#xa0;</param>
<_param name="serialHelp" type="description">This can be a physical serial connection or a USB-to-Serial bridge. Ask your plotter manufacturer for drivers if needed.</_param>
- <_param name="parallelHelp" type="description">Please note that Parallel (LPT) connections are not supported.</_param>
- <_param name="hpglNote" type="description">Please note that only the HPGL command language is supported at the moment.</_param>
+ <_param name="freezeHelp" type="description">Using wrong settings can under certain circumstances cause Inkscape to freeze. Always save your work before plotting.</_param>
+ <_param name="parallelHelp" type="description">Parallel (LPT) connections are not supported.</_param>
</page>
<page name="plotter" _gui-text="Plotter Settings">
<param name="pen" type="int" min="0" max="99" _gui-text="Pen number" _gui-description="The number of the pen (tool) to use, on most plotters 1 (Standard: '1')">1</param>
diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py
index 427e9401b..f57057435 100644
--- a/share/extensions/plotter.py
+++ b/share/extensions/plotter.py
@@ -82,20 +82,12 @@ class MyEffect(inkex.Effect):
'''
# reparse data for preview
self.options.showMovements = True
- self.options.docWidth = float(inkex.unittouu(self.document.getroot().get('width')))
- self.options.docHeight = float(inkex.unittouu(self.document.getroot().get('height')))
+ self.options.docWidth = float(self.unittouu(self.document.getroot().get('width')))
+ self.options.docHeight = float(self.unittouu(self.document.getroot().get('height')))
myHpglDecoder = hpgl_decoder.hpglDecoder(self.hpgl, self.options)
- try:
- doc, warnings = myHpglDecoder.getSvg()
- # deliver document to inkscape
- self.document = doc
- except Exception as inst:
- if inst.args[0] == 'NO_HPGL_DATA':
- # do nothing
- pass
- else:
- type, value, traceback = sys.exc_info()
- raise ValueError, ('', type, value), traceback
+ doc, warnings = myHpglDecoder.getSvg()
+ # deliver document to inkscape
+ self.document = doc
'''
if self.options.commandLanguage == 'dmpl':
# convert HPGL to DMPL
@@ -108,6 +100,7 @@ class MyEffect(inkex.Effect):
mySerial = serial.Serial()
mySerial.port = self.options.serialPort
mySerial.baudrate = self.options.serialBaudRate
+ mySerial.timeout = 0.1
if self.options.flowControl == 'xonxoff':
mySerial.xonxoff = True
if self.options.flowControl == 'rtscts' or self.options.flowControl == 'dsrdtrrtscts':
@@ -124,6 +117,7 @@ class MyEffect(inkex.Effect):
type, value, traceback = sys.exc_info()
raise ValueError, ('', type, value), traceback
mySerial.write(self.hpgl)
+ mySerial.read(2)
mySerial.close()
if __name__ == '__main__':