diff --git a/appDatabase.py b/appDatabase.py index 7349a945..2d544c68 100644 --- a/appDatabase.py +++ b/appDatabase.py @@ -2505,35 +2505,35 @@ class ToolsDB2(QtWidgets.QWidget): self.db_tool_dict[tool_id]['tools_mill_offset_value'] = val elif wdg_name == "gdb_cutz": - self.db_tool_dict[tool_id]['data']['cutz'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_cutz'] = val elif wdg_name == "gdb_multidepth": - self.db_tool_dict[tool_id]['data']['multidepth'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_multidepth'] = val elif wdg_name == "gdb_multidepth_entry": - self.db_tool_dict[tool_id]['data']['depthperpass'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_depthperpass'] = val elif wdg_name == "gdb_travelz": - self.db_tool_dict[tool_id]['data']['travelz'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_travelz'] = val elif wdg_name == "gdb_frxy": - self.db_tool_dict[tool_id]['data']['feedrate'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_feedrate'] = val elif wdg_name == "gdb_frz": - self.db_tool_dict[tool_id]['data']['feedrate_z'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_feedrate_z'] = val elif wdg_name == "gdb_spindle": - self.db_tool_dict[tool_id]['data']['spindlespeed'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_spindlespeed'] = val elif wdg_name == "gdb_dwell": - self.db_tool_dict[tool_id]['data']['dwell'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_dwell'] = val elif wdg_name == "gdb_dwelltime": - self.db_tool_dict[tool_id]['data']['dwelltime'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_dwelltime'] = val elif wdg_name == "gdb_vdia": - self.db_tool_dict[tool_id]['data']['vtipdia'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_vtipdia'] = val elif wdg_name == "gdb_vangle": - self.db_tool_dict[tool_id]['data']['vtipangle'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_vtipangle'] = val elif wdg_name == "gdb_frapids": - self.db_tool_dict[tool_id]['data']['feedrate_rapid'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_feedrate_rapid'] = val elif wdg_name == "gdb_ecut": - self.db_tool_dict[tool_id]['data']['extracut'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_extracut'] = val elif wdg_name == "gdb_ecut_length": - self.db_tool_dict[tool_id]['data']['extracut_length'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_extracut_length'] = val # NCC Tool elif wdg_name == "gdb_n_operation": diff --git a/appEditors/appExcEditor.py b/appEditors/appExcEditor.py index c1bc4ab9..34a687b7 100644 --- a/appEditors/appExcEditor.py +++ b/appEditors/appExcEditor.py @@ -4313,9 +4313,14 @@ class AppExcEditor(QtCore.QObject): else: self.edited_obj_name += "_edit" + def deactivate_signal_handler(_): + self.deactivate() + + self.app.connect_custom_signal(deactivate_signal_handler, object) self.app.worker_task.emit({'fcn': self.new_edited_excellon, 'params': [self.edited_obj_name, self.new_tools]}) + return self.edited_obj_name @staticmethod @@ -4380,7 +4385,7 @@ class AppExcEditor(QtCore.QObject): filename=None, use_thread=False) except Exception as e: - self.deactivate() + self.app.custom_signal.emit(None) # calls deactivate_signal_handler() on UI Thread # make sure that we do not carry the reference of the edited object further along self.edited_obj = None @@ -4388,7 +4393,7 @@ class AppExcEditor(QtCore.QObject): self.app.log.error("Error on Edited object creation: %s" % str(e)) return - self.deactivate() + self.app.custom_signal.emit(None) # calls deactivate_signal_handler() on UI Thread # make sure that we do not carry the reference of the edited object further along self.edited_obj = None diff --git a/appEditors/appGeoEditor.py b/appEditors/appGeoEditor.py index b3624ffe..37b626b8 100644 --- a/appEditors/appGeoEditor.py +++ b/appEditors/appGeoEditor.py @@ -1921,6 +1921,11 @@ class AppGeoEditor(QtCore.QObject): :return: None """ + def deactivate_signal_handler(): + self.deactivate() + + self.app.connect_custom_signal(deactivate_signal_handler, object) + def worker_job(editor_obj): # Link shapes into editor. with editor_obj.app.proc_container.new(_("Working...")): @@ -1971,7 +1976,7 @@ class AppGeoEditor(QtCore.QObject): except Exception: pass - self.deactivate() + self.app.custom_signal.emit(None) editor_obj.app.inform.emit(_("Editor Exit. Geometry object was updated ...")) self.app.worker_task.emit({'fcn': worker_job, 'params': [self]}) diff --git a/appEditors/appGerberEditor.py b/appEditors/appGerberEditor.py index c4b0dcfd..3365abd2 100644 --- a/appEditors/appGerberEditor.py +++ b/appEditors/appGerberEditor.py @@ -5405,6 +5405,11 @@ class AppGerberEditor(QtCore.QObject): else: new_grb_name = self.edited_obj_name + "_edit" + def deactivate_grb_editor_signal_handler(): + self.deactivate_grb_editor() + + self.app.connect_custom_signal(deactivate_grb_editor_signal_handler, object) + self.app.worker_task.emit({'fcn': self.new_edited_gerber, 'params': [new_grb_name, self.storage_dict]}) # self.new_edited_gerber(new_grb_name, self.storage_dict) @@ -5533,7 +5538,7 @@ class AppGerberEditor(QtCore.QObject): # make sure to clean the previous results self.results = [] - self.deactivate_grb_editor() + self.app.custom_signal.emit(None) self.app.inform.emit('[success] %s' % _("Done.")) def on_tool_select(self, tool): diff --git a/appMain.py b/appMain.py index b2bbc2f6..487a2a6d 100644 --- a/appMain.py +++ b/appMain.py @@ -283,6 +283,9 @@ class App(QtCore.QObject): # post-Edit actions post_edit_sig = pyqtSignal() + # any callback can be bound + custom_signal = pyqtSignal(object) + # noinspection PyUnresolvedReferences def __init__(self, qapp, user_defaults=True): """ @@ -1432,6 +1435,15 @@ class App(QtCore.QObject): from_new_path = os.path.dirname(os.path.realpath(__file__)) + '\\appGUI\\VisPyData\\data' shutil.copytree(from_new_path, to_path) + def connect_custom_signal(self, target, params): + try: + self.custom_signal.disconnect() + except TypeError: + pass + + if target is not None: + self.custom_signal[params].connect(target) + def on_startup_args(self, args, silent=False): """ This will process any arguments provided to the application at startup. Like trying to launch a file or project. @@ -2698,6 +2710,7 @@ class App(QtCore.QObject): if self.ui.notebook.tabText(idx) == _("Editor"): self.ui.notebook.tabBar.setTabTextColor(idx, self.old_tab_text_color) self.ui.notebook.tabBar.setTabText(idx, _("Properties")) + self.ui.app.on_notebook_tab_changed() # enable the Project Tab if self.ui.notebook.tabText(idx) == _("Project"): @@ -4336,12 +4349,17 @@ class App(QtCore.QObject): self.inform.emit(_('Click to set the origin ...')) self.inhibit_context_menu = True + def plotcanvas_fit_view(_): + self.plotcanvas.fit_view() + + self.connect_custom_signal(plotcanvas_fit_view, object) + def origin_replot(): def worker_task(): with self.proc_container.new('%s...' % _("Plotting")): for obj in self.collection.get_list(): obj.plot() - self.plotcanvas.fit_view() + self.custom_signal.emit(None) # Calls plotcanvas_fit_view() on UI Thread if self.use_3d_engine: self.plotcanvas.graph_event_disconnect('mouse_release', self.on_set_zero_click) else: @@ -4352,6 +4370,8 @@ class App(QtCore.QObject): self.mp_zc = self.plotcanvas.graph_event_connect('mouse_release', self.on_set_zero_click) + + # first disconnect it as it may have been used by something else try: self.replot_signal.disconnect() # noqa