From ac3833f746e5d1b60001adc83885194fff4f9fe8 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 25 Apr 2019 20:59:45 +0300 Subject: [PATCH] - added a toggle button in Preferences to toggle on/off the display of the selection box on canvas when the user is clicking an object or selecting it by mouse dragging. --- FlatCAMApp.py | 21 ++++++++++++++------- README.md | 2 +- flatcamGUI/FlatCAMGUI.py | 11 +++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index c7e89985..7b4654d0 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -345,7 +345,7 @@ class App(QtCore.QObject): # General GUI Settings "global_layout": self.ui.general_defaults_form.general_gui_set_group.layout_combo, "global_hover": self.ui.general_defaults_form.general_gui_set_group.hover_cb, - + "global_selection_shape": self.ui.general_defaults_form.general_gui_set_group.selection_cb, # Gerber General "gerber_plot": self.ui.gerber_defaults_form.gerber_gen_group.plot_cb, "gerber_solid": self.ui.gerber_defaults_form.gerber_gen_group.solid_cb, @@ -649,6 +649,7 @@ class App(QtCore.QObject): # General GUI Settings "global_hover": True, + "global_selection_shape": True, "global_layout": "compact", # Gerber General "gerber_plot": True, @@ -4691,7 +4692,8 @@ class App(QtCore.QObject): self.collection.set_active(name) curr_sel_obj = self.collection.get_by_name(name) # create the selection box around the selected object - self.draw_selection_shape(curr_sel_obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(curr_sel_obj) def on_preferences(self): @@ -5305,12 +5307,14 @@ class App(QtCore.QObject): if sel_type is True: if poly_obj.within(poly_selection): # create the selection box around the selected object - self.draw_selection_shape(obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(obj) self.collection.set_active(obj.options['name']) else: if poly_selection.intersects(poly_obj): # create the selection box around the selected object - self.draw_selection_shape(obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(obj) self.collection.set_active(obj.options['name']) except: # the Exception here will happen if we try to select on screen and we have an newly (and empty) @@ -5360,7 +5364,8 @@ class App(QtCore.QObject): self.collection.set_active(objects_under_the_click_list[0]) # create the selection box around the selected object curr_sel_obj = self.collection.get_active() - self.draw_selection_shape(curr_sel_obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(curr_sel_obj) # self.inform.emit('[selected] %s: %s selected' % # (str(curr_sel_obj.kind).capitalize(), str(curr_sel_obj.options['name']))) @@ -5383,7 +5388,8 @@ class App(QtCore.QObject): self.collection.set_active(objects_under_the_click_list[0]) # create the selection box around the selected object curr_sel_obj = self.collection.get_active() - self.draw_selection_shape(curr_sel_obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(curr_sel_obj) # self.inform.emit('[selected] %s: %s selected' % # (str(curr_sel_obj.kind).capitalize(), str(curr_sel_obj.options['name']))) @@ -5431,7 +5437,8 @@ class App(QtCore.QObject): # delete the possible selection box around a possible selected object self.delete_selection_shape() # create the selection box around the selected object - self.draw_selection_shape(curr_sel_obj) + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(curr_sel_obj) # self.inform.emit('[selected] %s: %s selected' % # (str(curr_sel_obj.kind).capitalize(), str(curr_sel_obj.options['name']))) diff --git a/README.md b/README.md index 38c7e281..697d3c34 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ CAD program, and create G-Code for Isolation routing. - for all objects, if in Selected the object name is changed to the same name, the rename is not done (because there is nothing changed) - fixed Edit -> Copy as Geom function handler to work for Excellon objects, too - made sure that the mouse pointer is restored to default on Editor exit -- +- added a toggle button in Preferences to toggle on/off the display of the selection box on canvas when the user is clicking an object or selecting it by mouse dragging. 24.04.2019 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index cde708a0..bdcfe934 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -3603,6 +3603,16 @@ class GeneralGUISetGroupUI(OptionsGroupUI): ) self.hover_cb = FCCheckBox() + # Enable Selection box + self.selection_label = QtWidgets.QLabel(_('Sel. Shape:')) + self.selection_label.setToolTip( + _("Enable the display of a selection shape for FlatCAM objects.\n" + "It is displayed whenever the mouse selects an object\n" + "either by clicking or dragging mouse from left to right or\n" + "right to left.") + ) + self.selection_cb = FCCheckBox() + # Just to add empty rows self.spacelabel = QtWidgets.QLabel('') @@ -3614,6 +3624,7 @@ class GeneralGUISetGroupUI(OptionsGroupUI): self.form_box.addRow(self.hdpi_label, self.hdpi_cb) self.form_box.addRow(self.clear_label, self.clear_btn) self.form_box.addRow(self.hover_label, self.hover_cb) + self.form_box.addRow(self.selection_label, self.selection_cb) # Add the QFormLayout that holds the Application general defaults # to the main layout of this TAB