From 97a1e17b0d760cd9b70f2b1094447b9befea48e7 Mon Sep 17 00:00:00 2001 From: jpcaram Date: Fri, 19 Dec 2014 13:40:14 -0500 Subject: [PATCH] Fixed bug preventing from saving G-Code. --- FlatCAMObj.py | 2 +- ObjectCollection.py | 8 +++++++- camlib.py | 33 ++++++++++++--------------------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 9fa6a90f..b43426a8 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -858,7 +858,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): try: filename = QtGui.QFileDialog.getSaveFileName(caption="Export G-Code ...", - directory=self.app.last_folder) + directory=self.app.defaults["last_folder"]) except TypeError: filename = QtGui.QFileDialog.getSaveFileName(caption="Export G-Code ...") diff --git a/ObjectCollection.py b/ObjectCollection.py index 92526d34..f4f051a9 100644 --- a/ObjectCollection.py +++ b/ObjectCollection.py @@ -4,8 +4,10 @@ import inspect # TODO: Remove import FlatCAMApp from PyQt4 import Qt, QtGui, QtCore - class ObjectCollection(QtCore.QAbstractListModel): + """ + Object storage and management. + """ classdict = { "gerber": FlatCAMGerber, @@ -39,9 +41,13 @@ class ObjectCollection(QtCore.QAbstractListModel): self.click_modifier = None + ## GUI Events self.view.selectionModel().selectionChanged.connect(self.on_list_selection_change) self.view.activated.connect(self.on_item_activated) + def on_key(self, event): + print event + def on_mouse_down(self, event): print "Mouse button pressed on list" diff --git a/camlib.py b/camlib.py index 53644bd5..9a94ea4b 100644 --- a/camlib.py +++ b/camlib.py @@ -1470,13 +1470,6 @@ class Gerber (Geometry): # Example: %LPD*% or %LPC*% # If polarity changes, creates geometry from current # buffer, then adds or subtracts accordingly. - - ## DEBUG - if line_num == 11: - print "LINE:", gline - print "RE:", self.lpol_re.pattern - print "MATCH:", self.lpol_re.search(gline) - match = self.lpol_re.search(gline) if match: if len(path) > 1 and current_polarity != match.group(1): @@ -1489,12 +1482,10 @@ class Gerber (Geometry): path = [path[-1]] # --- Apply buffer --- - print "current_polarity:", current_polarity # If added for testing of bug #83 # TODO: Remove when bug fixed if len(poly_buffer) > 0: if current_polarity == 'D': - print "Union with Cascaded Union of:", poly_buffer self.solid_geometry = self.solid_geometry.union(cascaded_union(poly_buffer)) else: self.solid_geometry = self.solid_geometry.difference(cascaded_union(poly_buffer)) @@ -1578,10 +1569,10 @@ class Gerber (Geometry): loc = location.coords[0] width = aperture['width'] height = aperture['height'] - minx = loc[0] - width/2 - maxx = loc[0] + width/2 - miny = loc[1] - height/2 - maxy = loc[1] + height/2 + minx = loc[0] - width / 2 + maxx = loc[0] + width / 2 + miny = loc[1] - height / 2 + maxy = loc[1] + height / 2 return shply_box(minx, miny, maxx, maxy) if aperture['type'] == 'O': # Obround @@ -1589,15 +1580,15 @@ class Gerber (Geometry): width = aperture['width'] height = aperture['height'] if width > height: - p1 = Point(loc[0] + 0.5*(width-height), loc[1]) - p2 = Point(loc[0] - 0.5*(width-height), loc[1]) - c1 = p1.buffer(height*0.5) - c2 = p2.buffer(height*0.5) + p1 = Point(loc[0] + 0.5 * (width - height), loc[1]) + p2 = Point(loc[0] - 0.5 * (width - height), loc[1]) + c1 = p1.buffer(height * 0.5) + c2 = p2.buffer(height * 0.5) else: - p1 = Point(loc[0], loc[1] + 0.5*(height-width)) - p2 = Point(loc[0], loc[1] - 0.5*(height-width)) - c1 = p1.buffer(width*0.5) - c2 = p2.buffer(width*0.5) + p1 = Point(loc[0], loc[1] + 0.5 * (height - width)) + p2 = Point(loc[0], loc[1] - 0.5 * (height - width)) + c1 = p1.buffer(width * 0.5) + c2 = p2.buffer(width * 0.5) return cascaded_union([c1, c2]).convex_hull if aperture['type'] == 'P': # Regular polygon