From 05e89b0ec3bf6195ae6aa86dc5942d283e77846a Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Wed, 4 Nov 2015 17:27:57 -0500 Subject: [PATCH 1/6] Last pass in multi-pass cuts limited to specified z_cut. --- camlib.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/camlib.py b/camlib.py index 5748635..23d5566 100644 --- a/camlib.py +++ b/camlib.py @@ -2733,6 +2733,9 @@ class CNCjob(Geometry): :param append: :param tooldia: :param tolerance: + :param multidepth: If True, use multiple passes to reach + the desired depth. + :param depthpercut: Maximum depth in each pass. :return: None """ assert isinstance(geometry, Geometry), \ @@ -2800,6 +2803,7 @@ class CNCjob(Geometry): if pt != geo.coords[0] and pt == geo.coords[-1]: geo.coords = list(geo.coords)[::-1] + #---------- Single depth/pass -------- if not multidepth: # G-code # Note: self.linear2gcode() and self.point2gcode() will @@ -2819,14 +2823,17 @@ class CNCjob(Geometry): depth = 0 reverse = False while depth > self.z_cut: - depth -= depthpercut - log.debug("DEPTH: %f" % depth) - # TODO: Working... - # G-code - # Note: self.linear2gcode() and self.point2gcode() will - # lower and raise the tool every time. - # Cut at specific depth and do not leave the tool. + # Increase depth. Limit to z_cut. + depth -= depthpercut + if depth < self.z_cut: + depth = self.z_cut + + # Cut at specific depth and do not lift the tool. + # Note: linear2gcode() will use G00 to move to the + # first point in the path, but it should be already + # at the first point if the tool is down (in the material). + # So, an extra G00 should show up but is inconsequential. if type(geo) == LineString or type(geo) == LinearRing: self.gcode += self.linear2gcode(geo, tolerance=tolerance, zcut=depth, From 83eb535479238095533d443829021fa729c0af64 Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Wed, 4 Nov 2015 18:07:23 -0500 Subject: [PATCH 2/6] Fixed missing first segment in path bug. Delete last point in sequence while drawing object with backspace. --- FlatCAMDraw.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/FlatCAMDraw.py b/FlatCAMDraw.py index 659506e..05a90c5 100644 --- a/FlatCAMDraw.py +++ b/FlatCAMDraw.py @@ -457,6 +457,11 @@ class FCPolygon(FCShapeTool): self.geometry = DrawToolShape(Polygon(self.points)) self.complete = True + def on_key(self, key): + if key == 'backspace': + if len(self.points) > 0: + self.points = self.points[0:-1] + class FCPath(FCPolygon): """ @@ -468,13 +473,18 @@ class FCPath(FCPolygon): self.complete = True def utility_geometry(self, data=None): - if len(self.points) > 1: + if len(self.points) > 0: temp_points = [x for x in self.points] temp_points.append(data) return DrawToolUtilityShape(LineString(temp_points)) return None + def on_key(self, key): + if key == 'backspace': + if len(self.points) > 0: + self.points = self.points[0:-1] + class FCSelect(DrawTool): def __init__(self, draw_app): From 60461d072497c456b10f2bc75fa4a261e9549113 Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Wed, 4 Nov 2015 18:17:45 -0500 Subject: [PATCH 3/6] Fixed messages on drawing completion with spacebar. --- FlatCAMDraw.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FlatCAMDraw.py b/FlatCAMDraw.py index 05a90c5..29eb478 100644 --- a/FlatCAMDraw.py +++ b/FlatCAMDraw.py @@ -1011,6 +1011,7 @@ class FlatCAMDraw(QtCore.QObject): self.active_tool.make() if self.active_tool.complete: self.on_shape_complete() + self.app.info("Done.") return ### Abort the current action @@ -1037,12 +1038,14 @@ class FlatCAMDraw(QtCore.QObject): self.move_btn.setChecked(True) self.on_tool_select('move') self.active_tool.set_origin(self.snap(event.xdata, event.ydata)) + self.app.info("Click on target point.") ### Copy if event.key == 'c': self.copy_btn.setChecked(True) self.on_tool_select('copy') self.active_tool.set_origin(self.snap(event.xdata, event.ydata)) + self.app.info("Click on target point.") ### Snap if event.key == 'g': From 3f6ba30f3e64c35d6bb61ac9bda178af816ea614 Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Wed, 4 Nov 2015 18:52:56 -0500 Subject: [PATCH 4/6] Better support for units in LengthEntry. --- GUIElements.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/GUIElements.py b/GUIElements.py index 831379b..4fc1536 100644 --- a/GUIElements.py +++ b/GUIElements.py @@ -85,15 +85,16 @@ class LengthEntry(QtGui.QLineEdit): def get_value(self): raw = str(self.text()).strip(' ') - match = self.format_re.search(raw) + # match = self.format_re.search(raw) - if not match: - return None try: - if match.group(2) is not None and match.group(2).upper() in self.scales: - return float(eval(match.group(1)))*float(self.scales[self.output_units][match.group(2).upper()]) - else: - return float(eval(match.group(1))) + units = raw[-2:] + units = self.scales[self.output_units][units.upper()] + value = raw[:-2] + return float(eval(value))*units + except IndexError: + value = raw + return float(eval(value)) except: log.warning("Could not parse value in entry: %s" % str(raw)) return None From 89f3d6e3e3c1aab6a08817e96c55a8b638967dce Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Mon, 30 Nov 2015 12:36:03 -0500 Subject: [PATCH 5/6] Added line number information to status bar message on parse error. --- FlatCAMApp.py | 2 +- FlatCAMGUI.py | 2 ++ camlib.py | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 4a67d62..9e4eab4 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1634,7 +1634,7 @@ class App(QtCore.QObject): raise IOError('Failed to open file: ' + filename) except ParseError, e: - app_obj.inform.emit("[error] Failed to parse file: " + filename) + app_obj.inform.emit("[error] Failed to parse file: " + filename + ". " + e[0]) app_obj.progress.emit(0) self.log.error(str(e)) raise diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index 6d981bf..4e5d467 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -300,6 +300,7 @@ class FlatCAMInfoBar(QtGui.QWidget): self.text = QtGui.QLabel(self) self.text.setText("Hello!") + self.text.setToolTip("Hello!") layout.addWidget(self.text) @@ -307,6 +308,7 @@ class FlatCAMInfoBar(QtGui.QWidget): def set_text_(self, text): self.text.setText(text) + self.text.setToolTip(text) def set_status(self, text, level="info"): level = str(level) diff --git a/camlib.py b/camlib.py index 23d5566..ae85dda 100644 --- a/camlib.py +++ b/camlib.py @@ -14,6 +14,8 @@ from numpy import arctan2, Inf, array, sqrt, pi, ceil, sin, cos, dot, float32, \ from numpy.linalg import solve, norm from matplotlib.figure import Figure import re +import sys +import traceback import collections import numpy as np @@ -2054,9 +2056,12 @@ class Gerber (Geometry): self.solid_geometry = self.solid_geometry.difference(new_poly) except Exception, err: + ex_type, ex, tb = sys.exc_info() + traceback.print_tb(tb) #print traceback.format_exc() + log.error("PARSING FAILED. Line %d: %s" % (line_num, gline)) - raise ParseError("%s\nLine %d: %s" % (repr(err), line_num, gline)) + raise ParseError("Line %d: %s" % (line_num, gline), repr(err)) @staticmethod def create_flash_geometry(location, aperture): From c4347bea000df75ae55ced4a91f6050615da5f77 Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Mon, 30 Nov 2015 12:54:13 -0500 Subject: [PATCH 6/6] Fixes #177 --- GUIElements.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GUIElements.py b/GUIElements.py index 4fc1536..ba240ad 100644 --- a/GUIElements.py +++ b/GUIElements.py @@ -95,6 +95,9 @@ class LengthEntry(QtGui.QLineEdit): except IndexError: value = raw return float(eval(value)) + except KeyError: + value = raw + return float(eval(value)) except: log.warning("Could not parse value in entry: %s" % str(raw)) return None