From 82b39d64d2da1baaee90fb85e82dd71c523686de Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 24 Aug 2019 05:08:27 +0300 Subject: [PATCH] - fixed selection by dragging a selection shape in Geometry Editor --- README.md | 1 + flatcamEditors/FlatCAMGeoEditor.py | 33 ++++++++++++++++++++++-------- flatcamTools/ToolPaint.py | 12 +++++------ 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a1c677bd..1bb62a18 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing. - modified CutOut Tool so now the manual gaps adding will continue until the user is clicking the RMB - added ability to turn on/of the grid snapping and to jump to a location while in CutOut Tool manual gap adding action - made PlotCanvas class inherit from VisPy Canvas instead of creating an instance of it (work of JP) +- fixed selection by dragging a selection shape in Geometry Editor 23.08.2019 diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index d45a3bf8..981529e5 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -3768,19 +3768,34 @@ class FlatCAMGeoEditor(QtCore.QObject): """ poly_selection = Polygon([start_pos, (end_pos[0], start_pos[1]), end_pos, (start_pos[0], end_pos[1])]) + key_modifier = QtWidgets.QApplication.keyboardModifiers() + + if key_modifier == QtCore.Qt.ShiftModifier: + mod_key = 'Shift' + elif key_modifier == QtCore.Qt.ControlModifier: + mod_key = 'Control' + else: + mod_key = None + self.app.delete_selection_shape() + + sel_objects_list = [] for obj in self.storage.get_objects(): if (sel_type is True and poly_selection.contains(obj.geo)) or (sel_type is False and poly_selection.intersects(obj.geo)): - if self.key == self.app.defaults["global_mselect_key"]: - if obj in self.selected: - self.selected.remove(obj) - else: - # add the object to the selected shapes - self.selected.append(obj) - else: - if obj not in self.selected: - self.selected.append(obj) + sel_objects_list.append(obj) + + if mod_key == self.app.defaults["global_mselect_key"]: + for obj in sel_objects_list: + if obj in self.selected: + self.selected.remove(obj) + else: + # add the object to the selected shapes + self.selected.append(obj) + else: + self.selected = [] + self.selected = sel_objects_list + self.replot() def draw_utility_geometry(self, geo): diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 2eb2b371..7d45ed51 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -281,12 +281,12 @@ class ToolPaint(FlatCAMTool, Gerber): # Polygon selection selectlabel = QtWidgets.QLabel('%s:' % _('Selection')) selectlabel.setToolTip( - _("How to select the polygons to paint.
" - "Options:
" - "- Single Polygons: left mouse click on the polygon to be painted.
" - "- Area Selection: left mouse click to start selection of the area to be painted.
" - "- All Polygons: paint all polygons.
" - "- Reference Object: paint an area described by an external reference object.") + _("How to select Polygons to be painted.\n\n" + "- 'Area Selection' - left mouse click to start selection of the area to be painted.\n" + "Keeping a modifier key pressed (CTRL or SHIFT) will allow to add multiple areas.\n" + "- 'All Polygons' - the Paint will start after click.\n" + "- 'Reference Object' - will do non copper clearing within the area\n" + "specified by another object.") ) grid3.addWidget(selectlabel, 7, 0) # grid3 = QtWidgets.QGridLayout()