From 98e246a5c4b7b65f2f71188e2098d449d77cc9eb Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 23 Dec 2019 17:30:04 +0200 Subject: [PATCH] - when the selection is changed in the Project Tree the selection shape on canvas is deleted - if an object is selected on Project Tree and it does not have the selection shape drawn, first click on canvas over it will draw the selection shape --- FlatCAMApp.py | 50 ++++++++++++++++++++++++++++++--------------- FlatCAMObj.py | 3 +++ ObjectCollection.py | 5 +++++ README.md | 3 +++ 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 75a77f76..a6c396b9 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -8904,20 +8904,26 @@ class App(QtCore.QObject): # create the selection box around the selected object if self.defaults['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) + curr_sel_obj.selection_shape_drawn = True - elif self.collection.get_active().options['name'] not in objects_under_the_click_list: + elif curr_sel_obj.options['name'] not in objects_under_the_click_list: self.on_objects_selection(False) self.delete_selection_shape() + curr_sel_obj.selection_shape_drawn = False self.collection.set_active(objects_under_the_click_list[0]) curr_sel_obj = self.collection.get_active() - # create the selection box around the selected object if self.defaults['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) + curr_sel_obj.selection_shape_drawn = True self.selected_message(curr_sel_obj=curr_sel_obj) + elif curr_sel_obj.selection_shape_drawn is False: + if self.defaults['global_selection_shape'] is True: + self.draw_selection_shape(curr_sel_obj) + curr_sel_obj.selection_shape_drawn = True else: self.on_objects_selection(False) self.delete_selection_shape() @@ -8932,6 +8938,7 @@ class App(QtCore.QObject): # make active the first element of the overlapped objects list if self.collection.get_active() is None: self.collection.set_active(objects_under_the_click_list[0]) + objects_under_the_click_list[0].selection_shape_drawn = True name_sel_obj = self.collection.get_active().options['name'] # In case that there is a selected object but it is not in the overlapped object list @@ -8949,9 +8956,12 @@ class App(QtCore.QObject): curr_sel_obj = self.collection.get_active() # delete the possible selection box around a possible selected object self.delete_selection_shape() + curr_sel_obj.selection_shape_drawn = False + # create the selection box around the selected object if self.defaults['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) + curr_sel_obj.selection_shape_drawn = True self.selected_message(curr_sel_obj=curr_sel_obj) @@ -8961,6 +8971,9 @@ class App(QtCore.QObject): # delete the possible selection box around a possible selected object self.delete_selection_shape() + for o in self.collection.get_list(): + o.selection_shape_drawn = False + # and as a convenience move the focus to the Project tab because Selected tab is now empty but # only when working on App if self.call_source == 'app': @@ -12365,7 +12378,10 @@ class App(QtCore.QObject): new_color = self.defaults['global_plot_fill'] act_name = self.sender().text().lower() - sel_obj = self.collection.get_active() + sel_obj_list = self.collection.get_selected() + + if not sel_obj_list: + return if act_name == 'red': new_color = '#FF0000' + \ @@ -12397,22 +12413,22 @@ class App(QtCore.QObject): new_color = str(plot_fill_color.name()) + \ str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:]) - if self.is_legacy is False: - new_line_color = color_variant(new_color[:7], 0.7) - sel_obj.fill_color = new_color - sel_obj.outline_color = new_line_color + new_line_color = color_variant(new_color[:7], 0.7) - sel_obj.shapes.redraw( - update_colors=(new_color, new_line_color) - ) - else: - new_line_color = color_variant(new_color[:7], 0.7) + for sel_obj in sel_obj_list: + if self.is_legacy is False: + sel_obj.fill_color = new_color + sel_obj.outline_color = new_line_color - sel_obj.fill_color = new_color - sel_obj.outline_color = new_line_color - sel_obj.shapes.redraw( - update_colors=(new_color, new_line_color) - ) + sel_obj.shapes.redraw( + update_colors=(new_color, new_line_color) + ) + else: + sel_obj.fill_color = new_color + sel_obj.outline_color = new_line_color + sel_obj.shapes.redraw( + update_colors=(new_color, new_line_color) + ) def on_grid_snap_triggered(self, state): if state: diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 44e5aa31..dbd5eb48 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -128,6 +128,9 @@ class FlatCAMObj(QtCore.QObject): self.isHovering = False self.notHovering = True + # Flag to show if a selection shape is drawn + self.selection_shape_drawn = False + # self.units = 'IN' self.units = self.app.defaults['units'] diff --git a/ObjectCollection.py b/ObjectCollection.py index f134fc32..d2c37096 100644 --- a/ObjectCollection.py +++ b/ObjectCollection.py @@ -787,6 +787,11 @@ class ObjectCollection(QtCore.QAbstractItemModel): # FlatCAMApp.App.log.debug("Current: %s, Previous %s" % (str(current), str(previous))) try: + # delete selection shape + self.app.delete_selection_shape() + for o in self.get_list(): + o.selection_shape_drawn = False + obj = current.indexes()[0].internalPointer().obj self.item_selected.emit(obj.options['name']) diff --git a/README.md b/README.md index 0ebd5ead..eef59695 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ CAD program, and create G-Code for Isolation routing. - when Printing as PDF Gerber objects now the rendered color is the print color - speed up the plotting in OpenGL(3D) graphic mode - spped up the color setting for Gerber object when using the OpenGL(3D) graphic mode +- setting color for Gerber objects work on a selection of Gerber objects +- when the selection is changed in the Project Tree the selection shape on canvas is deleted +- if an object is selected on Project Tree and it does not have the selection shape drawn, first click on canvas over it will draw the selection shape 22.12.2019