From 578ea34c5a2a7aa0c01d0ffe520ee901f3b11d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Mon, 15 Jul 2013 22:24:32 +0200 Subject: minor stuff (bzr r12417.1.12) --- share/extensions/hpgl_encoder.py | 11 ++++++++--- share/extensions/hpgl_output.py | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index b53f61109..27d1bf755 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -164,9 +164,9 @@ class hpglEncoder: oldPosX = posX oldPosY = posY - def getLength(self, x1, y1, x2, y2, abs = True): + def getLength(self, x1, y1, x2, y2, absolute = True): # calc absoulute or relative length between two points - if abs: return math.fabs(math.sqrt((x2 - x1) ** 2.0 + (y2 - y1) ** 2.0)) + if absolute: return math.fabs(math.sqrt((x2 - x1) ** 2.0 + (y2 - y1) ** 2.0)) else: return math.sqrt((x2 - x1) ** 2.0 + (y2 - y1) ** 2.0) def changeLengthX(self, x1, y1, x2, y2, offset): @@ -205,6 +205,10 @@ class hpglEncoder: else: # check if tool offset correction is needed (if the angle is big enough) if self.vData[2][0] == 'PD' and self.vData[3][0] == 'PD': + # TODO:2013-07-13:Sebastian Wüst:Is this necessary? + if self.getLength(self.vData[2][1], self.vData[2][2], self.vData[3][1], self.vData[3][2]) < self.options.toolOffset: + self.storeData(self.vData[2][0], self.vData[2][1], self.vData[2][2]) + return if self.getAlpha(self.vData[1][1], self.vData[1][2], self.vData[2][1], self.vData[2][2], self.vData[3][1], self.vData[3][2]) > 2.748893: self.storeData(self.vData[2][0], self.vData[2][1], self.vData[2][2]) return @@ -223,7 +227,7 @@ class hpglEncoder: self.storeData('PU', pointThreeX, pointThreeY) if self.vData[3][0] == 'PD': # If the 4th entry in the cache is a pen down command # TODO:2013-07-13:Sebastian Wüst:Either remove old method or make it selectable by parameter. - if 1 == 1: + if 1 == 2: pointFourX = self.changeLengthX(self.vData[3][1], self.vData[3][2], self.vData[2][1], self.vData[2][2], -(self.options.toolOffset * self.options.toolOffsetReturn)) pointFourY = self.changeLengthY(self.vData[3][1], self.vData[3][2], self.vData[2][1], self.vData[2][2], -(self.options.toolOffset * self.options.toolOffsetReturn)) self.storeData('PD', pointFourX, pointFourY) @@ -234,6 +238,7 @@ class hpglEncoder: # TODO:2013-07-13:Sebastian Wüst:Fix that sucker! (number of points in the circle has to be calculated) alpha1 = math.atan2(pointThreeY - self.vData[2][2], pointThreeX - self.vData[2][1]) alpha2 = math.atan2(pointFourY - self.vData[2][2], pointFourX - self.vData[2][1]) + inkex.errormsg(str(math.fabs(alpha2 - alpha1))) step = (2 * math.pi - math.fabs(alpha2 - alpha1)) * 6 + 1 #inkex.errormsg(str(alpha1) + ' | ' + str(alpha2)) for alpha in range(int(step), 101, int(step)): diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index 1de2a857b..b72996315 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -19,6 +19,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' +# TODO:2013-07-15:Sebastian Wüst:make text to guide the user to the extension when he wants to plot + # standard library import sys # local library -- cgit v1.2.3