From 9b874034994a7c9cfb650c46d4f4d6f166050b94 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 2 Dec 2020 00:39:14 +0200 Subject: [PATCH] - Milling Tool - selecting an object on canvas will update the selection of the object combobox, if the selected object type is the same sa the one selected in the Target radio --- CHANGELOG.md | 1 + appTools/ToolMilling.py | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb47ceeb..9e9e72a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ CHANGELOG for FlatCAM beta - Milling Tool - working in tool data structures - Milling Tool - more or less made the CNCJob generation for multigeo Geometries to work; still the parameters may not be used - removed the Generate CNCJob context menu action in the Project Menu as this will not work anymore +- Milling Tool - selecting an object on canvas will update the selection of the object combobox, if the selected object type is the same sa the one selected in the Target radio 29.11.2020 diff --git a/appTools/ToolMilling.py b/appTools/ToolMilling.py index 5f6eff52..7ea65e8d 100644 --- a/appTools/ToolMilling.py +++ b/appTools/ToolMilling.py @@ -249,10 +249,14 @@ class ToolMilling(AppTool, Excellon): self.ui.geo_tools_table.drag_drop_sig.connect(self.on_geo_rebuild_ui) self.ui.geo_tools_table.horizontalHeader().sectionClicked.connect(self.on_toggle_all_rows) + # Generate CNCJob 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) + + # Reset Tool self.ui.reset_button.clicked.connect(self.set_tool_ui) # Cleanup on Graceful exit (CTRL+ALT+X combo key) self.app.cleanup.connect(self.set_tool_ui) @@ -1029,6 +1033,13 @@ class ToolMilling(AppTool, Excellon): self.app.collection.set_active(self.obj_name) self.build_ui() + def on_object_selection_changed(self, current, previous): + try: + name = current.indexes()[0].internalPointer().obj.options['name'] + self.ui.object_combo.set_value(name) + except IndexError: + pass + def on_job_changed(self, idx): if self.ui.target_radio.get_value() == 'geo': if idx == 3: # 'Polish' @@ -2362,6 +2373,8 @@ class ToolMilling(AppTool, Excellon): self.app.worker_task.emit({'fcn': job_thread, 'params': [self]}) def on_generate_cncjob_click(self): + self.app.delete_selection_shape() + if self.target_obj.kind == 'geometry': self.on_generatecnc_from_geo() @@ -2764,24 +2777,29 @@ class ToolMilling(AppTool, Excellon): def job_thread(a_obj): if self.target_obj.multigeo is False: with self.app.proc_container.new('%s...' % _("Generating")): - ret_val = a_obj.app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) - if ret_val != 'fail': - a_obj.inform.emit('[success] %s: %s' % (_("CNCjob created"), outname)) + ret_val = a_obj.app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot, + autoselected=True) else: with self.app.proc_container.new('%s...' % _("Generating")): - ret_val = a_obj.app_obj.new_object("cncjob", outname, job_init_multi_geometry, plot=plot) - if ret_val != 'fail': - a_obj.inform.emit('[success] %s: %s' % (_("CNCjob created"), outname)) + ret_val = a_obj.app_obj.new_object("cncjob", outname, job_init_multi_geometry, plot=plot, + autoselected=True) + + if ret_val != 'fail': + a_obj.inform.emit('[success] %s: %s' % (_("CNCjob created"), outname)) # Create a promise with the name self.app.collection.promise(outname) # Send to worker self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) else: - if self.solid_geometry: - self.app.app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) + if self.target_obj.multigeo is False: + ret_val = self.app.app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot, + autoselected=True) else: - self.app.app_obj.new_object("cncjob", outname, job_init_multi_geometry, plot=plot) + ret_val = self.app.app_obj.new_object("cncjob", outname, job_init_multi_geometry, plot=plot, + autoselected=True) + if ret_val != 'fail': + self.app.inform.emit('[success] %s: %s' % (_("CNCjob created"), outname)) def on_pp_changed(self): current_pp = self.ui.pp_geo_name_cb.get_value()