diff options
| author | Sebastian Wüst <sebi@timewaster.de> | 2013-11-14 17:54:59 +0000 |
|---|---|---|
| committer | Sebastian Wüst <sebi@timewaster.de> | 2013-11-14 17:54:59 +0000 |
| commit | 52309907643a585c3765551c04d2da20cbd467a8 (patch) | |
| tree | fa7a6c7c50511533f2eb1ed023cdf1ef8f939dbb | |
| parent | More scan-build null pointer checks (diff) | |
| download | inkscape-52309907643a585c3765551c04d2da20cbd467a8.tar.gz inkscape-52309907643a585c3765551c04d2da20cbd467a8.zip | |
small optimizations
(bzr r12815)
| -rw-r--r-- | share/extensions/hpgl_encoder.py | 9 | ||||
| -rw-r--r-- | share/extensions/plotter.inx | 3 | ||||
| -rw-r--r-- | share/extensions/plotter.py | 20 |
3 files changed, 13 insertions, 19 deletions
diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index 3a0523391..b4191e7c0 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -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: + 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,7 +187,7 @@ 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)) diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index f33e3088b..7cc9f1c94 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -39,7 +39,8 @@ </param> <param name="space" type="description"> </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="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__': |
