From 2e23b8590b200b2a5c57864b9d5a767dce8133a0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 1 Sep 2021 23:16:17 +0300 Subject: [PATCH] - fixed the issue in Milling Plugin that did not automatically set the object combo to the previously selected object --- CHANGELOG.md | 6 +++- appGUI/GUIElements.py | 3 ++ appObjects/FlatCAMExcellon.py | 3 -- appObjects/FlatCAMGeometry.py | 3 -- appPlugins/ToolMilling.py | 64 ++++++++++++++++++++--------------- app_Main.py | 13 ++++++- 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c30bb18..ca9e82ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,14 @@ CHANGELOG for FlatCAM beta ================================================= +1.09.2021 + +- fixed the issue in Milling Plugin that did not automatically set the object combo to the previously selected object + 31.08.2021 - made sure that the location labels in the InfoBar have only the decimals required when the Grid snapping is ON -- fixed the bug where the HUD did not used the set font size from Preferences +- fixed the bug where the HUD have not used the set font size from Preferences 30.08.2021 diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index bca074ec..0aca957f 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -108,6 +108,9 @@ class RadioSet(QtWidgets.QWidget): if option['label'] in options: option['radio'].setDisabled(val) + def values(self): + return [choice['value'] for choice in self.choices] + class RadioSetDefaults(RadioSet): diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index cb60b6bf..e5f9b5bd 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -686,9 +686,6 @@ class ExcellonObject(FlatCAMObj, Excellon): def on_milling_button_clicked(self): self.app.milling_tool.run(toggle=True) - self.app.milling_tool.ui.target_radio.set_value('exc') - current_obj = self.app.collection.get_active() - self.app.milling_tool.ui.object_combo.set_value(current_obj.options['name']) def export_excellon(self, whole, fract, e_zeros=None, form='dec', factor=1, slot_type='routing'): """ diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 9c14a526..0c2c7656 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -462,9 +462,6 @@ class GeometryObject(FlatCAMObj, Geometry): def on_milling_button_clicked(self): self.app.milling_tool.run(toggle=True) - self.app.milling_tool.ui.target_radio.set_value('geo') - current_obj = self.app.collection.get_active() - self.app.milling_tool.ui.object_combo.set_value(current_obj.options['name']) def on_calculate_vertex_points(self): self.app.log.debug("GeometryObject.on_calculate_vertex_points()") diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 98cc5964..88611099 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -133,6 +133,10 @@ class ToolMilling(AppTool, Excellon): self.old_tool_dia = None self.poly_drawn = False + # When object selection on canvas change + # self.app.collection.view.selectionModel().selectionChanged.connect(self.on_object_selection_changed) + self.app.proj_selection_changed.connect(self.on_object_selection_changed) + def install(self, icon=None, separator=None, **kwargs): AppTool.install(self, icon, separator, shortcut='Alt+M', **kwargs) @@ -243,10 +247,6 @@ class ToolMilling(AppTool, Excellon): self.launch_job.connect(self.mtool_gen_cncjob) self.ui.generate_cnc_button.clicked.connect(self.on_generate_cncjob_click) - # When object selection on canvas change - # self.app.collection.view.selectionModel().selectionChanged.connect(self.on_object_selection_changed) - self.app.proj_selection_changed.connect(self.on_object_selection_changed) - # Reset Tool self.ui.reset_button.clicked.connect(self.set_tool_ui) # Cleanup on Graceful exit (CTRL+ALT+X combo key) @@ -284,6 +284,7 @@ class ToolMilling(AppTool, Excellon): self.ui.target_radio.activated_custom.disconnect() except (TypeError, AttributeError): pass + try: self.ui.job_type_combo.currentIndexChanged.disconnect() except (TypeError, AttributeError): @@ -366,13 +367,6 @@ class ToolMilling(AppTool, Excellon): except (TypeError, AttributeError): pass - # When object selection on canvas change - # self.app.collection.view.selectionModel().selectionChanged.disconnect() - try: - self.app.proj_selection_changed.disconnect() - except (TypeError, AttributeError): - pass - # Reset Tool try: self.ui.reset_button.clicked.disconnect() @@ -430,13 +424,22 @@ class ToolMilling(AppTool, Excellon): # try to select in the Gerber combobox the active object try: selected_obj = self.app.collection.get_active() - if selected_obj.kind == 'excellon': - current_name = selected_obj.options['name'] - self.ui.object_combo.set_value(current_name) - except Exception: - pass - self.form_fields.update({ + if not selected_obj: + self.ui.target_radio.set_value('geo') + + if selected_obj.kind == 'excellon': + self.ui.target_radio.set_value('exc') + self.ui.object_combo.set_value(selected_obj.options['name']) + + if selected_obj.kind == 'geometry': + self.ui.target_radio.set_value('geo') + self.ui.object_combo.set_value(selected_obj.options['name']) + + except Exception as err: + self.app.log.error("ToolMilling.set_tool_ui() --> %s" % str(err)) + + self.form_fields = { # Excellon properties "tools_mill_milling_type": self.ui.milling_type_radio, "tools_mill_milling_dia": self.ui.mill_dia_entry, @@ -470,9 +473,9 @@ class ToolMilling(AppTool, Excellon): "tools_mill_spindlespeed": self.ui.spindlespeed_entry, "tools_mill_dwell": self.ui.dwell_cb, "tools_mill_dwelltime": self.ui.dwelltime_entry, - }) + } - self.general_form_fields.update({ + self.general_form_fields = { "tools_mill_toolchange": self.ui.toolchange_cb, "tools_mill_toolchangez": self.ui.toolchangez_entry, "tools_mill_toolchangexy": self.ui.toolchangexy_entry, @@ -489,9 +492,9 @@ class ToolMilling(AppTool, Excellon): "tools_mill_area_shape": self.ui.area_shape_radio, "tools_mill_area_strategy": self.ui.strategy_radio, "tools_mill_area_overz": self.ui.over_z_entry, - }) + } - self.name2option.update({ + self.name2option = { "milling_type": "tools_mill_milling_type", "milling_dia": "tools_mill_milling_dia", @@ -540,7 +543,7 @@ class ToolMilling(AppTool, Excellon): "mill_area_shape": "tools_mill_area_shape", "mill_strategy": "tools_mill_area_strategy", "mill_overz": "tools_mill_area_overz", - }) + } # reset the Geometry preprocessor combo self.ui.pp_geo_name_cb.clear() @@ -1321,11 +1324,11 @@ class ToolMilling(AppTool, Excellon): if self.obj_name and self.obj_name != '': self.app.collection.set_all_inactive() self.app.collection.set_active(self.obj_name) - self.build_ui() + # self.build_ui() # new object that is now selected obj = self.app.collection.get_by_name(self.obj_name) - if obj is not None: + if obj is not None and obj.tools: last_key = list(obj.tools.keys())[-1] self.to_form(storage=obj.tools[last_key]['data']) @@ -1360,9 +1363,14 @@ class ToolMilling(AppTool, Excellon): self.app.collection.set_active(self.obj_name) self.build_ui() - if self.target_obj is not None: - last_key = list(self.target_obj.tools.keys())[-1] - self.to_form(storage=self.target_obj.tools[last_key]['data']) + if self.target_obj.tools: + self.ui.param_frame.setDisabled(False) + self.ui.generate_cnc_button.setDisabled(False) + last_key = list(self.target_obj.tools.keys())[-1] + self.to_form(storage=self.target_obj.tools[last_key]['data']) + else: + self.ui.param_frame.setDisabled(True) + self.ui.generate_cnc_button.setDisabled(True) def on_object_selection_changed(self, current, previous): try: @@ -1371,7 +1379,7 @@ class ToolMilling(AppTool, Excellon): kind = sel_obj.kind if kind in ['geometry', 'excellon']: self.ui.object_combo.set_value(name) - except IndexError: + except Exception: pass def on_job_changed(self, idx): diff --git a/app_Main.py b/app_Main.py index c149333c..75fbac7c 100644 --- a/app_Main.py +++ b/app_Main.py @@ -6685,7 +6685,7 @@ class App(QtCore.QObject): def on_notebook_closed(self, tab_obj_name): - # closed_plugin_name = self.ui.plugin_scroll_area.widget().objectName() + closed_plugin_name = self.ui.plugin_scroll_area.widget().objectName() # # print(closed_plugin_name) # if closed_plugin_name == _("Levelling"): # # clear the possible drawn probing shapes @@ -6693,6 +6693,17 @@ class App(QtCore.QObject): # elif closed_plugin_name in [_("Isolation"), _("NCC"), _("Paint"), _("Punch Gerber")]: # self.tool_shapes.clear(update=True) + disconnected_tool = self.ui.plugin_scroll_area.widget() + + # try: + # # if the closed plugin name is Milling + # disconnected_tool.disconnect_signals() + # disconnected_tool.ui_disconnect() + # disconnected_tool.clear_ui(disconnected_tool.layout) + # + # except Exception as err: + # print(str(err)) + try: # clear the possible drawn probing shapes for Levelling Tool self.levelling_tool.probing_shapes.clear(update=True)