From a98e6c3edade9f748dcb6a43abd42af749f5d67d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 1 May 2019 22:28:33 +0300 Subject: [PATCH] - Geometry Editor: restored the old behavior: a tool is active until it is voluntarily exited: either by using the 'ESC' key, or selecting the Select tool or new: right click on canvas - RELEASE 8.915 --- README.md | 2 ++ flatcamEditors/FlatCAMGeoEditor.py | 51 +++++++++++++++++++----------- flatcamEditors/FlatCAMGrbEditor.py | 1 - 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index e4d3df94..16a17ab8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ CAD program, and create G-Code for Isolation routing. - Excellon Editor: fixed mouse right click was always doing popup context menu - GUIElements.FCEntry2(): added a try-except clause - made sure that the Tools Tab is cleared on Editors exit +- Geometry Editor: restored the old behavior: a tool is active until it is voluntarily exited: either by using the 'ESC' key, or selecting the Select tool or new: right click on canvas +- RELEASE 8.915 30.04.2019 diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 933e5b93..8da538ac 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -3342,7 +3342,6 @@ class FlatCAMGeoEditor(QtCore.QObject): # Selection with left mouse button if self.active_tool is not None and event.button is 1: # Dispatch event to active_tool - # msg = self.active_tool.click(self.snap(event.xdata, event.ydata)) msg = self.active_tool.click(self.snap(self.pos[0], self.pos[1])) # If it is a shape generating tool @@ -3357,13 +3356,19 @@ class FlatCAMGeoEditor(QtCore.QObject): else: modifier_to_use = Qt.ShiftModifier + if isinstance(self.active_tool, FCText): + self.select_tool("select") + else: + self.select_tool(self.active_tool.name) + + # if modifier key is pressed then we add to the selected list the current shape but if # it's already in the selected list, we removed it. Therefore first click selects, second deselects. - if key_modifier == modifier_to_use: - self.select_tool(self.active_tool.name) - else: - self.select_tool("select") - return + # if key_modifier == modifier_to_use: + # self.select_tool(self.active_tool.name) + # else: + # self.select_tool("select") + # return if isinstance(self.active_tool, FCSelect): # self.app.log.debug("Replotting after click.") @@ -3471,9 +3476,16 @@ class FlatCAMGeoEditor(QtCore.QObject): except: pass - self.app.cursor = QtGui.QCursor() - self.app.populate_cmenu_grids() - self.app.ui.popMenu.popup(self.app.cursor.pos()) + if self.active_tool.complete is False and not isinstance(self.active_tool, FCSelect): + self.active_tool.complete = True + self.in_action = False + self.delete_utility_geometry() + self.app.inform.emit(_("[success] Done.")) + self.select_tool('select') + else: + self.app.cursor = QtGui.QCursor() + self.app.populate_cmenu_grids() + self.app.ui.popMenu.popup(self.app.cursor.pos()) else: # if right click on canvas and the active tool need to be finished (like Path or Polygon) # right mouse click will finish the action @@ -3483,19 +3495,20 @@ class FlatCAMGeoEditor(QtCore.QObject): if self.active_tool.complete: self.on_shape_complete() self.app.inform.emit(_("[success] Done.")) + self.select_tool(self.active_tool.name) # MS: always return to the Select Tool if modifier key is not pressed # else return to the current tool - key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.app.defaults["global_mselect_key"] == 'Control': - modifier_to_use = Qt.ControlModifier - else: - modifier_to_use = Qt.ShiftModifier - - if key_modifier == modifier_to_use: - self.select_tool(self.active_tool.name) - else: - self.select_tool("select") + # key_modifier = QtWidgets.QApplication.keyboardModifiers() + # if self.app.defaults["global_mselect_key"] == 'Control': + # modifier_to_use = Qt.ControlModifier + # else: + # modifier_to_use = Qt.ShiftModifier + # + # if key_modifier == modifier_to_use: + # self.select_tool(self.active_tool.name) + # else: + # self.select_tool("select") except Exception as e: log.warning("Error: %s" % str(e)) diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index 62791c19..1369e9a4 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -3258,7 +3258,6 @@ class FlatCAMGrbEditor(QtCore.QObject): # Selection with left mouse button if self.active_tool is not None and event.button is 1: # Dispatch event to active_tool - # msg = self.active_tool.click(self.app.geo_editor.snap(event.xdata, event.ydata)) msg = self.active_tool.click(self.app.geo_editor.snap(self.pos[0], self.pos[1])) # If it is a shape generating tool