From f08466e7f2c46f299f8623cd117bd43a41281422 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 14 Jul 2021 22:35:29 +0300 Subject: [PATCH] - preferences UI is now started on preferences open - more work/fixes in working on data structures (offset, offset_value, job_type, shape) --- CHANGELOG.md | 5 ++ appDatabase.py | 8 +- appEditors/appGCodeEditor.py | 2 +- appGUI/preferences/PreferencesUIManager.py | 72 ++++++++++++++++- appObjects/FlatCAMCNCJob.py | 2 +- appObjects/FlatCAMGeometry.py | 90 +++++++++------------- appPlugins/ToolCutOut.py | 17 ---- appPlugins/ToolIsolation.py | 29 ++----- appPlugins/ToolMilling.py | 26 +------ appPlugins/ToolNCC.py | 19 +---- appPlugins/ToolPaint.py | 5 +- appPlugins/ToolSolderPaste.py | 6 +- app_Main.py | 7 +- defaults.py | 2 +- tclCommands/TclCommandCopperClear.py | 46 +++++------ 15 files changed, 159 insertions(+), 177 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6718e949..e73598ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +14.07.2021 + +- preferences UI is now started on preferences open +- more work/fixes in working on data structures (offset, offset_value, job_type, shape) + 7.07.2021 - some changes in data tools structure ('tool_type' to ['data']['tools_mill_job_type]) diff --git a/appDatabase.py b/appDatabase.py index 288ef77d..cb0f9260 100644 --- a/appDatabase.py +++ b/appDatabase.py @@ -2514,7 +2514,7 @@ class ToolsDB2(QtWidgets.QWidget): elif wdg_name == "gdb_job": self.db_tool_dict[tool_id]['data']['job'] = val elif wdg_name == "gdb_shape": - self.db_tool_dict[tool_id]['tool_type'] = val + self.db_tool_dict[tool_id]['data']['tools_mill_shape'] = val else: # Milling Tool if wdg_name == "gdb_tool_target": @@ -3101,7 +3101,7 @@ class ToolsDB2(QtWidgets.QWidget): # tshape_item = FCComboBox() # for item in self.tool_type_item_options: # tshape_item.addItem(item) -# tshape_item.set_value(tooldict['tool_type']) +# tshape_item.set_value(tooldict['data']['tools_mill_shape']) # widget.setCellWidget(row, 6, tshape_item) # # cutz_item = FCDoubleSpinner() @@ -3281,7 +3281,7 @@ class ToolsDB2(QtWidgets.QWidget): # dict_elem['offset'] = 'Path' # dict_elem['offset_value'] = 0.0 # dict_elem['type'] = 'Rough' -# dict_elem['tool_type'] = 'C1' +# dict_elem['data']['tools_mill_shape'] = 'C1' # dict_elem['data'] = default_data # # new_toolid = len(self.db_tool_dict) + 1 @@ -3531,7 +3531,7 @@ class ToolsDB2(QtWidgets.QWidget): # elif column_header_text == _('Tool Type'): # dict_elem['type'] = self.table_widget.cellWidget(row, col).get_value() # elif column_header_text == _('Tool Shape'): -# dict_elem['tool_type'] = self.table_widget.cellWidget(row, col).get_value() +# dict_elem['data']['tools_mill_shape'] = self.table_widget.cellWidget(row, col).get_value() # else: # if column_header_text == _('Cut Z'): # default_data['cutz'] = self.table_widget.cellWidget(row, col).get_value() diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index 804bc675..3fcfc07d 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -188,7 +188,7 @@ class AppGCodeEditor(QtCore.QObject): offset_txt[0] = offset_txt[0].upper() offset_item = QtWidgets.QTableWidgetItem(''.join(offset_txt)) type_item = QtWidgets.QTableWidgetItem(str(dia_value['data']['job'])) - tool_type_item = QtWidgets.QTableWidgetItem(str(dia_value['tool_type'])) + tool_type_item = QtWidgets.QTableWidgetItem(str(dia_value['data']['tools_mill_shape'])) t_id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) dia_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index c7b62b0f..b3a2661c 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -841,7 +841,74 @@ class PreferencesUIManager: self.ui.pref_close_button.clicked.connect(self.on_pref_close_button) self.ui.pref_defaults_button.clicked.connect(self.on_restore_defaults_preferences) - log.debug("Finished Preferences GUI form initialization.") + # log.debug("Finished Preferences GUI form initialization.") + + def clear_preferences_gui(self): + # Disconnect Button handlers + try: + self.ui.pref_save_button.clicked.disconnect() + except Exception: + pass + + try: + self.ui.pref_apply_button.clicked.disconnect() + except Exception: + pass + + try: + self.ui.pref_close_button.clicked.disconnect() + except Exception: + pass + + try: + self.ui.pref_defaults_button.clicked.disconnect() + except Exception: + pass + + try: + self.ui.general_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.gerber_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.excellon_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.geometry_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.cncjob_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.plugins_engraving_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.tools_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.tools2_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") + + try: + self.ui.fa_scroll_area.takeWidget() + except Exception: + log.debug("Nothing to remove") def __init_color_pickers(self): # Init Gerber Plot Colors @@ -1173,12 +1240,15 @@ class PreferencesUIManager: self.preferences_changed_flag = True def on_close_preferences_tab(self, parent): + self.ui.app.log.debug("Preferences GUI was closed.") if self.ignore_tab_close_event: return # restore stylesheet to default for the statusBar icon self.ui.pref_status_label.setStyleSheet("") + self.clear_preferences_gui() + # disconnect for idx in range(self.ui.pref_tab_area.count()): for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject): diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 45cfd606..4f743a4b 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -230,7 +230,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): offset_txt[0] = offset_txt[0].upper() offset_item = QtWidgets.QTableWidgetItem(''.join(offset_txt)) type_item = QtWidgets.QTableWidgetItem(str(dia_value['data']['job'])) - tool_type_item = QtWidgets.QTableWidgetItem(str(dia_value['tool_type'])) + tool_type_item = QtWidgets.QTableWidgetItem(str(dia_value['data']['tools_mill_shape'])) t_id.setFlags(QtCore.Qt.ItemIsEnabled) dia_item.setFlags(QtCore.Qt.ItemIsEnabled) diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 2300e977..01862309 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -207,40 +207,44 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui.geo_tools_table.setItem(row_idx, 1, dia_item) # Diameter # -------------------- OFFSET ------------------------------------- # - offset_item = FCComboBox(policy=False) - for item in self.offset_item_options: - offset_item.addItem(item) - idx = offset_item.findText(tooluid_value['offset']) + offset_item = FCComboBox2(policy=False) + offset_item.addItems(self.offset_item_options) + # val = tooluid_value['data']['tools_mill_offset_type'] + # idx = offset_item.findText(val) + idx = int(tooluid_value['data']['tools_mill_offset_type']) # protection against having this translated or loading a project with translated values - if idx == -1: + # if idx == -1: + if idx not in [0, 1, 2, 3]: offset_item.setCurrentIndex(0) else: offset_item.setCurrentIndex(idx) self.ui.geo_tools_table.setCellWidget(row_idx, 2, offset_item) # -------------------- JOB ------------------------------------- # - type_item = FCComboBox(policy=False) + type_item = FCComboBox2(policy=False) type_item.addItems(self.job_item_options) - pos = tooluid_value['data']['tools_mill_job_type'] - idx = type_item.findText(self.job_item_options[pos]) + # pos = tooluid_value['data']['tools_mill_job_type'] + # idx = type_item.findText(self.job_item_options[pos]) + idx = int(tooluid_value['data']['tools_mill_job_type']) # protection against having this translated or loading a project with translated values - if idx == -1: + # if idx == -1: + if idx not in [0, 1, 2, 3]: type_item.setCurrentIndex(0) else: type_item.setCurrentIndex(idx) self.ui.geo_tools_table.setCellWidget(row_idx, 3, type_item) - # -------------------- TOOL TYPE ------------------------------------- # - tool_type_item = FCComboBox(policy=False) - for item in self.tool_type_item_options: - tool_type_item.addItem(item) - idx = tool_type_item.findText(tooluid_value['tool_type']) + # -------------------- TOOL SHAPE ------------------------------------- # + tool_shape_item = FCComboBox2(policy=False) + tool_shape_item.addItems(self.tool_type_item_options) + idx = int(tooluid_value['data']['tools_mill_shape']) # protection against having this translated or loading a project with translated values - if idx == -1: - tool_type_item.setCurrentIndex(0) + # if idx == -1: + if idx not in range(6): + tool_shape_item.setCurrentIndex(0) else: - tool_type_item.setCurrentIndex(idx) - self.ui.geo_tools_table.setCellWidget(row_idx, 4, tool_type_item) + tool_shape_item.setCurrentIndex(idx) + self.ui.geo_tools_table.setCellWidget(row_idx, 4, tool_shape_item) # -------------------- TOOL UID ------------------------------------- # tool_uid_item = QtWidgets.QTableWidgetItem(str(tooluid_key)) @@ -1243,13 +1247,9 @@ class GeometryObject(FlatCAMObj, Geometry): offset = 'Path' offset_val = 0.0 - tool_type = 'C1' + # look in database tools for db_tool, db_tool_val in tools_db_dict.items(): - offset = db_tool_val['offset'] - offset_val = db_tool_val['offset_value'] - tool_type = db_tool_val['tool_type'] - db_tooldia = db_tool_val['tooldia'] low_limit = float(db_tool_val['data']['tol_min']) high_limit = float(db_tool_val['data']['tol_max']) @@ -1300,9 +1300,6 @@ class GeometryObject(FlatCAMObj, Geometry): self.tools.update({ tooluid: { 'tooldia': new_tdia, - 'offset': deepcopy(offset), - 'offset_value': deepcopy(offset_val), - 'tool_type': deepcopy(tool_type), 'data': deepcopy(new_tools_dict), 'solid_geometry': self.solid_geometry } @@ -1341,9 +1338,9 @@ class GeometryObject(FlatCAMObj, Geometry): # otherwise we add a tool with data copied from last tool if self.tools: last_data = self.tools[max_uid]['data'] - last_offset = self.tools[max_uid]['offset'] - last_offset_value = self.tools[max_uid]['offset_value'] - last_tool_type = self.tools[max_uid]['tool_type'] + # last_offset = self.tools[max_uid]['offset'] + # last_offset_value = self.tools[max_uid]['offset_value'] + # last_tool_type = self.tools[max_uid]['data']['tools_mill_shape'] last_solid_geometry = self.tools[max_uid]['solid_geometry'] if new_geo is None else new_geo @@ -1355,9 +1352,6 @@ class GeometryObject(FlatCAMObj, Geometry): self.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': last_offset, - 'offset_value': last_offset_value, - 'tool_type': last_tool_type, 'data': deepcopy(last_data), 'solid_geometry': deepcopy(last_solid_geometry) } @@ -1366,9 +1360,6 @@ class GeometryObject(FlatCAMObj, Geometry): self.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': 'Path', - 'offset_value': 0.0, - 'tool_type': 'C1', 'data': deepcopy(self.default_data), 'solid_geometry': self.solid_geometry } @@ -1445,9 +1436,6 @@ class GeometryObject(FlatCAMObj, Geometry): self.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': tool['offset'], - 'offset_value': float(tool['offset_value']), - 'tool_type': tool['tool_type'], 'data': deepcopy(tool['data']), 'solid_geometry': self.solid_geometry } @@ -1742,7 +1730,7 @@ class GeometryObject(FlatCAMObj, Geometry): if int(tooluid_key) == current_uid: cb_txt = cw.currentText() if cw_col == 2: - tooluid_value['offset'] = cb_txt + tooluid_value['data']['tools_mill_offset_type'] = cb_txt if cb_txt == 'Custom': self.ui.tool_offset_entry.show() self.ui.tool_offset_lbl.show() @@ -1750,7 +1738,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui.tool_offset_entry.hide() self.ui.tool_offset_lbl.hide() # reset the offset_value in storage self.tools - tooluid_value['offset_value'] = 0.0 + tooluid_value['data']['tools_mill_offset_value'] = 0.0 elif cw_col == 3: # force toolpath type as 'Iso' if the tool type is V-Shape if self.ui.geo_tools_table.cellWidget(cw_row, 4).currentText() == 'V': @@ -1760,7 +1748,7 @@ class GeometryObject(FlatCAMObj, Geometry): else: tooluid_value['data']['tools_mill_job_type'] = cb_txt elif cw_col == 4: - tooluid_value['data']['tool_type'] = cb_txt + tooluid_value['data']['data']['tools_mill_shape'] = cb_txt # if the tool_type selected is V-Shape then autoselect the toolpath type as Iso if cb_txt == 'V': @@ -2293,11 +2281,11 @@ class GeometryObject(FlatCAMObj, Geometry): 'tooldia': tooldia_val }) - if dia_cnc_dict['offset'] == 'in': + if dia_cnc_dict['data']['tools_mill_offset_type'] == 'in': tool_offset = -dia_cnc_dict['tooldia'] / 2 - elif dia_cnc_dict['offset'].lower() == 'out': + elif dia_cnc_dict['data']['tools_mill_offset_type'].lower() == 'out': tool_offset = dia_cnc_dict['tooldia'] / 2 - elif dia_cnc_dict['offset'].lower() == 'custom': + elif dia_cnc_dict['data']['tools_mill_offset_type'].lower() == 'custom': try: offset_value = float(self.ui.tool_offset_entry.get_value()) except ValueError: @@ -2318,9 +2306,7 @@ class GeometryObject(FlatCAMObj, Geometry): else: tool_offset = 0.0 - dia_cnc_dict.update({ - 'offset_value': tool_offset - }) + dia_cnc_dict['data']['tools_mill_offset_type'] = tool_offset z_cut = tools_dict[tooluid_key]['data']["tools_mill_cutz"] z_move = tools_dict[tooluid_key]['data']["tools_mill_travelz"] @@ -2457,11 +2443,11 @@ class GeometryObject(FlatCAMObj, Geometry): # current_uid = int(k) # break - if dia_cnc_dict['offset'].lower() == 'in': + if dia_cnc_dict['data']['tools_mill_offset_type'].lower() == 'in': tool_offset = -tooldia_val / 2 - elif dia_cnc_dict['offset'].lower() == 'out': + elif dia_cnc_dict['data']['tools_mill_offset_type'].lower() == 'out': tool_offset = tooldia_val / 2 - elif dia_cnc_dict['offset'].lower() == 'custom': + elif dia_cnc_dict['data']['tools_mill_offset_type'].lower() == 'custom': offset_value = float(self.ui.tool_offset_entry.get_value()) if offset_value: tool_offset = float(offset_value) @@ -2474,9 +2460,7 @@ class GeometryObject(FlatCAMObj, Geometry): else: tool_offset = 0.0 - dia_cnc_dict.update({ - 'offset_value': tool_offset - }) + dia_cnc_dict['data']['tools_mill_offset_type'] = tool_offset # z_cut = tools_dict[tooluid_key]['data']["cutz"] # z_move = tools_dict[tooluid_key]['data']["travelz"] diff --git a/appPlugins/ToolCutOut.py b/appPlugins/ToolCutOut.py index c6c9be58..e146b981 100644 --- a/appPlugins/ToolCutOut.py +++ b/appPlugins/ToolCutOut.py @@ -512,15 +512,8 @@ class CutOut(AppTool): tool_found = 0 - offset = 'Path' - offset_val = 0.0 - tool_type = 'V' # look in database tools for db_tool, db_tool_val in tools_db_dict.items(): - offset = db_tool_val['offset'] - offset_val = db_tool_val['offset_value'] - tool_type = db_tool_val['tool_type'] - db_tooldia = db_tool_val['tooldia'] low_limit = float(db_tool_val['data']['tol_min']) high_limit = float(db_tool_val['data']['tol_max']) @@ -575,9 +568,6 @@ class CutOut(AppTool): new_tdia = deepcopy(updated_tooldia) if updated_tooldia is not None else deepcopy(truncated_tooldia) self.cut_tool_dict.update({ 'tooldia': new_tdia, - 'offset': deepcopy(offset), - 'offset_value': deepcopy(offset_val), - 'tool_type': deepcopy(tool_type), 'data': deepcopy(new_tools_dict), 'solid_geometry': [] }) @@ -654,10 +644,6 @@ class CutOut(AppTool): self.cut_tool_dict.update({ 'tooldia': dia, - 'offset': 'Path', - 'offset_value': 0.0, - 'type': 'Rough', - 'tool_type': 'C1', 'data': deepcopy(self.default_data), 'solid_geometry': [] }) @@ -717,9 +703,6 @@ class CutOut(AppTool): self.cutout_tools.update({ 1: { 'tooldia': truncated_tooldia, - 'offset': tool['offset'], - 'offset_value': tool['offset_value'], - 'tool_type': tool['tool_type'], 'data': deepcopy(tool['data']), 'solid_geometry': [] } diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index f7f49095..dc4c21fd 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -592,7 +592,7 @@ class ToolIsolation(AppTool, Gerber): # Tool Type tool_type_item = FCComboBox() tool_type_item.addItems(self.tool_type_item_options) - idx = tool_type_item.findText(tooluid_value['tool_type']) + idx = int(tooluid_value['data']['tools_mill_shape']) tool_type_item.setCurrentIndex(idx) self.ui.tools_table.setCellWidget(row_no, 2, tool_type_item) @@ -1318,15 +1318,8 @@ class ToolIsolation(AppTool, Gerber): tool_found = 0 - offset = 'Path' - offset_val = 0.0 - tool_type = 'V' # look in database tools for db_tool, db_tool_val in tools_db_dict.items(): - offset = db_tool_val['offset'] - offset_val = db_tool_val['offset_value'] - tool_type = db_tool_val['tool_type'] - db_tooldia = db_tool_val['tooldia'] low_limit = float(db_tool_val['data']['tol_min']) high_limit = float(db_tool_val['data']['tol_max']) @@ -1385,9 +1378,6 @@ class ToolIsolation(AppTool, Gerber): self.iso_tools.update({ tooluid: { 'tooldia': new_tdia, - 'offset': deepcopy(offset), - 'offset_value': deepcopy(offset_val), - 'tool_type': deepcopy(tool_type), 'data': deepcopy(new_tools_dict), 'solid_geometry': [] } @@ -1444,10 +1434,6 @@ class ToolIsolation(AppTool, Gerber): self.iso_tools.update({ int(self.tooluid): { 'tooldia': truncated_tooldia, - 'offset': 'Path', - 'offset_value': 0.0, - 'type': 'Iso' if self.app.defaults["tools_iso_tool_type"] == 'V' else 'Rough', - 'tool_type': deepcopy(self.app.defaults["tools_iso_tool_type"]), 'data': deepcopy(self.default_data), 'solid_geometry': [] } @@ -1751,7 +1737,7 @@ class ToolIsolation(AppTool, Gerber): tool_dia = tools_storage[tool]['tooldia'] for i in range(passes): - tool_type = tools_storage[tool]['tool_type'] + tool_type = tools_storage[tool]['data']['tools_mill_shape'] iso_offset = tool_dia * ((2 * i + 1) / 2.0000001) - (i * overlap * tool_dia) if negative_dia: @@ -1925,7 +1911,7 @@ class ToolIsolation(AppTool, Gerber): if float('%.*f' % (self.decimals, tools_storage[tool]['tooldia'])) == sorted_tool: tool_dia = tools_storage[tool]['tooldia'] - tool_type = tools_storage[tool]['tool_type'] + tool_type = tools_storage[tool]['data']['tools_mill_shape'] tool_data = tools_storage[tool]['data'] passes = tool_data['tools_iso_passes'] @@ -2098,9 +2084,9 @@ class ToolIsolation(AppTool, Gerber): for tool in sorted_tools: tool_dia = tools_storage[tool]['tooldia'] - tool_has_offset = tools_storage[tool]['offset'] - tool_offset_value = tools_storage[tool]['offset_value'] - tool_type = tools_storage[tool]['tool_type'] + tool_has_offset = tools_storage[tool]['data']['tools_mill_offset_type'] + tool_offset_value = tools_storage[tool]['data']['tools_mill_offset_value'] + tool_type = tools_storage[tool]['data']['tools_mill_shape'] tool_data = tools_storage[tool]['data'] work_geo = geometry @@ -2868,9 +2854,6 @@ class ToolIsolation(AppTool, Gerber): self.iso_tools.update({ tooluid: { 'tooldia': truncated_tooldia, - 'offset': deepcopy(tool['offset']), - 'offset_value': deepcopy(tool['offset_value']), - 'tool_type': deepcopy(tool['tool_type']), 'data': deepcopy(tool['data']), 'solid_geometry': [] } diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 26d71344..32d6d81e 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -2077,15 +2077,8 @@ class ToolMilling(AppTool, Excellon): tool_found = 0 - offset = 'Path' - offset_val = 0.0 - tool_type = 'C1' # look in database tools for db_tool, db_tool_val in tools_db_dict.items(): - offset = db_tool_val['offset'] - offset_val = db_tool_val['offset_value'] - tool_type = db_tool_val['tool_type'] - db_tooldia = db_tool_val['tooldia'] low_limit = float(db_tool_val['data']['tol_min']) high_limit = float(db_tool_val['data']['tol_max']) @@ -2138,9 +2131,6 @@ class ToolMilling(AppTool, Excellon): self.target_obj.tools.update({ tooluid: { 'tooldia': new_tdia, - 'offset': deepcopy(offset), - 'offset_value': deepcopy(offset_val), - 'tool_type': deepcopy(tool_type), 'data': deepcopy(new_tools_dict), 'solid_geometry': self.target_obj.solid_geometry } @@ -2187,10 +2177,6 @@ class ToolMilling(AppTool, Excellon): # otherwise we add a tool with data copied from last tool if self.target_obj.tools: last_data = self.target_obj.tools[max_uid]['data'] - last_offset = self.target_obj.tools[max_uid]['offset'] - last_offset_value = self.target_obj.tools[max_uid]['offset_value'] - last_tool_type = self.target_obj.tools[max_uid]['tool_type'] - last_solid_geometry = self.target_obj.tools[max_uid]['solid_geometry'] if new_geo is None else new_geo # if previous geometry was empty (it may happen for the first tool added) @@ -2201,9 +2187,6 @@ class ToolMilling(AppTool, Excellon): self.target_obj.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': last_offset, - 'offset_value': last_offset_value, - 'tool_type': last_tool_type, 'data': deepcopy(last_data), 'solid_geometry': deepcopy(last_solid_geometry) } @@ -2212,10 +2195,6 @@ class ToolMilling(AppTool, Excellon): self.target_obj.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': 'Path', - 'offset_value': 0.0, - 'type': 'Rough', - 'tool_type': 'C1', 'data': deepcopy(self.default_data), 'solid_geometry': self.solid_geometry } @@ -2291,9 +2270,6 @@ class ToolMilling(AppTool, Excellon): self.target_obj.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': tool['offset'], - 'offset_value': float(tool['offset_value']), - 'tool_type': tool['tool_type'], 'data': deepcopy(tool['data']), 'solid_geometry': self.target_obj.solid_geometry } @@ -3985,7 +3961,7 @@ class MillingUI: self.tool_shape_combo.setObjectName('mill_tool_type') self.tool_shape_combo.addItems(["C1", "C2", "C3", "C4", "B", "V"]) - idx = self.tool_shape_combo.findText(self.app.defaults['tools_mill_tool_type']) + idx = int(self.app.defaults['tools_mill_shape']) # protection against having this translated or loading a project with translated values if idx == -1: self.tool_shape_combo.setCurrentIndex(0) diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index 7939dfdb..1fa1d611 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -851,7 +851,7 @@ class NonCopperClear(AppTool, Gerber): # ------------------------ Tool Shape ------------------------------------------------------------- tool_type_item = FCComboBox() tool_type_item.addItems(self.tool_type_item_options) - idx = tool_type_item.findText(tooluid_value['tool_type']) + idx = int(tooluid_value['data']['tools_mill_shape']) tool_type_item.setCurrentIndex(idx) self.ui.tools_table.setCellWidget(row_no, 2, tool_type_item) @@ -1293,15 +1293,8 @@ class NonCopperClear(AppTool, Gerber): tool_found = 0 - offset = 'Path' - offset_val = 0.0 - tool_type = 'V' # look in database tools for db_tool, db_tool_val in tools_db_dict.items(): - offset = db_tool_val['offset'] - offset_val = db_tool_val['offset_value'] - tool_type = db_tool_val['tool_type'] - db_tooldia = db_tool_val['tooldia'] low_limit = float(db_tool_val['data']['tol_min']) high_limit = float(db_tool_val['data']['tol_max']) @@ -1358,9 +1351,6 @@ class NonCopperClear(AppTool, Gerber): self.ncc_tools.update({ tooluid: { 'tooldia': new_tdia, - 'offset': deepcopy(offset), - 'offset_value': deepcopy(offset_val), - 'tool_type': deepcopy(tool_type), 'data': deepcopy(new_tools_dict), 'solid_geometry': [] } @@ -1419,10 +1409,6 @@ class NonCopperClear(AppTool, Gerber): self.ncc_tools.update({ int(self.tooluid): { 'tooldia': truncated_tooldia, - 'offset': 'Path', - 'offset_value': 0.0, - 'type': 'Iso' if self.app.defaults["tools_ncc_tool_type"] == 'V' else 'Rough', - 'tool_type': deepcopy(self.app.defaults["tools_ncc_tool_type"]), 'data': deepcopy(self.default_data), 'solid_geometry': [] } @@ -4065,9 +4051,6 @@ class NonCopperClear(AppTool, Gerber): self.ncc_tools.update({ tooluid: { 'tooldia': truncated_tooldia, - 'offset': deepcopy(tool['offset']), - 'offset_value': deepcopy(tool['offset_value']), - 'tool_type': deepcopy(tool['tool_type']), 'data': deepcopy(tool['data']), 'solid_geometry': [] } diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index 38ac6743..4d1de43c 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -776,7 +776,7 @@ class ToolPaint(AppTool, Gerber): for item in self.tool_type_item_options: tool_type_item.addItem(item) # tool_type_item.setStyleSheet('background-color: rgb(255,255,255)') - idx = tool_type_item.findText(tooluid_value['tool_type']) + idx = int(tooluid_value['data']['tools_mill_shape']) tool_type_item.setCurrentIndex(idx) tool_uid_item = QtWidgets.QTableWidgetItem(str(int(tooluid_key))) @@ -2856,9 +2856,6 @@ class ToolPaint(AppTool, Gerber): self.paint_tools.update({ tooluid: { 'tooldia': float('%.*f' % (self.decimals, tooldia)), - 'offset': tool['offset'], - 'offset_value': tool['offset_value'], - 'tool_type': tool['tool_type'], 'data': deepcopy(tool['data']), 'solid_geometry': [] } diff --git a/appPlugins/ToolSolderPaste.py b/appPlugins/ToolSolderPaste.py index 6556d50d..c07e5cf9 100644 --- a/appPlugins/ToolSolderPaste.py +++ b/appPlugins/ToolSolderPaste.py @@ -790,10 +790,10 @@ class SolderPaste(AppTool): geo_obj.tools[tooluid]['tooldia'] = tool geo_obj.tools[tooluid]['data'] = deepcopy(self.tooltable_tools[tooluid]['data']) geo_obj.tools[tooluid]['solid_geometry'] = [] - geo_obj.tools[tooluid]['offset'] = 'Path' - geo_obj.tools[tooluid]['offset_value'] = 0.0 + geo_obj.tools[tooluid]['data']['tools_mill_offset_type']= 'Path' + geo_obj.tools[tooluid]['data']['tools_mill_offset_value'] = 0.0 geo_obj.tools[tooluid]['type'] = 'SolderPaste' - geo_obj.tools[tooluid]['tool_type'] = 'DN' + geo_obj.tools[tooluid]['data']['tools_mill_shape'] = 'DN' # self.flat_geometry is a list of LinearRings produced by flatten() from the exteriors of the Polygons # We get possible issues if we try to directly use the Polygons, due of possible the interiors, diff --git a/app_Main.py b/app_Main.py index 4da4e8b6..300fa32c 100644 --- a/app_Main.py +++ b/app_Main.py @@ -1075,7 +1075,7 @@ class App(QtCore.QObject): for def_key, def_val in self.defaults.items(): self.options[def_key] = deepcopy(def_val) - self.preferencesUiManager.show_preferences_gui() + # self.preferencesUiManager.show_preferences_gui() # ########################################################################################################### # #################################### SETUP OBJECT COLLECTION ############################################## @@ -6328,6 +6328,9 @@ class App(QtCore.QObject): if self.ui.plot_tab_area.tabText(idx) == _("Preferences"): self.ui.plot_tab_area.removeTab(idx) break + + self.log.debug("Preferences GUI was closed.") + self.preferencesUiManager.clear_preferences_gui() self.ui.pref_status_label.setStyleSheet("") else: self.on_preferences() @@ -6339,6 +6342,8 @@ class App(QtCore.QObject): :return: """ + self.preferencesUiManager.show_preferences_gui() + # add the tab if it was closed self.ui.plot_tab_area.addTab(self.ui.preferences_tab, _("Preferences")) diff --git a/defaults.py b/defaults.py index cd86f40b..d23c6184 100644 --- a/defaults.py +++ b/defaults.py @@ -416,7 +416,7 @@ class FlatCAMDefaults: "tools_mill_offset_type": 0, # _('Path') "tools_mill_offset_value": 0.0, "tools_mill_job_type": 0, # 'Roughing' - "tools_mill_shape": 'C1', + "tools_mill_shape": 0, # 'C1' "tools_mill_cutz": -2.4, "tools_mill_vtipdia": 0.1, diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 7afcff23..0502ed8c 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -193,27 +193,27 @@ class TclCommandCopperClear(TclCommand): default_data.update({ "name": outname, "plot": False, - "cutz": self.app.defaults["geometry_cutz"], - "vtipdia": float(self.app.defaults["tools_mill_vtipdia"]), - "vtipangle": float(self.app.defaults["tools_mill_vtipangle"]), - "travelz": self.app.defaults["geometry_travelz"], - "feedrate": self.app.defaults["geometry_feedrate"], - "feedrate_z": self.app.defaults["geometry_feedrate_z"], - "feedrate_rapid": self.app.defaults["geometry_feedrate_rapid"], - "dwell": self.app.defaults["geometry_dwell"], - "dwelltime": self.app.defaults["geometry_dwelltime"], - "multidepth": self.app.defaults["geometry_multidepth"], - "ppname_g": self.app.defaults["geometry_ppname_g"], - "depthperpass": self.app.defaults["geometry_depthperpass"], - "extracut": self.app.defaults["geometry_extracut"], - "extracut_length": self.app.defaults["geometry_extracut_length"], - "toolchange": self.app.defaults["geometry_toolchange"], - "toolchangez": self.app.defaults["geometry_toolchangez"], - "endz": self.app.defaults["geometry_endz"], - "endxy": self.app.defaults["geometry_endxy"], - "spindlespeed": self.app.defaults["geometry_spindlespeed"], - "toolchangexy": self.app.defaults["geometry_toolchangexy"], - "startz": self.app.defaults["geometry_startz"], + "tools_mill_cutz": self.app.defaults["tools_mill_cutz"], + "tools_mill_vtipdia": float(self.app.defaults["tools_mill_vtipdia"]), + "tools_mill_vtipangle": float(self.app.defaults["tools_mill_vtipangle"]), + "tools_mill_travelz": self.app.defaults["tools_mill__travelz"], + "tools_mill_feedrate": self.app.defaults["tools_mill_feedrate"], + "tools_mill_feedrate_z": self.app.defaults["tools_mill_feedrate_z"], + "tools_mill_feedrate_rapid": self.app.defaults["tools_mill_feedrate_rapid"], + "tools_mill_dwell": self.app.defaults["tools_mill_dwell"], + "tools_mill_dwelltime": self.app.defaults["tools_mill_dwelltime"], + "tools_mill_multidepth": self.app.defaults["tools_mill_multidepth"], + "tools_mill_ppname_g": self.app.defaults["tools_mill_ppname_g"], + "tools_mill_depthperpass": self.app.defaults["tools_mill_depthperpass"], + "tools_mill_extracut": self.app.defaults["tools_mill_extracut"], + "tools_mill_extracut_length": self.app.defaults["tools_mill_extracut_length"], + "tools_mill_toolchange": self.app.defaults["tools_mill_toolchange"], + "tools_mill_toolchangez": self.app.defaults["tools_mill_toolchangez"], + "tools_mill_endz": self.app.defaults["tools_mill_endz"], + "tools_mill_endxy": self.app.defaults["tools_mill_endxy"], + "tools_mill_spindlespeed": self.app.defaults["tools_mill_spindlespeed"], + "tools_mill_toolchangexy": self.app.defaults["tools_mill_toolchangexy"], + "tools_mill_startz": self.app.defaults["tools_mill_startz"], "area_exclusion": self.app.defaults["geometry_area_exclusion"], "area_shape": self.app.defaults["geometry_area_shape"], @@ -242,10 +242,6 @@ class TclCommandCopperClear(TclCommand): ncc_tools.update({ int(tooluid): { 'tooldia': float('%.*f' % (obj.decimals, tool)), - 'offset': 'Path', - 'offset_value': 0.0, - 'type': 'Iso', - 'tool_type': 'C1', 'data': dict(default_data), 'solid_geometry': [] }