diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 0106552d..dbf85f50 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -237,6 +237,9 @@ class App(QtCore.QObject): # should be disconnected after use so it can be reused replot_signal = pyqtSignal(list) + # signal emitted when jumping + jump_signal = pyqtSignal(tuple) + def __init__(self, user_defaults=True): """ Starts the application. @@ -7390,6 +7393,8 @@ class App(QtCore.QObject): else: location = custom_location + self.jump_signal.emit(location) + units = self.defaults['units'].upper() if fit_center: diff --git a/README.md b/README.md index 6838eb9d..746de8cc 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +16.12.2019 + +- in Geometry Editor added support for Jump To function such as that it works within the Editor Tools themselves. For now it works only in absolute jumps + 15.12.2019 - fixed a bug that created a crash in special conditions; it's related to the QSettings in FlatCAMGui.py diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 7786f051..3d91703b 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -1880,7 +1880,10 @@ class DrawTool(object): return "" def on_key(self, key): - return None + + # Jump to coords + if key == QtCore.Qt.Key_J or key == 'J': + self.draw_app.app.on_jump_to() def utility_geometry(self, data=None): return None @@ -1943,6 +1946,8 @@ class FCCircle(FCShapeTool): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_circle_geo.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) + self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) + self.draw_app.app.inform.emit(_("Click on Center point ...")) self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] @@ -1979,8 +1984,10 @@ class FCCircle(FCShapeTool): radius = distance(p1, p2) self.geometry = DrawToolShape(Point(p1).buffer(radius, int(self.steps_per_circ / 4))) self.complete = True - self.draw_app.app.inform.emit('[success] %s' % - _("Done. Adding Circle completed.")) + + self.draw_app.app.jump_signal.disconnect() + + self.draw_app.app.inform.emit('[success] %s' % _("Done. Adding Circle completed.")) class FCArc(FCShapeTool): @@ -1994,7 +2001,7 @@ class FCArc(FCShapeTool): QtGui.QGuiApplication.restoreOverrideCursor() except Exception: pass - self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.resource_location + '/aero_arc.png')) + self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_arc.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) self.draw_app.app.inform.emit(_("Click on Center point ...")) @@ -2010,6 +2017,8 @@ class FCArc(FCShapeTool): # 132 = p1, p3, p2 self.mode = "c12" # Center, p1, p2 + self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) + self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] def click(self, point): @@ -2044,6 +2053,10 @@ class FCArc(FCShapeTool): self.direction = 'cw' if self.direction == 'ccw' else 'ccw' return _('Direction: %s') % self.direction.upper() + # Jump to coords + if key == QtCore.Qt.Key_J or key == 'J': + self.draw_app.app.on_jump_to() + if key == 'M' or key == QtCore.Qt.Key_M: # delete the possible points made before this action; we want to start anew self.points[:] = [] @@ -2196,8 +2209,10 @@ class FCArc(FCShapeTool): self.geometry = DrawToolShape(LineString(arc(center, radius, startangle, stopangle, self.direction, self.steps_per_circ))) self.complete = True - self.draw_app.app.inform.emit('[success] %s' % - _("Done. Arc completed.")) + + self.draw_app.app.jump_signal.disconnect() + + self.draw_app.app.inform.emit('[success] %s' % _("Done. Arc completed.")) class FCRectangle(FCShapeTool): @@ -2217,6 +2232,8 @@ class FCRectangle(FCShapeTool): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) + self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) + self.draw_app.app.inform.emit(_("Click on 1st corner ...")) def click(self, point): @@ -2251,8 +2268,9 @@ class FCRectangle(FCShapeTool): # self.geometry = LinearRing([p1, (p2[0], p1[1]), p2, (p1[0], p2[1])]) self.geometry = DrawToolShape(Polygon([p1, (p2[0], p1[1]), p2, (p1[0], p2[1])])) self.complete = True - self.draw_app.app.inform.emit('[success] %s' % - _("Done. Rectangle completed.")) + + self.draw_app.app.jump_signal.disconnect() + self.draw_app.app.inform.emit('[success] %s' % _("Done. Rectangle completed.")) class FCPolygon(FCShapeTool): @@ -2272,6 +2290,8 @@ class FCPolygon(FCShapeTool): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) + self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) + self.draw_app.app.inform.emit(_("Click on 1st corner ...")) def click(self, point): @@ -2307,10 +2327,16 @@ class FCPolygon(FCShapeTool): self.geometry = DrawToolShape(Polygon(self.points)) self.draw_app.in_action = False self.complete = True - self.draw_app.app.inform.emit('[success] %s' % - _("Done. Polygon completed.")) + + self.draw_app.app.jump_signal.disconnect() + + self.draw_app.app.inform.emit('[success] %s' % _("Done. Polygon completed.")) def on_key(self, key): + # Jump to coords + if key == QtCore.Qt.Key_J or key == 'J': + self.draw_app.app.on_jump_to() + if key == 'Backspace' or key == QtCore.Qt.Key_Backspace: if len(self.points) > 0: self.points = self.points[0:-1] @@ -2336,6 +2362,8 @@ class FCPath(FCPolygon): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_path5.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) + self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) + def make(self): self.geometry = DrawToolShape(LineString(self.points)) self.name = 'path' @@ -2347,6 +2375,9 @@ class FCPath(FCPolygon): self.draw_app.in_action = False self.complete = True + + self.draw_app.app.jump_signal.disconnect() + self.draw_app.app.inform.emit('[success] %s' % _("Done. Path completed.")) def utility_geometry(self, data=None): @@ -2358,6 +2389,10 @@ class FCPath(FCPolygon): return None def on_key(self, key): + # Jump to coords + if key == QtCore.Qt.Key_J or key == 'J': + self.draw_app.app.on_jump_to() + if key == 'Backspace' or key == QtCore.Qt.Key_Backspace: if len(self.points) > 0: self.points = self.points[0:-1] @@ -3817,12 +3852,7 @@ class FlatCAMGeoEditor(QtCore.QObject): if event.button == 1 and event_is_dragging and isinstance(self.active_tool, FCEraser): pass else: - # ### Utility geometry (animated) ### - geo = self.active_tool.utility_geometry(data=(x, y)) - if isinstance(geo, DrawToolShape) and geo.geo is not None: - # Remove any previous utility shape - self.tool_shape.clear(update=True) - self.draw_utility_geometry(geo=geo) + self.update_utility_geometry(data=(x, y)) # ### Selection area on canvas section ### dx = pos[0] - self.pos[0] @@ -3839,6 +3869,14 @@ class FlatCAMGeoEditor(QtCore.QObject): else: self.app.selection_type = None + def update_utility_geometry(self, data): + # ### Utility geometry (animated) ### + geo = self.active_tool.utility_geometry(data=data) + if isinstance(geo, DrawToolShape) and geo.geo is not None: + # Remove any previous utility shape + self.tool_shape.clear(update=True) + self.draw_utility_geometry(geo=geo) + def on_geo_click_release(self, event): if self.app.is_legacy is False: event_pos = event.pos diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index 0cfcae18..5233314c 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -4530,13 +4530,7 @@ class FlatCAMGrbEditor(QtCore.QObject): self.app.ui.rel_position_label.setText("Dx: %.4f   Dy: " "%.4f    " % (dx, dy)) - # # ## Utility geometry (animated) - geo = self.active_tool.utility_geometry(data=(x, y)) - - if isinstance(geo, DrawToolShape) and geo.geo is not None: - # Remove any previous utility shape - self.tool_shape.clear(update=True) - self.draw_utility_geometry(geo=geo) + self.update_utility_geometry(data=(x, y)) # # ## Selection area on canvas section # ## if event_is_dragging == 1 and event.button == 1: @@ -4558,6 +4552,15 @@ class FlatCAMGrbEditor(QtCore.QObject): else: self.app.selection_type = None + def update_utility_geometry(self, data): + # # ## Utility geometry (animated) + geo = self.active_tool.utility_geometry(data=data) + + if isinstance(geo, DrawToolShape) and geo.geo is not None: + # Remove any previous utility shape + self.tool_shape.clear(update=True) + self.draw_utility_geometry(geo=geo) + def draw_utility_geometry(self, geo): if type(geo.geo) == list: for el in geo.geo: