diff --git a/Bookmark.py b/Bookmark.py index 3f0eca71..6ba11648 100644 --- a/Bookmark.py +++ b/Bookmark.py @@ -175,9 +175,9 @@ class BookmarkManager(QtWidgets.QWidget): self.mark_table_rows_for_actions() - self.app.defaults["global_bookmarks"].clear() + self.app.options["global_bookmarks"].clear() for key, val in self.bm_dict.items(): - self.app.defaults["global_bookmarks"][key] = deepcopy(val) + self.app.options["global_bookmarks"][key] = deepcopy(val) def on_add_entry(self, **kwargs): """ @@ -218,7 +218,7 @@ class BookmarkManager(QtWidgets.QWidget): self.bm_dict[str(new_entry)] = [title, link] # add the link to the menu but only if it is within the set limit - bm_limit = int(self.app.defaults["global_bookmarks_limit"]) + bm_limit = int(self.app.options["global_bookmarks_limit"]) if len(self.bm_dict) < bm_limit: act = QtGui.QAction(parent=self.app.ui.menuhelp_bookmarks) act.setText(title) @@ -360,7 +360,7 @@ class BookmarkManager(QtWidgets.QWidget): def mark_table_rows_for_actions(self): for row in range(self.table_widget.rowCount()): item_to_paint = self.table_widget.item(row, 0) - if row < self.app.defaults["global_bookmarks_limit"]: + if row < self.app.options["global_bookmarks_limit"]: item_to_paint.setBackground(QtGui.QColor('gray')) # item_to_paint.setForeground(QtGui.QColor('black')) else: diff --git a/CHANGELOG.md b/CHANGELOG.md index abd96645..e68a1053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ CHANGELOG for FlatCAM beta - fixed CNCJob UI showing all tools in the Tools Table even when only some tools were selected for processing - fixed the `drillcncjob` Tcl Command to work in the case of drilling a selection of tools instead of all, with toolchange inactive - in Excellon Object UI, Advanced Mode, added a Tools Table context menu allowing to copy the tool diameters in the selected rows to clipboard +- the application now uses only the default values from the app.options dict, the app.defaults dict holds the definitive default values +- fixed some outstanding issues from the PyQt6 port +- PEP8 fixes +- minor fixes +- updated the saving of Preferences to update the self.options too: the `Apply` action will update the self.options but the `Save` action will save the updated preferences to the file on disk 16.02.2022 diff --git a/appCommon/Common.py b/appCommon/Common.py index f61285b7..06b67fb2 100644 --- a/appCommon/Common.py +++ b/appCommon/Common.py @@ -588,8 +588,8 @@ class ExclusionAreas(QtCore.QObject): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) # update the positions on status bar if self.cursor_pos is None: diff --git a/appDatabase.py b/appDatabase.py index 311ca72a..45fd484b 100644 --- a/appDatabase.py +++ b/appDatabase.py @@ -1372,7 +1372,7 @@ class ToolsDB2(QtWidgets.QWidget): { tool_id: { 'name': 'new_tool' - 'tooldia': self.app.defaults["tools_mill_tooldia"] + 'tooldia': self.app.options["tools_mill_tooldia"] 'data': dict() } } @@ -1908,101 +1908,101 @@ class ToolsDB2(QtWidgets.QWidget): "tol_max": 0.0, # Milling - "tools_mill_tool_shape": self.app.defaults["tools_mill_tool_shape"], - "tools_mill_job_type": self.app.defaults["tools_mill_job_type"], - "tools_mill_offset_type": self.app.defaults["tools_mill_offset_type"], - "tools_mill_offset_value": float(self.app.defaults["tools_mill_offset_value"]), + "tools_mill_tool_shape": self.app.options["tools_mill_tool_shape"], + "tools_mill_job_type": self.app.options["tools_mill_job_type"], + "tools_mill_offset_type": self.app.options["tools_mill_offset_type"], + "tools_mill_offset_value": float(self.app.options["tools_mill_offset_value"]), - "tools_mill_cutz": float(self.app.defaults["tools_mill_cutz"]), - "tools_mill_multidepth": self.app.defaults["tools_mill_multidepth"], - "tools_mill_depthperpass": float(self.app.defaults["tools_mill_depthperpass"]), - "tools_mill_vtipdia": float(self.app.defaults["tools_mill_vtipdia"]), - "tools_mill_vtipangle": float(self.app.defaults["tools_mill_vtipangle"]), - "tools_mill_travelz": float(self.app.defaults["tools_mill_travelz"]), - "tools_mill_feedrate": float(self.app.defaults["tools_mill_feedrate"]), - "tools_mill_feedrate_z": float(self.app.defaults["tools_mill_feedrate_z"]), - "tools_mill_feedrate_rapid": float(self.app.defaults["tools_mill_feedrate_rapid"]), - "tools_mill_spindlespeed": self.app.defaults["tools_mill_spindlespeed"], - "tools_mill_dwell": self.app.defaults["tools_mill_dwell"], - "tools_mill_dwelltime": float(self.app.defaults["tools_mill_dwelltime"]), - "tools_mill_ppname_g": self.app.defaults["tools_mill_ppname_g"], - "tools_mill_extracut": self.app.defaults["tools_mill_extracut"], - "tools_mill_extracut_length": float(self.app.defaults["tools_mill_extracut_length"]), - "tools_mill_toolchange": self.app.defaults["tools_mill_toolchange"], - "tools_mill_toolchangexy": self.app.defaults["tools_mill_toolchangexy"], - "tools_mill_toolchangez": float(self.app.defaults["tools_mill_toolchangez"]), - "tools_mill_startz": self.app.defaults["tools_mill_startz"], - "tools_mill_endz": float(self.app.defaults["tools_mill_endz"]), - "tools_mill_endxy": self.app.defaults["tools_mill_endxy"], - "tools_mill_search_time": int(self.app.defaults["tools_mill_search_time"]), - "tools_mill_z_pdepth": float(self.app.defaults["tools_mill_z_pdepth"]), - "tools_mill_f_plunge": float(self.app.defaults["tools_mill_f_plunge"]), + "tools_mill_cutz": float(self.app.options["tools_mill_cutz"]), + "tools_mill_multidepth": self.app.options["tools_mill_multidepth"], + "tools_mill_depthperpass": float(self.app.options["tools_mill_depthperpass"]), + "tools_mill_vtipdia": float(self.app.options["tools_mill_vtipdia"]), + "tools_mill_vtipangle": float(self.app.options["tools_mill_vtipangle"]), + "tools_mill_travelz": float(self.app.options["tools_mill_travelz"]), + "tools_mill_feedrate": float(self.app.options["tools_mill_feedrate"]), + "tools_mill_feedrate_z": float(self.app.options["tools_mill_feedrate_z"]), + "tools_mill_feedrate_rapid": float(self.app.options["tools_mill_feedrate_rapid"]), + "tools_mill_spindlespeed": self.app.options["tools_mill_spindlespeed"], + "tools_mill_dwell": self.app.options["tools_mill_dwell"], + "tools_mill_dwelltime": float(self.app.options["tools_mill_dwelltime"]), + "tools_mill_ppname_g": self.app.options["tools_mill_ppname_g"], + "tools_mill_extracut": self.app.options["tools_mill_extracut"], + "tools_mill_extracut_length": float(self.app.options["tools_mill_extracut_length"]), + "tools_mill_toolchange": self.app.options["tools_mill_toolchange"], + "tools_mill_toolchangexy": self.app.options["tools_mill_toolchangexy"], + "tools_mill_toolchangez": float(self.app.options["tools_mill_toolchangez"]), + "tools_mill_startz": self.app.options["tools_mill_startz"], + "tools_mill_endz": float(self.app.options["tools_mill_endz"]), + "tools_mill_endxy": self.app.options["tools_mill_endxy"], + "tools_mill_search_time": int(self.app.options["tools_mill_search_time"]), + "tools_mill_z_pdepth": float(self.app.options["tools_mill_z_pdepth"]), + "tools_mill_f_plunge": float(self.app.options["tools_mill_f_plunge"]), - "tools_mill_spindledir": self.app.defaults["tools_mill_spindledir"], - "tools_mill_optimization_type": self.app.defaults["tools_mill_optimization_type"], - "tools_mill_feedrate_probe": self.app.defaults["tools_mill_feedrate_probe"], + "tools_mill_spindledir": self.app.options["tools_mill_spindledir"], + "tools_mill_optimization_type": self.app.options["tools_mill_optimization_type"], + "tools_mill_feedrate_probe": self.app.options["tools_mill_feedrate_probe"], - "segx": self.app.defaults["geometry_segx"], - "segy": self.app.defaults["geometry_segy"], - "tools_mill_area_exclusion": self.app.defaults["tools_mill_area_exclusion"], - "tools_mill_area_shape": self.app.defaults["tools_mill_area_shape"], - "tools_mill_area_strategy": self.app.defaults["tools_mill_area_strategy"], - "tools_mill_area_overz": self.app.defaults["tools_mill_area_overz"], - "tools_mill_polish": self.app.defaults["tools_mill_polish"], - "tools_mill_polish_margin": self.app.defaults["tools_mill_polish_margin"], - "tools_mill_polish_overlap": self.app.defaults["tools_mill_polish_overlap"], - "tools_mill_polish_method": self.app.defaults["tools_mill_polish_method"], + "segx": self.app.options["geometry_segx"], + "segy": self.app.options["geometry_segy"], + "tools_mill_area_exclusion": self.app.options["tools_mill_area_exclusion"], + "tools_mill_area_shape": self.app.options["tools_mill_area_shape"], + "tools_mill_area_strategy": self.app.options["tools_mill_area_strategy"], + "tools_mill_area_overz": self.app.options["tools_mill_area_overz"], + "tools_mill_polish": self.app.options["tools_mill_polish"], + "tools_mill_polish_margin": self.app.options["tools_mill_polish_margin"], + "tools_mill_polish_overlap": self.app.options["tools_mill_polish_overlap"], + "tools_mill_polish_method": self.app.options["tools_mill_polish_method"], # NCC - "tools_ncc_operation": self.app.defaults["tools_ncc_operation"], - "tools_ncc_milling_type": self.app.defaults["tools_ncc_milling_type"], - "tools_ncc_overlap": float(self.app.defaults["tools_ncc_overlap"]), - "tools_ncc_margin": float(self.app.defaults["tools_ncc_margin"]), - "tools_ncc_method": self.app.defaults["tools_ncc_method"], - "tools_ncc_connect": self.app.defaults["tools_ncc_connect"], - "tools_ncc_contour": self.app.defaults["tools_ncc_contour"], - "tools_ncc_offset_choice": self.app.defaults["tools_ncc_offset_choice"], - "tools_ncc_offset_value": float(self.app.defaults["tools_ncc_offset_value"]), + "tools_ncc_operation": self.app.options["tools_ncc_operation"], + "tools_ncc_milling_type": self.app.options["tools_ncc_milling_type"], + "tools_ncc_overlap": float(self.app.options["tools_ncc_overlap"]), + "tools_ncc_margin": float(self.app.options["tools_ncc_margin"]), + "tools_ncc_method": self.app.options["tools_ncc_method"], + "tools_ncc_connect": self.app.options["tools_ncc_connect"], + "tools_ncc_contour": self.app.options["tools_ncc_contour"], + "tools_ncc_offset_choice": self.app.options["tools_ncc_offset_choice"], + "tools_ncc_offset_value": float(self.app.options["tools_ncc_offset_value"]), # Paint - "tools_paint_overlap": float(self.app.defaults["tools_paint_overlap"]), - "tools_paint_offset": float(self.app.defaults["tools_paint_offset"]), - "tools_paint_method": self.app.defaults["tools_paint_method"], - "tools_paint_connect": self.app.defaults["tools_paint_connect"], - "tools_paint_contour": self.app.defaults["tools_paint_contour"], + "tools_paint_overlap": float(self.app.options["tools_paint_overlap"]), + "tools_paint_offset": float(self.app.options["tools_paint_offset"]), + "tools_paint_method": self.app.options["tools_paint_method"], + "tools_paint_connect": self.app.options["tools_paint_connect"], + "tools_paint_contour": self.app.options["tools_paint_contour"], # Isolation - "tools_iso_passes": int(self.app.defaults["tools_iso_passes"]), - "tools_iso_overlap": float(self.app.defaults["tools_iso_overlap"]), - "tools_iso_milling_type": self.app.defaults["tools_iso_milling_type"], - "tools_iso_isotype": self.app.defaults["tools_iso_isotype"], + "tools_iso_passes": int(self.app.options["tools_iso_passes"]), + "tools_iso_overlap": float(self.app.options["tools_iso_overlap"]), + "tools_iso_milling_type": self.app.options["tools_iso_milling_type"], + "tools_iso_isotype": self.app.options["tools_iso_isotype"], # Drilling - "tools_drill_cutz": float(self.app.defaults["tools_drill_cutz"]), - "tools_drill_multidepth": self.app.defaults["tools_drill_multidepth"], - "tools_drill_depthperpass": float(self.app.defaults["tools_drill_depthperpass"]), - "tools_drill_travelz": float(self.app.defaults["tools_drill_travelz"]), + "tools_drill_cutz": float(self.app.options["tools_drill_cutz"]), + "tools_drill_multidepth": self.app.options["tools_drill_multidepth"], + "tools_drill_depthperpass": float(self.app.options["tools_drill_depthperpass"]), + "tools_drill_travelz": float(self.app.options["tools_drill_travelz"]), - "tools_drill_feedrate_z": float(self.app.defaults["tools_drill_feedrate_z"]), - "tools_drill_feedrate_rapid": float(self.app.defaults["tools_drill_feedrate_rapid"]), - "tools_drill_spindlespeed": float(self.app.defaults["tools_drill_spindlespeed"]), - "tools_drill_dwell": self.app.defaults["tools_drill_dwell"], + "tools_drill_feedrate_z": float(self.app.options["tools_drill_feedrate_z"]), + "tools_drill_feedrate_rapid": float(self.app.options["tools_drill_feedrate_rapid"]), + "tools_drill_spindlespeed": float(self.app.options["tools_drill_spindlespeed"]), + "tools_drill_dwell": self.app.options["tools_drill_dwell"], - "tools_drill_offset": float(self.app.defaults["tools_drill_offset"]), - "tools_drill_drill_slots": self.app.defaults["tools_drill_drill_slots"], - "tools_drill_drill_overlap": float(self.app.defaults["tools_drill_drill_overlap"]), - "tools_drill_last_drill": self.app.defaults["tools_drill_last_drill"], + "tools_drill_offset": float(self.app.options["tools_drill_offset"]), + "tools_drill_drill_slots": self.app.options["tools_drill_drill_slots"], + "tools_drill_drill_overlap": float(self.app.options["tools_drill_drill_overlap"]), + "tools_drill_last_drill": self.app.options["tools_drill_last_drill"], # Cutout - "tools_cutout_margin": float(self.app.defaults["tools_cutout_margin"]), - "tools_cutout_gapsize": float(self.app.defaults["tools_cutout_gapsize"]), - "tools_cutout_gaps_ff": self.app.defaults["tools_cutout_gaps_ff"], - "tools_cutout_convexshape": self.app.defaults["tools_cutout_convexshape"], + "tools_cutout_margin": float(self.app.options["tools_cutout_margin"]), + "tools_cutout_gapsize": float(self.app.options["tools_cutout_gapsize"]), + "tools_cutout_gaps_ff": self.app.options["tools_cutout_gaps_ff"], + "tools_cutout_convexshape": self.app.options["tools_cutout_convexshape"], - "tools_cutout_gap_type": self.app.defaults["tools_cutout_gap_type"], - "tools_cutout_gap_depth": float(self.app.defaults["tools_cutout_gap_depth"]), - "tools_cutout_mb_dia": float(self.app.defaults["tools_cutout_mb_dia"]), - "tools_cutout_mb_spacing": float(self.app.defaults["tools_cutout_mb_spacing"]) + "tools_cutout_gap_type": self.app.options["tools_cutout_gap_type"], + "tools_cutout_gap_depth": float(self.app.options["tools_cutout_gap_depth"]), + "tools_cutout_mb_dia": float(self.app.options["tools_cutout_mb_dia"]), + "tools_cutout_mb_spacing": float(self.app.options["tools_cutout_mb_spacing"]) }) temp = [] @@ -2016,11 +2016,11 @@ class ToolsDB2(QtWidgets.QWidget): new_name = "new_tool_1" dict_elem = {'name': new_name} - if type(self.app.defaults["tools_mill_tooldia"]) == float: - dict_elem['tooldia'] = self.app.defaults["tools_mill_tooldia"] + if type(self.app.options["tools_mill_tooldia"]) == float: + dict_elem['tooldia'] = self.app.options["tools_mill_tooldia"] else: try: - tools_string = self.app.defaults["tools_mill_tooldia"].split(",") + tools_string = self.app.options["tools_mill_tooldia"].split(",") tools_diameters = [eval(a) for a in tools_string if a != ''] dict_elem['tooldia'] = tools_diameters[0] if tools_diameters else 0.0 except Exception as e: @@ -2719,7 +2719,7 @@ class ToolsDB2(QtWidgets.QWidget): # { # tool_id: { # 'name': 'new_tool' -# 'tooldia': self.app.defaults["tools_mill_tooldia"] +# 'tooldia': self.app.options["tools_mill_tooldia"] # 'offset': 'Path' # 'offset_value': 0.0 # 'type': 'Rough', @@ -3224,35 +3224,35 @@ class ToolsDB2(QtWidgets.QWidget): # # default_data = {} # default_data.update({ -# "cutz": float(self.app.defaults["geometry_cutz"]), -# "multidepth": self.app.defaults["geometry_multidepth"], -# "depthperpass": float(self.app.defaults["geometry_depthperpass"]), -# "vtipdia": float(self.app.defaults["geometry_vtipdia"]), -# "vtipangle": float(self.app.defaults["geometry_vtipangle"]), -# "travelz": float(self.app.defaults["geometry_travelz"]), -# "feedrate": float(self.app.defaults["geometry_feedrate"]), -# "feedrate_z": float(self.app.defaults["geometry_feedrate_z"]), -# "feedrate_rapid": float(self.app.defaults["geometry_feedrate_rapid"]), -# "spindlespeed": self.app.defaults["geometry_spindlespeed"], -# "dwell": self.app.defaults["geometry_dwell"], -# "dwelltime": float(self.app.defaults["geometry_dwelltime"]), -# "ppname_g": self.app.defaults["geometry_ppname_g"], -# "extracut": self.app.defaults["geometry_extracut"], -# "extracut_length": float(self.app.defaults["geometry_extracut_length"]), -# "toolchange": self.app.defaults["geometry_toolchange"], -# "toolchangexy": self.app.defaults["geometry_toolchangexy"], -# "toolchangez": float(self.app.defaults["geometry_toolchangez"]), -# "startz": self.app.defaults["geometry_startz"], -# "endz": float(self.app.defaults["geometry_endz"]) +# "cutz": float(self.app.options["geometry_cutz"]), +# "multidepth": self.app.options["geometry_multidepth"], +# "depthperpass": float(self.app.options["geometry_depthperpass"]), +# "vtipdia": float(self.app.options["geometry_vtipdia"]), +# "vtipangle": float(self.app.options["geometry_vtipangle"]), +# "travelz": float(self.app.options["geometry_travelz"]), +# "feedrate": float(self.app.options["geometry_feedrate"]), +# "feedrate_z": float(self.app.options["geometry_feedrate_z"]), +# "feedrate_rapid": float(self.app.options["geometry_feedrate_rapid"]), +# "spindlespeed": self.app.options["geometry_spindlespeed"], +# "dwell": self.app.options["geometry_dwell"], +# "dwelltime": float(self.app.options["geometry_dwelltime"]), +# "ppname_g": self.app.options["geometry_ppname_g"], +# "extracut": self.app.options["geometry_extracut"], +# "extracut_length": float(self.app.options["geometry_extracut_length"]), +# "toolchange": self.app.options["geometry_toolchange"], +# "toolchangexy": self.app.options["geometry_toolchangexy"], +# "toolchangez": float(self.app.options["geometry_toolchangez"]), +# "startz": self.app.options["geometry_startz"], +# "endz": float(self.app.options["geometry_endz"]) # }) # # dict_elem = {} # dict_elem['name'] = 'new_tool' -# if type(self.app.defaults["tools_mill_tooldia"]) == float: -# dict_elem['tooldia'] = self.app.defaults["tools_mill_tooldia"] +# if type(self.app.options["tools_mill_tooldia"]) == float: +# dict_elem['tooldia'] = self.app.options["tools_mill_tooldia"] # else: # try: -# tools_string = self.app.defaults["tools_mill_tooldia"].split(",") +# tools_string = self.app.options["tools_mill_tooldia"].split(",") # tools_diameters = [eval(a) for a in tools_string if a != ''] # dict_elem['tooldia'] = tools_diameters[0] if tools_diameters else 0.0 # except Exception as e: diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index b2aa2ebd..22eadeba 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -71,7 +71,7 @@ class SelectEditorExc(FCShapeTool): else: mod_key = None - if mod_key == self.draw_app.app.defaults["global_mselect_key"]: + if mod_key == self.draw_app.app.options["global_mselect_key"]: pass else: self.draw_app.selected = [] @@ -122,7 +122,7 @@ class SelectEditorExc(FCShapeTool): else: mod_key = None - if mod_key == self.draw_app.app.defaults["global_mselect_key"]: + if mod_key == self.draw_app.app.options["global_mselect_key"]: if closest_shape in self.draw_app.selected: self.draw_app.selected.remove(closest_shape) else: @@ -137,7 +137,7 @@ class SelectEditorExc(FCShapeTool): except (TypeError, AttributeError): pass - # if mod_key == self.draw_app.app.defaults["global_mselect_key"]: + # if mod_key == self.draw_app.app.options["global_mselect_key"]: # self.draw_app.ui.tools_table_exc.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection) self.sel_tools.clear() @@ -182,7 +182,7 @@ class SelectEditorExc(FCShapeTool): # AppExcEditor.draw_shape_idx = (AppExcEditor.draw_shape_idx + 1) % len(over_shape_list) # obj_to_add = over_shape_list[int(AppExcEditor.draw_shape_idx)] # - # if self.draw_app.app.defaults["global_mselect_key"] == 'Shift': + # if self.draw_app.app.options["global_mselect_key"] == 'Shift': # if self.draw_app.modifiers == Qt.KeyboardModifier.ShiftModifier: # if obj_to_add in self.draw_app.selected: # self.draw_app.selected.remove(obj_to_add) @@ -673,7 +673,7 @@ class SlotAdd(FCShapeTool): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_slot.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] self.half_height = 0.0 self.half_width = 0.0 @@ -711,7 +711,7 @@ class SlotAdd(FCShapeTool): # updating values here allows us to change the aperture on the fly, after the Tool has been started self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected] self.radius = float(self.selected_dia / 2.0) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] try: slot_length = float(self.draw_app.ui.slot_length_entry.get_value()) @@ -887,7 +887,7 @@ class SlotArray(FCShapeTool): self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero_array.png')) QtGui.QGuiApplication.setOverrideCursor(self.cursor) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] self.half_width = 0.0 self.half_height = 0.0 @@ -1073,7 +1073,7 @@ class SlotArray(FCShapeTool): # updating values here allows us to change the aperture on the fly, after the Tool has been started self.selected_dia = self.draw_app.tool2tooldia[self.draw_app.last_tool_selected] self.radius = float(self.selected_dia / 2.0) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] try: slot_length = float(self.draw_app.ui.slot_length_entry.get_value()) @@ -1534,7 +1534,7 @@ class MoveEditorExc(FCShapeTool): # self.shape_buffer = self.draw_app.shape_buffer self.origin = None self.destination = None - self.sel_limit = self.draw_app.app.defaults["excellon_editor_sel_limit"] + self.sel_limit = self.draw_app.app.options["excellon_editor_sel_limit"] self.selection_shape = self.selection_bbox() self.selected_dia_list = [] @@ -1794,9 +1794,9 @@ class AppExcEditor(QtCore.QObject): self.toolbar_old_state = False if self.units == 'MM': - self.tolerance = float(self.app.defaults["global_tolerance"]) + self.tolerance = float(self.app.options["global_tolerance"]) else: - self.tolerance = float(self.app.defaults["global_tolerance"]) / 20 + self.tolerance = float(self.app.options["global_tolerance"]) / 20 # VisPy Visuals if self.app.use_3d_engine: @@ -1994,24 +1994,24 @@ class AppExcEditor(QtCore.QObject): self.tool2tooldia[int(k)] = tool_dia # Init appGUI - self.ui.addtool_entry.set_value(float(self.app.defaults['excellon_editor_newdia'])) - self.ui.drill_array_size_entry.set_value(int(self.app.defaults['excellon_editor_array_size'])) - self.ui.drill_axis_radio.set_value(self.app.defaults['excellon_editor_lin_dir']) - self.ui.drill_pitch_entry.set_value(float(self.app.defaults['excellon_editor_lin_pitch'])) - self.ui.linear_angle_spinner.set_value(float(self.app.defaults['excellon_editor_lin_angle'])) - self.ui.drill_array_dir_radio.set_value(self.app.defaults['excellon_editor_circ_dir']) - self.ui.drill_angle_entry.set_value(float(self.app.defaults['excellon_editor_circ_angle'])) + self.ui.addtool_entry.set_value(float(self.app.options['excellon_editor_newdia'])) + self.ui.drill_array_size_entry.set_value(int(self.app.options['excellon_editor_array_size'])) + self.ui.drill_axis_radio.set_value(self.app.options['excellon_editor_lin_dir']) + self.ui.drill_pitch_entry.set_value(float(self.app.options['excellon_editor_lin_pitch'])) + self.ui.linear_angle_spinner.set_value(float(self.app.options['excellon_editor_lin_angle'])) + self.ui.drill_array_dir_radio.set_value(self.app.options['excellon_editor_circ_dir']) + self.ui.drill_angle_entry.set_value(float(self.app.options['excellon_editor_circ_angle'])) - self.ui.slot_length_entry.set_value(float(self.app.defaults['excellon_editor_slot_length'])) - self.ui.slot_axis_radio.set_value(self.app.defaults['excellon_editor_slot_direction']) - self.ui.slot_angle_spinner.set_value(float(self.app.defaults['excellon_editor_slot_angle'])) + self.ui.slot_length_entry.set_value(float(self.app.options['excellon_editor_slot_length'])) + self.ui.slot_axis_radio.set_value(self.app.options['excellon_editor_slot_direction']) + self.ui.slot_angle_spinner.set_value(float(self.app.options['excellon_editor_slot_angle'])) - self.ui.slot_array_size_entry.set_value(int(self.app.defaults['excellon_editor_slot_array_size'])) - self.ui.slot_array_axis_radio.set_value(self.app.defaults['excellon_editor_slot_lin_dir']) - self.ui.slot_array_pitch_entry.set_value(float(self.app.defaults['excellon_editor_slot_lin_pitch'])) - self.ui.slot_array_linear_angle_spinner.set_value(float(self.app.defaults['excellon_editor_slot_lin_angle'])) - self.ui.slot_array_direction_radio.set_value(self.app.defaults['excellon_editor_slot_circ_dir']) - self.ui.slot_array_angle_entry.set_value(float(self.app.defaults['excellon_editor_slot_circ_angle'])) + self.ui.slot_array_size_entry.set_value(int(self.app.options['excellon_editor_slot_array_size'])) + self.ui.slot_array_axis_radio.set_value(self.app.options['excellon_editor_slot_lin_dir']) + self.ui.slot_array_pitch_entry.set_value(float(self.app.options['excellon_editor_slot_lin_pitch'])) + self.ui.slot_array_linear_angle_spinner.set_value(float(self.app.options['excellon_editor_slot_lin_angle'])) + self.ui.slot_array_direction_radio.set_value(self.app.options['excellon_editor_slot_circ_dir']) + self.ui.slot_array_angle_entry.set_value(float(self.app.options['excellon_editor_slot_circ_angle'])) # make sure that th visibility of the various UI frame are updated # according to the set Preferences already loaded @@ -2025,7 +2025,7 @@ class AppExcEditor(QtCore.QObject): self.on_slot_array_linear_angle_radio() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def build_ui(self, first_run=None): @@ -2764,52 +2764,52 @@ class AppExcEditor(QtCore.QObject): self.data_defaults = { "name": outname + '_drill', - "plot": self.app.defaults["excellon_plot"], - "solid": self.app.defaults["excellon_solid"], - "multicolored": self.app.defaults["excellon_multicolored"], - "merge_fuse_tools": self.app.defaults["excellon_merge_fuse_tools"], - "format_upper_in": self.app.defaults["excellon_format_upper_in"], - "format_lower_in": self.app.defaults["excellon_format_lower_in"], - "format_upper_mm": self.app.defaults["excellon_format_upper_mm"], - "lower_mm": self.app.defaults["excellon_format_lower_mm"], - "zeros": self.app.defaults["excellon_zeros"], + "plot": self.app.options["excellon_plot"], + "solid": self.app.options["excellon_solid"], + "multicolored": self.app.options["excellon_multicolored"], + "merge_fuse_tools": self.app.options["excellon_merge_fuse_tools"], + "format_upper_in": self.app.options["excellon_format_upper_in"], + "format_lower_in": self.app.options["excellon_format_lower_in"], + "format_upper_mm": self.app.options["excellon_format_upper_mm"], + "lower_mm": self.app.options["excellon_format_lower_mm"], + "zeros": self.app.options["excellon_zeros"], - "tools_drill_tool_order": self.app.defaults["tools_drill_tool_order"], - "tools_drill_cutz": self.app.defaults["tools_drill_cutz"], - "tools_drill_multidepth": self.app.defaults["tools_drill_multidepth"], - "tools_drill_depthperpass": self.app.defaults["tools_drill_depthperpass"], - "tools_drill_travelz": self.app.defaults["tools_drill_travelz"], + "tools_drill_tool_order": self.app.options["tools_drill_tool_order"], + "tools_drill_cutz": self.app.options["tools_drill_cutz"], + "tools_drill_multidepth": self.app.options["tools_drill_multidepth"], + "tools_drill_depthperpass": self.app.options["tools_drill_depthperpass"], + "tools_drill_travelz": self.app.options["tools_drill_travelz"], - "tools_drill_feedrate_z": self.app.defaults["tools_drill_feedrate_z"], - "tools_drill_feedrate_rapid": self.app.defaults["tools_drill_feedrate_rapid"], + "tools_drill_feedrate_z": self.app.options["tools_drill_feedrate_z"], + "tools_drill_feedrate_rapid": self.app.options["tools_drill_feedrate_rapid"], - "tools_drill_toolchange": self.app.defaults["tools_drill_toolchange"], - "tools_drill_toolchangez": self.app.defaults["tools_drill_toolchangez"], - "tools_drill_toolchangexy": self.app.defaults["tools_drill_toolchangexy"], + "tools_drill_toolchange": self.app.options["tools_drill_toolchange"], + "tools_drill_toolchangez": self.app.options["tools_drill_toolchangez"], + "tools_drill_toolchangexy": self.app.options["tools_drill_toolchangexy"], # Drill Slots - "tools_drill_drill_slots": self.app.defaults["tools_drill_drill_slots"], - "tools_drill_drill_overlap": self.app.defaults["tools_drill_drill_overlap"], - "tools_drill_last_drill": self.app.defaults["tools_drill_last_drill"], + "tools_drill_drill_slots": self.app.options["tools_drill_drill_slots"], + "tools_drill_drill_overlap": self.app.options["tools_drill_drill_overlap"], + "tools_drill_last_drill": self.app.options["tools_drill_last_drill"], - "tools_drill_endz": self.app.defaults["tools_drill_endz"], - "tools_drill_endxy": self.app.defaults["tools_drill_endxy"], - "tools_drill_startz": self.app.defaults["tools_drill_startz"], - "tools_drill_offset": self.app.defaults["tools_drill_offset"], - "tools_drill_spindlespeed": self.app.defaults["tools_drill_spindlespeed"], - "tools_drill_dwell": self.app.defaults["tools_drill_dwell"], - "tools_drill_dwelltime": self.app.defaults["tools_drill_dwelltime"], - "tools_drill_ppname_e": self.app.defaults["tools_drill_ppname_e"], - "tools_drill_z_pdepth": self.app.defaults["tools_drill_z_pdepth"], - "tools_drill_feedrate_probe": self.app.defaults["tools_drill_feedrate_probe"], - "tools_drill_spindledir": self.app.defaults["tools_drill_spindledir"], - "tools_drill_f_plunge": self.app.defaults["tools_drill_f_plunge"], - "tools_drill_f_retract": self.app.defaults["tools_drill_f_retract"], + "tools_drill_endz": self.app.options["tools_drill_endz"], + "tools_drill_endxy": self.app.options["tools_drill_endxy"], + "tools_drill_startz": self.app.options["tools_drill_startz"], + "tools_drill_offset": self.app.options["tools_drill_offset"], + "tools_drill_spindlespeed": self.app.options["tools_drill_spindlespeed"], + "tools_drill_dwell": self.app.options["tools_drill_dwell"], + "tools_drill_dwelltime": self.app.options["tools_drill_dwelltime"], + "tools_drill_ppname_e": self.app.options["tools_drill_ppname_e"], + "tools_drill_z_pdepth": self.app.options["tools_drill_z_pdepth"], + "tools_drill_feedrate_probe": self.app.options["tools_drill_feedrate_probe"], + "tools_drill_spindledir": self.app.options["tools_drill_spindledir"], + "tools_drill_f_plunge": self.app.options["tools_drill_f_plunge"], + "tools_drill_f_retract": self.app.options["tools_drill_f_retract"], - "tools_drill_area_exclusion": self.app.defaults["tools_drill_area_exclusion"], - "tools_drill_area_shape": self.app.defaults["tools_drill_area_shape"], - "tools_drill_area_strategy": self.app.defaults["tools_drill_area_strategy"], - "tools_drill_area_overz": self.app.defaults["tools_drill_area_overz"], + "tools_drill_area_exclusion": self.app.options["tools_drill_area_exclusion"], + "tools_drill_area_shape": self.app.options["tools_drill_area_shape"], + "tools_drill_area_strategy": self.app.options["tools_drill_area_strategy"], + "tools_drill_area_overz": self.app.options["tools_drill_area_overz"], } # fill in self.default_data values from self.obj_options @@ -2899,7 +2899,7 @@ class AppExcEditor(QtCore.QObject): # add a first tool in the Tool Table but only if the Excellon Object is empty if not self.tool2tooldia: - self.on_tool_add(self.dec_format(float(self.app.defaults['excellon_editor_newdia']))) + self.on_tool_add(self.dec_format(float(self.app.options['excellon_editor_newdia']))) def update_fcexcellon(self, exc_obj): """ @@ -3201,7 +3201,7 @@ class AppExcEditor(QtCore.QObject): def on_row_selected(self, row, col): key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.app.defaults["global_mselect_key"] == 'Control': + if self.app.options["global_mselect_key"] == 'Control': modifier_to_use = Qt.KeyboardModifier.ControlModifier else: modifier_to_use = Qt.KeyboardModifier.ShiftModifier @@ -3277,7 +3277,7 @@ class AppExcEditor(QtCore.QObject): # MS: always return to the Select Tool if modifier key is not pressed # else return to the current tool key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.app.defaults["global_mselect_key"] == 'Control': + if self.app.options["global_mselect_key"] == 'Control': modifier_to_use = Qt.KeyboardModifier.ControlModifier else: modifier_to_use = Qt.KeyboardModifier.ShiftModifier @@ -3433,8 +3433,8 @@ class AppExcEditor(QtCore.QObject): # Update cursor self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) self.snap_x = x self.snap_y = y @@ -3473,8 +3473,8 @@ class AppExcEditor(QtCore.QObject): self.app.delete_selection_shape() if dx < 0: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y), - color=self.app.defaults["global_alt_sel_line"], - face_color=self.app.defaults['global_alt_sel_fill']) + color=self.app.options["global_alt_sel_line"], + face_color=self.app.options['global_alt_sel_fill']) self.app.selection_type = False else: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y)) @@ -3484,8 +3484,8 @@ class AppExcEditor(QtCore.QObject): # Update cursor self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) def add_exc_shape(self, shape, storage): """ @@ -3594,7 +3594,7 @@ class AppExcEditor(QtCore.QObject): elif self.modifiers == QtCore.Qt.KeyboardModifier.ControlModifier: modifiers = 'Control' - if modifiers == self.app.defaults["global_mselect_key"]: + if modifiers == self.app.options["global_mselect_key"]: for storage in self.storage_dict: for obj in self.storage_dict[storage].get_objects(): if (sel_type is True and poly_selection.contains(obj.geo)) or \ @@ -3673,7 +3673,7 @@ class AppExcEditor(QtCore.QObject): for sub_geo in el.geoms: self.tool_shape.add( shape=sub_geo, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None @@ -3681,14 +3681,14 @@ class AppExcEditor(QtCore.QObject): else: self.tool_shape.add( shape=el, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None) except TypeError: self.tool_shape.add( shape=util_geo, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None) @@ -3714,10 +3714,10 @@ class AppExcEditor(QtCore.QObject): continue if shape_plus in self.selected: - self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_sel_draw_color'] + 'FF', + self.plot_shape(geometry=shape_plus.geo, color=self.app.options['global_sel_draw_color'] + 'FF', linewidth=2) continue - self.plot_shape(geometry=shape_plus.geo, color=self.app.defaults['global_draw_color'][:-2] + 'FF') + self.plot_shape(geometry=shape_plus.geo, color=self.app.options['global_draw_color'][:-2] + 'FF') for shape_form in self.utility: self.plot_shape(geometry=shape_form.geo, linewidth=1) diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index 3b3ea9a3..5dea860c 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -645,33 +645,33 @@ class PaintOptionsTool(AppTool): def set_tool_ui(self): # Init appGUI - if self.app.defaults["tools_paint_tooldia"]: - self.painttooldia_entry.set_value(self.app.defaults["tools_paint_tooldia"]) + if self.app.options["tools_paint_tooldia"]: + self.painttooldia_entry.set_value(self.app.options["tools_paint_tooldia"]) else: self.painttooldia_entry.set_value(0.0) - if self.app.defaults["tools_paint_overlap"]: - self.paintoverlap_entry.set_value(self.app.defaults["tools_paint_overlap"]) + if self.app.options["tools_paint_overlap"]: + self.paintoverlap_entry.set_value(self.app.options["tools_paint_overlap"]) else: self.paintoverlap_entry.set_value(0.0) - if self.app.defaults["tools_paint_offset"]: - self.paintmargin_entry.set_value(self.app.defaults["tools_paint_offset"]) + if self.app.options["tools_paint_offset"]: + self.paintmargin_entry.set_value(self.app.options["tools_paint_offset"]) else: self.paintmargin_entry.set_value(0.0) - if self.app.defaults["tools_paint_method"]: - self.paintmethod_combo.set_value(self.app.defaults["tools_paint_method"]) + if self.app.options["tools_paint_method"]: + self.paintmethod_combo.set_value(self.app.options["tools_paint_method"]) else: self.paintmethod_combo.set_value(_("Seed")) - if self.app.defaults["tools_paint_connect"]: - self.pathconnect_cb.set_value(self.app.defaults["tools_paint_connect"]) + if self.app.options["tools_paint_connect"]: + self.pathconnect_cb.set_value(self.app.options["tools_paint_connect"]) else: self.pathconnect_cb.set_value(False) - if self.app.defaults["tools_paint_contour"]: - self.paintcontour_cb.set_value(self.app.defaults["tools_paint_contour"]) + if self.app.options["tools_paint_contour"]: + self.paintcontour_cb.set_value(self.app.options["tools_paint_contour"]) else: self.paintcontour_cb.set_value(False) @@ -1162,27 +1162,27 @@ class TransformEditorTool(AppTool): def set_tool_ui(self): # Initialize form - ref_val = self.app.defaults["tools_transform_reference"] + ref_val = self.app.options["tools_transform_reference"] if ref_val == _("Object"): ref_val = _("Selection") self.ref_combo.set_value(ref_val) - self.point_entry.set_value(self.app.defaults["tools_transform_ref_point"]) - self.rotate_entry.set_value(self.app.defaults["tools_transform_rotate"]) + self.point_entry.set_value(self.app.options["tools_transform_ref_point"]) + self.rotate_entry.set_value(self.app.options["tools_transform_rotate"]) - self.skewx_entry.set_value(self.app.defaults["tools_transform_skew_x"]) - self.skewy_entry.set_value(self.app.defaults["tools_transform_skew_y"]) - self.skew_link_cb.set_value(self.app.defaults["tools_transform_skew_link"]) + self.skewx_entry.set_value(self.app.options["tools_transform_skew_x"]) + self.skewy_entry.set_value(self.app.options["tools_transform_skew_y"]) + self.skew_link_cb.set_value(self.app.options["tools_transform_skew_link"]) - self.scalex_entry.set_value(self.app.defaults["tools_transform_scale_x"]) - self.scaley_entry.set_value(self.app.defaults["tools_transform_scale_y"]) - self.scale_link_cb.set_value(self.app.defaults["tools_transform_scale_link"]) + self.scalex_entry.set_value(self.app.options["tools_transform_scale_x"]) + self.scaley_entry.set_value(self.app.options["tools_transform_scale_y"]) + self.scale_link_cb.set_value(self.app.options["tools_transform_scale_link"]) - self.offx_entry.set_value(self.app.defaults["tools_transform_offset_x"]) - self.offy_entry.set_value(self.app.defaults["tools_transform_offset_y"]) + self.offx_entry.set_value(self.app.options["tools_transform_offset_x"]) + self.offy_entry.set_value(self.app.options["tools_transform_offset_y"]) - self.buffer_entry.set_value(self.app.defaults["tools_transform_buffer_dis"]) - self.buffer_factor_entry.set_value(self.app.defaults["tools_transform_buffer_factor"]) - self.buffer_rounded_cb.set_value(self.app.defaults["tools_transform_buffer_corner"]) + self.buffer_entry.set_value(self.app.options["tools_transform_buffer_dis"]) + self.buffer_factor_entry.set_value(self.app.options["tools_transform_buffer_factor"]) + self.buffer_rounded_cb.set_value(self.app.options["tools_transform_buffer_corner"]) # initial state is hidden self.point_label.hide() @@ -1568,7 +1568,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Rotate ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_rotate']), + init_val=float(self.app.options['tools_transform_rotate']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/rotate.png')) @@ -1586,7 +1586,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Offset on X axis ..."), text='%s: (%s)' % (_('Enter a distance Value'), str(units)), min=-10000.0000, max=10000.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_offset_x']), + init_val=float(self.app.options['tools_transform_offset_x']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/offsetx32.png')) @@ -1604,7 +1604,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Offset on Y axis ..."), text='%s: (%s)' % (_('Enter a distance Value'), str(units)), min=-10000.0000, max=10000.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_offset_y']), + init_val=float(self.app.options['tools_transform_offset_y']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/offsety32.png')) @@ -1620,7 +1620,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Skew on X axis ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_skew_x']), + init_val=float(self.app.options['tools_transform_skew_x']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/skewX.png')) @@ -1636,7 +1636,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Skew on Y axis ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_skew_y']), + init_val=float(self.app.options['tools_transform_skew_y']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/skewY.png')) @@ -2082,7 +2082,7 @@ class FCCircle(FCShapeTool): self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) self.draw_app.app.inform.emit(_("Click on Center point ...")) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] def click(self, point): try: @@ -2168,7 +2168,7 @@ class FCArc(FCShapeTool): self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] def click(self, point): try: @@ -2685,7 +2685,7 @@ class FCSelect(DrawTool): else: mod_key = None - if mod_key == self.draw_app.app.defaults["global_mselect_key"]: + if mod_key == self.draw_app.app.options["global_mselect_key"]: # if modifier key is pressed then we add to the selected list the current shape but if it's already # in the selected list, we removed it. Therefore first click selects, second deselects. if obj_to_add in self.draw_app.selected: @@ -2811,7 +2811,7 @@ class FCMove(FCShapeTool): self.origin = None self.destination = None - self.sel_limit = self.draw_app.app.defaults["geometry_editor_sel_limit"] + self.sel_limit = self.draw_app.app.options["geometry_editor_sel_limit"] self.selection_shape = self.selection_bbox() if len(self.draw_app.get_selected()) == 0: @@ -2949,7 +2949,7 @@ class FCMove(FCShapeTool): return key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.draw_app.app.defaults["global_mselect_key"] == 'Control': + if self.draw_app.app.options["global_mselect_key"] == 'Control': # if CONTROL key is pressed then we add to the selected list the current shape but if it's # already in the selected list, we removed it. Therefore first click selects, second deselects. if key_modifier == Qt.KeyboardModifier.ControlModifier: @@ -3850,7 +3850,7 @@ class AppGeoEditor(QtCore.QObject): text_value = text_value.replace(',', '.') self.editor_options[opt] = float(text_value) except Exception as e: - entry.set_value(self.app.defaults[opt]) + entry.set_value(self.app.options[opt]) self.app.log.error("AppGeoEditor.__init__().entry2option() --> %s" % str(e)) return @@ -3880,7 +3880,7 @@ class AppGeoEditor(QtCore.QObject): def on_gridx_val_changed(self): self.grid_changed("global_gridx", self.app.ui.grid_gap_x_entry) # try: - # self.app.defaults["global_gridx"] = float(self.app.ui.grid_gap_x_entry.get_value()) + # self.app.options["global_gridx"] = float(self.app.ui.grid_gap_x_entry.get_value()) # except ValueError: # return @@ -3910,7 +3910,7 @@ class AppGeoEditor(QtCore.QObject): self.geo_zoom.set_value(False) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def build_ui(self): @@ -4657,11 +4657,11 @@ class AppGeoEditor(QtCore.QObject): # make sure that the cursor shape is enabled/disabled, too if self.editor_options['grid_snap'] is True: - self.app.defaults['global_grid_snap'] = True + self.app.options['global_grid_snap'] = True self.app.inform[str, bool].emit(_("Grid Snap enabled."), False) self.app.app_cursor.enabled = True else: - self.app.defaults['global_grid_snap'] = False + self.app.options['global_grid_snap'] = False self.app.app_cursor.enabled = False self.app.inform[str, bool].emit(_("Grid Snap disabled."), False) @@ -4693,7 +4693,7 @@ class AppGeoEditor(QtCore.QObject): # If the SHIFT key is pressed when LMB is clicked then the coordinates are copied to clipboard if modifiers == QtCore.Qt.KeyboardModifier.ShiftModifier: self.app.clipboard.setText( - self.app.defaults["global_point_clipboard_format"] % + self.app.options["global_point_clipboard_format"] % (self.decimals, self.pos[0], self.decimals, self.pos[1]) ) return @@ -4767,8 +4767,8 @@ class AppGeoEditor(QtCore.QObject): # Update cursor self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) self.snap_x = x self.snap_y = y @@ -4805,8 +4805,8 @@ class AppGeoEditor(QtCore.QObject): self.app.delete_selection_shape() if dx < 0: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y), - color=self.app.defaults["global_alt_sel_line"], - face_color=self.app.defaults['global_alt_sel_fill']) + color=self.app.options["global_alt_sel_line"], + face_color=self.app.options['global_alt_sel_fill']) self.app.selection_type = False else: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y)) @@ -4913,7 +4913,7 @@ class AppGeoEditor(QtCore.QObject): poly_selection.intersects(obj.geo)): sel_objects_list.append(obj) - if mod_key == self.app.defaults["global_mselect_key"]: + if mod_key == self.app.options["global_mselect_key"]: for obj in sel_objects_list: if obj in self.selected: self.selected.remove(obj) @@ -4975,7 +4975,7 @@ class AppGeoEditor(QtCore.QObject): for poly in el: self.tool_shape.add( shape=poly, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None @@ -4984,7 +4984,7 @@ class AppGeoEditor(QtCore.QObject): for linestring in el: self.tool_shape.add( shape=linestring, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None @@ -4992,14 +4992,14 @@ class AppGeoEditor(QtCore.QObject): else: self.tool_shape.add( shape=el, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None ) except TypeError: self.tool_shape.add( - shape=geo.geo, color=(self.app.defaults["global_draw_color"]), + shape=geo.geo, color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None) self.tool_shape.redraw() @@ -5118,8 +5118,8 @@ class AppGeoEditor(QtCore.QObject): self.shapes.clear(update=True) - draw_color = self.app.defaults['global_draw_color'][:-2] + "FF" - sel_color = self.app.defaults['global_sel_draw_color'][:-2] + 'FF' + draw_color = self.app.options['global_draw_color'][:-2] + "FF" + sel_color = self.app.options['global_sel_draw_color'][:-2] + 'FF' for shape in self.storage.get_objects(): if shape.geo and not shape.geo.is_empty and shape.geo.is_valid: @@ -5143,7 +5143,7 @@ class AppGeoEditor(QtCore.QObject): except TypeError: geom = [self.active_tool.geometry.geo] - if self.app.defaults['geometry_editor_milling_type'] == 'cl': + if self.app.options['geometry_editor_milling_type'] == 'cl': # reverse the geometry coordinates direction to allow creation of Gcode for climb milling try: pl = [] @@ -5325,13 +5325,13 @@ class AppGeoEditor(QtCore.QObject): self.select_tool("select") - if self.app.defaults['tools_mill_spindledir'] == 'CW': - if self.app.defaults['geometry_editor_milling_type'] == 'cl': + if self.app.options['tools_mill_spindledir'] == 'CW': + if self.app.options['geometry_editor_milling_type'] == 'cl': milling_type = 1 # CCW motion = climb milling (spindle is rotating CW) else: milling_type = -1 # CW motion = conventional milling (spindle is rotating CW) else: - if self.app.defaults['geometry_editor_milling_type'] == 'cl': + if self.app.options['geometry_editor_milling_type'] == 'cl': milling_type = -1 # CCW motion = climb milling (spindle is rotating CCW) else: milling_type = 1 # CW motion = conventional milling (spindle is rotating CCW) @@ -5724,7 +5724,7 @@ class AppGeoEditor(QtCore.QObject): if t.geo.geom_type == 'Polygon': results.append(t.geo.exterior.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style) ) elif t.geo.geom_type == 'MultiLineString': @@ -5733,12 +5733,12 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(line) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) elif t.geo.geom_type in ['LineString', 'LinearRing']: @@ -5746,12 +5746,12 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(t.geo) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) @@ -5800,7 +5800,7 @@ class AppGeoEditor(QtCore.QObject): if t.geo.geom_type == 'Polygon': results.append(t.geo.exterior.buffer( -buf_distance + 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) elif t.geo.geom_type == 'MultiLineString': @@ -5809,7 +5809,7 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(line) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) elif t.geo.geom_type in ['LineString', 'LinearRing']: @@ -5817,7 +5817,7 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(t.geo) results.append(b_geo.buffer( -buf_distance + 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) @@ -5868,7 +5868,7 @@ class AppGeoEditor(QtCore.QObject): if t.geo.geom_type == 'Polygon': results.append(t.geo.exterior.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) elif t.geo.geom_type == 'MultiLineString': @@ -5877,7 +5877,7 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(line) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) elif t.geo.geom_type in ['LineString', 'LinearRing']: @@ -5885,7 +5885,7 @@ class AppGeoEditor(QtCore.QObject): b_geo = Polygon(t.geo) results.append(b_geo.buffer( buf_distance - 1e-10, - resolution=int(int(editor_self.app.defaults["geometry_circle_steps"]) / 4), + resolution=int(int(editor_self.app.options["geometry_circle_steps"]) / 4), join_style=join_style).exterior ) @@ -5967,17 +5967,17 @@ class AppGeoEditor(QtCore.QObject): if method == _("Seed"): cp = Geometry.clear_polygon2( editor_self, polygon_to_clear=poly_buf, tooldia=tooldia, - steps_per_circle=editor_self.app.defaults["geometry_circle_steps"], + steps_per_circle=editor_self.app.options["geometry_circle_steps"], overlap=overlap, contour=contour, connect=connect) elif method == _("Lines"): cp = Geometry.clear_polygon3( editor_self, polygon=poly_buf, tooldia=tooldia, - steps_per_circle=editor_self.app.defaults["geometry_circle_steps"], + steps_per_circle=editor_self.app.options["geometry_circle_steps"], overlap=overlap, contour=contour, connect=connect) else: cp = Geometry.clear_polygon( editor_self, polygon=poly_buf, tooldia=tooldia, - steps_per_circle=editor_self.app.defaults["geometry_circle_steps"], + steps_per_circle=editor_self.app.options["geometry_circle_steps"], overlap=overlap, contour=contour, connect=connect) if cp is not None: diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index d5c35613..a05eab15 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -228,7 +228,7 @@ class PadEditorGrb(ShapeToolEditorGrb): self.dont_execute = False self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['geometry'] - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] # if those cause KeyError exception it means that the aperture type is not 'R'. Only 'R' type has those keys try: @@ -273,7 +273,7 @@ class PadEditorGrb(ShapeToolEditorGrb): # updating values here allows us to change the aperture on the fly, after the Tool has been started self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['geometry'] self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2 - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] # if those cause KeyError exception it means that the aperture type is not 'R'. Only 'R' type has those keys try: @@ -438,7 +438,7 @@ class PadArrayEditorGrb(ShapeToolEditorGrb): QtGui.QGuiApplication.setOverrideCursor(self.cursor) self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['geometry'] - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] # if those cause KeyError exception it means that the aperture type is not 'R'. Only 'R' type has those keys try: @@ -629,7 +629,7 @@ class PadArrayEditorGrb(ShapeToolEditorGrb): # updating values here allows us to change the aperture on the fly, after the Tool has been started self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['geometry'] self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2 - self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["geometry_circle_steps"] # if those cause KeyError exception it means that the aperture type is not 'R'. Only 'R' type has those keys try: @@ -942,7 +942,7 @@ class PoligonizeEditorGrb(ShapeToolEditorGrb): # MS: always return to the Select Tool if modifier key is not pressed # else return to the current tool key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.draw_app.app.defaults["global_mselect_key"] == 'Control': + if self.draw_app.app.options["global_mselect_key"] == 'Control': modifier_to_use = Qt.KeyboardModifier.ControlModifier else: modifier_to_use = Qt.KeyboardModifier.ShiftModifier @@ -971,7 +971,7 @@ class RegionEditorGrb(ShapeToolEditorGrb): self.draw_app = draw_app self.dont_execute = False - self.steps_per_circle = self.draw_app.app.defaults["gerber_circle_steps"] + self.steps_per_circle = self.draw_app.app.options["gerber_circle_steps"] # try: # size_ap = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) @@ -1337,7 +1337,7 @@ class TrackEditorGrb(ShapeToolEditorGrb): self.draw_app = draw_app self.dont_execute = False - self.steps_per_circle = self.draw_app.app.defaults["gerber_circle_steps"] + self.steps_per_circle = self.draw_app.app.options["gerber_circle_steps"] try: size_ap = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) @@ -1667,7 +1667,7 @@ class DiscEditorGrb(ShapeToolEditorGrb): self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) - self.steps_per_circ = self.draw_app.app.defaults["gerber_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["gerber_circle_steps"] def click(self, point): self.points.append(point) @@ -1787,7 +1787,7 @@ class DiscSemiEditorGrb(ShapeToolEditorGrb): } self.storage_obj = self.draw_app.storage_dict[0]['geometry'] - self.steps_per_circ = self.draw_app.app.defaults["gerber_circle_steps"] + self.steps_per_circ = self.draw_app.app.options["gerber_circle_steps"] self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) def click(self, point): @@ -2206,7 +2206,7 @@ class MoveEditorGrb(ShapeToolEditorGrb): self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) - self.sel_limit = self.draw_app.app.defaults["gerber_editor_sel_limit"] + self.sel_limit = self.draw_app.app.options["gerber_editor_sel_limit"] self.selection_shape = self.selection_bbox() def set_origin(self, origin): @@ -2421,7 +2421,7 @@ class EraserEditorGrb(ShapeToolEditorGrb): self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x)) - self.sel_limit = self.draw_app.app.defaults["gerber_editor_sel_limit"] + self.sel_limit = self.draw_app.app.options["gerber_editor_sel_limit"] def set_origin(self, origin): self.origin = origin @@ -2614,7 +2614,7 @@ class SelectEditorGrb(QtCore.QObject, DrawTool): else: mod_key = None - if mod_key == self.draw_app.app.defaults["global_mselect_key"]: + if mod_key == self.draw_app.app.options["global_mselect_key"]: pass else: self.draw_app.selected = [] @@ -2630,7 +2630,7 @@ class SelectEditorGrb(QtCore.QObject, DrawTool): else: mod_key = None - if mod_key != self.draw_app.app.defaults["global_mselect_key"]: + if mod_key != self.draw_app.app.options["global_mselect_key"]: self.draw_app.selected.clear() self.sel_aperture.clear() @@ -2903,8 +2903,8 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): # Update cursor self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) self.snap_x = x self.snap_y = y @@ -2931,8 +2931,8 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): self.app.delete_selection_shape() if dx < 0: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y), - color=self.app.defaults["global_alt_sel_line"], - face_color=self.app.defaults['global_alt_sel_fill']) + color=self.app.options["global_alt_sel_line"], + face_color=self.app.options['global_alt_sel_fill']) self.app.selection_type = False else: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y)) @@ -3024,9 +3024,9 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): if solid_geo not in self.get_selected_geos(): shape_id = self.app.tool_shapes.add(tolerance=obj.drawing_tolerance, layer=0, shape=solid_geo, - color=self.app.defaults[ + color=self.app.options[ 'global_sel_draw_color'] + 'AF', - face_color=self.app.defaults[ + face_color=self.app.options[ 'global_sel_draw_color' ] + 'AF', visible=True) @@ -3068,8 +3068,8 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): added_poly_count = 0 - color = self.app.defaults['global_sel_draw_color'] + 'AF' - face_color = self.app.defaults['global_sel_draw_color'] + 'AF' + color = self.app.options['global_sel_draw_color'] + 'AF' + face_color = self.app.options['global_sel_draw_color'] + 'AF' for obj in self.app.collection.get_list(): # only Gerber objects and only those that are active and not the edited object @@ -3347,7 +3347,7 @@ class AppGerberEditor(QtCore.QObject): # this will flag if the Editor "tools" are launched from key shortcuts (True) or from menu toolbar (False) self.launched_from_shortcuts = False - def_tol_val = float(self.app.defaults["global_tolerance"]) + def_tol_val = float(self.app.options["global_tolerance"]) self.tolerance = def_tol_val if self.units == 'MM' else def_tol_val / 25.4 # options of this widget (AppGerberEditor class is a widget) @@ -3527,31 +3527,31 @@ class AppGerberEditor(QtCore.QObject): # ############################################################################################################# # Init appGUI # ############################################################################################################# - self.ui.buffer_distance_entry.set_value(self.app.defaults["gerber_editor_buff_f"]) - self.ui.scale_factor_entry.set_value(self.app.defaults["gerber_editor_scale_f"]) - self.ui.ma_upper_threshold_entry.set_value(self.app.defaults["gerber_editor_ma_high"]) - self.ui.ma_lower_threshold_entry.set_value(self.app.defaults["gerber_editor_ma_low"]) + self.ui.buffer_distance_entry.set_value(self.app.options["gerber_editor_buff_f"]) + self.ui.scale_factor_entry.set_value(self.app.options["gerber_editor_scale_f"]) + self.ui.ma_upper_threshold_entry.set_value(self.app.options["gerber_editor_ma_high"]) + self.ui.ma_lower_threshold_entry.set_value(self.app.options["gerber_editor_ma_low"]) - self.ui.apsize_entry.set_value(self.app.defaults["gerber_editor_newsize"]) - self.ui.aptype_cb.set_value(self.app.defaults["gerber_editor_newtype"]) - self.ui.apdim_entry.set_value(self.app.defaults["gerber_editor_newdim"]) + self.ui.apsize_entry.set_value(self.app.options["gerber_editor_newsize"]) + self.ui.aptype_cb.set_value(self.app.options["gerber_editor_newtype"]) + self.ui.apdim_entry.set_value(self.app.options["gerber_editor_newdim"]) # PAD Array self.ui.array_type_radio.set_value('linear') # Linear self.on_array_type_radio(val=self.ui.array_type_radio.get_value()) - self.ui.pad_array_size_entry.set_value(int(self.app.defaults["gerber_editor_array_size"])) + self.ui.pad_array_size_entry.set_value(int(self.app.options["gerber_editor_array_size"])) # linear array self.ui.pad_axis_radio.set_value('X') self.on_linear_angle_radio(val=self.ui.pad_axis_radio.get_value()) - self.ui.pad_axis_radio.set_value(self.app.defaults["gerber_editor_lin_axis"]) - self.ui.pad_pitch_entry.set_value(float(self.app.defaults["gerber_editor_lin_pitch"])) - self.ui.linear_angle_spinner.set_value(self.app.defaults["gerber_editor_lin_angle"]) + self.ui.pad_axis_radio.set_value(self.app.options["gerber_editor_lin_axis"]) + self.ui.pad_pitch_entry.set_value(float(self.app.options["gerber_editor_lin_pitch"])) + self.ui.linear_angle_spinner.set_value(self.app.options["gerber_editor_lin_angle"]) # circular array self.ui.pad_direction_radio.set_value('CW') - self.ui.pad_direction_radio.set_value(self.app.defaults["gerber_editor_circ_dir"]) - self.ui.pad_angle_entry.set_value(float(self.app.defaults["gerber_editor_circ_angle"])) + self.ui.pad_direction_radio.set_value(self.app.options["gerber_editor_circ_dir"]) + self.ui.pad_angle_entry.set_value(float(self.app.options["gerber_editor_circ_angle"])) self.ui.geo_coords_entry.setText('') self.ui.geo_vertex_entry.set_value(0.0) @@ -3559,7 +3559,7 @@ class AppGerberEditor(QtCore.QObject): self.ui.geo_zoom.set_value(False) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def build_ui(self, first_run=None): @@ -3724,7 +3724,7 @@ class AppGerberEditor(QtCore.QObject): self.ui.apcode_entry.set_value(max(self.tid2apcode.values()) + 1) except ValueError: # this means that the edited object has no apertures so we start with 10 (Gerber specifications) - self.ui.apcode_entry.set_value(self.app.defaults["gerber_editor_newcode"]) + self.ui.apcode_entry.set_value(self.app.options["gerber_editor_newcode"]) def on_aperture_add(self, apcode=None): self.is_modified = True @@ -4551,7 +4551,7 @@ class AppGerberEditor(QtCore.QObject): else: self.conversion_factor = 0.0393700787401575 - def_tol_val = float(self.app.defaults["global_tolerance"]) + def_tol_val = float(self.app.options["global_tolerance"]) self.tolerance = def_tol_val if self.units == 'MM' else def_tol_val / 25.4 # Hide original geometry @@ -4995,7 +4995,7 @@ class AppGerberEditor(QtCore.QObject): def on_row_selected(self, row, col): # if col == 0: key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.app.defaults["global_mselect_key"] == 'Control': + if self.app.options["global_mselect_key"] == 'Control': modifier_to_use = Qt.KeyboardModifier.ControlModifier else: modifier_to_use = Qt.KeyboardModifier.ShiftModifier @@ -5188,7 +5188,7 @@ class AppGerberEditor(QtCore.QObject): # If the SHIFT key is pressed when LMB is clicked then the coordinates are copied to clipboard if modifiers == QtCore.Qt.KeyboardModifier.ShiftModifier: self.app.clipboard.setText( - self.app.defaults["global_point_clipboard_format"] % + self.app.options["global_point_clipboard_format"] % (self.decimals, self.pos[0], self.decimals, self.pos[1]) ) self.app.inform.emit('[success] %s' % _("Copied to clipboard.")) @@ -5206,7 +5206,7 @@ class AppGerberEditor(QtCore.QObject): # MS: always return to the Select Tool if modifier key is not pressed # else return to the current tool key_modifier = QtWidgets.QApplication.keyboardModifiers() - if self.app.defaults["global_mselect_key"] == 'Control': + if self.app.options["global_mselect_key"] == 'Control': modifier_to_use = Qt.KeyboardModifier.ControlModifier else: modifier_to_use = Qt.KeyboardModifier.ShiftModifier @@ -5286,9 +5286,9 @@ class AppGerberEditor(QtCore.QObject): self.select_tool(self.active_tool.name) else: key_modifier = QtWidgets.QApplication.keyboardModifiers() - if (self.app.defaults["global_mselect_key"] == 'Control' and + if (self.app.options["global_mselect_key"] == 'Control' and key_modifier == Qt.KeyboardModifier.ControlModifier) or \ - (self.app.defaults["global_mselect_key"] == 'Shift' and + (self.app.options["global_mselect_key"] == 'Shift' and key_modifier == Qt.KeyboardModifier.ShiftModifier): self.select_tool(self.active_tool.name) @@ -5335,7 +5335,7 @@ class AppGerberEditor(QtCore.QObject): geometric_data = obj.geo['solid'] if (sel_type is True and poly_selection.contains(geometric_data)) or \ (sel_type is False and poly_selection.intersects(geometric_data)): - if self.key == self.app.defaults["global_mselect_key"]: + if self.key == self.app.options["global_mselect_key"]: if obj in self.selected: self.selected.remove(obj) else: @@ -5448,8 +5448,8 @@ class AppGerberEditor(QtCore.QObject): # Update cursor self.app.app_cursor.set_data(np.asarray([(x, y)]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) self.snap_x = x self.snap_y = y @@ -5489,8 +5489,8 @@ class AppGerberEditor(QtCore.QObject): self.app.delete_selection_shape() if dx < 0: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y), - color=self.app.defaults["global_alt_sel_line"], - face_color=self.app.defaults['global_alt_sel_fill']) + color=self.app.options["global_alt_sel_line"], + face_color=self.app.options['global_alt_sel_fill']) self.app.selection_type = False else: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x, y)) @@ -5516,8 +5516,8 @@ class AppGerberEditor(QtCore.QObject): geometric_data = el['solid'] # Add the new utility shape self.tool_shape.add( - shape=geometric_data, color=(self.app.defaults["global_draw_color"]), - # face_color=self.app.defaults['global_alt_sel_fill'], + shape=geometric_data, color=(self.app.options["global_draw_color"]), + # face_color=self.app.options['global_alt_sel_fill'], update=False, layer=0, tolerance=None ) except TypeError: @@ -5525,8 +5525,8 @@ class AppGerberEditor(QtCore.QObject): # Add the new utility shape self.tool_shape.add( shape=geometric_data, - color=(self.app.defaults["global_draw_color"]), - # face_color=self.app.defaults['global_alt_sel_fill'], + color=(self.app.options["global_draw_color"]), + # face_color=self.app.options['global_alt_sel_fill'], update=False, layer=0, tolerance=None ) @@ -5553,11 +5553,11 @@ class AppGerberEditor(QtCore.QObject): if elem in self.selected: self.plot_shape(geometry=geometric_data, - color=self.app.defaults['global_sel_draw_color'] + 'FF', + color=self.app.options['global_sel_draw_color'] + 'FF', linewidth=2) else: self.plot_shape(geometry=geometric_data, - color=self.app.defaults['global_draw_color'][:-2] + 'FF') + color=self.app.options['global_draw_color'][:-2] + 'FF') if self.utility: for elem in self.utility: @@ -6001,7 +6001,7 @@ class AppGerberEditor(QtCore.QObject): if text: self.ma_annotation.set(text=text, pos=position, visible=True, - font_size=self.app.defaults["cncjob_annotation_fontsize"], + font_size=self.app.options["cncjob_annotation_fontsize"], color='#000000FF') self.app.inform.emit('[success] %s' % _("Polygons marked.")) else: @@ -7159,27 +7159,27 @@ class TransformEditorTool(AppTool): def set_tool_ui(self): # Initialize form - ref_val = self.app.defaults["tools_transform_reference"] + ref_val = self.app.options["tools_transform_reference"] if ref_val == _("Object"): ref_val = _("Selection") self.ref_combo.set_value(ref_val) - self.point_entry.set_value(self.app.defaults["tools_transform_ref_point"]) - self.rotate_entry.set_value(self.app.defaults["tools_transform_rotate"]) + self.point_entry.set_value(self.app.options["tools_transform_ref_point"]) + self.rotate_entry.set_value(self.app.options["tools_transform_rotate"]) - self.skewx_entry.set_value(self.app.defaults["tools_transform_skew_x"]) - self.skewy_entry.set_value(self.app.defaults["tools_transform_skew_y"]) - self.skew_link_cb.set_value(self.app.defaults["tools_transform_skew_link"]) + self.skewx_entry.set_value(self.app.options["tools_transform_skew_x"]) + self.skewy_entry.set_value(self.app.options["tools_transform_skew_y"]) + self.skew_link_cb.set_value(self.app.options["tools_transform_skew_link"]) - self.scalex_entry.set_value(self.app.defaults["tools_transform_scale_x"]) - self.scaley_entry.set_value(self.app.defaults["tools_transform_scale_y"]) - self.scale_link_cb.set_value(self.app.defaults["tools_transform_scale_link"]) + self.scalex_entry.set_value(self.app.options["tools_transform_scale_x"]) + self.scaley_entry.set_value(self.app.options["tools_transform_scale_y"]) + self.scale_link_cb.set_value(self.app.options["tools_transform_scale_link"]) - self.offx_entry.set_value(self.app.defaults["tools_transform_offset_x"]) - self.offy_entry.set_value(self.app.defaults["tools_transform_offset_y"]) + self.offx_entry.set_value(self.app.options["tools_transform_offset_x"]) + self.offy_entry.set_value(self.app.options["tools_transform_offset_y"]) - self.buffer_entry.set_value(self.app.defaults["tools_transform_buffer_dis"]) - self.buffer_factor_entry.set_value(self.app.defaults["tools_transform_buffer_factor"]) - self.buffer_rounded_cb.set_value(self.app.defaults["tools_transform_buffer_corner"]) + self.buffer_entry.set_value(self.app.options["tools_transform_buffer_dis"]) + self.buffer_factor_entry.set_value(self.app.options["tools_transform_buffer_factor"]) + self.buffer_rounded_cb.set_value(self.app.options["tools_transform_buffer_corner"]) # initial state is hidden self.point_label.hide() @@ -7603,10 +7603,10 @@ class TransformEditorTool(AppTool): else: if 'solid' in sel_el: sel_el['solid'] = sel_el['solid'].buffer( - value, resolution=self.app.defaults["gerber_circle_steps"], join_style=join) + value, resolution=self.app.options["gerber_circle_steps"], join_style=join) if 'clear' in sel_el: sel_el['clear'] = sel_el['clear'].buffer( - value, resolution=self.app.defaults["gerber_circle_steps"], join_style=join) + value, resolution=self.app.options["gerber_circle_steps"], join_style=join) self.draw_app.plot_all() @@ -7621,7 +7621,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Rotate ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_rotate']), + init_val=float(self.app.options['tools_transform_rotate']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/rotate.png')) @@ -7639,7 +7639,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Offset on X axis ..."), text='%s: (%s)' % (_('Enter a distance Value'), str(units)), min=-10000.0000, max=10000.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_offset_x']), + init_val=float(self.app.options['tools_transform_offset_x']), parent=self.app.ui) val_box.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/offsetx32.png')) @@ -7657,7 +7657,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Offset on Y axis ..."), text='%s: (%s)' % (_('Enter a distance Value'), str(units)), min=-10000.0000, max=10000.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_offset_y']), + init_val=float(self.app.options['tools_transform_offset_y']), parent=self.app.ui) val_box.set_icon(QtGui.QIcon(self.app.resource_location + '/offsety32.png')) @@ -7673,7 +7673,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Skew on X axis ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_skew_x']), + init_val=float(self.app.options['tools_transform_skew_x']), parent=self.app.ui) val_box.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/skewX.png')) @@ -7689,7 +7689,7 @@ class TransformEditorTool(AppTool): val_box = FCInputDoubleSpinner(title=_("Skew on Y axis ..."), text='%s:' % _('Enter an Angle Value (degrees)'), min=-359.9999, max=360.0000, decimals=self.decimals, - init_val=float(self.app.defaults['tools_transform_skew_y']), + init_val=float(self.app.options['tools_transform_skew_y']), parent=self.app.ui) val_box.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/skewY.png')) diff --git a/appEditors/AppTextEditor.py b/appEditors/AppTextEditor.py index 51735687..d30de3ab 100644 --- a/appEditors/AppTextEditor.py +++ b/appEditors/AppTextEditor.py @@ -253,7 +253,7 @@ class AppTextEditor(QtWidgets.QWidget): try: filename = str(FCFileSaveDialog.get_saved_filename( caption=_("Export Code ..."), - directory=self.app.defaults["global_last_folder"] + '/' + str(obj_name), + directory=self.app.options["global_last_folder"] + '/' + str(obj_name), ext_filter=_filter_ )[0]) except TypeError: @@ -269,8 +269,8 @@ class AppTextEditor(QtWidgets.QWidget): my_gcode = self.code_editor.toPlainText() if filename.rpartition('.')[2].lower() == 'pdf': page_size = ( - self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][0] * mm, - self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][1] * mm + self.app.plotcanvas.pagesize_dict[self.app.options['global_workspaceT']][0] * mm, + self.app.plotcanvas.pagesize_dict[self.app.options['global_workspaceT']][1] * mm ) # add new line after each line @@ -282,15 +282,15 @@ class AppTextEditor(QtWidgets.QWidget): story = [] if self.app.app_units.lower() == 'mm': - bmargin = self.app.defaults['global_tpdf_bmargin'] * mm - tmargin = self.app.defaults['global_tpdf_tmargin'] * mm - rmargin = self.app.defaults['global_tpdf_rmargin'] * mm - lmargin = self.app.defaults['global_tpdf_lmargin'] * mm + bmargin = self.app.options['global_tpdf_bmargin'] * mm + tmargin = self.app.options['global_tpdf_tmargin'] * mm + rmargin = self.app.options['global_tpdf_rmargin'] * mm + lmargin = self.app.options['global_tpdf_lmargin'] * mm else: - bmargin = self.app.defaults['global_tpdf_bmargin'] * inch - tmargin = self.app.defaults['global_tpdf_tmargin'] * inch - rmargin = self.app.defaults['global_tpdf_rmargin'] * inch - lmargin = self.app.defaults['global_tpdf_lmargin'] * inch + bmargin = self.app.options['global_tpdf_bmargin'] * inch + tmargin = self.app.options['global_tpdf_tmargin'] * inch + rmargin = self.app.options['global_tpdf_rmargin'] * inch + lmargin = self.app.options['global_tpdf_lmargin'] * inch doc = SimpleDocTemplate( filename, @@ -322,7 +322,7 @@ class AppTextEditor(QtWidgets.QWidget): return # Just for adding it to the recent files list. - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("cncjob", filename) self.app.file_saved.emit("cncjob", filename) self.app.inform.emit('%s: %s' % (_("Saved to"), str(filename))) diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index 53175490..1d35bb41 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -104,8 +104,8 @@ class AppGCodeEditor(QtCore.QObject): # ############################################################################################################# # ############################################################################################################# - self.ui.append_text.set_value(self.app.defaults["cncjob_append"]) - self.ui.prepend_text.set_value(self.app.defaults["cncjob_prepend"]) + self.ui.append_text.set_value(self.app.options["cncjob_append"]) + self.ui.prepend_text.set_value(self.app.options["cncjob_prepend"]) # Remove anything else in the GUI Properties Tab self.app.ui.properties_scroll_area.takeWidget() @@ -121,7 +121,7 @@ class AppGCodeEditor(QtCore.QObject): self.activate() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def build_ui(self): diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index 2a616758..0c9d8834 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -5176,26 +5176,24 @@ class FlatCAMActivityView(QtWidgets.QWidget): This class create and control the activity icon displayed in the App status bar """ - def __init__(self, app, parent=None): + def __init__(self, icon_location, icon_kind, replot_callback, parent=None): super().__init__(parent=parent) - self.app = app - - if self.app.defaults["global_activity_icon"] == "Ball green": - icon = self.app.resource_location + '/active_2_static.png' - movie = self.app.resource_location + "/active_2.gif" - elif self.app.defaults["global_activity_icon"] == "Ball black": - icon = self.app.resource_location + '/active_static.png' - movie = self.app.resource_location + "/active.gif" - elif self.app.defaults["global_activity_icon"] == "Arrow green": - icon = self.app.resource_location + '/active_3_static.png' - movie = self.app.resource_location + "/active_3.gif" - elif self.app.defaults["global_activity_icon"] == "Eclipse green": - icon = self.app.resource_location + '/active_4_static.png' - movie = self.app.resource_location + "/active_4.gif" + if icon_kind == "Ball green": + icon = icon_location + '/active_2_static.png' + movie = icon_location + "/active_2.gif" + elif icon_kind == "Ball black": + icon = icon_location + '/active_static.png' + movie = icon_location + "/active.gif" + elif icon_kind == "Arrow green": + icon = icon_location + '/active_3_static.png' + movie = icon_location + "/active_3.gif" + elif icon_kind == "Eclipse green": + icon = icon_location + '/active_4_static.png' + movie = icon_location + "/active_4.gif" else: - icon = self.app.resource_location + '/active_static.png' - movie = self.app.resource_location + "/active.gif" + icon = icon_location + '/active_static.png' + movie = icon_location + "/active.gif" # ###############################################################3 # self.setMinimumWidth(200) @@ -5223,7 +5221,7 @@ class FlatCAMActivityView(QtWidgets.QWidget): layout.addWidget(self.text) - self.icon.clicked.connect(self.app.on_toolbar_replot) + self.icon.clicked.connect(replot_callback) def set_idle(self): self.movie.stop() @@ -5295,7 +5293,6 @@ class FlatCAMInfoBar(QtWidgets.QWidget): self.icon.setPixmap(self.blue_pamap) else: self.icon.setPixmap(self.gray_pmap) - except Exception as e: self.app.log.error("FlatCAMInfoBar.set_status() set Icon --> %s" % str(e)) @@ -5371,10 +5368,10 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon): self.menu_open.addSeparator() - menu_openproject.triggered.connect(self.app.f_handlers.on_file_openproject) - menu_opengerber.triggered.connect(self.app.f_handlers.on_fileopengerber) - menu_openexcellon.triggered.connect(self.app.f_handlers.on_fileopenexcellon) - menu_opengcode.triggered.connect(self.app.f_handlers.on_fileopengcode) + menu_openproject.triggered.connect(lambda: self.app.f_handlers.on_file_openproject()) + menu_opengerber.triggered.connect(lambda: self.app.f_handlers.on_fileopengerber()) + menu_openexcellon.triggered.connect(lambda: self.app.f_handlers.on_fileopenexcellon()) + menu_opengcode.triggered.connect(lambda: self.app.f_handlers.on_fileopengcode()) exitAction = menu.addAction(_("Exit")) exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png')) diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 0687a506..3302fdc4 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1867,18 +1867,18 @@ class MainGUI(QtWidgets.QMainWindow): self.infobar.addWidget(self.fcinfo, stretch=1) self.infobar.addWidget(self.delta_coords_toolbar) - self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"]) + self.delta_coords_toolbar.setVisible(self.app.options["global_delta_coordsbar_show"]) self.infobar.addWidget(self.coords_toolbar) - self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"]) + self.coords_toolbar.setVisible(self.app.options["global_coordsbar_show"]) self.grid_toolbar.setMaximumHeight(24) self.infobar.addWidget(self.grid_toolbar) - self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"]) + self.grid_toolbar.setVisible(self.app.options["global_gridbar_show"]) self.status_toolbar.setMaximumHeight(24) self.infobar.addWidget(self.status_toolbar) - self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"]) + self.status_toolbar.setVisible(self.app.options["global_statusbar_show"]) self.units_label = FCLabel("[mm]") self.units_label.setToolTip(_("Application units")) @@ -1886,7 +1886,9 @@ class MainGUI(QtWidgets.QMainWindow): self.infobar.addWidget(self.units_label) # this used to be done in the APP.__init__() - self.activity_view = FlatCAMActivityView(app=self.app) + self.activity_view = FlatCAMActivityView(icon_location=self.app.resource_location, + icon_kind=self.app.options["global_activity_icon"], + replot_callback=self.app.on_toolbar_replot) self.infobar.addWidget(self.activity_view) # disabled @@ -1935,16 +1937,16 @@ class MainGUI(QtWidgets.QMainWindow): # ######################################################################## # ######################## BUILD PREFERENCES ############################# # ######################################################################## - self.general_pref_form = GeneralPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.gerber_pref_form = GerberPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.excellon_pref_form = ExcellonPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.geo_pref_form = GeometryPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.cncjob_pref_form = CNCJobPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.plugin_pref_form = PluginsPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.plugin2_pref_form = Plugins2PreferencesUI(decimals=self.decimals, defaults=self.app.defaults) - self.plugin_eng_pref_form = PluginsEngravingPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) + self.general_pref_form = GeneralPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.gerber_pref_form = GerberPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.excellon_pref_form = ExcellonPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.geo_pref_form = GeometryPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.cncjob_pref_form = CNCJobPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.plugin_pref_form = PluginsPreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.plugin2_pref_form = Plugins2PreferencesUI(decimals=self.decimals, defaults=self.app.options) + self.plugin_eng_pref_form = PluginsEngravingPreferencesUI(decimals=self.decimals, defaults=self.app.options) - self.util_pref_form = UtilPreferencesUI(decimals=self.decimals, defaults=self.app.defaults) + self.util_pref_form = UtilPreferencesUI(decimals=self.decimals, defaults=self.app.options) QtCore.QCoreApplication.instance().installEventFilter(self) @@ -2042,7 +2044,7 @@ class MainGUI(QtWidgets.QMainWindow): self.plot_tab_area.tabBar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu) self.on_tab_setup_context_menu() # activate initial state - self.on_detachable_tab_rmb_click(self.app.defaults["global_tabs_detachable"]) + self.on_detachable_tab_rmb_click(self.app.options["global_tabs_detachable"]) # status bar activation/deactivation self.infobar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu) @@ -2162,20 +2164,20 @@ class MainGUI(QtWidgets.QMainWindow): :return: None """ - self.app.defaults["global_def_win_x"] = x - self.app.defaults["global_def_win_y"] = y - self.app.defaults["global_def_win_w"] = width - self.app.defaults["global_def_win_h"] = height - self.app.defaults["global_def_notebook_width"] = notebook_width + self.app.options["global_def_win_x"] = x + self.app.options["global_def_win_y"] = y + self.app.options["global_def_win_w"] = width + self.app.options["global_def_win_h"] = height + self.app.options["global_def_notebook_width"] = notebook_width self.app.preferencesUiManager.save_defaults() def restore_main_win_geom(self): try: - self.setGeometry(self.app.defaults["global_def_win_x"], - self.app.defaults["global_def_win_y"], - self.app.defaults["global_def_win_w"], - self.app.defaults["global_def_win_h"]) - self.splitter.setSizes([self.app.defaults["global_def_notebook_width"], 0]) + self.setGeometry(self.app.options["global_def_win_x"], + self.app.options["global_def_win_y"], + self.app.options["global_def_win_w"], + self.app.options["global_def_win_h"]) + self.splitter.setSizes([self.app.options["global_def_notebook_width"], 0]) except KeyError as e: self.app.log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e)) @@ -2186,7 +2188,7 @@ class MainGUI(QtWidgets.QMainWindow): :return: None """ - tb = self.app.defaults["global_toolbar_view"] + tb = self.app.options["global_toolbar_view"] if tb & 1: self.toolbarfile.setVisible(True) @@ -2236,7 +2238,7 @@ class MainGUI(QtWidgets.QMainWindow): self.toolbarshell.setVisible(False) def on_tab_setup_context_menu(self): - initial_checked = self.app.defaults["global_tabs_detachable"] + initial_checked = self.app.options["global_tabs_detachable"] action_name = str(_("Detachable Tabs")) action = QtGui.QAction(self) action.setCheckable(True) @@ -2254,17 +2256,17 @@ class MainGUI(QtWidgets.QMainWindow): def on_detachable_tab_rmb_click(self, checked): self.notebook.set_detachable(val=checked) - self.app.defaults["global_tabs_detachable"] = checked + self.app.options["global_tabs_detachable"] = checked self.plot_tab_area.set_detachable(val=checked) - self.app.defaults["global_tabs_detachable"] = checked + self.app.options["global_tabs_detachable"] = checked def build_infobar_context_menu(self): delta_coords_action_name = str(_("Delta Coordinates Toolbar")) delta_coords_action = QtGui.QAction(self) delta_coords_action.setCheckable(True) delta_coords_action.setText(delta_coords_action_name) - delta_coords_action.setChecked(self.app.defaults["global_delta_coordsbar_show"]) + delta_coords_action.setChecked(self.app.options["global_delta_coordsbar_show"]) self.infobar.addAction(delta_coords_action) delta_coords_action.triggered.connect(self.toggle_delta_coords) @@ -2272,7 +2274,7 @@ class MainGUI(QtWidgets.QMainWindow): coords_action = QtGui.QAction(self) coords_action.setCheckable(True) coords_action.setText(coords_action_name) - coords_action.setChecked(self.app.defaults["global_coordsbar_show"]) + coords_action.setChecked(self.app.options["global_coordsbar_show"]) self.infobar.addAction(coords_action) coords_action.triggered.connect(self.toggle_coords) @@ -2280,7 +2282,7 @@ class MainGUI(QtWidgets.QMainWindow): grid_action = QtGui.QAction(self) grid_action.setCheckable(True) grid_action.setText(grid_action_name) - grid_action.setChecked(self.app.defaults["global_gridbar_show"]) + grid_action.setChecked(self.app.options["global_gridbar_show"]) self.infobar.addAction(grid_action) grid_action.triggered.connect(self.toggle_gridbar) @@ -2288,24 +2290,24 @@ class MainGUI(QtWidgets.QMainWindow): status_action = QtGui.QAction(self) status_action.setCheckable(True) status_action.setText(status_action_name) - status_action.setChecked(self.app.defaults["global_statusbar_show"]) + status_action.setChecked(self.app.options["global_statusbar_show"]) self.infobar.addAction(status_action) status_action.triggered.connect(self.toggle_statusbar) def toggle_coords(self, checked): - self.app.defaults["global_coordsbar_show"] = checked + self.app.options["global_coordsbar_show"] = checked self.coords_toolbar.setVisible(checked) def toggle_delta_coords(self, checked): - self.app.defaults["global_delta_coordsbar_show"] = checked + self.app.options["global_delta_coordsbar_show"] = checked self.delta_coords_toolbar.setVisible(checked) def toggle_gridbar(self, checked): - self.app.defaults["global_gridbar_show"] = checked + self.app.options["global_gridbar_show"] = checked self.grid_toolbar.setVisible(checked) def toggle_statusbar(self, checked): - self.app.defaults["global_statusbar_show"] = checked + self.app.options["global_statusbar_show"] = checked self.status_toolbar.setVisible(checked) def on_preferences_open_folder(self): @@ -2768,10 +2770,10 @@ class MainGUI(QtWidgets.QMainWindow): for tb in self.findChildren(QtWidgets.QToolBar): tb.setVisible(False) - self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"]) - self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"]) - self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"]) - self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"]) + self.coords_toolbar.setVisible(self.app.options["global_coordsbar_show"]) + self.delta_coords_toolbar.setVisible(self.app.options["global_delta_coordsbar_show"]) + self.grid_toolbar.setVisible(self.app.options["global_gridbar_show"]) + self.status_toolbar.setVisible(self.app.options["global_statusbar_show"]) self.splitter.setSizes([0, 1]) self.toggle_fscreen = True @@ -2944,7 +2946,7 @@ class MainGUI(QtWidgets.QMainWindow): # Open Excellon file if key == QtCore.Qt.Key.Key_E: - self.app.f_handlers.on_fileopenexcellon(signal=None) + self.app.f_handlers.on_fileopenexcellon() # Open Gerber file if key == QtCore.Qt.Key.Key_G: @@ -2952,7 +2954,7 @@ class MainGUI(QtWidgets.QMainWindow): if 'editor' in widget_name.lower(): self.app.goto_text_line() else: - self.app.f_handlers.on_fileopengerber(signal=None) + self.app.f_handlers.on_fileopengerber() # Distance Tool if key == QtCore.Qt.Key.Key_M: @@ -2964,7 +2966,7 @@ class MainGUI(QtWidgets.QMainWindow): # Open Project if key == QtCore.Qt.Key.Key_O: - self.app.f_handlers.on_file_openproject(signal=None) + self.app.f_handlers.on_file_openproject() # Open Project if key == QtCore.Qt.Key.Key_P: @@ -3033,7 +3035,7 @@ class MainGUI(QtWidgets.QMainWindow): # Rotate Object by 90 degree CCW if key == QtCore.Qt.Key.Key_R: - self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate'])) + self.app.on_rotate(silent=True, preset=-float(self.app.options['tools_transform_rotate'])) return # Run a Script @@ -3348,7 +3350,7 @@ class MainGUI(QtWidgets.QMainWindow): # Rotate Object by 90 degree CW if key == QtCore.Qt.Key.Key_R: - self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate']) + self.app.on_rotate(silent=True, preset=self.app.options['tools_transform_rotate']) # Shell toggle if key == QtCore.Qt.Key.Key_S: @@ -3379,11 +3381,11 @@ class MainGUI(QtWidgets.QMainWindow): # Zoom In if key == QtCore.Qt.Key.Key_Equal: - self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse) + self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], self.app.mouse) # Zoom Out if key == QtCore.Qt.Key.Key_Minus: - self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse) + self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], self.app.mouse) # toggle display of Notebook area if key == QtCore.Qt.Key.Key_QuoteLeft: @@ -3511,12 +3513,12 @@ class MainGUI(QtWidgets.QMainWindow): # Zoom Out if key == QtCore.Qt.Key.Key_Minus or key == '-': - self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y]) # Zoom In if key == QtCore.Qt.Key.Key_Equal or key == '=': - self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y]) # Switch to Project Tab @@ -3748,13 +3750,13 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key.Key_Minus or key == '-': self.app.grb_editor.launched_from_shortcuts = True - self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y]) return if key == QtCore.Qt.Key.Key_Equal or key == '=': self.app.grb_editor.launched_from_shortcuts = True - self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y]) return @@ -3976,13 +3978,13 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key.Key_Minus or key == '-': self.app.exc_editor.launched_from_shortcuts = True - self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y]) return if key == QtCore.Qt.Key.Key_Equal or key == '=': self.app.exc_editor.launched_from_shortcuts = True - self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], + self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y]) return @@ -4348,7 +4350,7 @@ class MainGUI(QtWidgets.QMainWindow): :param event: QT event to filter :return: """ - if self.app.defaults["global_toggle_tooltips"] is False: + if self.app.options["global_toggle_tooltips"] is False: if event.type() == QtCore.QEvent.Type.ToolTip: return True else: diff --git a/appGUI/PlotCanvas.py b/appGUI/PlotCanvas.py index d02c9b50..4c6c4271 100644 --- a/appGUI/PlotCanvas.py +++ b/appGUI/PlotCanvas.py @@ -128,7 +128,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): self.create_native() self.native.setParent(self.fcapp.ui) - axis_default_color = self.fcapp.defaults['global_axis_color'] + axis_default_color = self.fcapp.options['global_axis_color'] self.axis_transparency = 0.8 axis_color = self.color_hex2tuple(axis_default_color) @@ -144,8 +144,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): parent=self.view.scene) self.line_parent = None - if self.fcapp.defaults["global_cursor_color_enabled"]: - c_color = Color(self.fcapp.defaults["global_cursor_color"]).rgba + if self.fcapp.options["global_cursor_color_enabled"]: + c_color = Color(self.fcapp.options["global_cursor_color"]).rgba else: c_color = self.line_color @@ -168,14 +168,14 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): # draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area # all CNC have a limited workspace - if self.fcapp.defaults['global_workspace'] is True: - self.draw_workspace(workspace_size=self.fcapp.defaults["global_workspaceT"]) + if self.fcapp.options['global_workspace'] is True: + self.draw_workspace(workspace_size=self.fcapp.options["global_workspaceT"]) # HUD Display self.hud_enabled = False # enable the HUD if it is activated in FlatCAM Preferences - if self.fcapp.defaults['global_hud'] is True: + if self.fcapp.options['global_hud'] is True: self.on_toggle_hud(state=True, silent=True) # Axis Display @@ -229,7 +229,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): if state: self.axis_enabled = True - self.fcapp.defaults['global_axis'] = True + self.fcapp.options['global_axis'] = True self.v_line.parent = self.view.scene self.h_line.parent = self.view.scene self.fcapp.ui.axis_status_label.setStyleSheet(""" @@ -243,7 +243,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): self.fcapp.inform[str, bool].emit(_("Axis enabled."), False) else: self.axis_enabled = False - self.fcapp.defaults['global_axis'] = False + self.fcapp.options['global_axis'] = False self.v_line.parent = None self.h_line.parent = None self.fcapp.ui.axis_status_label.setStyleSheet("") @@ -253,7 +253,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): def apply_axis_color(self): self.fcapp.log.debug('PlotCanvas.apply_axis_color() -> axis color applied') - axis_default_color = self.fcapp.defaults['global_axis_color'] + axis_default_color = self.fcapp.options['global_axis_color'] axis_color = self.color_hex2tuple(axis_default_color) axis_color = axis_color[0], axis_color[1], axis_color[2], self.axis_transparency @@ -277,7 +277,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): self.hud_enabled = True self.rect_hud.parent = self.view self.text_hud.parent = self.view - self.fcapp.defaults['global_hud'] = True + self.fcapp.options['global_hud'] = True self.fcapp.ui.hud_label.setStyleSheet(""" QLabel { @@ -292,7 +292,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): self.hud_enabled = False self.rect_hud.parent = None self.text_hud.parent = None - self.fcapp.defaults['global_hud'] = False + self.fcapp.options['global_hud'] = False self.fcapp.ui.hud_label.setStyleSheet("") if silent is None: self.fcapp.inform[str, bool].emit(_("HUD disabled."), False) @@ -386,14 +386,14 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): color = '#dededeff' if state: - self.fcapp.defaults['global_grid_lines'] = True + self.fcapp.options['global_grid_lines'] = True self.grid_lines_enabled = True # self.grid.parent = self.view.scene self.grid._grid_color_fn['color'] = Color(color).rgba if silent is None: self.fcapp.inform[str, bool].emit(_("Grid enabled."), False) else: - self.fcapp.defaults['global_grid_lines'] = False + self.fcapp.options['global_grid_lines'] = False self.grid_lines_enabled = False # self.grid.parent = None self.grid._grid_color_fn['color'] = Color('#FFFFFFFF').rgba @@ -424,7 +424,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): self.app.log.error("PlotCanvas.draw_workspace() --> %s" % str(e)) return - if self.fcapp.defaults['global_workspace_orientation'] == 'l': + if self.fcapp.options['global_workspace_orientation'] == 'l': dims = (dims[1], dims[0]) a = np.array([(0, 0), (dims[0], 0), (dims[0], dims[1]), (0, dims[1])]) @@ -534,8 +534,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): def on_mouse_position(self, pos): - if self.fcapp.defaults['global_cursor_color_enabled']: - color = Color(self.fcapp.defaults['global_cursor_color']).rgba + if self.fcapp.options['global_cursor_color_enabled']: + color = Color(self.fcapp.options['global_cursor_color']).rgba else: color = self.line_color @@ -547,8 +547,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): # key modifiers modifiers = event.modifiers - pan_delta_x = self.fcapp.defaults["global_gridx"] - pan_delta_y = self.fcapp.defaults["global_gridy"] + pan_delta_x = self.fcapp.options["global_gridx"] + pan_delta_y = self.fcapp.options["global_gridy"] curr_pos = event.pos # Controlled pan by mouse wheel @@ -578,8 +578,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): # Update cursor self.fcapp.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), symbol='++', edge_color=self.fcapp.cursor_color_3D, - edge_width=self.fcapp.defaults["global_cursor_width"], - size=self.fcapp.defaults["global_cursor_size"]) + edge_width=self.fcapp.options["global_cursor_width"], + size=self.fcapp.options["global_cursor_size"]) def new_text_group(self, collection=None): if collection: @@ -689,7 +689,7 @@ class CursorBig(QtCore.QObject): # if 'edge_color' in kwargs: # color = kwargs['edge_color'] # else: - # if self.app.defaults['global_theme'] == 'white': + # if self.app.options['global_theme'] == 'white': # color = '#000000FF' # else: # color = '#FFFFFFFF' diff --git a/appGUI/PlotCanvas3d.py b/appGUI/PlotCanvas3d.py index 04a68b32..98051ece 100644 --- a/appGUI/PlotCanvas3d.py +++ b/appGUI/PlotCanvas3d.py @@ -151,8 +151,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas): self.container.addWidget(self.native) self.line_parent = None - if self.fcapp.defaults["global_cursor_color_enabled"]: - c_color = Color(self.fcapp.defaults["global_cursor_color"]).rgba + if self.fcapp.options["global_cursor_color_enabled"]: + c_color = Color(self.fcapp.options["global_cursor_color"]).rgba else: c_color = self.line_color @@ -253,8 +253,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas): # key modifiers modifiers = event.modifiers - pan_delta_x = self.fcapp.defaults["global_gridx"] - pan_delta_y = self.fcapp.defaults["global_gridy"] + pan_delta_x = self.fcapp.options["global_gridx"] + pan_delta_y = self.fcapp.options["global_gridy"] curr_pos = event.pos # Controlled pan by mouse wheel @@ -284,8 +284,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas): # # Update cursor # self.fcapp.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), # symbol='++', edge_color=self.fcapp.cursor_color_3D, - # edge_width=self.fcapp.defaults["global_cursor_width"], - # size=self.fcapp.defaults["global_cursor_size"]) + # edge_width=self.fcapp.options["global_cursor_width"], + # size=self.fcapp.options["global_cursor_size"]) def new_text_group(self, collection=None): if collection: diff --git a/appGUI/PlotCanvasLegacy.py b/appGUI/PlotCanvasLegacy.py index d7aab5da..a5c7e0ac 100644 --- a/appGUI/PlotCanvasLegacy.py +++ b/appGUI/PlotCanvasLegacy.py @@ -82,7 +82,7 @@ class CanvasCache(QtCore.QObject): self.axes.set_xticks([]) self.axes.set_yticks([]) - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': self.axes.set_facecolor('#FFFFFF') else: self.axes.set_facecolor('#000000') @@ -154,7 +154,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.app = app - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': theme_color = '#FFFFFF' tick_color = '#000000' self.rect_hud_color = '#0000FF10' @@ -241,7 +241,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.axes.set_aspect(1) self.axes.grid(True, color='gray') - axis_default_color = self.app.defaults['global_axis_color'] + axis_default_color = self.app.options['global_axis_color'] self.axis_transparency = 0.8 axis_color = self.color_hex2tuple(axis_default_color) @@ -322,7 +322,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.hud_enabled = False self.text_hud = self.Thud(plotcanvas=self) - if self.app.defaults['global_hud'] is True: + if self.app.options['global_hud'] is True: self.on_toggle_hud(state=True, silent=None) # enable Grid lines @@ -330,8 +330,8 @@ class PlotCanvasLegacy(QtCore.QObject): # draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area # all CNC have a limited workspace - if self.app.defaults['global_workspace'] is True: - self.draw_workspace(workspace_size=self.app.defaults["global_workspaceT"]) + if self.app.options['global_workspace'] is True: + self.draw_workspace(workspace_size=self.app.options["global_workspaceT"]) # Axis Display self.axis_enabled = True @@ -365,7 +365,7 @@ class PlotCanvasLegacy(QtCore.QObject): def apply_axis_color(self): self.app.self.app.log.debug('PlotCanvasLegacy.apply_axis_color() -> axis color applied') - axis_default_color = self.app.defaults['global_axis_color'] + axis_default_color = self.app.options['global_axis_color'] axis_color = self.color_hex2tuple(axis_default_color) axis_color = axis_color[0], axis_color[1], axis_color[2] @@ -380,7 +380,7 @@ class PlotCanvasLegacy(QtCore.QObject): if state: self.axis_enabled = True - self.app.defaults['global_axis'] = True + self.app.options['global_axis'] = True if self.h_line not in self.axes.lines and self.v_line not in self.axes.lines: self.h_line = self.axes.axhline(color=(0.70, 0.3, 0.3), linewidth=2) self.v_line = self.axes.axvline(color=(0.70, 0.3, 0.3), linewidth=2) @@ -395,7 +395,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.app.inform[str, bool].emit(_("Axis enabled."), False) else: self.axis_enabled = False - self.app.defaults['global_axis'] = False + self.app.options['global_axis'] = False if self.h_line in self.axes.lines and self.v_line in self.axes.lines: self.axes.lines.remove(self.h_line) self.axes.lines.remove(self.v_line) @@ -412,7 +412,7 @@ class PlotCanvasLegacy(QtCore.QObject): if state: self.hud_enabled = True self.text_hud.add_artist() - self.app.defaults['global_hud'] = True + self.app.options['global_hud'] = True self.app.ui.hud_label.setStyleSheet(""" QLabel @@ -426,7 +426,7 @@ class PlotCanvasLegacy(QtCore.QObject): else: self.hud_enabled = False self.text_hud.remove_artist() - self.app.defaults['global_hud'] = False + self.app.options['global_hud'] = False self.app.ui.hud_label.setStyleSheet("") if silent is None: self.app.inform[str, bool].emit(_("HUD disabled."), False) @@ -523,7 +523,7 @@ class PlotCanvasLegacy(QtCore.QObject): state = not self.grid_lines_enabled if state: - self.app.defaults['global_grid_lines'] = True + self.app.options['global_grid_lines'] = True self.grid_lines_enabled = True self.axes.grid(True) try: @@ -533,7 +533,7 @@ class PlotCanvasLegacy(QtCore.QObject): if silent is None: self.app.inform[str, bool].emit(_("Grid enabled."), False) else: - self.app.defaults['global_grid_lines'] = False + self.app.options['global_grid_lines'] = False self.grid_lines_enabled = False self.axes.grid(False) try: @@ -558,7 +558,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.app.log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e)) return - if self.app.defaults['global_workspace_orientation'] == 'l': + if self.app.options['global_workspace_orientation'] == 'l': dims = (dims[1], dims[0]) xdata = [0, dims[0], dims[0], 0, 0] @@ -631,18 +631,18 @@ class PlotCanvasLegacy(QtCore.QObject): # else: # c = MplCursor(axes=axes, color='black', linewidth=1) - if self.app.defaults["global_cursor_color_enabled"]: - color = self.app.defaults["global_cursor_color"] + if self.app.options["global_cursor_color_enabled"]: + color = self.app.options["global_cursor_color"] else: - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': color = '#000000' else: color = '#FFFFFF' if big is True: self.big_cursor = True - self.ch_line = self.axes.axhline(color=color, linewidth=self.app.defaults["global_cursor_width"]) - self.cv_line = self.axes.axvline(color=color, linewidth=self.app.defaults["global_cursor_width"]) + self.ch_line = self.axes.axhline(color=color, linewidth=self.app.options["global_cursor_width"]) + self.cv_line = self.axes.axvline(color=color, linewidth=self.app.options["global_cursor_width"]) self.big_cursor_isdisabled = False else: self.big_cursor = False @@ -667,7 +667,7 @@ class PlotCanvasLegacy(QtCore.QObject): if color: color = color else: - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': color = '#000000' else: color = '#FFFFFF' @@ -679,9 +679,9 @@ class PlotCanvasLegacy(QtCore.QObject): # Pointer (snapped) # The size of the cursor is multiplied by 1.65 because that value made the cursor similar with the # one in the OpenGL(3D) graphic engine - pointer_size = int(float(self.app.defaults["global_cursor_size"]) * 1.65) + pointer_size = int(float(self.app.options["global_cursor_size"]) * 1.65) elements = self.axes.plot(x, y, '+', color=color, ms=pointer_size, - mew=self.app.defaults["global_cursor_width"], animated=True) + mew=self.app.options["global_cursor_width"], animated=True) for el in elements: self.axes.draw_artist(el) except Exception as e: @@ -691,8 +691,8 @@ class PlotCanvasLegacy(QtCore.QObject): self.app.log.error("PlotCanvasLegacy.draw_cursor() big_cursor is False --> %s" % str(e)) else: try: - self.ch_line.set_markeredgewidth(self.app.defaults["global_cursor_width"]) - self.cv_line.set_markeredgewidth(self.app.defaults["global_cursor_width"]) + self.ch_line.set_markeredgewidth(self.app.options["global_cursor_width"]) + self.cv_line.set_markeredgewidth(self.app.options["global_cursor_width"]) except Exception: pass @@ -712,18 +712,18 @@ class PlotCanvasLegacy(QtCore.QObject): def clear_cursor(self, state): if state is True: if self.big_cursor is True and self.big_cursor_isdisabled is True: - if self.app.defaults["global_cursor_color_enabled"]: - color = self.app.defaults["global_cursor_color"] + if self.app.options["global_cursor_color_enabled"]: + color = self.app.options["global_cursor_color"] else: - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': color = '#000000' else: color = '#FFFFFF' - self.ch_line = self.axes.axhline(color=color, linewidth=self.app.defaults["global_cursor_width"]) - self.cv_line = self.axes.axvline(color=color, linewidth=self.app.defaults["global_cursor_width"]) + self.ch_line = self.axes.axhline(color=color, linewidth=self.app.options["global_cursor_width"]) + self.cv_line = self.axes.axvline(color=color, linewidth=self.app.options["global_cursor_width"]) self.big_cursor_isdisabled = False - if self.app.defaults["global_cursor_color_enabled"] is True: + if self.app.options["global_cursor_color_enabled"] is True: self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D) else: self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) @@ -1035,7 +1035,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.mouse_press_pos = (event.x, event.y) # Check for middle mouse button press - if self.app.defaults["global_pan_button"] == '2': + if self.app.options["global_pan_button"] == '2': pan_button = 3 # right button for Matplotlib else: pan_button = 2 # middle button for Matplotlib @@ -1066,7 +1066,7 @@ class PlotCanvasLegacy(QtCore.QObject): # Check for middle mouse button release to complete pan procedure # Check for middle mouse button press - if self.app.defaults["global_pan_button"] == '2': + if self.app.options["global_pan_button"] == '2': pan_button = 3 # right button for Matplotlib else: pan_button = 2 # middle button for Matplotlib @@ -1079,7 +1079,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.panning = False # And update the cursor - if self.app.defaults["global_cursor_color_enabled"] is True: + if self.app.options["global_cursor_color_enabled"] is True: self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D) else: self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) @@ -1116,7 +1116,7 @@ class PlotCanvasLegacy(QtCore.QObject): # #### Temporary place-holder for cached update ##### # self.update_screen_request.emit([0, 0, 0, 0, 0]) - if self.app.defaults["global_cursor_color_enabled"] is True: + if self.app.options["global_cursor_color_enabled"] is True: self.draw_cursor(x_pos=x, y_pos=y, color=self.app.cursor_color_3D) else: self.draw_cursor(x_pos=x, y_pos=y) @@ -1181,10 +1181,10 @@ class PlotCanvasLegacy(QtCore.QObject): # ### Grid snap if self.app.grid_status(): - if self.app.defaults["global_gridx"] != 0: + if self.app.options["global_gridx"] != 0: try: - snap_x_ = round(x / float(self.app.defaults["global_gridx"])) * \ - float(self.app.defaults["global_gridx"]) + snap_x_ = round(x / float(self.app.options["global_gridx"])) * \ + float(self.app.options["global_gridx"]) except TypeError: snap_x_ = x else: @@ -1193,19 +1193,19 @@ class PlotCanvasLegacy(QtCore.QObject): # If the Grid_gap_linked on Grid Toolbar is checked then the snap distance on GridY entry will be ignored # and it will use the snap distance from GridX entry if self.app.ui.grid_gap_link_cb.isChecked(): - if self.app.defaults["global_gridx"] != 0: + if self.app.options["global_gridx"] != 0: try: - snap_y_ = round(y / float(self.app.defaults["global_gridx"])) * \ - float(self.app.defaults["global_gridx"]) + snap_y_ = round(y / float(self.app.options["global_gridx"])) * \ + float(self.app.options["global_gridx"]) except TypeError: snap_y_ = y else: snap_y_ = y else: - if self.app.defaults["global_gridy"] != 0: + if self.app.options["global_gridy"] != 0: try: - snap_y_ = round(y / float(self.app.defaults["global_gridy"])) * \ - float(self.app.defaults["global_gridy"]) + snap_y_ = round(y / float(self.app.options["global_gridy"])) * \ + float(self.app.options["global_gridy"]) except TypeError: snap_y_ = y else: diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 1436ccf0..3f318b90 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -16,7 +16,7 @@ if '_' not in builtins.__dict__: class PreferencesUIManager: - def __init__(self, defaults: FlatCAMDefaults, data_path: str, ui, inform): + def __init__(self, defaults: FlatCAMDefaults, data_path: str, ui, inform, options): """ Class that control the Preferences Tab @@ -24,6 +24,7 @@ class PreferencesUIManager: :param data_path: a path to the file where all the preferences are stored for persistence :param ui: reference to the MainGUI class which constructs the UI :param inform: a pyqtSignal used to display information's in the StatusBar of the GUI + :param options: a dict holding the current defaults loaded in the application """ self.defaults = defaults @@ -1093,15 +1094,20 @@ class PreferencesUIManager: else: self.ui.general_pref_form.general_app_group.ge_radio.set_value(ge) - if save_to_file or should_restart is True: - # Re-fresh project options - self.ui.app.on_options_app2project() + # ############################################################################################################# + # ############################ Here is done the actual preferences updates ################################## + # ############################################################################################################# + # update the `defaults` dict from the Preferences UI form + self.defaults_read_form() + # Apply the `defaults` dict to project options + self.ui.app.options.update(self.defaults) + # ############################################################################################################# + if save_to_file or should_restart is True: self.save_defaults(silent=False) # load the defaults so they are updated into the app - self.defaults.load(filename=os.path.join(self.data_path, - 'current_defaults_%s.FlatConfig' % self.defaults.version), - inform=self.inform) + saved_filename_path = os.path.join(self.data_path, 'current_defaults_%s.FlatConfig' % self.defaults.version) + self.defaults.load(filename=saved_filename_path, inform=self.inform) settgs = QSettings("Open Source", "FlatCAM") diff --git a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py index 123f73cb..8e1291fd 100644 --- a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py @@ -63,4 +63,4 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI): self.annotation_fontcolor_entry.editingFinished.connect(self.on_annotation_fontcolor_entry) def on_annotation_fontcolor_entry(self): - self.app.defaults['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value() + self.app.options['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value() diff --git a/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py index a01b9f36..fde0a066 100644 --- a/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py @@ -238,28 +238,28 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI): # Setting travel colors handlers # ------------------------------------------------------ def on_tfill_color_entry(self): - self.app.defaults['cncjob_travel_fill'] = self.tfill_color_entry.get_value()[:7] + \ - self.app.defaults['cncjob_travel_fill'][7:9] + self.app.options['cncjob_travel_fill'] = self.tfill_color_entry.get_value()[:7] + \ + self.app.options['cncjob_travel_fill'][7:9] def on_tline_color_entry(self): - self.app.defaults['cncjob_travel_line'] = self.tline_color_entry.get_value()[:7] + \ - self.app.defaults['cncjob_travel_line'][7:9] + self.app.options['cncjob_travel_line'] = self.tline_color_entry.get_value()[:7] + \ + self.app.options['cncjob_travel_line'][7:9] def on_cncjob_alpha_changed(self, spinner_value): - self.app.defaults['cncjob_travel_fill'] = \ - self.app.defaults['cncjob_travel_fill'][:7] + \ + self.app.options['cncjob_travel_fill'] = \ + self.app.options['cncjob_travel_fill'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.app.defaults['cncjob_travel_line'] = \ - self.app.defaults['cncjob_travel_line'][:7] + \ + self.app.options['cncjob_travel_line'] = \ + self.app.options['cncjob_travel_line'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') # ------------------------------------------------------ # Setting plot colors handlers # ------------------------------------------------------ def on_fill_color_entry(self): - self.app.defaults['cncjob_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ - self.app.defaults['cncjob_plot_fill'][7:9] + self.app.options['cncjob_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ + self.app.options['cncjob_plot_fill'][7:9] def on_line_color_entry(self): - self.app.defaults['cncjob_plot_line'] = self.line_color_entry.get_value()[:7] + \ - self.app.defaults['cncjob_plot_line'][7:9] + self.app.options['cncjob_plot_line'] = self.line_color_entry.get_value()[:7] + \ + self.app.options['cncjob_plot_line'][7:9] diff --git a/appGUI/preferences/excellon/ExcellonGenPrefGroupUI.py b/appGUI/preferences/excellon/ExcellonGenPrefGroupUI.py index 13adaa86..b7946bae 100644 --- a/appGUI/preferences/excellon/ExcellonGenPrefGroupUI.py +++ b/appGUI/preferences/excellon/ExcellonGenPrefGroupUI.py @@ -366,7 +366,7 @@ class ExcellonGenPrefGroupUI(OptionsGroupUI): self.update_excellon_cb.stateChanged.connect(self.on_update_exc_export) # call it once to make sure it is updated at startup - self.on_update_exc_export(state=self.app.defaults["excellon_update"]) + self.on_update_exc_export(state=self.app.options["excellon_update"]) self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection) @@ -388,19 +388,19 @@ class ExcellonGenPrefGroupUI(OptionsGroupUI): # Setting plot colors handlers def on_fill_color_entry(self): - self.app.defaults['excellon_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ - self.app.defaults['excellon_plot_fill'][7:9] + self.app.options['excellon_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ + self.app.options['excellon_plot_fill'][7:9] def on_line_color_entry(self): - self.app.defaults['excellon_plot_line'] = self.line_color_entry.get_value()[:7] + \ - self.app.defaults['excellon_plot_line'][7:9] + self.app.options['excellon_plot_line'] = self.line_color_entry.get_value()[:7] + \ + self.app.options['excellon_plot_line'][7:9] def on_excellon_alpha_changed(self, spinner_value): - self.app.defaults['excellon_plot_fill'] = \ - self.app.defaults['excellon_plot_fill'][:7] + \ + self.app.options['excellon_plot_fill'] = \ + self.app.options['excellon_plot_fill'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.app.defaults['excellon_plot_line'] = \ - self.app.defaults['excellon_plot_line'][:7] + \ + self.app.options['excellon_plot_line'] = \ + self.app.options['excellon_plot_line'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') def on_excellon_defaults_button(self): diff --git a/appGUI/preferences/general/GeneralAPPSetGroupUI.py b/appGUI/preferences/general/GeneralAPPSetGroupUI.py index 37d969a4..ef91ae27 100644 --- a/appGUI/preferences/general/GeneralAPPSetGroupUI.py +++ b/appGUI/preferences/general/GeneralAPPSetGroupUI.py @@ -490,7 +490,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI): def on_mouse_cursor_color_enable(self, val): if val: - self.app.cursor_color_3D = self.app.defaults["global_cursor_color"] + self.app.cursor_color_3D = self.app.options["global_cursor_color"] else: theme_settings = QtCore.QSettings("Open Source", "FlatCAM") if theme_settings.contains("theme"): @@ -504,9 +504,9 @@ class GeneralAPPSetGroupUI(OptionsGroupUI): self.app.cursor_color_3D = 'gray' def on_mouse_cursor_entry(self): - self.app.defaults['global_cursor_color'] = self.mouse_cursor_entry.get_value() - self.app.cursor_color_3D = self.app.defaults["global_cursor_color"] + self.app.options['global_cursor_color'] = self.mouse_cursor_entry.get_value() + self.app.cursor_color_3D = self.app.options["global_cursor_color"] def on_axis_color_entry(self): - self.app.defaults['global_axis_color'] = self.axis_color_entry.get_value() + self.app.options['global_axis_color'] = self.axis_color_entry.get_value() self.app.plotcanvas.apply_axis_color() \ No newline at end of file diff --git a/appGUI/preferences/general/GeneralAppSettingsGroupUI.py b/appGUI/preferences/general/GeneralAppSettingsGroupUI.py index c9d29e28..0bea646b 100644 --- a/appGUI/preferences/general/GeneralAppSettingsGroupUI.py +++ b/appGUI/preferences/general/GeneralAppSettingsGroupUI.py @@ -286,7 +286,7 @@ class GeneralAppSettingsGroupUI(OptionsGroupUI2): def on_mouse_cursor_color_enable(self, val): if val: - self.app.cursor_color_3D = self.app.defaults["global_cursor_color"] + self.app.cursor_color_3D = self.app.options["global_cursor_color"] else: theme_settings = QtCore.QSettings("Open Source", "FlatCAM") if theme_settings.contains("theme"): @@ -300,5 +300,5 @@ class GeneralAppSettingsGroupUI(OptionsGroupUI2): self.app.cursor_color_3D = 'gray' def on_mouse_cursor_entry(self): - self.app.defaults['global_cursor_color'] = self.mouse_cursor_color_field.get_value() - self.app.cursor_color_3D = self.app.defaults["global_cursor_color"] + self.app.options['global_cursor_color'] = self.mouse_cursor_color_field.get_value() + self.app.cursor_color_3D = self.app.options["global_cursor_color"] diff --git a/appGUI/preferences/general/GeneralGUIPrefGroupUI.py b/appGUI/preferences/general/GeneralGUIPrefGroupUI.py index 4fbc7d9c..bb7399cd 100644 --- a/appGUI/preferences/general/GeneralGUIPrefGroupUI.py +++ b/appGUI/preferences/general/GeneralGUIPrefGroupUI.py @@ -332,11 +332,11 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): # Setting selection colors (left - right) handlers def on_sf_color_entry(self): - self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][7:9] + self.app.options['global_sel_fill'] = self.app.options['global_sel_fill'][7:9] def on_sl_color_entry(self): - self.app.defaults['global_sel_line'] = self.sl_color_entry.get_value()[:7] + \ - self.app.defaults['global_sel_line'][7:9] + self.app.options['global_sel_line'] = self.sl_color_entry.get_value()[:7] + \ + self.app.options['global_sel_line'][7:9] def on_left_right_alpha_changed(self, spinner_value): """ @@ -349,19 +349,19 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): :rtype: """ - self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][:7] + \ + self.app.options['global_sel_fill'] = self.app.options['global_sel_fill'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.app.defaults['global_sel_line'] = self.app.defaults['global_sel_line'][:7] + \ + self.app.options['global_sel_line'] = self.app.options['global_sel_line'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') # Setting selection colors (right - left) handlers def on_alt_sf_color_entry(self): - self.app.defaults['global_alt_sel_fill'] = self.alt_sf_color_entry.get_value()[:7] + \ - self.app.defaults['global_alt_sel_fill'][7:9] + self.app.options['global_alt_sel_fill'] = self.alt_sf_color_entry.get_value()[:7] + \ + self.app.options['global_alt_sel_fill'][7:9] def on_alt_sl_color_entry(self): - self.app.defaults['global_alt_sel_line'] = self.alt_sl_color_entry.get_value()[:7] + \ - self.app.defaults['global_alt_sel_line'][7:9] + self.app.options['global_alt_sel_line'] = self.alt_sl_color_entry.get_value()[:7] + \ + self.app.options['global_alt_sel_line'][7:9] def on_right_left_alpha_changed(self, spinner_value): """ @@ -374,20 +374,20 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): :rtype: """ - self.app.defaults['global_alt_sel_fill'] = self.app.defaults['global_alt_sel_fill'][:7] + \ + self.app.options['global_alt_sel_fill'] = self.app.options['global_alt_sel_fill'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.app.defaults['global_alt_sel_line'] = self.app.defaults['global_alt_sel_line'][:7] + \ + self.app.options['global_alt_sel_line'] = self.app.options['global_alt_sel_line'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') # Setting Editor colors def on_draw_color_entry(self): - self.app.defaults['global_draw_color'] = self.draw_color_entry.get_value() + self.app.options['global_draw_color'] = self.draw_color_entry.get_value() def on_sel_draw_color_entry(self): - self.app.defaults['global_sel_draw_color'] = self.sel_draw_color_entry.get_value() + self.app.options['global_sel_draw_color'] = self.sel_draw_color_entry.get_value() def on_proj_color_entry(self): - self.app.defaults['global_proj_item_color'] = self.proj_color_entry.get_value() + self.app.options['global_proj_item_color'] = self.proj_color_entry.get_value() def on_proj_color_dis_entry(self): - self.app.defaults['global_proj_item_dis_color'] = self.proj_color_dis_entry.get_value() + self.app.options['global_proj_item_dis_color'] = self.proj_color_dis_entry.get_value() diff --git a/appGUI/preferences/geometry/GeometryGenPrefGroupUI.py b/appGUI/preferences/geometry/GeometryGenPrefGroupUI.py index e9df9163..7de4be1d 100644 --- a/appGUI/preferences/geometry/GeometryGenPrefGroupUI.py +++ b/appGUI/preferences/geometry/GeometryGenPrefGroupUI.py @@ -184,7 +184,7 @@ class GeometryGenPrefGroupUI(OptionsGroupUI): self.line_color_entry.editingFinished.connect(self.on_line_color_entry) def on_line_color_entry(self): - self.app.defaults['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF' + self.app.options['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF' def optimization_selection(self, val): if platform.architecture()[0] != '64bit': diff --git a/appGUI/preferences/gerber/GerberGenPrefGroupUI.py b/appGUI/preferences/gerber/GerberGenPrefGroupUI.py index 25f240d4..a2fa8a19 100644 --- a/appGUI/preferences/gerber/GerberGenPrefGroupUI.py +++ b/appGUI/preferences/gerber/GerberGenPrefGroupUI.py @@ -292,8 +292,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI): :return: :rtype: """ - self.app.defaults['gerber_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ - self.app.defaults['gerber_plot_fill'][7:9] + self.app.options['gerber_plot_fill'] = self.fill_color_entry.get_value()[:7] + \ + self.app.options['gerber_plot_fill'][7:9] def on_gerber_alpha_changed(self, spinner_value): """ @@ -303,11 +303,11 @@ class GerberGenPrefGroupUI(OptionsGroupUI): :return: :rtype: """ - self.app.defaults['gerber_plot_fill'] = \ - self.app.defaults['gerber_plot_fill'][:7] + \ + self.app.options['gerber_plot_fill'] = \ + self.app.options['gerber_plot_fill'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.app.defaults['gerber_plot_line'] = \ - self.app.defaults['gerber_plot_line'][:7] + \ + self.app.options['gerber_plot_line'] = \ + self.app.options['gerber_plot_line'][:7] + \ (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') def on_line_color_changed(self): @@ -316,8 +316,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI): :return: :rtype: """ - self.app.defaults['gerber_plot_line'] = (self.line_color_entry.get_value()[:7] + - self.app.defaults['gerber_plot_line'][7:9]) + self.app.options['gerber_plot_line'] = (self.line_color_entry.get_value()[:7] + + self.app.options['gerber_plot_line'][7:9]) def on_colors_clear_clicked(self): """ @@ -325,7 +325,7 @@ class GerberGenPrefGroupUI(OptionsGroupUI): :return: :rtype: """ - self.app.defaults["gerber_color_list"].clear() + self.app.options["gerber_color_list"].clear() self.app.inform.emit('[WARNING_NOTCL] %s' % _("Stored colors for Gerber objects are deleted.")) def on_layers_manager(self): @@ -348,7 +348,7 @@ class ColorsManager(QtWidgets.QDialog): self.ok = False self.color_list = [] - self.original_color_list = deepcopy(self.app.defaults["gerber_color_list"]) + self.original_color_list = deepcopy(self.app.options["gerber_color_list"]) self.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/set_colors64.png')) self.setWindowTitle('%s' % _('Color manager')) @@ -502,8 +502,8 @@ class ColorsManager(QtWidgets.QDialog): layer_nr = list_len self.original_color_list.append( ( - self.app.defaults['gerber_plot_line'], - self.app.defaults['gerber_plot_fill'], + self.app.options['gerber_plot_line'], + self.app.options['gerber_plot_fill'], '%s_%d' % (_("Layer"), layer_nr) ) ) diff --git a/appGUI/preferences/tools/Tools2QRCodePrefGroupUI.py b/appGUI/preferences/tools/Tools2QRCodePrefGroupUI.py index 43a61c57..46d9f0ec 100644 --- a/appGUI/preferences/tools/Tools2QRCodePrefGroupUI.py +++ b/appGUI/preferences/tools/Tools2QRCodePrefGroupUI.py @@ -186,7 +186,7 @@ class Tools2QRCodePrefGroupUI(OptionsGroupUI): self.back_color_entry.editingFinished.connect(self.on_qrcode_back_color_entry) def on_qrcode_fill_color_entry(self): - self.app.defaults['tools_qrcode_fill_color'] = self.fill_color_entry.get_value() + self.app.options['tools_qrcode_fill_color'] = self.fill_color_entry.get_value() def on_qrcode_back_color_entry(self): - self.app.defaults['tools_qrcode_back_color'] = self.back_color_entry.get_value() + self.app.options['tools_qrcode_back_color'] = self.back_color_entry.get_value() diff --git a/appGUI/preferences/tools/ToolsFilmPrefGroupUI.py b/appGUI/preferences/tools/ToolsFilmPrefGroupUI.py index eb0a3474..4c208718 100644 --- a/appGUI/preferences/tools/ToolsFilmPrefGroupUI.py +++ b/appGUI/preferences/tools/ToolsFilmPrefGroupUI.py @@ -375,4 +375,4 @@ class ToolsFilmPrefGroupUI(OptionsGroupUI): self.film_color_entry.editingFinished.connect(self.on_film_color_entry) def on_film_color_entry(self): - self.app.defaults['tools_film_color'] = self.film_color_entry.get_value() + self.app.options['tools_film_color'] = self.film_color_entry.get_value() diff --git a/appObjects/AppObject.py b/appObjects/AppObject.py index 54af32a4..72e86e6e 100644 --- a/appObjects/AppObject.py +++ b/appObjects/AppObject.py @@ -300,28 +300,28 @@ class AppObject(QtCore.QObject): if obj.kind in ['excellon', 'gerber']: try: if obj.kind == 'excellon': - if self.app.defaults["excellon_color"]: - obj.fill_color = self.app.defaults["excellon_color"][0] - obj.outline_color = self.app.defaults["excellon_color"][1] + if self.app.options["excellon_color"]: + obj.fill_color = self.app.options["excellon_color"][0] + obj.outline_color = self.app.options["excellon_color"][1] else: - obj.fill_color = self.app.defaults["excellon_plot_fill"] - obj.outline_color = self.app.defaults["excellon_plot_line"] + obj.fill_color = self.app.options["excellon_plot_fill"] + obj.outline_color = self.app.options["excellon_plot_line"] if obj.kind == 'gerber': - if self.app.defaults["gerber_store_color_list"] is True: + if self.app.options["gerber_store_color_list"] is True: group = self.app.collection.group_items["gerber"] index = group.child_count() - 1 # when loading a Gerber object always create a color tuple (line color, fill_color, layer_name) - # and add it to the self.app.defaults["gerber_color_list"] from where it will be picked and used + # and add it to the self.app.options["gerber_color_list"] from where it will be picked and used try: - colors = self.app.defaults["gerber_color_list"][index] + colors = self.app.options["gerber_color_list"][index] except IndexError: - obj.outline_color = self.app.defaults["gerber_plot_line"] - obj.fill_color = self.app.defaults["gerber_plot_fill"] + obj.outline_color = self.app.options["gerber_plot_line"] + obj.fill_color = self.app.options["gerber_plot_fill"] obj.alpha_level = str(hex(int(obj.fill_color[7:9], 16))[2:]) colors = (obj.outline_color, obj.fill_color, '%s_%d' % (_("Layer"), int(index))) - self.app.defaults["gerber_color_list"].append(colors) + self.app.options["gerber_color_list"].append(colors) new_line_color = colors[0] new_fill = colors[1] @@ -330,9 +330,9 @@ class AppObject(QtCore.QObject): obj.fill_color = new_fill obj.alpha_level = new_alpha else: - obj.outline_color = self.app.defaults["gerber_plot_line"] - obj.fill_color = self.app.defaults["gerber_plot_fill"] - obj.alpha_level = str(hex(int(self.app.defaults['gerber_plot_fill'][7:9], 16))[2:]) + obj.outline_color = self.app.options["gerber_plot_line"] + obj.fill_color = self.app.options["gerber_plot_fill"] + obj.alpha_level = str(hex(int(self.app.options['gerber_plot_fill'][7:9], 16))[2:]) except Exception as e: self.app.log.error("AppObject.new_object() -> setting colors error. %s" % str(e)) @@ -352,7 +352,7 @@ class AppObject(QtCore.QObject): def plotting_task(t_obj): with self.app.proc_container.new('%s ...' % _("Plotting")): if t_obj.kind == 'cncjob': - t_obj.plot(kind=self.app.defaults["cncjob_plot_kind"]) + t_obj.plot(kind=self.app.options["cncjob_plot_kind"]) elif t_obj.kind == 'gerber': t_obj.plot(color=t_obj.outline_color, face_color=t_obj.fill_color) else: @@ -363,8 +363,8 @@ class AppObject(QtCore.QObject): self.app.log.debug(msg) self.object_plotted.emit(t_obj) - if t_obj.kind == 'gerber' and self.app.defaults["gerber_buffering"] != 'full' and \ - self.app.defaults["gerber_delayed_buffering"]: + if t_obj.kind == 'gerber' and self.app.options["gerber_buffering"] != 'full' and \ + self.app.options["gerber_delayed_buffering"]: t_obj.do_buffer_signal.emit() # Send to worker diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 7e3c1f67..70176175 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -50,7 +50,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): CNCjob.__init__(self, units=units, kind=kind, z_move=z_move, feedrate=feedrate, feedrate_rapid=feedrate_rapid, z_cut=z_cut, tooldia=tooldia, - spindlespeed=spindlespeed, steps_per_circle=int(self.app.defaults["cncjob_steps_per_circle"])) + spindlespeed=spindlespeed, steps_per_circle=int(self.app.options["cncjob_steps_per_circle"])) FlatCAMObj.__init__(self, name) @@ -66,16 +66,16 @@ class CNCJobObject(FlatCAMObj, CNCjob): "type": 'Geometry', # "toolchange_macro": '', # "toolchange_macro_enable": False - "tools_al_travelz": self.app.defaults["tools_al_travelz"], - "tools_al_probe_depth": self.app.defaults["tools_al_probe_depth"], - "tools_al_probe_fr": self.app.defaults["tools_al_probe_fr"], - "tools_al_controller": self.app.defaults["tools_al_controller"], - "tools_al_method": self.app.defaults["tools_al_method"], - "tools_al_mode": self.app.defaults["tools_al_mode"], - "tools_al_rows": self.app.defaults["tools_al_rows"], - "tools_al_columns": self.app.defaults["tools_al_columns"], - "tools_al_grbl_jog_step": self.app.defaults["tools_al_grbl_jog_step"], - "tools_al_grbl_jog_fr": self.app.defaults["tools_al_grbl_jog_fr"], + "tools_al_travelz": self.app.options["tools_al_travelz"], + "tools_al_probe_depth": self.app.options["tools_al_probe_depth"], + "tools_al_probe_fr": self.app.options["tools_al_probe_fr"], + "tools_al_controller": self.app.options["tools_al_controller"], + "tools_al_method": self.app.options["tools_al_method"], + "tools_al_mode": self.app.options["tools_al_mode"], + "tools_al_rows": self.app.options["tools_al_rows"], + "tools_al_columns": self.app.options["tools_al_columns"], + "tools_al_grbl_jog_step": self.app.options["tools_al_grbl_jog_step"], + "tools_al_grbl_jog_fr": self.app.options["tools_al_grbl_jog_fr"], }) ''' @@ -474,7 +474,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.updateplot_button.hide() # set the kind of geometries are plotted by default with plot2() from camlib.CNCJob - self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"]) + self.ui.cncplot_method_combo.set_value(self.app.options["cncjob_plot_kind"]) # ############################################################################################################# # ##################################### SIGNALS CONNECTIONS ################################################### @@ -489,7 +489,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.annotation_cb.stateChanged.connect(self.on_annotation_change) # set if to display text annotations - self.ui.annotation_cb.set_value(self.app.defaults["cncjob_annotation"]) + self.ui.annotation_cb.set_value(self.app.options["cncjob_annotation"]) # update plot button - active only for SingleGeo type objects self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click) @@ -518,8 +518,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): # ###################################### END Signal connections ############################################### # ############################################################################################################# - self.append_snippet = self.app.defaults['cncjob_append'] - self.prepend_snippet = self.app.defaults['cncjob_prepend'] + self.append_snippet = self.app.options['cncjob_append'] + self.prepend_snippet = self.app.options['cncjob_prepend'] if self.append_snippet != '' or self.prepend_snippet != '': self.ui.snippets_cb.set_value(True) @@ -543,7 +543,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.source_file = gc # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -669,7 +669,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): _filter_ = "HPGL Files .plt (*.plt);;All Files (*.*)" else: save_gcode = True - _filter_ = self.app.defaults['cncjob_save_filters'] + _filter_ = self.app.options['cncjob_save_filters'] try: dir_file_to_save = self.app.get_last_save_folder() + '/' + str(name) @@ -719,7 +719,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): return 'fail' try: - force_windows_line_endings = self.app.defaults['cncjob_line_ending'] + force_windows_line_endings = self.app.options['cncjob_line_ending'] if force_windows_line_endings and sys.platform != 'win32': with open(filename, 'w', newline='\r\n') as f: for line in self.source_file: @@ -738,7 +738,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): ) return 'fail' - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("gcode", filename) self.app.file_saved.emit("gcode", filename) self.app.inform.emit('[success] %s: %s' % (_("File saved to"), filename)) @@ -966,9 +966,9 @@ class CNCJobObject(FlatCAMObj, CNCjob): include_header = True if preamble == '': - preamble = self.app.defaults["cncjob_prepend"] + preamble = self.app.options["cncjob_prepend"] if postamble == '': - postamble = self.app.defaults["cncjob_append"] + postamble = self.app.options["cncjob_append"] try: if self.special_group: @@ -1026,7 +1026,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble g = '' - end_gcode = self.gcode_footer() if self.app.defaults['cncjob_footer'] is True else '' + end_gcode = self.gcode_footer() if self.app.options['cncjob_footer'] is True else '' if preamble != '' and postamble != '': g = self.gc_start + '\n' + preamble + '\n' + gcode + '\n' + postamble + '\n' + end_gcode if preamble == '': @@ -1058,7 +1058,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): else: gcode += self.gcode - end_gcode = self.gcode_footer() if self.app.defaults['cncjob_footer'] is True else '' + end_gcode = self.gcode_footer() if self.app.options['cncjob_footer'] is True else '' # detect if using a HPGL preprocessor hpgl = False @@ -1146,7 +1146,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # Write if filename is not None: try: - force_windows_line_endings = self.app.defaults['cncjob_line_ending'] + force_windows_line_endings = self.app.options['cncjob_line_ending'] if force_windows_line_endings and sys.platform != 'win32': with open(filename, 'w', newline='\r\n') as f: for line in lines: @@ -1166,7 +1166,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): return 'fail' elif to_file is False: # Just for adding it to the recent files list. - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("cncjob", filename) self.app.file_saved.emit("cncjob", filename) diff --git a/appObjects/FlatCAMDocument.py b/appObjects/FlatCAMDocument.py index a0ca68df..418cbc25 100644 --- a/appObjects/FlatCAMDocument.py +++ b/appObjects/FlatCAMDocument.py @@ -65,7 +65,7 @@ class DocumentObject(FlatCAMObj): self.to_form() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) self.document_editor_tab = AppTextEditor(app=self.app) @@ -73,15 +73,15 @@ class DocumentObject(FlatCAMObj): QTextEdit {selection-background-color:%s; selection-color:white; } - """ % self.app.defaults["document_sel_color"] + """ % self.app.options["document_sel_color"] self.document_editor_tab.code_editor.setStyleSheet(stylesheet) self.document_editor_tab.buttonRun.hide() - self.ui.autocomplete_cb.set_value(self.app.defaults['document_autocompleter']) - self.on_autocomplete_changed(state=self.app.defaults['document_autocompleter']) - self.on_tab_size_change(val=self.app.defaults['document_tab_size']) + self.ui.autocomplete_cb.set_value(self.app.options['document_autocompleter']) + self.on_autocomplete_changed(state=self.app.options['document_autocompleter']) + self.on_tab_size_change(val=self.app.options['document_tab_size']) flt = "FlatCAM Docs (*.FlatDoc);;All Files (*.*)" @@ -122,15 +122,15 @@ class DocumentObject(FlatCAMObj): self.ui.tab_size_spinner.returnPressed.connect(self.on_tab_size_change) # ####################################################################### - self.ui.font_color_entry.set_value(self.app.defaults['document_font_color']) + self.ui.font_color_entry.set_value(self.app.options['document_font_color']) self.ui.font_color_button.setStyleSheet( - "background-color:%s" % str(self.app.defaults['document_font_color'])) + "background-color:%s" % str(self.app.options['document_font_color'])) - self.ui.sel_color_entry.set_value(self.app.defaults['document_sel_color']) + self.ui.sel_color_entry.set_value(self.app.options['document_sel_color']) self.ui.sel_color_button.setStyleSheet( - "background-color:%s" % self.app.defaults['document_sel_color']) + "background-color:%s" % self.app.options['document_sel_color']) - self.ui.font_size_cb.setCurrentIndex(int(self.app.defaults['document_font_size'])) + self.ui.font_size_cb.setCurrentIndex(int(self.app.options['document_font_size'])) # self.document_editor_tab.handleTextChanged() self.ser_attrs = ['options', 'kind', 'source_file'] @@ -224,7 +224,7 @@ class DocumentObject(FlatCAMObj): tab_balue = int(self.ui.tab_size_spinner.get_value()) self.document_editor_tab.code_editor.setTabStopDistance(tab_balue) - self.app.defaults['document_tab_size'] = tab_balue + self.app.options['document_tab_size'] = tab_balue self.ui.tab_size_spinner.returnPressed.connect(self.on_tab_size_change) @@ -268,11 +268,11 @@ class DocumentObject(FlatCAMObj): # Setting font colors handlers def on_font_color_entry(self): - self.app.defaults['document_font_color'] = self.ui.font_color_entry.get_value() - self.ui.font_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['document_font_color'])) + self.app.options['document_font_color'] = self.ui.font_color_entry.get_value() + self.ui.font_color_button.setStyleSheet("background-color:%s" % str(self.app.options['document_font_color'])) def on_font_color_button(self): - current_color = QtGui.QColor(self.app.defaults['document_font_color']) + current_color = QtGui.QColor(self.app.options['document_font_color']) c_dialog = QtWidgets.QColorDialog() font_color = c_dialog.getColor(initial=current_color) @@ -285,15 +285,15 @@ class DocumentObject(FlatCAMObj): new_val = str(font_color.name()) self.ui.font_color_entry.set_value(new_val) - self.app.defaults['document_font_color'] = new_val + self.app.options['document_font_color'] = new_val # Setting selection colors handlers def on_selection_color_entry(self): - self.app.defaults['document_sel_color'] = self.ui.sel_color_entry.get_value() - self.ui.sel_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['document_sel_color'])) + self.app.options['document_sel_color'] = self.ui.sel_color_entry.get_value() + self.ui.sel_color_button.setStyleSheet("background-color:%s" % str(self.app.options['document_sel_color'])) def on_selection_color_button(self): - current_color = QtGui.QColor(self.app.defaults['document_sel_color']) + current_color = QtGui.QColor(self.app.options['document_sel_color']) c_dialog = QtWidgets.QColorDialog() sel_color = c_dialog.getColor(initial=current_color) @@ -311,7 +311,7 @@ class DocumentObject(FlatCAMObj): new_val = str(sel_color.name()) self.ui.sel_color_entry.set_value(new_val) - self.app.defaults['document_sel_color'] = new_val + self.app.options['document_sel_color'] = new_val def mirror(self, axis, point): pass diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index 7984c03a..03703511 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -40,7 +40,7 @@ class ExcellonObject(FlatCAMObj, Excellon): def __init__(self, name): self.decimals = self.app.decimals - self.circle_steps = int(self.app.defaults["excellon_circle_steps"]) + self.circle_steps = int(self.app.options["excellon_circle_steps"]) Excellon.__init__(self, excellon_circle_steps=self.circle_steps) FlatCAMObj.__init__(self, name) @@ -96,8 +96,8 @@ class ExcellonObject(FlatCAMObj, Excellon): self.multigeo = False self.units_found = self.app.app_units - self.fill_color = self.app.defaults['excellon_plot_fill'] - self.outline_color = self.app.defaults['excellon_plot_line'] + self.fill_color = self.app.options['excellon_plot_fill'] + self.outline_color = self.app.options['excellon_plot_line'] self.alpha_level = 'bf' # the key is the tool id and the value is a list of shapes keys (indexes) @@ -189,7 +189,7 @@ class ExcellonObject(FlatCAMObj, Excellon): self.init_context_menu() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def set_offset_values(self): @@ -244,8 +244,8 @@ class ExcellonObject(FlatCAMObj, Excellon): self.ui.tools_table.setColumnHidden(4, False) self.ui.tools_table.setColumnHidden(5, False) self.ui.table_visibility_cb.show() - self.ui.table_visibility_cb.set_value(self.app.defaults["excellon_tools_table_display"]) - self.on_table_visibility_toggle(state=self.app.defaults["excellon_tools_table_display"]) + self.ui.table_visibility_cb.set_value(self.app.options["excellon_tools_table_display"]) + self.on_table_visibility_toggle(state=self.app.options["excellon_tools_table_display"]) self.ui.autoload_db_cb.show() # Context Menu section @@ -356,8 +356,8 @@ class ExcellonObject(FlatCAMObj, Excellon): h_color = QtGui.QColor(red, green, blue, alpha) self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color) else: - h1 = self.app.defaults["excellon_plot_fill"][1:7] - h2 = self.app.defaults["excellon_plot_fill"][7:9] + h1 = self.app.options["excellon_plot_fill"][1:7] + h2 = self.app.options["excellon_plot_fill"][7:9] h_color = QtGui.QColor('#' + h2 + h1) self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color) @@ -1184,10 +1184,10 @@ class ExcellonObject(FlatCAMObj, Excellon): # self.obj_options['feedrate_rapid'] = float(self.obj_options['feedrate_rapid']) * factor # self.obj_options['toolchangez'] = float(self.obj_options['toolchangez']) * factor # - # if self.app.defaults["excellon_toolchangexy"] == '': + # if self.app.options["excellon_toolchangexy"] == '': # self.obj_options['toolchangexy'] = "0.0, 0.0" # else: - # coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")] + # coords_xy = [float(eval(coord)) for coord in self.app.options["excellon_toolchangexy"].split(",")] # if len(coords_xy) < 2: # self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences has to be " # "in the format (x, y) \n" @@ -1216,7 +1216,7 @@ class ExcellonObject(FlatCAMObj, Excellon): self.build_ui() def on_autoload_db_toggled(self, state): - self.app.defaults["excellon_autoload_db"] = True if state else False + self.app.options["excellon_autoload_db"] = True if state else False def on_plot_cb_click(self): if self.muted_ui: diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index f7bd554d..f254e194 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -47,7 +47,7 @@ class GeometryObject(FlatCAMObj, Geometry): def __init__(self, name): self.decimals = self.app.decimals - self.circle_steps = int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["geometry_circle_steps"]) FlatCAMObj.__init__(self, name) Geometry.__init__(self, geo_steps_per_circle=self.circle_steps) @@ -89,17 +89,17 @@ class GeometryObject(FlatCAMObj, Geometry): }) if "tools_mill_tooldia" not in self.obj_options: - if type(self.app.defaults["tools_mill_tooldia"]) == float: - self.obj_options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"] + if type(self.app.options["tools_mill_tooldia"]) == float: + self.obj_options["tools_mill_tooldia"] = self.app.options["tools_mill_tooldia"] else: try: - tools_string = self.app.defaults["tools_mill_tooldia"].split(",") + tools_string = self.app.options["tools_mill_tooldia"].split(",") tools_diameters = [eval(a) for a in tools_string if a != ''] self.obj_options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 except Exception as e: self.app.log.error("FlatCAMObj.GeometryObject.init() --> %s" % str(e)) - self.obj_options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"] + self.obj_options["tools_mill_startz"] = self.app.options["tools_mill_startz"] # this will hold the tool unique ID that is useful when having multiple tools with same diameter self.tooluid = 0 @@ -136,24 +136,24 @@ class GeometryObject(FlatCAMObj, Geometry): # engine of FlatCAM. Most likely are generated by some tools and are special cases of geometries. self.special_group = None - # self.old_pp_state = self.app.defaults["tools_mill_multidepth"] - # self.old_toolchangeg_state = self.app.defaults["tools_mill_toolchange"] + # self.old_pp_state = self.app.options["tools_mill_multidepth"] + # self.old_toolchangeg_state = self.app.options["tools_mill_toolchange"] self.units_found = self.app.app_units # this variable can be updated by the Object that generates the geometry self.tool_type = 'C1' # save here the old value for the Cut Z before it is changed by selecting a V-shape type tool in the tool table - self.old_cutz = self.app.defaults["tools_mill_cutz"] + self.old_cutz = self.app.options["tools_mill_cutz"] - self.fill_color = self.app.defaults['geometry_plot_line'] - self.outline_color = self.app.defaults['geometry_plot_line'] + self.fill_color = self.app.options['geometry_plot_line'] + self.outline_color = self.app.options['geometry_plot_line'] self.alpha_level = 'FF' self.param_fields = {} # store here the state of the exclusion checkbox state to be restored after building the UI - self.exclusion_area_cb_is_checked = self.app.defaults["tools_mill_area_exclusion"] + self.exclusion_area_cb_is_checked = self.app.options["tools_mill_area_exclusion"] # Attributes to be included in serialization # Always append to it because it carries contents @@ -397,7 +397,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui.geo_tools_table.itemSelectionChanged.connect(self.on_row_changed) self.ui.geo_tools_table.horizontalHeader().sectionClicked.connect(self.table_toggle_all) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def on_row_changed(self): @@ -563,7 +563,7 @@ class GeometryObject(FlatCAMObj, Geometry): def export_dxf(self): dwg = None - dxf_format = self.app.defaults['geometry_dxf_format'] + dxf_format = self.app.options['geometry_dxf_format'] try: dwg = ezdxf.new(dxf_format) @@ -638,8 +638,8 @@ class GeometryObject(FlatCAMObj, Geometry): outname = "%s_%s" % (self.obj_options["name"], 'cnc') if outname is None else outname tools_dict = self.sel_tools if tools_dict is None else tools_dict - segx = segx if segx is not None else float(self.app.defaults['geometry_segx']) - segy = segy if segy is not None else float(self.app.defaults['geometry_segy']) + segx = segx if segx is not None else float(self.app.options['geometry_segx']) + segy = segy if segy is not None else float(self.app.options['geometry_segy']) try: xmin = self.obj_options['xmin'] @@ -679,11 +679,11 @@ class GeometryObject(FlatCAMObj, Geometry): job_obj.multigeo = False job_obj.tools.clear() - job_obj.segx = segx if segx else float(self.app.defaults["geometry_segx"]) - job_obj.segy = segy if segy else float(self.app.defaults["geometry_segy"]) + job_obj.segx = segx if segx else float(self.app.options["geometry_segx"]) + job_obj.segy = segy if segy else float(self.app.options["geometry_segy"]) - job_obj.z_pdepth = float(self.app.defaults["tools_mill_z_pdepth"]) - job_obj.feedrate_probe = float(self.app.defaults["tools_mill_feedrate_probe"]) + job_obj.z_pdepth = float(self.app.options["tools_mill_z_pdepth"]) + job_obj.feedrate_probe = float(self.app.options["tools_mill_feedrate_probe"]) total_gcode = '' for tooluid_key in list(tools_dict.keys()): @@ -742,11 +742,11 @@ class GeometryObject(FlatCAMObj, Geometry): dwelltime = tools_dict[tooluid_key]['data']["tools_mill_dwelltime"] pp_geometry_name = tools_dict[tooluid_key]['data']["tools_mill_ppname_g"] - spindledir = self.app.defaults['tools_mill_spindledir'] + spindledir = self.app.options['tools_mill_spindledir'] tool_solid_geometry = self.solid_geometry - job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] # Propagate options job_obj.obj_options["tooldia"] = tooldia_val @@ -758,7 +758,7 @@ class GeometryObject(FlatCAMObj, Geometry): # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially # to a value of 0.0005 which is 20 times less than 0.01 - tol = float(self.app.defaults['global_tolerance']) / 20 + tol = float(self.app.options['global_tolerance']) / 20 res, start_gcode = job_obj.generate_from_geometry_2( self, tooldia=tooldia_val, offset=tool_offset, tolerance=tol, z_cut=z_cut, z_move=z_move, @@ -821,11 +821,11 @@ class GeometryObject(FlatCAMObj, Geometry): job_obj.multigeo = True job_obj.tools.clear() - job_obj.segx = segx if segx else float(self.app.defaults["geometry_segx"]) - job_obj.segy = segy if segy else float(self.app.defaults["geometry_segy"]) + job_obj.segx = segx if segx else float(self.app.options["geometry_segx"]) + job_obj.segy = segy if segy else float(self.app.options["geometry_segy"]) - job_obj.z_pdepth = float(self.app.defaults["tools_mill_z_pdepth"]) - job_obj.feedrate_probe = float(self.app.defaults["tools_mill_feedrate_probe"]) + job_obj.z_pdepth = float(self.app.options["tools_mill_z_pdepth"]) + job_obj.feedrate_probe = float(self.app.options["tools_mill_feedrate_probe"]) # make sure that trying to make a CNCJob from an empty file is not creating an app crash if not self.solid_geometry: @@ -847,7 +847,7 @@ class GeometryObject(FlatCAMObj, Geometry): }) if "optimization_type" not in tools_dict[tooluid_key]['data']: tools_dict[tooluid_key]['data']["tools_mill_optimization_type"] = \ - self.app.defaults["tools_mill_optimization_type"] + self.app.options["tools_mill_optimization_type"] # find the tool_dia associated with the tooluid_key # search in the self.tools for the sel_tool_dia and when found see what tooluid has @@ -896,11 +896,11 @@ class GeometryObject(FlatCAMObj, Geometry): # dwelltime = tools_dict[tooluid_key]['data']["dwelltime"] # pp_geometry_name = tools_dict[tooluid_key]['data']["ppname_g"] # - # spindledir = self.app.defaults['geometry_spindledir'] + # spindledir = self.app.options['geometry_spindledir'] tool_solid_geometry = self.tools[tooluid_key]['solid_geometry'] - job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] # Propagate options job_obj.obj_options["tooldia"] = tooldia_val @@ -909,7 +909,7 @@ class GeometryObject(FlatCAMObj, Geometry): # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially # to a value of 0.0005 which is 20 times less than 0.01 - tol = float(self.app.defaults['global_tolerance']) / 20 + tol = float(self.app.options['global_tolerance']) / 20 tool_lst = list(tools_dict.keys()) is_first = True if tooluid_key == tool_lst[0] else False @@ -1034,8 +1034,8 @@ class GeometryObject(FlatCAMObj, Geometry): multidepth = multidepth if multidepth is not None else self.obj_options["tools_mill_multidepth"] depthperpass = dpp if dpp is not None else float(self.obj_options["tools_mill_depthperpass"]) - segx = segx if segx is not None else float(self.app.defaults['geometry_segx']) - segy = segy if segy is not None else float(self.app.defaults['geometry_segy']) + segx = segx if segx is not None else float(self.app.options['geometry_segx']) + segy = segy if segy is not None else float(self.app.options['geometry_segy']) extracut = extracut if extracut is not None else float(self.obj_options["tools_mill_extracut"]) extracut_length = extracut_length if extracut_length is not None else float(self.obj_options[ @@ -1079,8 +1079,8 @@ class GeometryObject(FlatCAMObj, Geometry): job_obj.obj_options["tooldia"] = tooldia job_obj.obj_options["tools_mill_tooldia"] = tooldia - job_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + job_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + job_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] job_obj.obj_options['type'] = 'Geometry' job_obj.obj_options['tool_dia'] = tooldia @@ -1098,7 +1098,7 @@ class GeometryObject(FlatCAMObj, Geometry): # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially # to a value of 0.0005 which is 20 times less than 0.01 - tol = float(self.app.defaults['global_tolerance']) / 20 + tol = float(self.app.options['global_tolerance']) / 20 res, start_gcode = job_obj.generate_from_geometry_2( self, tooldia=tooldia, offset=offset, tolerance=tol, z_cut=z_cut, z_move=z_move, feedrate=feedrate, feedrate_z=feedrate_z, feedrate_rapid=feedrate_rapid, spindlespeed=spindlespeed, dwell=dwell, @@ -1319,10 +1319,10 @@ class GeometryObject(FlatCAMObj, Geometry): self.obj_options["toolchangez"] = float(self.obj_options["toolchangez"]) * factor - if self.app.defaults["tools_mill_toolchangexy"] == '': + if self.app.options["tools_mill_toolchangexy"] == '': self.obj_options['toolchangexy'] = "0.0, 0.0" else: - coords_xy = [float(eval(coord)) for coord in self.app.defaults["tools_mill_toolchangexy"].split(",")] + coords_xy = [float(eval(coord)) for coord in self.app.options["tools_mill_toolchangexy"].split(",")] if len(coords_xy) < 2: self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences " @@ -1465,7 +1465,7 @@ class GeometryObject(FlatCAMObj, Geometry): color = self.tools[tooluid_key]['data']['override_color'] else: color = random_color() if self.obj_options['multicolored'] else \ - self.app.defaults["geometry_plot_line"] + self.app.options["geometry_plot_line"] self.plot_element(solid_geometry, visible=visible, color=color) else: @@ -1474,7 +1474,7 @@ class GeometryObject(FlatCAMObj, Geometry): color = self.tools[plot_tool]['data']['override_color'] else: color = random_color() if self.obj_options['multicolored'] else \ - self.app.defaults["geometry_plot_line"] + self.app.options["geometry_plot_line"] self.plot_element(solid_geometry, visible=visible, color=color) else: @@ -1482,7 +1482,7 @@ class GeometryObject(FlatCAMObj, Geometry): # for SingleGeo if self.solid_geometry: solid_geometry = self.solid_geometry - color = self.app.defaults["geometry_plot_line"] + color = self.app.options["geometry_plot_line"] self.plot_element(solid_geometry, visible=visible, color=color) diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 4c455aca..72383af1 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -43,7 +43,7 @@ class GerberObject(FlatCAMObj, Gerber): def __init__(self, name): self.decimals = self.app.decimals - self.circle_steps = int(self.app.defaults["gerber_circle_steps"]) + self.circle_steps = int(self.app.options["gerber_circle_steps"]) Gerber.__init__(self, steps_per_circle=self.circle_steps) FlatCAMObj.__init__(self, name) @@ -93,8 +93,8 @@ class GerberObject(FlatCAMObj, Gerber): self.units_found = self.app.app_units - self.fill_color = self.app.defaults['gerber_plot_fill'] - self.outline_color = self.app.defaults['gerber_plot_line'] + self.fill_color = self.app.options['gerber_plot_fill'] + self.outline_color = self.app.options['gerber_plot_line'] self.alpha_level = 'bf' # keep track if the UI is built so we don't have to build it every time @@ -178,10 +178,10 @@ class GerberObject(FlatCAMObj, Gerber): self.do_buffer_signal.connect(self.on_generate_buffer) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) - if self.app.defaults["gerber_buffering"] == 'no': + if self.app.options["gerber_buffering"] == 'no': self.ui.create_buffer_button.show() try: self.ui.create_buffer_button.clicked.disconnect(self.on_generate_buffer) @@ -542,20 +542,20 @@ class GerberObject(FlatCAMObj, Gerber): work_geo = geometry if dia is None: - dia = float(self.app.defaults["tools_iso_tooldia"]) + dia = float(self.app.options["tools_iso_tooldia"]) if passes is None: - passes = int(self.app.defaults["tools_iso_passes"]) + passes = int(self.app.options["tools_iso_passes"]) if overlap is None: - overlap = float(self.app.defaults["tools_iso_overlap"]) + overlap = float(self.app.options["tools_iso_overlap"]) overlap /= 100.0 - combine = self.app.defaults["tools_iso_combine_passes"] if combine is None else bool(combine) + combine = self.app.options["tools_iso_combine_passes"] if combine is None else bool(combine) if milling_type is None: - milling_type = self.app.defaults["tools_iso_milling_type"] + milling_type = self.app.options["tools_iso_milling_type"] if iso_type is None: iso_t = 2 @@ -578,7 +578,7 @@ class GerberObject(FlatCAMObj, Gerber): def iso_init(geo_obj, app_obj): # Propagate options geo_obj.obj_options["tools_mill_tooldia"] = str(dia) - geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"] + geo_obj.tool_type = self.app.options["tools_iso_tool_shape"] geo_obj.multigeo = True geo_obj.solid_geometry = [] @@ -643,7 +643,7 @@ class GerberObject(FlatCAMObj, Gerber): # ############################################################ # ########## AREA SUBTRACTION ################################ # ############################################################ - # if self.app.defaults["tools_iso_except"]: + # if self.app.options["tools_iso_except"]: # self.app.proc_container.update_view_text(' %s' % _("Subtracting Geo")) # geo_obj.solid_geometry = self.area_subtraction(geo_obj.solid_geometry) @@ -676,7 +676,7 @@ class GerberObject(FlatCAMObj, Gerber): def iso_init(geo_obj, app_obj): # Propagate options geo_obj.obj_options["tools_mill_tooldia"] = str(dia) - geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"] + geo_obj.tool_type = self.app.options["tools_iso_tool_shape"] geo_obj.multigeo = True # if milling type is climb then the move is counter-clockwise around features @@ -734,7 +734,7 @@ class GerberObject(FlatCAMObj, Gerber): # ############################################################ # ########## AREA SUBTRACTION ################################ # ############################################################ - # if self.app.defaults["tools_iso_except"]: + # if self.app.options["tools_iso_except"]: # self.app.proc_container.update_view_text(' %s' % _("Subtracting Geo")) # geo_obj.solid_geometry = self.area_subtraction(geo_obj.solid_geometry) @@ -805,7 +805,7 @@ class GerberObject(FlatCAMObj, Gerber): # Propagate options new_obj.multigeo = True - # new_obj.obj_options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"]) + # new_obj.obj_options["tools_mill_tooldia"] = str(self.app.options["tools_iso_tooldia"]) new_obj.solid_geometry = deepcopy(self.follow_geometry) new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] @@ -973,7 +973,7 @@ class GerberObject(FlatCAMObj, Gerber): used_color = random_color() if self.obj_options['multicolored'] else 'black' used_face_color = None - if self.app.defaults["gerber_plot_line_enable"] is False: + if self.app.options["gerber_plot_line_enable"] is False: used_color = None if isinstance(g, (Polygon, LineString)): self.add_shape(shape=g, color=used_color, face_color=used_face_color, visible=visible) @@ -988,7 +988,7 @@ class GerberObject(FlatCAMObj, Gerber): used_color = random_color() if self.obj_options['multicolored'] else 'black' used_face_color = None - if self.app.defaults["gerber_plot_line_disable"] is True: + if self.app.options["gerber_plot_line_disable"] is True: used_color = None if isinstance(plot_geometry, (Polygon, LineString)): self.add_shape(shape=plot_geometry, color=used_color, face_color=used_face_color, visible=visible) @@ -1024,7 +1024,7 @@ class GerberObject(FlatCAMObj, Gerber): if 'color' in kwargs: color = kwargs['color'] else: - color = self.app.defaults['gerber_plot_fill'] + color = self.app.options['gerber_plot_fill'] if 'marked_aperture' in kwargs: aperture_to_plot_mark = kwargs['marked_aperture'] @@ -1120,7 +1120,7 @@ class GerberObject(FlatCAMObj, Gerber): if self.ui.apertures_table.cellWidget(cw_row, 5).isChecked(): self.marked_rows.append(True) # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) - color = self.app.defaults['global_sel_draw_color'] + color = self.app.options['global_sel_draw_color'] color = (color + 'AF') if len(color) == 7 else (color[:-2] + 'AF') self.plot_aperture(color=color, marked_aperture=aperture, visible=True, run_thread=True) else: @@ -1158,7 +1158,7 @@ class GerberObject(FlatCAMObj, Gerber): if mark_all: for aperture in self.tools: # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) - color = self.app.defaults['global_sel_draw_color'] + color = self.app.options['global_sel_draw_color'] color = (color + 'AF') if len(color) == 7 else (color[:-2] + 'AF') self.plot_aperture(color=color, marked_aperture=aperture, visible=True) # HACK: enable/disable the grid for a better look diff --git a/appObjects/FlatCAMObj.py b/appObjects/FlatCAMObj.py index 5e04285e..2928440b 100644 --- a/appObjects/FlatCAMObj.py +++ b/appObjects/FlatCAMObj.py @@ -105,8 +105,8 @@ class FlatCAMObj(QtCore.QObject): self.deleted = False try: - self._drawing_tolerance = float(self.app.defaults["global_tolerance"]) if \ - self.app.defaults["global_tolerance"] else 0.001 + self._drawing_tolerance = float(self.app.options["global_tolerance"]) if \ + self.app.options["global_tolerance"] else 0.001 except ValueError: self._drawing_tolerance = 0.001 @@ -493,12 +493,12 @@ class FlatCAMObj(QtCore.QObject): used file extension as the first one in the special string :param last_ext: The file extension that was last used to save a file - :param filter_string: A key in self.app.defaults that holds a string with the filter from QFileDialog + :param filter_string: A key in self.app.options that holds a string with the filter from QFileDialog used when saving a file :return: None """ - filters = copy(self.app.defaults[filter_string]) + filters = copy(self.app.options[filter_string]) filter_list = filters.split(';;') filter_list_enum_1 = enumerate(filter_list) @@ -521,7 +521,7 @@ class FlatCAMObj(QtCore.QObject): # add back the element that should always be the last (All Files) filter_list.append(last_elem) - self.app.defaults[filter_string] = ';;'.join(filter_list) + self.app.options[filter_string] = ';;'.join(filter_list) return def add_properties_items(self, obj, treeWidget): @@ -536,7 +536,7 @@ class FlatCAMObj(QtCore.QObject): font = QtGui.QFont() font.setBold(True) - p_color = QtGui.QColor("#000000") if self.app.defaults['global_gray_icons'] is False \ + p_color = QtGui.QColor("#000000") if self.app.options['global_gray_icons'] is False \ else QtGui.QColor("#FFFFFF") # main Items categories diff --git a/appObjects/FlatCAMScript.py b/appObjects/FlatCAMScript.py index 7e3080b5..034c4beb 100644 --- a/appObjects/FlatCAMScript.py +++ b/appObjects/FlatCAMScript.py @@ -74,7 +74,7 @@ class ScriptObject(FlatCAMObj): self.to_form() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) self.script_editor_tab = AppTextEditor(app=self.app, plain_text=True, parent=self.app.ui) @@ -98,8 +98,8 @@ class ScriptObject(FlatCAMObj): # self.script_editor_tab.code_editor.clear() # self.script_editor_tab.code_editor.setReadOnly(False) - self.ui.autocomplete_cb.set_value(self.app.defaults['script_autocompleter']) - self.on_autocomplete_changed(state=self.app.defaults['script_autocompleter']) + self.ui.autocomplete_cb.set_value(self.app.options['script_autocompleter']) + self.on_autocomplete_changed(state=self.app.options['script_autocompleter']) self.script_editor_tab.buttonRun.show() diff --git a/appObjects/ObjectCollection.py b/appObjects/ObjectCollection.py index bbc13d48..c304f1bb 100644 --- a/appObjects/ObjectCollection.py +++ b/appObjects/ObjectCollection.py @@ -318,7 +318,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.view.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu) self.view.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) - if self.app.defaults["global_allow_edit_in_project_tab"] is True: + if self.app.options["global_allow_edit_in_project_tab"] is True: self.view.setEditTriggers(QtWidgets.QTreeView.EditTrigger.SelectedClicked) # allow Edit on Tree else: self.view.setEditTriggers(QtWidgets.QTreeView.EditTrigger.NoEditTriggers) @@ -482,8 +482,8 @@ class ObjectCollection(QtCore.QAbstractItemModel): return index.internalPointer().data(index.column()) if role == Qt.ItemDataRole.ForegroundRole: - color = QColor(self.app.defaults['global_proj_item_color'][:-2]) - color_disabled = QColor(self.app.defaults['global_proj_item_dis_color'][:-2]) + color = QColor(self.app.options['global_proj_item_color'][:-2]) + color_disabled = QColor(self.app.options['global_proj_item_dis_color'][:-2]) obj = index.internalPointer().obj if obj: return QtGui.QBrush(color) if obj.obj_options["plot"] else QtGui.QBrush(color_disabled) @@ -627,7 +627,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.app.object_status_changed.emit(obj, 'append', name) # decide if to show or hide the Notebook side of the screen - if self.app.defaults["global_project_autohide"] is True: + if self.app.options["global_project_autohide"] is True: # always open the notebook on object added to collection self.app.ui.splitter.setSizes([1, 1]) @@ -742,7 +742,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.app.should_we_save = True # decide if to show or hide the Notebook side of the screen - if self.app.defaults["global_project_autohide"] is True: + if self.app.options["global_project_autohide"] is True: # hide the notebook if there are no objects in the collection if not self.get_list(): self.app.ui.splitter.setSizes([0, 1]) @@ -796,7 +796,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): self.app.should_we_save = True # decide if to show or hide the Notebook side of the screen - if self.app.defaults["global_project_autohide"] is True: + if self.app.options["global_project_autohide"] is True: # hide the notebook if there are no objects in the collection if not self.get_list(): self.app.ui.splitter.setSizes([0, 1]) @@ -1014,7 +1014,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): # works only for mouse button 1 (left click) if button == Qt.MouseButton.LeftButton: # on Gerber object selection it will redrawn on top of the other Gerber objects - if self.app.defaults["gerber_plot_on_select"] is True: + if self.app.options["gerber_plot_on_select"] is True: self.app.gerber_redraw() def on_item_activated(self, index): diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index 951bb919..74b31dad 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -82,7 +82,7 @@ class Gerber(Geometry): # How to approximate a circle with lines. if steps_per_circle is None: - self.steps_per_circle = int(self.app.defaults["gerber_circle_steps"]) + self.steps_per_circle = int(self.app.options["gerber_circle_steps"]) else: self.steps_per_circle = steps_per_circle self.decimals = self.app.decimals @@ -97,7 +97,7 @@ class Gerber(Geometry): self.frac_digits = 4 """Number of fraction digits in Gerber numbers. Used during parsing.""" - self.gerber_zeros = self.app.defaults['gerber_def_zeros'] + self.gerber_zeros = self.app.options['gerber_def_zeros'] """Zeros in Gerber numbers. If 'L' then remove leading zeros, if 'T' remove trailing zeros. Used during parsing. """ @@ -121,7 +121,7 @@ class Gerber(Geometry): ''' # store the file units here: - self.units = self.app.defaults['gerber_def_units'] + self.units = self.app.options['gerber_def_units'] # aperture storage self.tools = {} @@ -231,7 +231,7 @@ class Gerber(Geometry): # in a Gerber file (normal or obsolete ones) self.conversion_done = False - self.use_buffer_for_union = self.app.defaults["gerber_use_buffer_for_union"] + self.use_buffer_for_union = self.app.options["gerber_use_buffer_for_union"] # Attributes to be included in serialization # Always append to it because it carries contents @@ -441,7 +441,7 @@ class Gerber(Geometry): line_num = 0 gline = "" - s_tol = float(self.app.defaults["gerber_simp_tolerance"]) + s_tol = float(self.app.options["gerber_simp_tolerance"]) self.app.inform.emit('%s %d %s.' % (_("Gerber processing. Parsing"), len(glines), _("Lines").lower())) try: @@ -510,7 +510,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle)) - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) if not geo_s.is_empty and geo_s.is_valid: poly_buffer.append(geo_s) @@ -579,7 +579,7 @@ class Gerber(Geometry): self.app.log.debug("Gerber units found = %s" % self.units) # Changed for issue #80 # self.convert_units(match.group(1)) - s_tol = float(self.app.defaults["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol + s_tol = float(self.app.options["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol self.conversion_done = True continue @@ -601,7 +601,7 @@ class Gerber(Geometry): self.app.log.debug("Gerber format found. Coordinates type = %s (Absolute or Relative)" % absolute) self.units = match.group(5) - s_tol = float(self.app.defaults["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol + s_tol = float(self.app.options["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol self.app.log.debug("Gerber units found = %s" % self.units) # Changed for issue #80 @@ -634,7 +634,7 @@ class Gerber(Geometry): self.units = match.group(1) s_tol = float( - self.app.defaults["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol + self.app.options["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol self.app.log.debug("Gerber units found = %s" % self.units) # Changed for issue #80 @@ -649,7 +649,7 @@ class Gerber(Geometry): if match: obs_gerber_units = {'0': 'IN', '1': 'MM'}[match.group(1)] self.units = obs_gerber_units - s_tol = float(self.app.defaults["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol + s_tol = float(self.app.options["gerber_simp_tolerance"]) / 25.4 if self.units == 'IN' else s_tol self.app.log.warning("Gerber obsolete units found = %s" % obs_gerber_units) # Changed for issue #80 @@ -731,7 +731,7 @@ class Gerber(Geometry): geo_dict['follow'] = Point([current_x, current_y]) if not flash.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: flash = flash.simplify(s_tol) poly_buffer.append(flash) @@ -791,7 +791,7 @@ class Gerber(Geometry): # --- Buffered ---- width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle)) - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) if not geo_s.is_empty: poly_buffer.append(geo_s) @@ -848,7 +848,7 @@ class Gerber(Geometry): for pol in geo_s: if not pol.is_empty: # is it possible that simplification creates an Empty Geometry ????? - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: pol = pol.simplify(s_tol) poly_buffer.append(pol) @@ -862,7 +862,7 @@ class Gerber(Geometry): except TypeError: if not geo_s.is_empty: # is it possible that simplification creates an Empty Geometry ????? - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -911,7 +911,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f if geo_s: if not geo_s.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) if not geo_s.is_valid: @@ -967,7 +967,7 @@ class Gerber(Geometry): try: for pol in region_s: # is it possible that simplification creates an Empty Geometry ????? - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: pol = pol.simplify(s_tol) pol_f = pol.exterior @@ -986,7 +986,7 @@ class Gerber(Geometry): self.tools[0]['geometry'].append(geo_dict) except TypeError: # is it possible that simplification creates an Empty Geometry ????? - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: region_s = region_s.simplify(s_tol) region_f = region_s.exterior @@ -1005,7 +1005,7 @@ class Gerber(Geometry): self.tools[0]['geometry'].append(geo_dict) else: # is it possible that simplification creates an Empty Geometry ????? - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: region_s = region_s.simplify(s_tol) region_f = region_s.exterior @@ -1104,7 +1104,7 @@ class Gerber(Geometry): self.steps_per_circle ) if not flash.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: flash = flash.simplify(s_tol) poly_buffer.append(flash) @@ -1140,7 +1140,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f geo_s = shply_box(minx, miny, maxx, maxy) - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1237,7 +1237,7 @@ class Gerber(Geometry): try: if self.tools[last_path_aperture]["type"] != 'R': if not geo_s.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1248,7 +1248,7 @@ class Gerber(Geometry): geo_dict['solid'] = geo_s except Exception as e: self.app.log.error("camlib.Gerber.parse_lines() --> %s" % str(e)) - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1305,7 +1305,7 @@ class Gerber(Geometry): if not geo_s.is_empty: try: if self.tools[last_path_aperture]["type"] != 'R': - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1315,7 +1315,7 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s except Exception: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1350,7 +1350,7 @@ class Gerber(Geometry): ) if not flash.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: flash = flash.simplify(s_tol) poly_buffer.append(flash) @@ -1463,7 +1463,7 @@ class Gerber(Geometry): # this treats the case when we are storing geometry as solids buffered = LineString(path).buffer(width / 1.999, int(self.steps_per_circle)) if not buffered.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: buffered = buffered.simplify(s_tol) poly_buffer.append(buffered) @@ -1616,7 +1616,7 @@ class Gerber(Geometry): width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle)) if not geo_s.is_empty: - if self.app.defaults['gerber_simplification']: + if self.app.options['gerber_simplification']: geo_s = geo_s.simplify(s_tol) poly_buffer.append(geo_s) @@ -1667,7 +1667,7 @@ class Gerber(Geometry): self.app.log.debug("Union by buffer...") new_poly = MultiPolygon(poly_buffer) - if self.app.defaults["gerber_buffering"] == 'full': + if self.app.options["gerber_buffering"] == 'full': new_poly = new_poly.buffer(0.00000001) new_poly = new_poly.buffer(-0.00000001) self.app.log.warning("Union(buffer) done.") @@ -1703,7 +1703,7 @@ class Gerber(Geometry): # FIX for issue #347 - Sprint Layout generate Gerber files when the copper pour is enabled # it use a filled bounding box polygon to which add clear polygons (negative) to isolate the copper # features - if self.app.defaults['gerber_extra_buffering']: + if self.app.options['gerber_extra_buffering']: candidate_geo = [] if isinstance(self.solid_geometry, MultiPolygon): geo_to_buff = self.solid_geometry.geoms @@ -1722,7 +1722,7 @@ class Gerber(Geometry): # flatten the solid geometry self.solid_geometry = flatten_shapely_geometry(self.solid_geometry) - if self.app.defaults['gerber_clean_apertures']: + if self.app.options['gerber_clean_apertures']: # clean the Gerber file of apertures with no geometry for apid, apvalue in list(self.tools.items()): if 'geometry' not in apvalue: @@ -1952,7 +1952,7 @@ class Gerber(Geometry): h = svgparselength(svg_root.get('height'))[0] # TODO: No units support yet units = self.app.app_units if units is None else units - res = self.app.defaults['gerber_circle_steps'] + res = self.app.options['gerber_circle_steps'] factor = svgparse_viewbox(svg_root) geos = getsvggeo(svg_root, 'gerber', units=units, res=res, factor=factor, app=self.app) diff --git a/appParsers/ParseHPGL2.py b/appParsers/ParseHPGL2.py index 844d3a0a..d91d9493 100644 --- a/appParsers/ParseHPGL2.py +++ b/appParsers/ParseHPGL2.py @@ -41,7 +41,7 @@ class HPGL2: self.app = app # How to approximate a circle with lines. - self.steps_per_circle = int(self.app.defaults["geometry_circle_steps"]) + self.steps_per_circle = int(self.app.options["geometry_circle_steps"]) self.decimals = self.app.decimals # store the file units here @@ -53,67 +53,67 @@ class HPGL2: self.default_data = {} self.default_data.update({ "name": '_ncc', - "plot": self.app.defaults["geometry_plot"], - "cutz": self.app.defaults["geometry_cutz"], - "vtipdia": self.app.defaults["tools_mill_vtipdia"], - "vtipangle": 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"], - "area_exclusion": self.app.defaults["geometry_area_exclusion"], - "area_shape": self.app.defaults["geometry_area_shape"], - "area_strategy": self.app.defaults["geometry_area_strategy"], - "area_overz": self.app.defaults["geometry_area_overz"], + "plot": self.app.options["geometry_plot"], + "cutz": self.app.options["geometry_cutz"], + "vtipdia": self.app.options["tools_mill_vtipdia"], + "vtipangle": self.app.options["tools_mill_vtipangle"], + "travelz": self.app.options["geometry_travelz"], + "feedrate": self.app.options["geometry_feedrate"], + "feedrate_z": self.app.options["geometry_feedrate_z"], + "feedrate_rapid": self.app.options["geometry_feedrate_rapid"], + "dwell": self.app.options["geometry_dwell"], + "dwelltime": self.app.options["geometry_dwelltime"], + "multidepth": self.app.options["geometry_multidepth"], + "ppname_g": self.app.options["geometry_ppname_g"], + "depthperpass": self.app.options["geometry_depthperpass"], + "extracut": self.app.options["geometry_extracut"], + "extracut_length": self.app.options["geometry_extracut_length"], + "toolchange": self.app.options["geometry_toolchange"], + "toolchangez": self.app.options["geometry_toolchangez"], + "endz": self.app.options["geometry_endz"], + "endxy": self.app.options["geometry_endxy"], + "area_exclusion": self.app.options["geometry_area_exclusion"], + "area_shape": self.app.options["geometry_area_shape"], + "area_strategy": self.app.options["geometry_area_strategy"], + "area_overz": self.app.options["geometry_area_overz"], - "spindlespeed": self.app.defaults["geometry_spindlespeed"], - "toolchangexy": self.app.defaults["geometry_toolchangexy"], - "startz": self.app.defaults["geometry_startz"], + "spindlespeed": self.app.options["geometry_spindlespeed"], + "toolchangexy": self.app.options["geometry_toolchangexy"], + "startz": self.app.options["geometry_startz"], - "tooldia": self.app.defaults["tools_paint_tooldia"], - "tools_paint_offset": self.app.defaults["tools_paint_offset"], - "tools_paint_method": self.app.defaults["tools_paint_method"], - "tools_paint_selectmethod": self.app.defaults["tools_paint_selectmethod"], - "tools_paint_connect": self.app.defaults["tools_paint_connect"], - "tools_paint_contour": self.app.defaults["tools_paint_contour"], - "tools_paint_overlap": self.app.defaults["tools_paint_overlap"], - "tools_paint_rest": self.app.defaults["tools_paint_rest"], + "tooldia": self.app.options["tools_paint_tooldia"], + "tools_paint_offset": self.app.options["tools_paint_offset"], + "tools_paint_method": self.app.options["tools_paint_method"], + "tools_paint_selectmethod": self.app.options["tools_paint_selectmethod"], + "tools_paint_connect": self.app.options["tools_paint_connect"], + "tools_paint_contour": self.app.options["tools_paint_contour"], + "tools_paint_overlap": self.app.options["tools_paint_overlap"], + "tools_paint_rest": self.app.options["tools_paint_rest"], - "tools_ncc_operation": self.app.defaults["tools_ncc_operation"], - "tools_ncc_margin": self.app.defaults["tools_ncc_margin"], - "tools_ncc_method": self.app.defaults["tools_ncc_method"], - "tools_ncc_connect": self.app.defaults["tools_ncc_connect"], - "tools_ncc_contour": self.app.defaults["tools_ncc_contour"], - "tools_ncc_overlap": self.app.defaults["tools_ncc_overlap"], - "tools_ncc_rest": self.app.defaults["tools_ncc_rest"], - "tools_ncc_ref": self.app.defaults["tools_ncc_ref"], - "tools_ncc_offset_choice": self.app.defaults["tools_ncc_offset_choice"], - "tools_ncc_offset_value": self.app.defaults["tools_ncc_offset_value"], - "tools_ncc_milling_type": self.app.defaults["tools_ncc_milling_type"], + "tools_ncc_operation": self.app.options["tools_ncc_operation"], + "tools_ncc_margin": self.app.options["tools_ncc_margin"], + "tools_ncc_method": self.app.options["tools_ncc_method"], + "tools_ncc_connect": self.app.options["tools_ncc_connect"], + "tools_ncc_contour": self.app.options["tools_ncc_contour"], + "tools_ncc_overlap": self.app.options["tools_ncc_overlap"], + "tools_ncc_rest": self.app.options["tools_ncc_rest"], + "tools_ncc_ref": self.app.options["tools_ncc_ref"], + "tools_ncc_offset_choice": self.app.options["tools_ncc_offset_choice"], + "tools_ncc_offset_value": self.app.options["tools_ncc_offset_value"], + "tools_ncc_milling_type": self.app.options["tools_ncc_milling_type"], - "tools_iso_passes": self.app.defaults["tools_iso_passes"], - "tools_iso_overlap": self.app.defaults["tools_iso_overlap"], - "tools_iso_milling_type": self.app.defaults["tools_iso_milling_type"], - "tools_iso_isotype": self.app.defaults["tools_iso_isotype"], + "tools_iso_passes": self.app.options["tools_iso_passes"], + "tools_iso_overlap": self.app.options["tools_iso_overlap"], + "tools_iso_milling_type": self.app.options["tools_iso_milling_type"], + "tools_iso_isotype": self.app.options["tools_iso_isotype"], - "tools_iso_rest": self.app.defaults["tools_iso_rest"], - "tools_iso_combine_passes": self.app.defaults["tools_iso_combine_passes"], - "tools_iso_isoexcept": self.app.defaults["tools_iso_isoexcept"], - "tools_iso_selection": self.app.defaults["tools_iso_selection"], - "tools_iso_poly_ints": self.app.defaults["tools_iso_poly_ints"], - "tools_iso_force": self.app.defaults["tools_iso_force"], - "tools_iso_area_shape": self.app.defaults["tools_iso_area_shape"] + "tools_iso_rest": self.app.options["tools_iso_rest"], + "tools_iso_combine_passes": self.app.options["tools_iso_combine_passes"], + "tools_iso_isoexcept": self.app.options["tools_iso_isoexcept"], + "tools_iso_selection": self.app.options["tools_iso_selection"], + "tools_iso_poly_ints": self.app.options["tools_iso_poly_ints"], + "tools_iso_force": self.app.options["tools_iso_force"], + "tools_iso_area_shape": self.app.options["tools_iso_area_shape"] }) # will store the geometry here for compatibility reason @@ -237,7 +237,7 @@ class HPGL2: 'tooldia': float('%.*f' % ( self.decimals, - float(self.app.defaults['tools_mill_tooldia']) + float(self.app.options['tools_mill_tooldia']) ) ), 'offset': 'Path', diff --git a/appPlugins/ToolAlignObjects.py b/appPlugins/ToolAlignObjects.py index 1f8069b3..24f6ce73 100644 --- a/appPlugins/ToolAlignObjects.py +++ b/appPlugins/ToolAlignObjects.py @@ -155,7 +155,7 @@ class AlignObjects(AppTool): self.aligned_old_fill_color = None self.aligned_old_line_color = None - self.ui.a_type_radio.set_value(self.app.defaults["tools_align_objects_align_type"]) + self.ui.a_type_radio.set_value(self.app.options["tools_align_objects_align_type"]) self.ui.type_obj_radio.set_value('grb') self.ui.type_aligner_obj_radio.set_value('grb') diff --git a/appPlugins/ToolCalculators.py b/appPlugins/ToolCalculators.py index 483bd851..1b309da8 100644 --- a/appPlugins/ToolCalculators.py +++ b/appPlugins/ToolCalculators.py @@ -128,23 +128,23 @@ class ToolCalculator(AppTool): self.ui.fl_oz_entry.set_value('%.*f' % (self.decimals, 0)) # Electroplating Calculator - length = self.app.defaults["tools_calc_electro_length"] - width = self.app.defaults["tools_calc_electro_width"] - density = self.app.defaults["tools_calc_electro_cdensity"] - growth = self.app.defaults["tools_calc_electro_growth"] + length = self.app.options["tools_calc_electro_length"] + width = self.app.options["tools_calc_electro_width"] + density = self.app.options["tools_calc_electro_cdensity"] + growth = self.app.options["tools_calc_electro_growth"] self.ui.pcblength_entry.set_value(length) self.ui.pcbwidth_entry.set_value(width) - self.ui.area_entry.set_value(self.app.defaults["tools_calc_electro_area"]) + self.ui.area_entry.set_value(self.app.options["tools_calc_electro_area"]) self.ui.cdensity_entry.set_value(density) self.ui.growth_entry.set_value(growth) self.ui.cvalue_entry.set_value(0.00) self.ui.time_entry.set_value(0.0) # V-Shape tool Calculator - tip_dia = self.app.defaults["tools_calc_vshape_tip_dia"] - tip_angle = self.app.defaults["tools_calc_vshape_tip_angle"] - cut_z = self.app.defaults["tools_calc_vshape_cut_z"] + tip_dia = self.app.options["tools_calc_vshape_tip_dia"] + tip_angle = self.app.options["tools_calc_vshape_tip_angle"] + cut_z = self.app.options["tools_calc_vshape_cut_z"] self.ui.tipDia_entry.set_value(tip_dia) self.ui.tipAngle_entry.set_value(tip_angle) diff --git a/appPlugins/ToolCalibration.py b/appPlugins/ToolCalibration.py index 012cd929..c579f530 100644 --- a/appPlugins/ToolCalibration.py +++ b/appPlugins/ToolCalibration.py @@ -163,14 +163,14 @@ class ToolCalibration(AppTool): self.reset_calibration_points() - self.ui.cal_source_radio.set_value(self.app.defaults['tools_cal_calsource']) - self.ui.travelz_entry.set_value(self.app.defaults['tools_cal_travelz']) - self.ui.verz_entry.set_value(self.app.defaults['tools_cal_verz']) - self.ui.zeroz_cb.set_value(self.app.defaults['tools_cal_zeroz']) - self.ui.toolchangez_entry.set_value(self.app.defaults['tools_cal_toolchangez']) - self.ui.toolchange_xy_entry.set_value(self.app.defaults['tools_cal_toolchange_xy']) + self.ui.cal_source_radio.set_value(self.app.options['tools_cal_calsource']) + self.ui.travelz_entry.set_value(self.app.options['tools_cal_travelz']) + self.ui.verz_entry.set_value(self.app.options['tools_cal_verz']) + self.ui.zeroz_cb.set_value(self.app.options['tools_cal_zeroz']) + self.ui.toolchangez_entry.set_value(self.app.options['tools_cal_toolchangez']) + self.ui.toolchange_xy_entry.set_value(self.app.options['tools_cal_toolchange_xy']) - self.ui.second_point_radio.set_value(self.app.defaults['tools_cal_sec_point']) + self.ui.second_point_radio.set_value(self.app.options['tools_cal_sec_point']) self.ui.scalex_entry.set_value(1.0) self.ui.scaley_entry.set_value(1.0) diff --git a/appPlugins/ToolCopperThieving.py b/appPlugins/ToolCopperThieving.py index a70824ce..36306dc5 100644 --- a/appPlugins/ToolCopperThieving.py +++ b/appPlugins/ToolCopperThieving.py @@ -162,32 +162,32 @@ class ToolCopperThieving(AppTool): def set_tool_ui(self): self.units = self.app.app_units - self.geo_steps_per_circle = int(self.app.defaults["tools_copper_thieving_circle_steps"]) + self.geo_steps_per_circle = int(self.app.options["tools_copper_thieving_circle_steps"]) self.clear_ui(self.layout) self.ui = ThievingUI(layout=self.layout, app=self.app) self.pluginName = self.ui.pluginName self.connect_signals_at_init() - self.ui.clearance_entry.set_value(float(self.app.defaults["tools_copper_thieving_clearance"])) - self.ui.margin_entry.set_value(float(self.app.defaults["tools_copper_thieving_margin"])) - self.ui.reference_combo.set_value(self.app.defaults["tools_copper_thieving_reference"]) - self.ui.bbox_type_radio.set_value(self.app.defaults["tools_copper_thieving_box_type"]) - self.ui.fill_type_combo.set_value(self.app.defaults["tools_copper_thieving_fill_type"]) + self.ui.clearance_entry.set_value(float(self.app.options["tools_copper_thieving_clearance"])) + self.ui.margin_entry.set_value(float(self.app.options["tools_copper_thieving_margin"])) + self.ui.reference_combo.set_value(self.app.options["tools_copper_thieving_reference"]) + self.ui.bbox_type_radio.set_value(self.app.options["tools_copper_thieving_box_type"]) + self.ui.fill_type_combo.set_value(self.app.options["tools_copper_thieving_fill_type"]) - self.ui.area_entry.set_value(self.app.defaults["tools_copper_thieving_area"]) - self.ui.dot_dia_entry.set_value(self.app.defaults["tools_copper_thieving_dots_dia"]) - self.ui.dot_spacing_entry.set_value(self.app.defaults["tools_copper_thieving_dots_spacing"]) - self.ui.square_size_entry.set_value(self.app.defaults["tools_copper_thieving_squares_size"]) - self.ui.squares_spacing_entry.set_value(self.app.defaults["tools_copper_thieving_squares_spacing"]) - self.ui.line_size_entry.set_value(self.app.defaults["tools_copper_thieving_lines_size"]) - self.ui.lines_spacing_entry.set_value(self.app.defaults["tools_copper_thieving_lines_spacing"]) + self.ui.area_entry.set_value(self.app.options["tools_copper_thieving_area"]) + self.ui.dot_dia_entry.set_value(self.app.options["tools_copper_thieving_dots_dia"]) + self.ui.dot_spacing_entry.set_value(self.app.options["tools_copper_thieving_dots_spacing"]) + self.ui.square_size_entry.set_value(self.app.options["tools_copper_thieving_squares_size"]) + self.ui.squares_spacing_entry.set_value(self.app.options["tools_copper_thieving_squares_spacing"]) + self.ui.line_size_entry.set_value(self.app.options["tools_copper_thieving_lines_size"]) + self.ui.lines_spacing_entry.set_value(self.app.options["tools_copper_thieving_lines_spacing"]) - self.ui.rb_margin_entry.set_value(self.app.defaults["tools_copper_thieving_rb_margin"]) - self.ui.rb_thickness_entry.set_value(self.app.defaults["tools_copper_thieving_rb_thickness"]) - self.ui.only_pads_cb.set_value(self.app.defaults["tools_copper_thieving_only_apds"]) - self.ui.clearance_ppm_entry.set_value(self.app.defaults["tools_copper_thieving_mask_clearance"]) - self.ui.ppm_choice_combo.set_value(self.app.defaults["tools_copper_thieving_geo_choice"]) + self.ui.rb_margin_entry.set_value(self.app.options["tools_copper_thieving_rb_margin"]) + self.ui.rb_thickness_entry.set_value(self.app.options["tools_copper_thieving_rb_thickness"]) + self.ui.only_pads_cb.set_value(self.app.options["tools_copper_thieving_only_apds"]) + self.ui.clearance_ppm_entry.set_value(self.app.options["tools_copper_thieving_mask_clearance"]) + self.ui.ppm_choice_combo.set_value(self.app.options["tools_copper_thieving_geo_choice"]) # INIT SECTION self.handlers_connected = False @@ -506,8 +506,8 @@ class ToolCopperThieving(AppTool): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) if self.cursor_pos is None: self.cursor_pos = (0, 0) @@ -561,9 +561,9 @@ class ToolCopperThieving(AppTool): ref_selected = self.ui.reference_combo.get_value() if c_val is None: - c_val = float(self.app.defaults["tools_copper_thieving_clearance"]) + c_val = float(self.app.options["tools_copper_thieving_clearance"]) if margin is None: - margin = float(self.app.defaults["tools_copper_thieving_margin"]) + margin = float(self.app.options["tools_copper_thieving_margin"]) min_area = self.ui.area_entry.get_value() fill_type = self.ui.fill_type_combo.get_value() diff --git a/appPlugins/ToolCutOut.py b/appPlugins/ToolCutOut.py index c0fd60dc..48c1b7ab 100644 --- a/appPlugins/ToolCutOut.py +++ b/appPlugins/ToolCutOut.py @@ -81,10 +81,10 @@ class CutOut(AppTool): self.default_data = {} # store the current cursor type to be restored after manual geo - self.old_cursor_type = self.app.defaults["global_cursor_type"] + self.old_cursor_type = self.app.options["global_cursor_type"] # store the current selection shape status to be restored after manual geo - self.old_selection_state = self.app.defaults['global_selection_shape'] + self.old_selection_state = self.app.options['global_selection_shape'] # store original geometry for manual cutout self.manual_solid_geo = None @@ -264,12 +264,12 @@ class CutOut(AppTool): if option.find('tools_') == 0: self.default_data[option] = self.app.options[option] - self.ui.gaptype_combo.set_value(self.app.defaults["tools_cutout_gap_type"]) + self.ui.gaptype_combo.set_value(self.app.options["tools_cutout_gap_type"]) self.ui.on_gap_type_radio(self.ui.gaptype_combo.get_value()) # add a default tool - self.ui.dia.set_value(float(self.app.defaults["tools_cutout_tooldia"])) - tool_dia = float(self.app.defaults["tools_cutout_tooldia"]) + self.ui.dia.set_value(float(self.app.options["tools_cutout_tooldia"])) + tool_dia = float(self.app.options["tools_cutout_tooldia"]) self.on_tool_add(custom_dia=tool_dia) # set as default the automatic adding of gaps @@ -280,12 +280,12 @@ class CutOut(AppTool): self.on_cutout_shape_changed(self.ui.cutout_shape_cb.get_value()) # set the Cut By Drilling parameters - self.ui.drill_dia_entry.set_value(float(self.app.defaults["tools_cutout_drill_dia"])) - self.ui.drill_pitch_entry.set_value(float(self.app.defaults["tools_cutout_drill_pitch"])) - self.ui.drill_margin_entry.set_value(float(self.app.defaults["tools_cutout_drill_margin"])) + self.ui.drill_dia_entry.set_value(float(self.app.options["tools_cutout_drill_dia"])) + self.ui.drill_pitch_entry.set_value(float(self.app.options["tools_cutout_drill_pitch"])) + self.ui.drill_margin_entry.set_value(float(self.app.options["tools_cutout_drill_margin"])) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -358,7 +358,7 @@ class CutOut(AppTool): # Tool parameters section if self.cut_tool_dict: - app_defaults = self.app.defaults + app_defaults = self.app.options tool_data = self.cut_tool_dict['data'] tool_data['tools_cutout_convexshape'] = app_defaults['tools_cutout_convexshape'] @@ -540,7 +540,7 @@ class CutOut(AppTool): def on_tool_default_add(self, dia=None, muted=None): - dia = dia if dia else str(self.app.defaults["tools_cutout_tooldia"]) + dia = dia if dia else str(self.app.options["tools_cutout_tooldia"]) # init the working variables self.default_data.clear() @@ -1583,10 +1583,10 @@ class CutOut(AppTool): self.mouse_events_connected = True if self.ui.big_cursor_cb.get_value(): - self.old_cursor_type = self.app.defaults["global_cursor_type"] + self.old_cursor_type = self.app.options["global_cursor_type"] self.app.on_cursor_type(val="big") - self.app.defaults['global_selection_shape'] = False + self.app.options['global_selection_shape'] = False # disable the notebook until finished self.app.ui.notebook.setDisabled(True) @@ -1833,7 +1833,7 @@ class CutOut(AppTool): # restore cursor self.app.on_cursor_type(val=self.old_cursor_type) # restore selection - self.app.defaults['global_selection_shape'] = self.old_selection_state + self.app.options['global_selection_shape'] = self.old_selection_state # rebuild the manual Geometry object self.man_cutout_obj.build_ui() @@ -1991,7 +1991,7 @@ class CutOut(AppTool): def draw_utility_geometry(self, geo): self.app.geo_editor.tool_shape.add( shape=geo, - color=(self.app.defaults["global_draw_color"]), + color=(self.app.options["global_draw_color"]), update=False, layer=0, tolerance=None) @@ -2052,7 +2052,7 @@ class CutOut(AppTool): # restore cursor self.app.on_cursor_type(val=self.old_cursor_type) # restore selection - self.app.defaults['global_selection_shape'] = self.old_selection_state + self.app.options['global_selection_shape'] = self.old_selection_state # Remove any previous utility shape self.app.geo_editor.tool_shape.clear(update=True) diff --git a/appPlugins/ToolDblSided.py b/appPlugins/ToolDblSided.py index 21298174..b5c8f443 100644 --- a/appPlugins/ToolDblSided.py +++ b/appPlugins/ToolDblSided.py @@ -154,12 +154,12 @@ class DblSidedTool(AppTool): self.ui.point_entry.set_value("") self.ui.alignment_holes.set_value("") - self.ui.mirror_axis.set_value(self.app.defaults["tools_2sided_mirror_axis"]) - self.ui.axis_location.set_value(self.app.defaults["tools_2sided_axis_loc"]) + self.ui.mirror_axis.set_value(self.app.options["tools_2sided_mirror_axis"]) + self.ui.axis_location.set_value(self.app.options["tools_2sided_axis_loc"]) self.on_toggle_pointbox(self.ui.axis_location.get_value()) - self.ui.drill_dia.set_value(self.app.defaults["tools_2sided_drilldia"]) - self.ui.align_type_radio.set_value(self.app.defaults["tools_2sided_align_type"]) + self.ui.drill_dia.set_value(self.app.options["tools_2sided_drilldia"]) + self.ui.align_type_radio.set_value(self.app.options["tools_2sided_align_type"]) self.ui.on_align_type_changed(val=self.ui.align_type_radio.get_value()) self.ui.xmin_entry.set_value(0.0) @@ -202,7 +202,7 @@ class DblSidedTool(AppTool): self.disconnect_events() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -545,7 +545,7 @@ class DblSidedTool(AppTool): self.app.inform.emit('[success] %s: %s' % (_("Object was mirrored"), str(fcobj.obj_options['name']))) def on_point_add(self): - val = self.app.defaults["global_point_clipboard_format"] % \ + val = self.app.options["global_point_clipboard_format"] % \ (self.decimals, self.app.pos[0], self.decimals, self.app.pos[1]) self.ui.point_entry.set_value(val) @@ -632,9 +632,9 @@ class DblSidedTool(AppTool): try: px, py = self.ui.point_entry.get_value() - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, xmin, self.decimals, py) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, xmin, self.decimals, py) except TypeError: - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, xmin, self.decimals, 0.0) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, xmin, self.decimals, 0.0) self.ui.point_entry.set_value(val) def on_ymin_clicked(self): @@ -643,9 +643,9 @@ class DblSidedTool(AppTool): try: px, py = self.ui.point_entry.get_value() - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, px, self.decimals, ymin) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, px, self.decimals, ymin) except TypeError: - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, 0.0, self.decimals, ymin) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, 0.0, self.decimals, ymin) self.ui.point_entry.set_value(val) def on_xmax_clicked(self): @@ -654,9 +654,9 @@ class DblSidedTool(AppTool): try: px, py = self.ui.point_entry.get_value() - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, xmax, self.decimals, py) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, xmax, self.decimals, py) except TypeError: - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, xmax, self.decimals, 0.0) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, xmax, self.decimals, 0.0) self.ui.point_entry.set_value(val) def on_ymax_clicked(self): @@ -665,9 +665,9 @@ class DblSidedTool(AppTool): try: px, py = self.ui.point_entry.get_value() - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, px, self.decimals, ymax) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, px, self.decimals, ymax) except TypeError: - val = self.app.defaults["global_point_clipboard_format"] % (self.decimals, 0.0, self.decimals, ymax) + val = self.app.options["global_point_clipboard_format"] % (self.decimals, 0.0, self.decimals, ymax) self.ui.point_entry.set_value(val) def reset_fields(self): diff --git a/appPlugins/ToolDistance.py b/appPlugins/ToolDistance.py index 19c9338f..9c826d29 100644 --- a/appPlugins/ToolDistance.py +++ b/appPlugins/ToolDistance.py @@ -153,12 +153,12 @@ class Distance(AppTool): self.app.command_active = "Distance" - self.ui.snap_center_cb.set_value(self.app.defaults['tools_dist_snap_center']) + self.ui.snap_center_cb.set_value(self.app.options['tools_dist_snap_center']) # snap center works only for Gerber and Execellon Editor's if self.original_call_source == 'exc_editor' or self.original_call_source == 'grb_editor': self.ui.snap_center_cb.show() - snap_center = self.app.defaults['tools_dist_snap_center'] + snap_center = self.app.options['tools_dist_snap_center'] self.on_snap_toggled(snap_center) self.ui.snap_center_cb.toggled.connect(self.on_snap_toggled) @@ -190,7 +190,7 @@ class Distance(AppTool): self.ui.total_distance_entry.set_value('%.*f' % (self.decimals, 0.0)) def on_snap_toggled(self, state): - self.app.defaults['tools_dist_snap_center'] = state + self.app.options['tools_dist_snap_center'] = state if state: # disengage the grid snapping since it will be hard to find the drills or pads on grid if self.app.ui.grid_snap_btn.isChecked(): @@ -483,8 +483,8 @@ class Distance(AppTool): self.app.app_cursor.enabled = True self.app.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), symbol='++', edge_color='#000000', - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) def on_multipoint_measurement_changed(self, val): if val: @@ -526,8 +526,8 @@ class Distance(AppTool): # Update cursor self.app.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) else: pos = (pos_canvas[0], pos_canvas[1]) diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index 5c630693..73ff7e88 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -46,7 +46,7 @@ class ToolDrilling(AppTool, Excellon): self.dec_format = self.app.dec_format AppTool.__init__(self, app) - Excellon.__init__(self, excellon_circle_steps=self.app.defaults["excellon_circle_steps"]) + Excellon.__init__(self, excellon_circle_steps=self.app.options["excellon_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -109,7 +109,7 @@ class ToolDrilling(AppTool, Excellon): # store here solid_geometry when there are tool with isolation job self.solid_geometry = [] - self.circle_steps = int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["geometry_circle_steps"]) self.tooldia = None @@ -450,7 +450,7 @@ class ToolDrilling(AppTool, Excellon): self.ui.pp_excellon_name_cb.setItemData(it, self.ui.pp_excellon_name_cb.itemText(it), QtCore.Qt.ItemDataRole.ToolTipRole) - self.ui.order_combo.set_value(self.app.defaults["tools_drill_tool_order"]) + self.ui.order_combo.set_value(self.app.options["tools_drill_tool_order"]) if loaded_obj: outname = loaded_obj.obj_options['name'] @@ -524,7 +524,7 @@ class ToolDrilling(AppTool, Excellon): self.ui.last_drill_cb.hide() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) self.ui.tools_frame.show() @@ -953,7 +953,7 @@ class ToolDrilling(AppTool, Excellon): self.app.collection.set_active(self.obj_name) self.ui.exc_param_frame.setDisabled(False) - if self.app.defaults["excellon_autoload_db"]: + if self.app.options["excellon_autoload_db"]: self.excellon_tools = self.excellon_obj.tools self.on_tool_db_load() else: @@ -1731,11 +1731,11 @@ class ToolDrilling(AppTool, Excellon): self.delete_sel_shape() if self.app.use_3d_engine: - face = self.app.defaults['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] - outline = self.app.defaults['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] + face = self.app.options['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] + outline = self.app.options['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] else: - face = self.app.defaults['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] - outline = self.app.defaults['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] + face = self.app.options['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] + outline = self.app.options['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] for row in sel_rows: sel_rect = self.app.exc_areas.exclusion_areas_storage[row]['shape'] @@ -2038,7 +2038,7 @@ class ToolDrilling(AppTool, Excellon): # ############################################################################################################# # General Parameters # ############################################################################################################# - used_exc_optim_type = self.app.defaults["excellon_optimization_type"] + used_exc_optim_type = self.app.options["excellon_optimization_type"] current_platform = platform.architecture()[0] if current_platform != '64bit': used_exc_optim_type = 'T' @@ -2178,14 +2178,14 @@ class ToolDrilling(AppTool, Excellon): cnc_job_obj.use_ui = True - cnc_job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"]) - cnc_job_obj.fr_decimals = int(self.app.defaults["cncjob_fr_decimals"]) + cnc_job_obj.coords_decimals = int(self.app.options["cncjob_coords_decimals"]) + cnc_job_obj.fr_decimals = int(self.app.options["cncjob_fr_decimals"]) cnc_job_obj.multitool = True # it does not matter for the Excellon codes because we are not going to autolevel GCode out of Excellon # but it is here for uniformity between the Geometry and Excellon objects - cnc_job_obj.segx = self.app.defaults["geometry_segx"] - cnc_job_obj.segy = self.app.defaults["geometry_segy"] + cnc_job_obj.segx = self.app.options["geometry_segx"] + cnc_job_obj.segy = self.app.options["geometry_segy"] # first drill point # I can read the toolchange x,y point from any tool since it is the same for all, so I read it diff --git a/appPlugins/ToolEtchCompensation.py b/appPlugins/ToolEtchCompensation.py index a3e28dbf..a2d92930 100644 --- a/appPlugins/ToolEtchCompensation.py +++ b/appPlugins/ToolEtchCompensation.py @@ -183,7 +183,7 @@ class ToolEtchCompensation(AppTool): ratio_type = self.ui.ratio_radio.get_value() thickness = self.ui.thick_entry.get_value() / 1000 # in microns - grb_circle_steps = int(self.app.defaults["gerber_circle_steps"]) + grb_circle_steps = int(self.app.options["gerber_circle_steps"]) obj_name = self.ui.gerber_combo.currentText() outname = obj_name + "_comp" diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index 6c63c52d..47677e8c 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -184,30 +184,30 @@ class ToolExtract(AppTool): self.ui_disconnect() self.ui_connect() - self.ui.method_radio.set_value(self.app.defaults["tools_extract_hole_type"]) + self.ui.method_radio.set_value(self.app.options["tools_extract_hole_type"]) - self.ui.dia_entry.set_value(float(self.app.defaults["tools_extract_hole_fixed_dia"])) + self.ui.dia_entry.set_value(float(self.app.options["tools_extract_hole_fixed_dia"])) - self.ui.circular_ring_entry.set_value(float(self.app.defaults["tools_extract_circular_ring"])) - self.ui.oblong_ring_entry.set_value(float(self.app.defaults["tools_extract_oblong_ring"])) - self.ui.square_ring_entry.set_value(float(self.app.defaults["tools_extract_square_ring"])) - self.ui.rectangular_ring_entry.set_value(float(self.app.defaults["tools_extract_rectangular_ring"])) - self.ui.other_ring_entry.set_value(float(self.app.defaults["tools_extract_others_ring"])) + self.ui.circular_ring_entry.set_value(float(self.app.options["tools_extract_circular_ring"])) + self.ui.oblong_ring_entry.set_value(float(self.app.options["tools_extract_oblong_ring"])) + self.ui.square_ring_entry.set_value(float(self.app.options["tools_extract_square_ring"])) + self.ui.rectangular_ring_entry.set_value(float(self.app.options["tools_extract_rectangular_ring"])) + self.ui.other_ring_entry.set_value(float(self.app.options["tools_extract_others_ring"])) - self.ui.circular_cb.set_value(self.app.defaults["tools_extract_circular"]) - self.ui.oblong_cb.set_value(self.app.defaults["tools_extract_oblong"]) - self.ui.square_cb.set_value(self.app.defaults["tools_extract_square"]) - self.ui.rectangular_cb.set_value(self.app.defaults["tools_extract_rectangular"]) - self.ui.other_cb.set_value(self.app.defaults["tools_extract_others"]) + self.ui.circular_cb.set_value(self.app.options["tools_extract_circular"]) + self.ui.oblong_cb.set_value(self.app.options["tools_extract_oblong"]) + self.ui.square_cb.set_value(self.app.options["tools_extract_square"]) + self.ui.rectangular_cb.set_value(self.app.options["tools_extract_rectangular"]) + self.ui.other_cb.set_value(self.app.options["tools_extract_others"]) - self.ui.factor_entry.set_value(float(self.app.defaults["tools_extract_hole_prop_factor"])) + self.ui.factor_entry.set_value(float(self.app.options["tools_extract_hole_prop_factor"])) # Extract Soldermask - self.ui.clearance_entry.set_value(float(self.app.defaults["tools_extract_sm_clearance"])) + self.ui.clearance_entry.set_value(float(self.app.options["tools_extract_sm_clearance"])) # Extract Cutout - self.ui.margin_cut_entry.set_value(float(self.app.defaults["tools_extract_cut_margin"])) - self.ui.thick_cut_entry.set_value(float(self.app.defaults["tools_extract_cut_thickness"])) + self.ui.margin_cut_entry.set_value(float(self.app.options["tools_extract_cut_margin"])) + self.ui.thick_cut_entry.set_value(float(self.app.options["tools_extract_cut_thickness"])) # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() @@ -928,7 +928,7 @@ class ToolExtract(AppTool): if self.ui.apertures_table.cellWidget(cw_row, 3).isChecked(): # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) - color = self.app.defaults['global_sel_draw_color'] + color = self.app.options['global_sel_draw_color'] color = (color + 'AA') if len(color) == 7 else (color[:-2] + 'AA') grb_obj.plot_aperture(color=color, marked_aperture=aperture, visible=True, run_thread=True) else: diff --git a/appPlugins/ToolFiducials.py b/appPlugins/ToolFiducials.py index 1ee2036d..3365ccee 100644 --- a/appPlugins/ToolFiducials.py +++ b/appPlugins/ToolFiducials.py @@ -76,7 +76,7 @@ class ToolFiducials(AppTool): self.margin_val = None self.sec_position = None - self.grb_steps_per_circle = self.app.defaults["gerber_circle_steps"] + self.grb_steps_per_circle = self.app.options["gerber_circle_steps"] self.click_points = [] @@ -162,14 +162,14 @@ class ToolFiducials(AppTool): self.pluginName = self.ui.pluginName self.connect_signals_at_init() - self.ui.fid_size_entry.set_value(self.app.defaults["tools_fiducials_dia"]) - self.ui.margin_entry.set_value(float(self.app.defaults["tools_fiducials_margin"])) - self.ui.mode_radio.set_value(self.app.defaults["tools_fiducials_mode"]) - self.ui.pos_radio.set_value(self.app.defaults["tools_fiducials_second_pos"]) - self.ui.fid_type_combo.set_value(self.app.defaults["tools_fiducials_type"]) + self.ui.fid_size_entry.set_value(self.app.options["tools_fiducials_dia"]) + self.ui.margin_entry.set_value(float(self.app.options["tools_fiducials_margin"])) + self.ui.mode_radio.set_value(self.app.options["tools_fiducials_mode"]) + self.ui.pos_radio.set_value(self.app.options["tools_fiducials_second_pos"]) + self.ui.fid_type_combo.set_value(self.app.options["tools_fiducials_type"]) # needed so the visibility of some objects will be updated self.on_fiducial_type(val=self.ui.fid_type_combo.get_value()) - self.ui.line_thickness_entry.set_value(float(self.app.defaults["tools_fiducials_line_thickness"])) + self.ui.line_thickness_entry.set_value(float(self.app.options["tools_fiducials_line_thickness"])) self.click_points = [] self.ui.bottom_left_coords_entry.set_value('') @@ -180,7 +180,7 @@ class ToolFiducials(AppTool): self.sm_obj_set = set() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) # SELECT THE CURRENT OBJECT diff --git a/appPlugins/ToolFilm.py b/appPlugins/ToolFilm.py index 3b1ba9a6..88a2dd18 100644 --- a/appPlugins/ToolFilm.py +++ b/appPlugins/ToolFilm.py @@ -186,40 +186,40 @@ class Film(AppTool): self.reset_fields() - f_type = self.app.defaults["tools_film_polarity"] if self.app.defaults["tools_film_polarity"] else 'neg' + f_type = self.app.options["tools_film_polarity"] if self.app.options["tools_film_polarity"] else 'neg' self.ui.film_type.set_value(str(f_type)) self.ui.on_film_type(val=f_type) - b_entry = self.app.defaults["tools_film_boundary"] if self.app.defaults["tools_film_boundary"] else 0.0 + b_entry = self.app.options["tools_film_boundary"] if self.app.options["tools_film_boundary"] else 0.0 self.ui.boundary_entry.set_value(float(b_entry)) - scale_stroke_width = self.app.defaults["tools_film_scale_stroke"] if \ - self.app.defaults["tools_film_scale_stroke"] else 0.0 + scale_stroke_width = self.app.options["tools_film_scale_stroke"] if \ + self.app.options["tools_film_scale_stroke"] else 0.0 self.ui.film_scale_stroke_entry.set_value(float(scale_stroke_width)) self.ui.punch_cb.set_value(False) self.ui.source_punch.set_value('exc') - self.ui.film_scale_cb.set_value(self.app.defaults["tools_film_scale_cb"]) - self.ui.film_scalex_entry.set_value(float(self.app.defaults["tools_film_scale_x_entry"])) - self.ui.film_scaley_entry.set_value(float(self.app.defaults["tools_film_scale_y_entry"])) - self.ui.scale_ref_combo.set_value(self.app.defaults["tools_film_scale_ref"]) + self.ui.film_scale_cb.set_value(self.app.options["tools_film_scale_cb"]) + self.ui.film_scalex_entry.set_value(float(self.app.options["tools_film_scale_x_entry"])) + self.ui.film_scaley_entry.set_value(float(self.app.options["tools_film_scale_y_entry"])) + self.ui.scale_ref_combo.set_value(self.app.options["tools_film_scale_ref"]) - self.ui.film_skew_cb.set_value(self.app.defaults["tools_film_skew_cb"]) - self.ui.film_skewx_entry.set_value(float(self.app.defaults["tools_film_skew_x_entry"])) - self.ui.film_skewy_entry.set_value(float(self.app.defaults["tools_film_skew_y_entry"])) - self.ui.skew_ref_combo.set_value(self.app.defaults["tools_film_skew_ref"]) + self.ui.film_skew_cb.set_value(self.app.options["tools_film_skew_cb"]) + self.ui.film_skewx_entry.set_value(float(self.app.options["tools_film_skew_x_entry"])) + self.ui.film_skewy_entry.set_value(float(self.app.options["tools_film_skew_y_entry"])) + self.ui.skew_ref_combo.set_value(self.app.options["tools_film_skew_ref"]) - self.ui.film_mirror_cb.set_value(self.app.defaults["tools_film_mirror_cb"]) - self.ui.film_mirror_axis.set_value(self.app.defaults["tools_film_mirror_axis_radio"]) - self.ui.file_type_radio.set_value(self.app.defaults["tools_film_file_type_radio"]) - self.ui.orientation_radio.set_value(self.app.defaults["tools_film_orientation"]) - self.ui.pagesize_combo.set_value(self.app.defaults["tools_film_pagesize"]) + self.ui.film_mirror_cb.set_value(self.app.options["tools_film_mirror_cb"]) + self.ui.film_mirror_axis.set_value(self.app.options["tools_film_mirror_axis_radio"]) + self.ui.file_type_radio.set_value(self.app.options["tools_film_file_type_radio"]) + self.ui.orientation_radio.set_value(self.app.options["tools_film_orientation"]) + self.ui.pagesize_combo.set_value(self.app.options["tools_film_pagesize"]) - self.ui.png_dpi_spinner.set_value(self.app.defaults["tools_film_png_dpi"]) + self.ui.png_dpi_spinner.set_value(self.app.options["tools_film_png_dpi"]) - self.ui.convex_box_cb.set_value(self.app.defaults["tools_film_shape"]) - self.ui.rounded_cb.set_value(self.app.defaults["tools_film_rounded"]) + self.ui.convex_box_cb.set_value(self.app.options["tools_film_shape"]) + self.ui.rounded_cb.set_value(self.app.options["tools_film_rounded"]) obj = self.app.collection.get_active() if obj: @@ -251,7 +251,7 @@ class Film(AppTool): self.on_type_box_index_changed(val='grb') # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -298,12 +298,12 @@ class Film(AppTool): self.ui.film_adj_label.show() self.ui.adj_frame.show() - self.ui.film_scale_cb.set_value(self.app.defaults["tools_film_scale_cb"]) - self.ui.film_skew_cb.set_value(self.app.defaults["tools_film_skew_cb"]) - self.ui.film_mirror_cb.set_value(self.app.defaults["tools_film_mirror_cb"]) + self.ui.film_scale_cb.set_value(self.app.options["tools_film_scale_cb"]) + self.ui.film_skew_cb.set_value(self.app.options["tools_film_skew_cb"]) + self.ui.film_mirror_cb.set_value(self.app.options["tools_film_mirror_cb"]) - scale_stroke_width = self.app.defaults["tools_film_scale_stroke"] if \ - self.app.defaults["tools_film_scale_stroke"] else 0.0 + scale_stroke_width = self.app.options["tools_film_scale_stroke"] if \ + self.app.options["tools_film_scale_stroke"] else 0.0 self.ui.film_scale_stroke_entry.set_value(float(scale_stroke_width)) def on_film_creation(self): @@ -599,7 +599,7 @@ class Film(AppTool): self.app.defaults.report_usage("export_negative()") if filename is None: - filename = self.app.defaults["global_last_save_folder"] + filename = self.app.options["global_last_save_folder"] self.app.log.debug("Film.export_svg() negative") @@ -896,7 +896,7 @@ class Film(AppTool): self.app.log.error("FilmTool.export_negative() --> PDF output Reportlab section --> %s" % str(e)) return 'fail' - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("SVG", filename) self.app.file_saved.emit("SVG", filename) self.app.inform.emit('[success] %s: %s' % (_("Film file exported to"), filename)) @@ -949,7 +949,7 @@ class Film(AppTool): self.app.defaults.report_usage("export_positive()") if filename is None: - filename = self.app.defaults["global_last_save_folder"] + filename = self.app.options["global_last_save_folder"] self.app.log.debug("Film.export_positive() black") @@ -1171,7 +1171,7 @@ class Film(AppTool): self.app.log.error("FilmTool.export_positive() --> PDF output --> %s" % str(e)) return 'fail' - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("SVG", filename) self.app.file_saved.emit("SVG", filename) self.app.inform.emit('[success] %s: %s' % (_("Film file exported to"), filename)) diff --git a/appPlugins/ToolFollow.py b/appPlugins/ToolFollow.py index 0ce765b2..42fd3b00 100644 --- a/appPlugins/ToolFollow.py +++ b/appPlugins/ToolFollow.py @@ -42,7 +42,7 @@ class ToolFollow(AppTool, Gerber): self.decimals = self.app.decimals AppTool.__init__(self, app) - Gerber.__init__(self, steps_per_circle=self.app.defaults["gerber_circle_steps"]) + Gerber.__init__(self, steps_per_circle=self.app.options["gerber_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -157,7 +157,7 @@ class ToolFollow(AppTool, Gerber): self.ui.object_combo.set_value(obj_name) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -560,8 +560,8 @@ class ToolFollow(AppTool, Gerber): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) if self.cursor_pos is None: self.cursor_pos = (0, 0) diff --git a/appPlugins/ToolInvertGerber.py b/appPlugins/ToolInvertGerber.py index 909a0965..babc15eb 100644 --- a/appPlugins/ToolInvertGerber.py +++ b/appPlugins/ToolInvertGerber.py @@ -113,8 +113,8 @@ class ToolInvertGerber(AppTool): self.pluginName = self.ui.pluginName self.connect_signals_at_init() - self.ui.margin_entry.set_value(float(self.app.defaults["tools_invert_margin"])) - self.ui.join_radio.set_value(self.app.defaults["tools_invert_join_style"]) + self.ui.margin_entry.set_value(float(self.app.options["tools_invert_margin"])) + self.ui.join_radio.set_value(self.app.options["tools_invert_join_style"]) # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() @@ -131,7 +131,7 @@ class ToolInvertGerber(AppTool): if join_style is None: join_style = 'r' - grb_circle_steps = int(self.app.defaults["gerber_circle_steps"]) + grb_circle_steps = int(self.app.options["gerber_circle_steps"]) obj_name = self.ui.gerber_combo.currentText() outname = obj_name + "_inverted" diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index 73e18ad4..d11ed3a1 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -47,7 +47,7 @@ class ToolIsolation(AppTool, Gerber): self.decimals = self.app.decimals AppTool.__init__(self, app) - Gerber.__init__(self, steps_per_circle=self.app.defaults["gerber_circle_steps"]) + Gerber.__init__(self, steps_per_circle=self.app.options["gerber_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -95,14 +95,14 @@ class ToolIsolation(AppTool, Gerber): # store here the state of the combine_cb GUI element # used when the rest machining is toggled - self.old_combine_state = self.app.defaults["tools_iso_combine_passes"] + self.old_combine_state = self.app.options["tools_iso_combine_passes"] # store here solid_geometry when there are tool with isolation job self.solid_geometry = [] self.tool_type_item_options = [] - self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"]) + self.grb_circle_steps = int(self.app.options["gerber_circle_steps"]) self.tooldia = None # store here the tool diameter that is guaranteed to isolate the object @@ -312,10 +312,10 @@ class ToolIsolation(AppTool, Gerber): self.app.log.debug("ToolIsolation.set_tool_ui() Select Gerber object -> %s" % str(ee)) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) - if self.app.defaults["gerber_buffering"] == 'no': + if self.app.options["gerber_buffering"] == 'no': self.ui.create_buffer_button.show() try: self.ui.create_buffer_button.clicked.disconnect(self.on_generate_buffer) @@ -334,24 +334,24 @@ class ToolIsolation(AppTool, Gerber): self.on_type_excobj_index_changed(val="gerber") self.on_reference_combo_changed() - self.ui.iso_order_combo.set_value(self.app.defaults["tools_iso_order"]) - self.ui.tool_shape_combo.set_value(self.app.defaults["tools_iso_tool_shape"]) + self.ui.iso_order_combo.set_value(self.app.options["tools_iso_order"]) + self.ui.tool_shape_combo.set_value(self.app.options["tools_iso_tool_shape"]) - self.ui.tipdia_entry.set_value(self.app.defaults["tools_iso_vtipdia"]) - self.ui.tipangle_entry.set_value(self.app.defaults["tools_iso_vtipangle"]) - self.ui.cutz_entry.set_value(self.app.defaults["tools_iso_cutz"]) + self.ui.tipdia_entry.set_value(self.app.options["tools_iso_vtipdia"]) + self.ui.tipangle_entry.set_value(self.app.options["tools_iso_vtipangle"]) + self.ui.cutz_entry.set_value(self.app.options["tools_iso_cutz"]) - self.ui.passes_entry.set_value(self.app.defaults["tools_iso_passes"]) - self.ui.pad_passes_entry.set_value(self.app.defaults["tools_iso_pad_passes"]) - self.ui.iso_overlap_entry.set_value(self.app.defaults["tools_iso_overlap"]) - self.ui.milling_type_radio.set_value(self.app.defaults["tools_iso_milling_type"]) - self.ui.combine_passes_cb.set_value(self.app.defaults["tools_iso_combine_passes"]) - self.ui.valid_cb.set_value(self.app.defaults["tools_iso_check_valid"]) - self.ui.area_shape_radio.set_value(self.app.defaults["tools_iso_area_shape"]) - self.ui.poly_int_cb.set_value(self.app.defaults["tools_iso_poly_ints"]) - self.ui.forced_rest_iso_cb.set_value(self.app.defaults["tools_iso_force"]) + self.ui.passes_entry.set_value(self.app.options["tools_iso_passes"]) + self.ui.pad_passes_entry.set_value(self.app.options["tools_iso_pad_passes"]) + self.ui.iso_overlap_entry.set_value(self.app.options["tools_iso_overlap"]) + self.ui.milling_type_radio.set_value(self.app.options["tools_iso_milling_type"]) + self.ui.combine_passes_cb.set_value(self.app.options["tools_iso_combine_passes"]) + self.ui.valid_cb.set_value(self.app.options["tools_iso_check_valid"]) + self.ui.area_shape_radio.set_value(self.app.options["tools_iso_area_shape"]) + self.ui.poly_int_cb.set_value(self.app.options["tools_iso_poly_ints"]) + self.ui.forced_rest_iso_cb.set_value(self.app.options["tools_iso_force"]) - self.ui.new_tooldia_entry.set_value(self.app.defaults["tools_iso_newdia"]) + self.ui.new_tooldia_entry.set_value(self.app.options["tools_iso_newdia"]) # loaded_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value()) # if loaded_obj: @@ -377,48 +377,48 @@ class ToolIsolation(AppTool, Gerber): # self.default_data.update({ # "name": outname + '_iso', - # "plot": self.app.defaults["geometry_plot"], - # "cutz": float(self.app.defaults["tools_iso_tool_cutz"]), - # "vtipdia": float(self.app.defaults["tools_iso_tool_vtipdia"]), - # "vtipangle": float(self.app.defaults["tools_iso_tool_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"], + # "plot": self.app.options["geometry_plot"], + # "cutz": float(self.app.options["tools_iso_tool_cutz"]), + # "vtipdia": float(self.app.options["tools_iso_tool_vtipdia"]), + # "vtipangle": float(self.app.options["tools_iso_tool_vtipangle"]), + # "travelz": self.app.options["geometry_travelz"], + # "feedrate": self.app.options["geometry_feedrate"], + # "feedrate_z": self.app.options["geometry_feedrate_z"], + # "feedrate_rapid": self.app.options["geometry_feedrate_rapid"], # - # "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"], + # "multidepth": self.app.options["geometry_multidepth"], + # "ppname_g": self.app.options["geometry_ppname_g"], + # "depthperpass": self.app.options["geometry_depthperpass"], + # "extracut": self.app.options["geometry_extracut"], + # "extracut_length": self.app.options["geometry_extracut_length"], + # "toolchange": self.app.options["geometry_toolchange"], + # "toolchangez": self.app.options["geometry_toolchangez"], + # "endz": self.app.options["geometry_endz"], + # "endxy": self.app.options["geometry_endxy"], # - # "dwell": self.app.defaults["geometry_dwell"], - # "dwelltime": self.app.defaults["geometry_dwelltime"], - # "spindlespeed": self.app.defaults["geometry_spindlespeed"], - # "spindledir": self.app.defaults["geometry_spindledir"], + # "dwell": self.app.options["geometry_dwell"], + # "dwelltime": self.app.options["geometry_dwelltime"], + # "spindlespeed": self.app.options["geometry_spindlespeed"], + # "spindledir": self.app.options["geometry_spindledir"], # - # "optimization_type": self.app.defaults["geometry_optimization_type"], - # "search_time": self.app.defaults["geometry_search_time"], - # "toolchangexy": self.app.defaults["geometry_toolchangexy"], - # "startz": self.app.defaults["geometry_startz"], + # "optimization_type": self.app.options["geometry_optimization_type"], + # "search_time": self.app.options["geometry_search_time"], + # "toolchangexy": self.app.options["geometry_toolchangexy"], + # "startz": self.app.options["geometry_startz"], # - # "area_exclusion": self.app.defaults["geometry_area_exclusion"], - # "area_shape": self.app.defaults["geometry_area_shape"], - # "area_strategy": self.app.defaults["geometry_area_strategy"], - # "area_overz": float(self.app.defaults["geometry_area_overz"]), + # "area_exclusion": self.app.options["geometry_area_exclusion"], + # "area_shape": self.app.options["geometry_area_shape"], + # "area_strategy": self.app.options["geometry_area_strategy"], + # "area_overz": float(self.app.options["geometry_area_overz"]), # }) try: - dias = [float(self.app.defaults["tools_iso_tooldia"])] + dias = [float(self.app.options["tools_iso_tooldia"])] except (ValueError, TypeError): - if isinstance(self.app.defaults["tools_iso_tooldia"], str): - dias = [float(eval(dia)) for dia in self.app.defaults["tools_iso_tooldia"].split(",") if dia != ''] + if isinstance(self.app.options["tools_iso_tooldia"], str): + dias = [float(eval(dia)) for dia in self.app.options["tools_iso_tooldia"].split(",") if dia != ''] else: - dias = self.app.defaults["tools_iso_tooldia"] + dias = self.app.options["tools_iso_tooldia"] if not dias: self.app.log.error( @@ -438,7 +438,7 @@ class ToolIsolation(AppTool, Gerber): self.cursor_pos = None self.mouse_is_dragging = False - prog_plot = True if self.app.defaults["tools_iso_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_iso_plotting"] == 'progressive' else False if prog_plot: self.temp_shapes.clear(update=True) @@ -446,7 +446,7 @@ class ToolIsolation(AppTool, Gerber): self.tool_type_item_options = ["C1", "C2", "C3", "C4", "B", "V", "L"] - self.on_rest_machining_check(state=self.app.defaults["tools_iso_rest"]) + self.on_rest_machining_check(state=self.app.options["tools_iso_rest"]) self.ui.tools_table.drag_drop_sig.connect(self.rebuild_ui) @@ -535,7 +535,7 @@ class ToolIsolation(AppTool, Gerber): self.ui.add_tool_frame.show() # Tool parameters section - app_defaults = self.app.defaults + app_defaults = self.app.options if self.iso_tools: for tool in self.iso_tools: tool_data = self.iso_tools[tool]['data'] @@ -1779,7 +1779,7 @@ class ToolIsolation(AppTool, Gerber): negative_dia=negative_dia, extra_passes=use_extra_passes, plot=plot) else: - prog_plot = self.app.defaults["tools_iso_plotting"] + prog_plot = self.app.options["tools_iso_plotting"] for tool in sel_tools: tool_data = tools_storage[tool]['data'] @@ -1850,7 +1850,7 @@ class ToolIsolation(AppTool, Gerber): if negative_dia: iso_offset = -iso_offset pad_pass_geo.append( - geo.buffer(iso_offset, int(self.app.defaults["gerber_circle_steps"]))) + geo.buffer(iso_offset, int(self.app.options["gerber_circle_steps"]))) pad_geo.append(unary_union(pad_pass_geo).difference(solid_geo_union)) total_geo = [] @@ -1999,7 +1999,7 @@ class ToolIsolation(AppTool, Gerber): pass # decide to use "progressive" or "normal" plotting - prog_plot = self.app.defaults["tools_iso_plotting"] + prog_plot = self.app.options["tools_iso_plotting"] for sorted_tool in sorted_tools: for tool in tools_storage: @@ -2072,7 +2072,7 @@ class ToolIsolation(AppTool, Gerber): break # clean the progressive plotted shapes if it was used - if plot and self.app.defaults["tools_iso_plotting"] == 'progressive': + if plot and self.app.options["tools_iso_plotting"] == 'progressive': self.temp_shapes.clear(update=True) # remove tools without geometry @@ -2171,7 +2171,7 @@ class ToolIsolation(AppTool, Gerber): iso_name = iso_obj.obj_options["name"] + '_iso_combined' geometry = iso2geo if prog_plot is None: - prog_plot = self.app.defaults["tools_iso_plotting"] + prog_plot = self.app.options["tools_iso_plotting"] for tool in sel_tools: tool_dia = tools_storage[tool]['tooldia'] @@ -2246,7 +2246,7 @@ class ToolIsolation(AppTool, Gerber): iso_offset = tool_dia * ((2 * nr_pass + 1) / 2.0000001) - (nr_pass * overlap * tool_dia) if negative_dia: iso_offset = -iso_offset - pad_pass_geo.append(geo.buffer(iso_offset, int(self.app.defaults["gerber_circle_steps"]))) + pad_pass_geo.append(geo.buffer(iso_offset, int(self.app.options["gerber_circle_steps"]))) pad_geo.append(unary_union(pad_pass_geo).difference(solid_geo_union)) solid_geo += pad_geo @@ -2483,8 +2483,8 @@ class ToolIsolation(AppTool, Gerber): elif clicked_poly: if clicked_poly not in self.poly_dict.values(): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=clicked_poly, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults['global_sel_draw_color'] + 'AF', + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options['global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = clicked_poly self.app.inform.emit( @@ -2571,15 +2571,15 @@ class ToolIsolation(AppTool, Gerber): try: for poly in self.grb_obj.solid_geometry: shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=poly, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults['global_sel_draw_color'] + 'AF', + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options['global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = poly except TypeError: poly = self.grb_obj.solid_geometry shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=poly, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults['global_sel_draw_color'] + 'AF', + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options['global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = poly @@ -2611,8 +2611,8 @@ class ToolIsolation(AppTool, Gerber): if geo.within(poly_selection): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=geo, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults[ + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options[ 'global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = geo @@ -2621,8 +2621,8 @@ class ToolIsolation(AppTool, Gerber): if poly_selection.intersects(geo): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=geo, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults[ + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options[ 'global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = geo @@ -2633,8 +2633,8 @@ class ToolIsolation(AppTool, Gerber): if poly_selection.contains(self.solid_geometry): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=self.solid_geometry, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults[ + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options[ 'global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = self.solid_geometry @@ -2643,8 +2643,8 @@ class ToolIsolation(AppTool, Gerber): if poly_selection.intersects(self.solid_geometry): shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=self.solid_geometry, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults[ + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options[ 'global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = self.solid_geometry @@ -2813,8 +2813,8 @@ class ToolIsolation(AppTool, Gerber): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) if self.cursor_pos is None: self.cursor_pos = (0, 0) @@ -3552,7 +3552,7 @@ class IsoUI: self.tool_shape_combo.setObjectName('i_tool_shape') self.tool_shape_combo.addItems(["C1", "C2", "C3", "C4", "B", "V", "L"]) - idx = int(self.app.defaults['tools_iso_tool_shape']) + idx = int(self.app.options['tools_iso_tool_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/ToolLevelling.py b/appPlugins/ToolLevelling.py index 1070f475..2be5a36e 100644 --- a/appPlugins/ToolLevelling.py +++ b/appPlugins/ToolLevelling.py @@ -68,7 +68,7 @@ class ToolLevelling(AppTool, CNCjob): self.decimals = self.app.decimals AppTool.__init__(self, app) - CNCjob.__init__(self, steps_per_circle=self.app.defaults["cncjob_steps_per_circle"]) + CNCjob.__init__(self, steps_per_circle=self.app.options["cncjob_steps_per_circle"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -126,7 +126,7 @@ class ToolLevelling(AppTool, CNCjob): self.gcode_viewer_tab = None # store the current selection shape status to be restored after manual adding test points - self.old_selection_state = self.app.defaults['global_selection_shape'] + self.old_selection_state = self.app.options['global_selection_shape'] def install(self, icon=None, separator=None, **kwargs): AppTool.install(self, icon, separator, shortcut='', **kwargs) @@ -322,7 +322,7 @@ class ToolLevelling(AppTool, CNCjob): self.ui.al_frame.setDisabled(True) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) try: @@ -600,7 +600,7 @@ class ToolLevelling(AppTool, CNCjob): fprobe_pt_buff = f_probe_pt.buffer(radius) self.app.inform.emit(_("Click on canvas to add a Probe Point...")) - self.app.defaults['global_selection_shape'] = False + self.app.options['global_selection_shape'] = False if self.app.use_3d_engine: self.app.plotcanvas.graph_event_disconnect('key_press', self.app.ui.keyPressEvent) @@ -887,7 +887,7 @@ class ToolLevelling(AppTool, CNCjob): self.mouse_events_connected = False # restore selection - self.app.defaults['global_selection_shape'] = self.old_selection_state + self.app.options['global_selection_shape'] = self.old_selection_state self.app.inform.emit(_("Finished adding Probe Points...")) @@ -961,7 +961,7 @@ class ToolLevelling(AppTool, CNCjob): self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) # restore selection - self.app.defaults['global_selection_shape'] = self.old_selection_state + self.app.options['global_selection_shape'] = self.old_selection_state # Grid toggle if key == QtCore.Qt.Key.Key_G or key == 'G': @@ -1021,7 +1021,7 @@ class ToolLevelling(AppTool, CNCjob): self.ui.al_columns_label.setDisabled(False) self.ui.al_method_lbl.setDisabled(False) self.ui.al_method_radio.setDisabled(False) - self.ui.al_method_radio.set_value(self.app.defaults['tools_al_method']) + self.ui.al_method_radio.set_value(self.app.options['tools_al_method']) def on_method_radio(self, val): if val == 'b': @@ -1278,7 +1278,7 @@ class ToolLevelling(AppTool, CNCjob): step = self.ui.jog_step_entry.get_value(), feedrate = self.ui.jog_fr_entry.get_value() - travelz = float(self.app.defaults["tools_al_grbl_travelz"]) + travelz = float(self.app.options["tools_al_grbl_travelz"]) if direction == 'xplus': cmd = "$J=G91 %s X%s F%s" % ({'IN': 'G20', 'MM': 'G21'}[self.units], str(step), str(feedrate)) @@ -1477,7 +1477,7 @@ class ToolLevelling(AppTool, CNCjob): def on_save_probing_gcode(self): lines = StringIO(self.probing_gcode_text) - _filter_ = self.app.defaults['cncjob_save_filters'] + _filter_ = self.app.options['cncjob_save_filters'] name = "probing_gcode" try: dir_file_to_save = self.app.get_last_save_folder() + '/' + str(name) @@ -1496,7 +1496,7 @@ class ToolLevelling(AppTool, CNCjob): return else: try: - force_windows_line_endings = self.app.defaults['cncjob_line_ending'] + force_windows_line_endings = self.app.options['cncjob_line_ending'] if force_windows_line_endings and sys.platform != 'win32': with open(filename, 'w', newline='\r\n') as f: for line in lines: @@ -1688,7 +1688,7 @@ class ToolLevelling(AppTool, CNCjob): return else: try: - force_windows_line_endings = self.app.defaults['cncjob_line_ending'] + force_windows_line_endings = self.app.options['cncjob_line_ending'] if force_windows_line_endings and sys.platform != 'win32': with open(filename, 'w', newline='\r\n') as f: for line in self.grbl_probe_result: diff --git a/appPlugins/ToolMarkers.py b/appPlugins/ToolMarkers.py index e40b03e9..73114a3e 100644 --- a/appPlugins/ToolMarkers.py +++ b/appPlugins/ToolMarkers.py @@ -63,7 +63,7 @@ class ToolMarkers(AppTool): # Tool properties self.fid_dia = None - self.grb_steps_per_circle = self.app.defaults["gerber_circle_steps"] + self.grb_steps_per_circle = self.app.options["gerber_circle_steps"] self.handlers_connected = False @@ -180,18 +180,18 @@ class ToolMarkers(AppTool): self.pluginName = self.ui.pluginName self.connect_signals_at_init() - self.ui.thick_entry.set_value(self.app.defaults["tools_markers_thickness"]) - self.ui.l_entry.set_value(float(self.app.defaults["tools_markers_length"])) + self.ui.thick_entry.set_value(self.app.options["tools_markers_thickness"]) + self.ui.l_entry.set_value(float(self.app.options["tools_markers_length"])) - self.ui.ref_radio.set_value(self.app.defaults["tools_markers_reference"]) - self.ui.offset_x_entry.set_value(float(self.app.defaults["tools_markers_offset_x"])) - self.ui.offset_y_entry.set_value(float(self.app.defaults["tools_markers_offset_y"])) + self.ui.ref_radio.set_value(self.app.options["tools_markers_reference"]) + self.ui.offset_x_entry.set_value(float(self.app.options["tools_markers_offset_x"])) + self.ui.offset_y_entry.set_value(float(self.app.options["tools_markers_offset_y"])) self.ui.offset_link_button.setChecked(True) self.ui.on_link_checked(True) self.ui.toggle_all_cb.set_value(False) - self.ui.type_radio.set_value(self.app.defaults["tools_markers_type"]) - self.ui.drill_dia_entry.set_value(self.app.defaults["tools_markers_drill_dia"]) + self.ui.type_radio.set_value(self.app.options["tools_markers_type"]) + self.ui.drill_dia_entry.set_value(self.app.options["tools_markers_drill_dia"]) self.ui.mode_radio.set_value("a") self.ui.insert_type_radio.set_value(val="grb") @@ -209,7 +209,7 @@ class ToolMarkers(AppTool): self.ui.object_combo.setCurrentIndex(0) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 00951520..c76d89b4 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -93,7 +93,7 @@ class ToolMilling(AppTool, Excellon): self.decimals = self.app.decimals AppTool.__init__(self, app) - Excellon.__init__(self, excellon_circle_steps=self.app.defaults["excellon_circle_steps"]) + Excellon.__init__(self, excellon_circle_steps=self.app.options["excellon_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -149,13 +149,13 @@ class ToolMilling(AppTool, Excellon): self.grid_status_memory = self.app.ui.grid_snap_btn.isChecked() # store here the state of the exclusion checkbox state to be restored after building the UI - # TODO add this in the self.app.defaults dict and in Preferences + # TODO add this in the self.app.options dict and in Preferences self.exclusion_area_cb_is_checked = False # store here solid_geometry when there are tool with isolation job self.solid_geometry = [] - self.circle_steps = int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["geometry_circle_steps"]) self.tooldia = None @@ -451,7 +451,7 @@ class ToolMilling(AppTool, Excellon): def set_tool_ui(self): self.units = self.app.app_units.upper() - self.old_tool_dia = self.app.defaults["tools_iso_newdia"] + self.old_tool_dia = self.app.options["tools_iso_newdia"] self.obj_name = "" self.target_obj = None @@ -622,8 +622,8 @@ class ToolMilling(AppTool, Excellon): self.ui.tools_frame.show() - self.ui.order_combo.set_value(self.app.defaults["tools_drill_tool_order"]) - self.ui.milling_type_radio.set_value(self.app.defaults["tools_mill_milling_type"]) + self.ui.order_combo.set_value(self.app.options["tools_drill_tool_order"]) + self.ui.milling_type_radio.set_value(self.app.options["tools_mill_milling_type"]) # init the working variables self.default_data.clear() @@ -649,7 +649,7 @@ class ToolMilling(AppTool, Excellon): # #######3 TEMP SETTINGS ################# # ######################################## - self.ui.addtool_entry.set_value(self.app.defaults["tools_mill_tooldia"]) + self.ui.addtool_entry.set_value(self.app.options["tools_mill_tooldia"]) self.on_object_changed() if self.target_obj: @@ -667,7 +667,7 @@ class ToolMilling(AppTool, Excellon): self.plot_cb_handler() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def plot_cb_handler(self): @@ -738,8 +738,8 @@ class ToolMilling(AppTool, Excellon): # some will disable some of the hidden features but other are set by # other plugins so we hide them but we do not disable (like the `multidepth`) # tool_data['tools_mill_multidepth'] = False - tool_data['tools_mill_extracut'] = self.app.defaults["tools_mill_extracut"] - tool_data['tools_mill_dwell'] = self.app.defaults["tools_mill_dwell"] + tool_data['tools_mill_extracut'] = self.app.options["tools_mill_extracut"] + tool_data['tools_mill_dwell'] = self.app.options["tools_mill_dwell"] tool_data['tools_mill_area_exclusion'] = False self.ui.offset_type_lbl.hide() @@ -1344,7 +1344,7 @@ class ToolMilling(AppTool, Excellon): self.ui.job_type_lbl.show() self.ui.job_type_combo.show() - # self.ui.job_type_combo.set_value(self.app.defaults["tools_mill_job_val"]) + # self.ui.job_type_combo.set_value(self.app.options["tools_mill_job_val"]) self.ui.offset_separator_line.show() self.ui.tool_shape_label.show() @@ -1957,7 +1957,7 @@ class ToolMilling(AppTool, Excellon): if t_type.upper() == 'L': self.ui.pp_geo_name_cb.set_value('default_laser') else: - self.ui.pp_geo_name_cb.set_value(self.app.defaults['tools_mill_ppname_g']) + self.ui.pp_geo_name_cb.set_value(self.app.options['tools_mill_ppname_g']) self.on_pp_changed() def ui_update_v_shape(self, tool_type_txt): @@ -2880,7 +2880,7 @@ class ToolMilling(AppTool, Excellon): # graceful abort requested by the user raise grace geo_res = self.clear_polygon2(pp, seedpoint=pp.centroid, tooldia=mill_dia, overlap=over, - steps_per_circle=self.app.defaults['geometry_circle_steps'], + steps_per_circle=self.app.options['geometry_circle_steps'], connect=conn, contour=cont, prog_plot=False) if geo_res: cp.append(geo_res) @@ -3038,7 +3038,7 @@ class ToolMilling(AppTool, Excellon): try: segx = geo_obj.obj_options['segx'] except KeyError: - segx = self.app.defaults['geometry_segx'] + segx = self.app.options['geometry_segx'] try: segy = data_dict['segy'] except KeyError: @@ -3048,7 +3048,7 @@ class ToolMilling(AppTool, Excellon): try: segy = geo_obj.obj_options['segy'] except KeyError: - segy = self.app.defaults['geometry_segy'] + segy = self.app.options['geometry_segy'] try: xmin = geo_obj.obj_options['xmin'] @@ -3160,11 +3160,11 @@ class ToolMilling(AppTool, Excellon): laser_min_power = tools_dict[tooluid_key]['data']["tools_mill_min_power"] pp_geometry_name = tools_dict[tooluid_key]['data']["tools_mill_ppname_g"] - spindledir = self.app.defaults['tools_mill_spindledir'] + spindledir = self.app.options['tools_mill_spindledir'] tool_solid_geometry = self.solid_geometry - new_cncjob_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - new_cncjob_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + new_cncjob_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + new_cncjob_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] # Propagate options new_cncjob_obj.obj_options["tooldia"] = tooldia_val @@ -3176,7 +3176,7 @@ class ToolMilling(AppTool, Excellon): # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially # to a value of 0.0005 which is 20 times less than 0.01 - glob_tol = float(self.app.defaults['global_tolerance']) + glob_tol = float(self.app.options['global_tolerance']) tol = glob_tol / 20 if self.units.lower() == 'in' else glob_tol res, start_gcode = new_cncjob_obj.generate_from_geometry_2( @@ -3352,7 +3352,7 @@ class ToolMilling(AppTool, Excellon): self.ui.toolchangez_entry.get_value() except AttributeError: tools_dict[tooluid_key]['data']['tools_mill_toolchangez'] = \ - self.app.defaults['tools_mill_toolchangez'] + self.app.options['tools_mill_toolchangez'] # Toolchange X-Y try: if not from_tcl: @@ -3360,25 +3360,25 @@ class ToolMilling(AppTool, Excellon): self.ui.toolchangexy_entry.get_value() except AttributeError: tools_dict[tooluid_key]['data']['tools_mill_toolchangexy'] = \ - self.app.defaults['tools_mill_toolchangexy'] + self.app.options['tools_mill_toolchangexy'] # End Move Z try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_endz'] = self.ui.endz_entry.get_value() except AttributeError: - tools_dict[tooluid_key]['data']['tools_mill_endz'] = self.app.defaults['tools_mill_endz'] + tools_dict[tooluid_key]['data']['tools_mill_endz'] = self.app.options['tools_mill_endz'] # End Move XY try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_endxy'] = self.ui.endxy_entry.get_value() except AttributeError: - tools_dict[tooluid_key]['data']['tools_mill_endxy'] = self.app.defaults['tools_mill_endxy'] + tools_dict[tooluid_key]['data']['tools_mill_endxy'] = self.app.options['tools_mill_endxy'] # Probe Z try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_z_pdepth'] = self.ui.pdepth_entry.get_value() except AttributeError: - tools_dict[tooluid_key]['data']['tools_mill_z_pdepth'] = self.app.defaults['tools_mill_z_pdepth'] + tools_dict[tooluid_key]['data']['tools_mill_z_pdepth'] = self.app.options['tools_mill_z_pdepth'] # Probe FR try: if not from_tcl: @@ -3386,7 +3386,7 @@ class ToolMilling(AppTool, Excellon): self.ui.feedrate_probe_entry.get_value() except AttributeError: tools_dict[tooluid_key]['data'][ - 'tools_mill_feedrate_probe'] = self.app.defaults['tools_mill_feedrate_probe'] + 'tools_mill_feedrate_probe'] = self.app.options['tools_mill_feedrate_probe'] # Exclusion Areas Enable try: @@ -3400,28 +3400,28 @@ class ToolMilling(AppTool, Excellon): tools_dict[tooluid_key]['data']['tools_mill_area_shape'] = self.ui.area_shape_radio.get_value() except AttributeError: tools_dict[tooluid_key]['data']['tools_mill_area_shape'] = \ - self.app.defaults['tools_mill_area_shape'] + self.app.options['tools_mill_area_shape'] # Exclusion Areas Strategy try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_area_strategy'] = self.ui.strategy_radio.get_value() except AttributeError: tools_dict[tooluid_key]['data']['tools_mill_area_strategy'] = \ - self.app.defaults['tools_mill_area_strategy'] + self.app.options['tools_mill_area_strategy'] # Exclusion Areas Overz try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_area_overz'] = self.ui.over_z_entry.get_value() except AttributeError: tools_dict[tooluid_key]['data']['tools_mill_area_overz'] = \ - self.app.defaults['tools_mill_area_overz'] + self.app.options['tools_mill_area_overz'] # Preprocessor try: if not from_tcl: tools_dict[tooluid_key]['data']['tools_mill_ppname_g'] = self.ui.pp_geo_name_cb.get_value() except AttributeError: - tools_dict[tooluid_key]['data']['tools_mill_ppname_g'] = self.app.defaults['tools_mill_ppname_g'] + tools_dict[tooluid_key]['data']['tools_mill_ppname_g'] = self.app.options['tools_mill_ppname_g'] # Offset calculation offset_type = dia_cnc_dict['data']['tools_mill_offset_type'] @@ -3436,7 +3436,7 @@ class ToolMilling(AppTool, Excellon): else: offset_value = tools_dict[tooluid_key]['data']['tools_mill_offset_value'] except AttributeError: - offset_value = self.app.defaults['tools_mill_offset_value'] + offset_value = self.app.options['tools_mill_offset_value'] if offset_value: tool_offset = float(offset_value) else: @@ -3458,8 +3458,8 @@ class ToolMilling(AppTool, Excellon): tool_solid_geometry = geo_obj.tools[tooluid_key]['solid_geometry'] # Coordinates - new_cncjob_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - new_cncjob_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + new_cncjob_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + new_cncjob_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] # Propagate options new_cncjob_obj.obj_options["tooldia"] = tooldia_val @@ -3468,7 +3468,7 @@ class ToolMilling(AppTool, Excellon): # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially # to a value of 0.0005 which is 20 times less than 0.01 - glob_tol = float(self.app.defaults['global_tolerance']) + glob_tol = float(self.app.options['global_tolerance']) tol = glob_tol / 20 if self.units.lower() == 'in' else glob_tol tool_lst = list(tools_dict.keys()) @@ -3828,11 +3828,11 @@ class ToolMilling(AppTool, Excellon): self.delete_sel_shape() if self.app.use_3d_engine: - face = self.app.defaults['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] - outline = self.app.defaults['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] + face = self.app.options['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] + outline = self.app.options['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] else: - face = self.app.defaults['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] - outline = self.app.defaults['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] + face = self.app.options['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] + outline = self.app.options['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] for row in sel_rows: sel_rect = self.app.exc_areas.exclusion_areas_storage[row]['shape'] @@ -4448,7 +4448,7 @@ class MillingUI: self.tool_shape_combo.setObjectName('mill_tool_shape') self.tool_shape_combo.addItems(["C1", "C2", "C3", "C4", "B", "V", "L"]) - idx = int(self.app.defaults['tools_mill_tool_shape']) + idx = int(self.app.options['tools_mill_tool_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 2f9ab019..276e1bd3 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -48,7 +48,7 @@ class NonCopperClear(AppTool, Gerber): self.decimals = self.app.decimals AppTool.__init__(self, app) - Gerber.__init__(self, steps_per_circle=self.app.defaults["gerber_circle_steps"]) + Gerber.__init__(self, steps_per_circle=self.app.options["gerber_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -112,7 +112,7 @@ class NonCopperClear(AppTool, Gerber): self.select_method = None self.tool_type_item_options = [] - self.circle_steps = int(self.app.defaults["gerber_circle_steps"]) + self.circle_steps = int(self.app.options["gerber_circle_steps"]) self.tooldia = None @@ -272,7 +272,7 @@ class NonCopperClear(AppTool, Gerber): def set_tool_ui(self): self.units = self.app.app_units.upper() - self.old_tool_dia = self.app.defaults["tools_ncc_newdia"] + self.old_tool_dia = self.app.options["tools_ncc_newdia"] self.clear_ui(self.layout) self.ui = NccUI(layout=self.layout, app=self.app) @@ -325,35 +325,35 @@ class NonCopperClear(AppTool, Gerber): self.on_type_obj_index_changed(val=kind) self.on_reference_combo_changed() - self.ui.op_radio.set_value(self.app.defaults["tools_ncc_operation"]) - self.ui.ncc_order_combo.set_value(self.app.defaults["tools_ncc_order"]) - self.ui.ncc_overlap_entry.set_value(self.app.defaults["tools_ncc_overlap"]) - self.ui.ncc_margin_entry.set_value(self.app.defaults["tools_ncc_margin"]) - self.ui.ncc_method_combo.set_value(self.app.defaults["tools_ncc_method"]) - self.ui.ncc_connect_cb.set_value(self.app.defaults["tools_ncc_connect"]) - self.ui.ncc_contour_cb.set_value(self.app.defaults["tools_ncc_contour"]) - self.ui.ncc_choice_offset_cb.set_value(self.app.defaults["tools_ncc_offset_choice"]) - self.ui.ncc_offset_spinner.set_value(self.app.defaults["tools_ncc_offset_value"]) + self.ui.op_radio.set_value(self.app.options["tools_ncc_operation"]) + self.ui.ncc_order_combo.set_value(self.app.options["tools_ncc_order"]) + self.ui.ncc_overlap_entry.set_value(self.app.options["tools_ncc_overlap"]) + self.ui.ncc_margin_entry.set_value(self.app.options["tools_ncc_margin"]) + self.ui.ncc_method_combo.set_value(self.app.options["tools_ncc_method"]) + self.ui.ncc_connect_cb.set_value(self.app.options["tools_ncc_connect"]) + self.ui.ncc_contour_cb.set_value(self.app.options["tools_ncc_contour"]) + self.ui.ncc_choice_offset_cb.set_value(self.app.options["tools_ncc_offset_choice"]) + self.ui.ncc_offset_spinner.set_value(self.app.options["tools_ncc_offset_value"]) - self.ui.ncc_rest_cb.set_value(self.app.defaults["tools_ncc_rest"]) - self.ui.on_rest_machining_check(state=self.app.defaults["tools_ncc_rest"]) + self.ui.ncc_rest_cb.set_value(self.app.options["tools_ncc_rest"]) + self.ui.on_rest_machining_check(state=self.app.options["tools_ncc_rest"]) - self.ui.rest_ncc_margin_entry.set_value(self.app.defaults["tools_ncc_margin"]) - self.ui.rest_ncc_connect_cb.set_value(self.app.defaults["tools_ncc_connect"]) - self.ui.rest_ncc_contour_cb.set_value(self.app.defaults["tools_ncc_contour"]) - self.ui.rest_ncc_choice_offset_cb.set_value(self.app.defaults["tools_ncc_offset_choice"]) - self.ui.rest_ncc_offset_spinner.set_value(self.app.defaults["tools_ncc_offset_value"]) + self.ui.rest_ncc_margin_entry.set_value(self.app.options["tools_ncc_margin"]) + self.ui.rest_ncc_connect_cb.set_value(self.app.options["tools_ncc_connect"]) + self.ui.rest_ncc_contour_cb.set_value(self.app.options["tools_ncc_contour"]) + self.ui.rest_ncc_choice_offset_cb.set_value(self.app.options["tools_ncc_offset_choice"]) + self.ui.rest_ncc_offset_spinner.set_value(self.app.options["tools_ncc_offset_value"]) - self.ui.select_combo.set_value(self.app.defaults["tools_ncc_ref"]) - self.ui.area_shape_radio.set_value(self.app.defaults["tools_ncc_area_shape"]) - self.ui.valid_cb.set_value(self.app.defaults["tools_ncc_check_valid"]) + self.ui.select_combo.set_value(self.app.options["tools_ncc_ref"]) + self.ui.area_shape_radio.set_value(self.app.options["tools_ncc_area_shape"]) + self.ui.valid_cb.set_value(self.app.options["tools_ncc_check_valid"]) - self.ui.milling_type_radio.set_value(self.app.defaults["tools_ncc_milling_type"]) + self.ui.milling_type_radio.set_value(self.app.options["tools_ncc_milling_type"]) - self.ui.new_tooldia_entry.set_value(self.app.defaults["tools_ncc_newdia"]) + self.ui.new_tooldia_entry.set_value(self.app.options["tools_ncc_newdia"]) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) # init the working variables @@ -368,12 +368,12 @@ class NonCopperClear(AppTool, Gerber): self.default_data[option] = self.app.options[option] try: - dias = [float(self.app.defaults["tools_ncc_tools"])] + dias = [float(self.app.options["tools_ncc_tools"])] except (ValueError, TypeError): try: - dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncc_tools"].split(",") if dia != ''] + dias = [float(eval(dia)) for dia in self.app.options["tools_ncc_tools"].split(",") if dia != ''] except AttributeError: - dias = self.app.defaults["tools_ncc_tools"] + dias = self.app.options["tools_ncc_tools"] except Exception: dias = [] @@ -395,7 +395,7 @@ class NonCopperClear(AppTool, Gerber): self.cursor_pos = None self.mouse_is_dragging = False - prog_plot = True if self.app.defaults["tools_ncc_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_ncc_plotting"] == 'progressive' else False if prog_plot: self.temp_shapes.clear(update=True) @@ -470,7 +470,7 @@ class NonCopperClear(AppTool, Gerber): # Tool parameters section if self.ncc_tools: - app_defaults = self.app.defaults + app_defaults = self.app.options for tool in self.ncc_tools: tool_data = self.ncc_tools[tool]['data'] @@ -712,7 +712,7 @@ class NonCopperClear(AppTool, Gerber): # if form_key == data_key: # temp_data[data_key] = form_value.get_value() # # make sure we make a copy of the keys not in the form (we may use 'data' keys that are - # # updated from self.app.defaults + # # updated from self.app.options # if data_key not in self.form_fields: # temp_data[data_key] = value[data_key] # temp_dia[key] = deepcopy(temp_data) @@ -1514,15 +1514,15 @@ class NonCopperClear(AppTool, Gerber): self.cursor_pos = None self.mouse_is_dragging = False - prog_plot = True if self.app.defaults["tools_ncc_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_ncc_plotting"] == 'progressive' else False if prog_plot: self.temp_shapes.clear(update=True) self.sel_rect = [] obj_type = self.ui.type_obj_radio.get_value - self.circle_steps = int(self.app.defaults["gerber_circle_steps"]) if obj_type == 'gerber' else \ - int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["gerber_circle_steps"]) if obj_type == 'gerber' else \ + int(self.app.options["geometry_circle_steps"]) self.obj_name = self.ui.object_combo.currentText() # Get source object. @@ -1768,8 +1768,8 @@ class NonCopperClear(AppTool, Gerber): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) if self.cursor_pos is None: self.cursor_pos = (0, 0) @@ -2034,7 +2034,7 @@ class NonCopperClear(AppTool, Gerber): if ncc_obj.kind == 'gerber' and not isotooldia: # unfortunately for this function to work time efficient, # if the Gerber was loaded without buffering then it require the buffering now. - if self.app.defaults['gerber_buffering'] == 'no': + if self.app.options['gerber_buffering'] == 'no': sol_geo = ncc_obj.solid_geometry.buffer(0) else: sol_geo = ncc_obj.solid_geometry @@ -2058,7 +2058,7 @@ class NonCopperClear(AppTool, Gerber): # unfortunately for this function to work time efficient, # if the Gerber was loaded without buffering then it require the buffering now. # TODO 'buffering status' should be a property of the object not the project property - if self.app.defaults['gerber_buffering'] == 'no': + if self.app.options['gerber_buffering'] == 'no': self.solid_geometry = ncc_obj.solid_geometry.buffer(0) else: self.solid_geometry = ncc_obj.solid_geometry @@ -2302,7 +2302,7 @@ class NonCopperClear(AppTool, Gerber): rest_machining_choice = self.ui.ncc_rest_cb.get_value() # determine if to use the progressive plotting - prog_plot = True if self.app.defaults["tools_ncc_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_ncc_plotting"] == 'progressive' else False tools_storage = tools_storage if tools_storage is not None else self.ncc_tools sorted_clear_tools = ncctooldia @@ -2496,7 +2496,7 @@ class NonCopperClear(AppTool, Gerber): self.app.log.debug("There are no geometries in the cleared polygon.") # clean the progressive plotted shapes if it was used - if self.app.defaults["tools_ncc_plotting"] == 'progressive': + if self.app.options["tools_ncc_plotting"] == 'progressive': self.temp_shapes.clear(update=True) # delete tools with empty geometry @@ -2614,8 +2614,8 @@ class NonCopperClear(AppTool, Gerber): # for testing purposes ---------------------------------- # for po in area.geoms: - # self.app.tool_shapes.add(po, color=self.app.defaults['global_sel_line'], - # face_color=self.app.defaults['global_sel_line'], + # self.app.tool_shapes.add(po, color=self.app.options['global_sel_line'], + # face_color=self.app.options['global_sel_line'], # update=True, layer=0, tolerance=None) # ------------------------------------------------------- @@ -2682,10 +2682,10 @@ class NonCopperClear(AppTool, Gerber): # if self.app.dec_format(float(tool), self.decimals) == 0.15: # # for testing purposes ---------------------------------- - # self.app.tool_shapes.add(p, color=self.app.defaults['global_sel_line'], + # self.app.tool_shapes.add(p, color=self.app.options['global_sel_line'], # face_color=random_color(), # update=True, layer=0, tolerance=None) - # self.app.tool_shapes.add(check_buff, color=self.app.defaults['global_sel_line'], + # self.app.tool_shapes.add(check_buff, color=self.app.options['global_sel_line'], # face_color='#FFFFFFFF', # update=True, layer=0, tolerance=None) # # ------------------------------------------------------- @@ -2783,7 +2783,7 @@ class NonCopperClear(AppTool, Gerber): geo_obj.obj_options["tools_mill_tooldia"] = '0.0' # clean the progressive plotted shapes if it was used - if self.app.defaults["tools_ncc_plotting"] == 'progressive': + if self.app.options["tools_ncc_plotting"] == 'progressive': self.temp_shapes.clear(update=True) # check to see if geo_obj.tools is empty @@ -3041,9 +3041,9 @@ class NonCopperClear(AppTool, Gerber): offset_a = sum(sorted_tools) current_uid = int(1) # try: - # tool = eval(self.app.defaults["tools_ncc_tools"])[0] + # tool = eval(self.app.options["tools_ncc_tools"])[0] # except TypeError: - # tool = eval(self.app.defaults["tools_ncc_tools"]) + # tool = eval(self.app.options["tools_ncc_tools"]) # ################################################################################################### # Calculate the empty area by subtracting the solid_geometry from the object bounding box geometry ## @@ -3054,7 +3054,7 @@ class NonCopperClear(AppTool, Gerber): if ncc_obj.kind == 'gerber' and not isotooldia: # unfortunately for this function to work time efficient, # if the Gerber was loaded without buffering then it require the buffering now. - if self.app.defaults['gerber_buffering'] == 'no': + if self.app.options['gerber_buffering'] == 'no': sol_geo = ncc_obj.solid_geometry.buffer(0) else: sol_geo = ncc_obj.solid_geometry @@ -3079,13 +3079,13 @@ class NonCopperClear(AppTool, Gerber): # unfortunately for this function to work time efficient, # if the Gerber was loaded without buffering then it require the buffering now. - if self.app.defaults['gerber_buffering'] == 'no': + if self.app.options['gerber_buffering'] == 'no': self.solid_geometry = ncc_obj.solid_geometry.buffer(0) else: self.solid_geometry = ncc_obj.solid_geometry # if milling type is climb then the move is counter-clockwise around features - milling_type = self.app.defaults["tools_ncc_milling_type"] + milling_type = self.app.options["tools_ncc_milling_type"] for tool_iso in isotooldia: new_geometry = [] @@ -3435,9 +3435,9 @@ class NonCopperClear(AppTool, Gerber): rest_geo = [] current_uid = 1 try: - tool = eval(str(self.app.defaults["tools_ncc_tools"]))[0] + tool = eval(str(self.app.options["tools_ncc_tools"]))[0] except TypeError: - tool = eval(self.app.defaults["tools_ncc_tools"]) + tool = eval(self.app.options["tools_ncc_tools"]) # repurposed flag for final object, geo_obj. True if it has any solid_geometry, False if not. app_obj.poly_not_cleared = True @@ -3466,7 +3466,7 @@ class NonCopperClear(AppTool, Gerber): self.solid_geometry = ncc_obj.solid_geometry # if milling type is climb then the move is counter-clockwise around features - milling_type = self.app.defaults["tools_ncc_milling_type"] + milling_type = self.app.options["tools_ncc_milling_type"] for tool_iso in isotooldia: new_geometry = [] diff --git a/appPlugins/ToolOptimal.py b/appPlugins/ToolOptimal.py index a557ef21..6ecdfa8b 100644 --- a/appPlugins/ToolOptimal.py +++ b/appPlugins/ToolOptimal.py @@ -185,7 +185,7 @@ class ToolOptimal(AppTool): self.ui.result_entry.set_value(0.0) self.ui.freq_entry.set_value(0) - self.ui.precision_spinner.set_value(int(self.app.defaults["tools_opt_precision"])) + self.ui.precision_spinner.set_value(int(self.app.options["tools_opt_precision"])) self.ui.locations_textb.clear() # new cursor - select all document cursor = self.ui.locations_textb.textCursor() diff --git a/appPlugins/ToolPDF.py b/appPlugins/ToolPDF.py index 0f2044d7..d4867916 100644 --- a/appPlugins/ToolPDF.py +++ b/appPlugins/ToolPDF.py @@ -64,7 +64,7 @@ class ToolPDF(AppTool): self.parsing_promises = [] self.parser = PdfParser(units=self.app.app_units, - resolution=self.app.defaults["gerber_circle_steps"], + resolution=self.app.options["gerber_circle_steps"], abort=self.app.abort_flag) def run(self, toggle=True): diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index 7b2cb9b6..29a7f86e 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -46,7 +46,7 @@ class ToolPaint(AppTool, Gerber): self.decimals = self.app.decimals AppTool.__init__(self, app) - Geometry.__init__(self, geo_steps_per_circle=self.app.defaults["geometry_circle_steps"]) + Geometry.__init__(self, geo_steps_per_circle=self.app.options["geometry_circle_steps"]) # ############################################################################# # ######################### Tool GUI ########################################## @@ -64,7 +64,7 @@ class ToolPaint(AppTool, Gerber): self.bound_obj_name = "" self.bound_obj = None - self.circle_steps = int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["geometry_circle_steps"]) self.tooldia_list = [] self.tooldia = None @@ -301,58 +301,58 @@ class ToolPaint(AppTool, Gerber): # self.default_data.clear() # self.default_data.update({ # "name": '_paint', - # "plot": self.app.defaults["geometry_plot"], - # "cutz": float(self.app.defaults["tools_paint_cutz"]), - # "vtipdia": float(self.app.defaults["tools_paint_tipdia"]), - # "vtipangle": float(self.app.defaults["tools_paint_tipangle"]), - # "travelz": float(self.app.defaults["geometry_travelz"]), - # "feedrate": float(self.app.defaults["geometry_feedrate"]), - # "feedrate_z": float(self.app.defaults["geometry_feedrate_z"]), - # "feedrate_rapid": float(self.app.defaults["geometry_feedrate_rapid"]), - # "dwell": self.app.defaults["geometry_dwell"], - # "dwelltime": float(self.app.defaults["geometry_dwelltime"]), - # "multidepth": self.app.defaults["geometry_multidepth"], - # "ppname_g": self.app.defaults["geometry_ppname_g"], - # "depthperpass": float(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": float(self.app.defaults["geometry_toolchangez"]), - # "endz": float(self.app.defaults["geometry_endz"]), - # "endxy": self.app.defaults["geometry_endxy"], + # "plot": self.app.options["geometry_plot"], + # "cutz": float(self.app.options["tools_paint_cutz"]), + # "vtipdia": float(self.app.options["tools_paint_tipdia"]), + # "vtipangle": float(self.app.options["tools_paint_tipangle"]), + # "travelz": float(self.app.options["geometry_travelz"]), + # "feedrate": float(self.app.options["geometry_feedrate"]), + # "feedrate_z": float(self.app.options["geometry_feedrate_z"]), + # "feedrate_rapid": float(self.app.options["geometry_feedrate_rapid"]), + # "dwell": self.app.options["geometry_dwell"], + # "dwelltime": float(self.app.options["geometry_dwelltime"]), + # "multidepth": self.app.options["geometry_multidepth"], + # "ppname_g": self.app.options["geometry_ppname_g"], + # "depthperpass": float(self.app.options["geometry_depthperpass"]), + # "extracut": self.app.options["geometry_extracut"], + # "extracut_length": self.app.options["geometry_extracut_length"], + # "toolchange": self.app.options["geometry_toolchange"], + # "toolchangez": float(self.app.options["geometry_toolchangez"]), + # "endz": float(self.app.options["geometry_endz"]), + # "endxy": self.app.options["geometry_endxy"], # - # "spindlespeed": self.app.defaults["geometry_spindlespeed"], - # "toolchangexy": self.app.defaults["geometry_toolchangexy"], - # "startz": self.app.defaults["geometry_startz"], + # "spindlespeed": self.app.options["geometry_spindlespeed"], + # "toolchangexy": self.app.options["geometry_toolchangexy"], + # "startz": self.app.options["geometry_startz"], # - # "area_exclusion": self.app.defaults["geometry_area_exclusion"], - # "area_shape": self.app.defaults["geometry_area_shape"], - # "area_strategy": self.app.defaults["geometry_area_strategy"], - # "area_overz": float(self.app.defaults["geometry_area_overz"]), - # "optimization_type": self.app.defaults["geometry_optimization_type"], + # "area_exclusion": self.app.options["geometry_area_exclusion"], + # "area_shape": self.app.options["geometry_area_shape"], + # "area_strategy": self.app.options["geometry_area_strategy"], + # "area_overz": float(self.app.options["geometry_area_overz"]), + # "optimization_type": self.app.options["geometry_optimization_type"], # - # "tooldia": self.app.defaults["tools_paint_tooldia"], - # "tools_paint_offset": self.app.defaults["tools_paint_offset"], - # "tools_paint_method": self.app.defaults["tools_paint_method"], - # "tools_paint_selectmethod": self.app.defaults["tools_paint_selectmethod"], - # "tools_paint_connect": self.app.defaults["tools_paint_connect"], - # "tools_paint_contour": self.app.defaults["tools_paint_contour"], - # "tools_paint_overlap": self.app.defaults["tools_paint_overlap"], - # "tools_paint_rest": self.app.defaults["tools_paint_rest"], + # "tooldia": self.app.options["tools_paint_tooldia"], + # "tools_paint_offset": self.app.options["tools_paint_offset"], + # "tools_paint_method": self.app.options["tools_paint_method"], + # "tools_paint_selectmethod": self.app.options["tools_paint_selectmethod"], + # "tools_paint_connect": self.app.options["tools_paint_connect"], + # "tools_paint_contour": self.app.options["tools_paint_contour"], + # "tools_paint_overlap": self.app.options["tools_paint_overlap"], + # "tools_paint_rest": self.app.options["tools_paint_rest"], # }) # ## Init the GUI interface - self.ui.paint_order_combo.set_value(self.app.defaults["tools_paint_order"]) - self.ui.offset_entry.set_value(self.app.defaults["tools_paint_offset"]) - self.ui.paintmethod_combo.set_value(self.app.defaults["tools_paint_method"]) - self.ui.selectmethod_combo.set_value(self.app.defaults["tools_paint_selectmethod"]) - self.ui.area_shape_radio.set_value(self.app.defaults["tools_paint_area_shape"]) - self.ui.pathconnect_cb.set_value(self.app.defaults["tools_paint_connect"]) - self.ui.paintcontour_cb.set_value(self.app.defaults["tools_paint_contour"]) - self.ui.paintoverlap_entry.set_value(self.app.defaults["tools_paint_overlap"]) + self.ui.paint_order_combo.set_value(self.app.options["tools_paint_order"]) + self.ui.offset_entry.set_value(self.app.options["tools_paint_offset"]) + self.ui.paintmethod_combo.set_value(self.app.options["tools_paint_method"]) + self.ui.selectmethod_combo.set_value(self.app.options["tools_paint_selectmethod"]) + self.ui.area_shape_radio.set_value(self.app.options["tools_paint_area_shape"]) + self.ui.pathconnect_cb.set_value(self.app.options["tools_paint_connect"]) + self.ui.paintcontour_cb.set_value(self.app.options["tools_paint_contour"]) + self.ui.paintoverlap_entry.set_value(self.app.options["tools_paint_overlap"]) - self.ui.new_tooldia_entry.set_value(self.app.defaults["tools_paint_newdia"]) - self.ui.rest_cb.set_value(self.app.defaults["tools_paint_rest"]) + self.ui.new_tooldia_entry.set_value(self.app.options["tools_paint_newdia"]) + self.ui.rest_cb.set_value(self.app.options["tools_paint_rest"]) # # make the default object type, "Geometry" # self.type_obj_radio.set_value("geometry") @@ -384,12 +384,12 @@ class ToolPaint(AppTool, Gerber): self.on_reference_combo_changed() try: - diameters = [float(self.app.defaults["tools_paint_tooldia"])] + diameters = [float(self.app.options["tools_paint_tooldia"])] except (ValueError, TypeError): - if isinstance(self.app.defaults["tools_paint_tooldia"], str): - diameters = [eval(x) for x in self.app.defaults["tools_paint_tooldia"].split(",") if x != ''] + if isinstance(self.app.options["tools_paint_tooldia"], str): + diameters = [eval(x) for x in self.app.options["tools_paint_tooldia"].split(",") if x != ''] else: - diameters = self.app.defaults["tools_paint_tooldia"] + diameters = self.app.options["tools_paint_tooldia"] if not diameters: self.app.log.error( @@ -404,7 +404,7 @@ class ToolPaint(AppTool, Gerber): for dia in diameters: self.on_tool_add(custom_dia=dia) - self.ui.on_rest_machining_check(state=self.app.defaults["tools_paint_rest"]) + self.ui.on_rest_machining_check(state=self.app.options["tools_paint_rest"]) # if the Paint Method is "Polygon Selection" disable the tool table context menu if self.default_data["tools_paint_selectmethod"] == 1: @@ -421,7 +421,7 @@ class ToolPaint(AppTool, Gerber): self.ui.paintmethod_combo.set_value(idx + 1) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) self.ui.tools_table.drag_drop_sig.connect(self.rebuild_ui) @@ -480,7 +480,7 @@ class ToolPaint(AppTool, Gerber): # Tool parameters section if self.paint_tools: - app_defaults = self.app.defaults + app_defaults = self.app.options for tool in self.paint_tools: tool_data = self.paint_tools[tool]['data'] @@ -1135,15 +1135,15 @@ class ToolPaint(AppTool, Gerber): self.cursor_pos = None self.mouse_is_dragging = False - prog_plot = True if self.app.defaults["tools_paint_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_paint_plotting"] == 'progressive' else False if prog_plot: self.temp_shapes.clear(update=True) self.sel_rect = [] obj_type = self.ui.type_obj_radio.get_value() - self.circle_steps = int(self.app.defaults["gerber_circle_steps"]) if obj_type == 'gerber' else \ - int(self.app.defaults["geometry_circle_steps"]) + self.circle_steps = int(self.app.options["gerber_circle_steps"]) if obj_type == 'gerber' else \ + int(self.app.options["geometry_circle_steps"]) self.obj_name = self.ui.obj_combo.currentText() # Get source object. @@ -1275,8 +1275,8 @@ class ToolPaint(AppTool, Gerber): shape_id = self.app.tool_shapes.add(tolerance=self.paint_obj.drawing_tolerance, layer=0, shape=clicked_poly, - color=self.app.defaults['global_sel_draw_color'] + 'AF', - face_color=self.app.defaults['global_sel_draw_color'] + 'AF', + color=self.app.options['global_sel_draw_color'] + 'AF', + face_color=self.app.options['global_sel_draw_color'] + 'AF', visible=True) self.poly_dict[shape_id] = clicked_poly self.app.inform.emit( @@ -1490,8 +1490,8 @@ class ToolPaint(AppTool, Gerber): self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]), symbol='++', edge_color=self.app.cursor_color_3D, - edge_width=self.app.defaults["global_cursor_width"], - size=self.app.defaults["global_cursor_size"]) + edge_width=self.app.options["global_cursor_width"], + size=self.app.options["global_cursor_size"]) if self.cursor_pos is None: self.cursor_pos = (0, 0) @@ -1718,7 +1718,7 @@ class ToolPaint(AppTool, Gerber): if ap_type == 'C': f_o = self.clear_polygon2(elem['solid'], tooldia=tooldiameter, - steps_per_circle=self.app.defaults[ + steps_per_circle=self.app.options[ "geometry_circle_steps"], overlap=over, contour=True, @@ -1729,7 +1729,7 @@ class ToolPaint(AppTool, Gerber): elif ap_type == 'O': f_o = self.clear_polygon2(elem['solid'], tooldia=tooldiameter, - steps_per_circle=self.app.defaults[ + steps_per_circle=self.app.options[ "geometry_circle_steps"], overlap=over, contour=True, @@ -1740,7 +1740,7 @@ class ToolPaint(AppTool, Gerber): elif ap_type == 'R': f_o = self.clear_polygon3(elem['solid'], tooldia=tooldiameter, - steps_per_circle=self.app.defaults[ + steps_per_circle=self.app.options[ "geometry_circle_steps"], overlap=over, contour=True, @@ -1773,7 +1773,7 @@ class ToolPaint(AppTool, Gerber): if line and isinstance(line, (LineString, MultiLineString)): t_o = self.fill_with_lines(line, aperture_size, tooldia=tooldiameter, - steps_per_circle=self.app.defaults["geometry_circle_steps"], + steps_per_circle=self.app.options["geometry_circle_steps"], overlap=over, contour=cont, connect=conn, @@ -1861,7 +1861,7 @@ class ToolPaint(AppTool, Gerber): paint_method = method if method is not None else self.ui.paintmethod_combo.get_value() # determine if to use the progressive plotting - prog_plot = True if self.app.defaults["tools_paint_plotting"] == 'progressive' else False + prog_plot = True if self.app.options["tools_paint_plotting"] == 'progressive' else False name = outname if outname is not None else self.obj_name + "_paint" order = order if order is not None else self.ui.paint_order_combo.get_value() @@ -2013,7 +2013,7 @@ class ToolPaint(AppTool, Gerber): tools_storage[current_uid]['data']['name'] = name # clean the progressive plotted shapes if it was used - if self.app.defaults["tools_paint_plotting"] == 'progressive': + if self.app.options["tools_paint_plotting"] == 'progressive': self.temp_shapes.clear(update=True) # delete tools with empty geometry @@ -2258,7 +2258,7 @@ class ToolPaint(AppTool, Gerber): geo_obj.obj_options["tools_mill_tooldia"] = '0.0' # clean the progressive plotted shapes if it was used - if self.app.defaults["tools_paint_plotting"] == 'progressive': + if self.app.options["tools_paint_plotting"] == 'progressive': self.temp_shapes.clear(update=True) # delete tools with empty geometry @@ -2370,7 +2370,7 @@ class ToolPaint(AppTool, Gerber): if obj.kind == 'gerber': # I don't do anything here, like buffering when the Gerber is loaded without buffering????!!!! - if self.app.defaults["gerber_buffering"] == 'no': + if self.app.options["gerber_buffering"] == 'no': msg = '%s %s %s' % (_("Paint Plugin."), _("Normal painting polygon task started."), _("Buffering geometry...")) @@ -2378,7 +2378,7 @@ class ToolPaint(AppTool, Gerber): else: self.app.inform.emit('%s %s' % (_("Paint Plugin."), _("Normal painting polygon task started."))) - if self.app.defaults["tools_paint_plotting"] == 'progressive': + if self.app.options["tools_paint_plotting"] == 'progressive': if isinstance(obj.solid_geometry, list): obj.solid_geometry = MultiPolygon(obj.solid_geometry).buffer(0) else: @@ -2472,13 +2472,13 @@ class ToolPaint(AppTool, Gerber): if obj.kind == 'gerber': # I don't do anything here, like buffering when the Gerber is loaded without buffering????!!!! - if self.app.defaults["gerber_buffering"] == 'no': + if self.app.options["gerber_buffering"] == 'no': msg = '%s %s %s' % (_("Paint Plugin."), _("Paint all polygons task started."), _("Buffering geometry...")) self.app.inform.emit(msg) else: self.app.inform.emit('%s %s' % (_("Paint Plugin."), _("Paint all polygons task started."))) - if self.app.defaults["tools_paint_plotting"] == 'progressive': + if self.app.options["tools_paint_plotting"] == 'progressive': if isinstance(obj.solid_geometry, list): obj.solid_geometry = MultiPolygon(obj.solid_geometry).buffer(0) else: @@ -2554,7 +2554,7 @@ class ToolPaint(AppTool, Gerber): if obj.kind == 'gerber': # I don't do anything here, like buffering when the Gerber is loaded without buffering????!!!! - if self.app.defaults["gerber_buffering"] == 'no': + if self.app.options["gerber_buffering"] == 'no': msg = '%s %s %s' % (_("Paint Plugin."), _("Painting area task started."), _("Buffering geometry...")) @@ -2563,7 +2563,7 @@ class ToolPaint(AppTool, Gerber): self.app.inform.emit('%s %s' % (_("Paint Plugin."), _("Painting area task started."))) if obj.kind == 'gerber': - if self.app.defaults["tools_paint_plotting"] == 'progressive': + if self.app.options["tools_paint_plotting"] == 'progressive': target_geo = target_geo.buffer(0) else: self.app.inform.emit('%s %s' % (_("Paint Plugin."), _("Painting area task started."))) diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index 56c037ca..28d7aa4b 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -151,40 +151,40 @@ class Panelize(AppTool): self.ui.object_combo.set_value(obj_name) - sp_c = self.app.defaults["tools_panelize_spacing_columns"] if \ - self.app.defaults["tools_panelize_spacing_columns"] else 0.0 + sp_c = self.app.options["tools_panelize_spacing_columns"] if \ + self.app.options["tools_panelize_spacing_columns"] else 0.0 self.ui.spacing_columns.set_value(float(sp_c)) - sp_r = self.app.defaults["tools_panelize_spacing_rows"] if \ - self.app.defaults["tools_panelize_spacing_rows"] else 0.0 + sp_r = self.app.options["tools_panelize_spacing_rows"] if \ + self.app.options["tools_panelize_spacing_rows"] else 0.0 self.ui.spacing_rows.set_value(float(sp_r)) - rr = self.app.defaults["tools_panelize_rows"] if \ - self.app.defaults["tools_panelize_rows"] else 0.0 + rr = self.app.options["tools_panelize_rows"] if \ + self.app.options["tools_panelize_rows"] else 0.0 self.ui.rows.set_value(int(rr)) - cc = self.app.defaults["tools_panelize_columns"] if \ - self.app.defaults["tools_panelize_columns"] else 0.0 + cc = self.app.options["tools_panelize_columns"] if \ + self.app.options["tools_panelize_columns"] else 0.0 self.ui.columns.set_value(int(cc)) - optimized_path_cb = self.app.defaults["tools_panelize_optimization"] if \ - self.app.defaults["tools_panelize_optimization"] else True + optimized_path_cb = self.app.options["tools_panelize_optimization"] if \ + self.app.options["tools_panelize_optimization"] else True self.ui.optimization_cb.set_value(optimized_path_cb) - c_cb = self.app.defaults["tools_panelize_constrain"] if \ - self.app.defaults["tools_panelize_constrain"] else False + c_cb = self.app.options["tools_panelize_constrain"] if \ + self.app.options["tools_panelize_constrain"] else False self.ui.constrain_cb.set_value(c_cb) - x_w = self.app.defaults["tools_panelize_constrainx"] if \ - self.app.defaults["tools_panelize_constrainx"] else 0.0 + x_w = self.app.options["tools_panelize_constrainx"] if \ + self.app.options["tools_panelize_constrainx"] else 0.0 self.ui.x_width_entry.set_value(float(x_w)) - y_w = self.app.defaults["tools_panelize_constrainy"] if \ - self.app.defaults["tools_panelize_constrainy"] else 0.0 + y_w = self.app.options["tools_panelize_constrainy"] if \ + self.app.options["tools_panelize_constrainy"] else 0.0 self.ui.y_height_entry.set_value(float(y_w)) - panel_type = self.app.defaults["tools_panelize_panel_type"] if \ - self.app.defaults["tools_panelize_panel_type"] else 'gerber' + panel_type = self.app.options["tools_panelize_panel_type"] if \ + self.app.options["tools_panelize_panel_type"] else 'gerber' self.ui.panel_type_radio.set_value(panel_type) self.ui.on_panel_type(val=panel_type) @@ -197,7 +197,7 @@ class Panelize(AppTool): self.connect_signals_at_init() # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def on_type_obj_index_changed(self): @@ -793,7 +793,7 @@ class Panelize(AppTool): new_sgeo = [g['solid'] for g in new_obj.tools[apid]['geometry'] if 'solid' in g] new_sgeo = unary_union(new_sgeo) new_obj.tools[new_tid] = { - 'tooldia': self.app.defaults["tools_mill_tooldia"], + 'tooldia': self.app.options["tools_mill_tooldia"], 'offset': 'Path', 'offset_value': 0.0, 'type': 'Rough', @@ -803,7 +803,7 @@ class Panelize(AppTool): } new_tid += 1 new_obj.tools[new_tid] = { - 'tooldia': self.app.defaults["tools_mill_tooldia"], + 'tooldia': self.app.options["tools_mill_tooldia"], 'offset': 'Path', 'offset_value': 0.0, 'type': 'Rough', diff --git a/appPlugins/ToolPcbWizard.py b/appPlugins/ToolPcbWizard.py index cadb5033..27b9e4a9 100644 --- a/appPlugins/ToolPcbWizard.py +++ b/appPlugins/ToolPcbWizard.py @@ -331,7 +331,7 @@ class PcbWizard(AppTool): self.process_finished = True # Register recent file - self.app.defaults["global_last_folder"] = os.path.split(str(filename))[0] + self.app.options["global_last_folder"] = os.path.split(str(filename))[0] def on_import_excellon(self, signal=None, excellon_fileobj=None): self.app.log.debug("import_2files_excellon()") diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index 43c7befa..ce5200b7 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -36,7 +36,7 @@ class ToolPunchGerber(AppTool, Gerber): def __init__(self, app): AppTool.__init__(self, app) - Geometry.__init__(self, geo_steps_per_circle=self.app.defaults["geometry_circle_steps"]) + Geometry.__init__(self, geo_steps_per_circle=self.app.options["geometry_circle_steps"]) self.app = app self.decimals = self.app.decimals @@ -216,24 +216,24 @@ class ToolPunchGerber(AppTool, Gerber): self.ui_disconnect() self.ui_connect() - self.ui.method_punch.set_value(self.app.defaults["tools_punch_hole_type"]) + self.ui.method_punch.set_value(self.app.options["tools_punch_hole_type"]) self.ui.select_all_cb.set_value(False) - self.ui.dia_entry.set_value(float(self.app.defaults["tools_punch_hole_fixed_dia"])) + self.ui.dia_entry.set_value(float(self.app.options["tools_punch_hole_fixed_dia"])) - self.ui.circular_ring_entry.set_value(float(self.app.defaults["tools_punch_circular_ring"])) - self.ui.oblong_ring_entry.set_value(float(self.app.defaults["tools_punch_oblong_ring"])) - self.ui.square_ring_entry.set_value(float(self.app.defaults["tools_punch_square_ring"])) - self.ui.rectangular_ring_entry.set_value(float(self.app.defaults["tools_punch_rectangular_ring"])) - self.ui.other_ring_entry.set_value(float(self.app.defaults["tools_punch_others_ring"])) + self.ui.circular_ring_entry.set_value(float(self.app.options["tools_punch_circular_ring"])) + self.ui.oblong_ring_entry.set_value(float(self.app.options["tools_punch_oblong_ring"])) + self.ui.square_ring_entry.set_value(float(self.app.options["tools_punch_square_ring"])) + self.ui.rectangular_ring_entry.set_value(float(self.app.options["tools_punch_rectangular_ring"])) + self.ui.other_ring_entry.set_value(float(self.app.options["tools_punch_others_ring"])) - self.ui.circular_cb.set_value(self.app.defaults["tools_punch_circular"]) - self.ui.oblong_cb.set_value(self.app.defaults["tools_punch_oblong"]) - self.ui.square_cb.set_value(self.app.defaults["tools_punch_square"]) - self.ui.rectangular_cb.set_value(self.app.defaults["tools_punch_rectangular"]) - self.ui.other_cb.set_value(self.app.defaults["tools_punch_others"]) + self.ui.circular_cb.set_value(self.app.options["tools_punch_circular"]) + self.ui.oblong_cb.set_value(self.app.options["tools_punch_oblong"]) + self.ui.square_cb.set_value(self.app.options["tools_punch_square"]) + self.ui.rectangular_cb.set_value(self.app.options["tools_punch_rectangular"]) + self.ui.other_cb.set_value(self.app.options["tools_punch_others"]) - self.ui.factor_entry.set_value(float(self.app.defaults["tools_punch_hole_prop_factor"])) + self.ui.factor_entry.set_value(float(self.app.options["tools_punch_hole_prop_factor"])) self.ui.punch_type_radio.set_value("a") self.old_selection_status = None @@ -248,7 +248,7 @@ class ToolPunchGerber(AppTool, Gerber): self.ui.gerber_object_combo.set_value(obj_name) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def build_tool_ui(self): @@ -566,8 +566,8 @@ class ToolPunchGerber(AppTool, Gerber): self.app.ui.notebook.setDisabled(True) # disable the canvas mouse dragging seelction shape - self.old_selection_status = deepcopy(self.app.defaults['global_selection_shape']) - self.app.defaults['global_selection_shape'] = False + self.old_selection_status = deepcopy(self.app.options['global_selection_shape']) + self.app.options['global_selection_shape'] = False def on_excellon_method(self, grb_obj, outname): # get the Excellon file whose geometry will create the punch holes @@ -1703,8 +1703,8 @@ class ToolPunchGerber(AppTool, Gerber): if clicked_poly not in self.poly_dict.values(): shape_id = self.app.tool_shapes.add( tolerance=self.grb_obj.drawing_tolerance, layer=0, shape=clicked_poly, - color=self.app.defaults['global_sel_draw_color'] + 'FF', - face_color=self.app.defaults['global_sel_draw_color'] + 'FF', visible=True) + color=self.app.options['global_sel_draw_color'] + 'FF', + face_color=self.app.options['global_sel_draw_color'] + 'FF', visible=True) self.poly_dict[shape_id] = clicked_poly self.app.inform.emit( '%s: %d. %s' % (_("Added pad"), int(len(self.poly_dict)), @@ -1749,7 +1749,7 @@ class ToolPunchGerber(AppTool, Gerber): self.poly_sel_disconnect_flag = False # restore the selection shape - self.app.defaults['global_selection_shape'] = self.old_selection_status + self.app.options['global_selection_shape'] = self.old_selection_status self.app.tool_shapes.clear(update=True) @@ -1846,7 +1846,7 @@ class ToolPunchGerber(AppTool, Gerber): self.app.on_mouse_click_over_plot) # restore the selection shape if self.old_selection_status is not None: - self.app.defaults['global_selection_shape'] = self.old_selection_status + self.app.options['global_selection_shape'] = self.old_selection_status self.app.ui.notebook.setDisabled(False) self.poly_dict.clear() @@ -1924,8 +1924,8 @@ class ToolPunchGerber(AppTool, Gerber): shape_id = self.app.tool_shapes.add( tolerance=self.grb_obj.drawing_tolerance, layer=0, shape=sol_geo, - color=self.app.defaults['global_sel_draw_color'] + 'FF', - face_color=self.app.defaults['global_sel_draw_color'] + 'FF', visible=True) + color=self.app.options['global_sel_draw_color'] + 'FF', + face_color=self.app.options['global_sel_draw_color'] + 'FF', visible=True) self.poly_dict[shape_id] = sol_geo self.app.tool_shapes.redraw() self.app.inform.emit(_("All selectable pads are selected.")) diff --git a/appPlugins/ToolQRCode.py b/appPlugins/ToolQRCode.py index d18881a9..1a396aab 100644 --- a/appPlugins/ToolQRCode.py +++ b/appPlugins/ToolQRCode.py @@ -156,22 +156,22 @@ class QRCode(AppTool): self.ui.border_size_entry.set_value(4) - self.ui.version_entry.set_value(int(self.app.defaults["tools_qrcode_version"])) - self.ui.error_radio.set_value(self.app.defaults["tools_qrcode_error"]) - self.ui.bsize_entry.set_value(int(self.app.defaults["tools_qrcode_box_size"])) - self.ui.border_size_entry.set_value(int(self.app.defaults["tools_qrcode_border_size"])) - self.ui.pol_radio.set_value(self.app.defaults["tools_qrcode_polarity"]) - self.ui.bb_radio.set_value(self.app.defaults["tools_qrcode_rounded"]) + self.ui.version_entry.set_value(int(self.app.options["tools_qrcode_version"])) + self.ui.error_radio.set_value(self.app.options["tools_qrcode_error"]) + self.ui.bsize_entry.set_value(int(self.app.options["tools_qrcode_box_size"])) + self.ui.border_size_entry.set_value(int(self.app.options["tools_qrcode_border_size"])) + self.ui.pol_radio.set_value(self.app.options["tools_qrcode_polarity"]) + self.ui.bb_radio.set_value(self.app.options["tools_qrcode_rounded"]) - self.ui.text_data.set_value(self.app.defaults["tools_qrcode_qrdata"]) + self.ui.text_data.set_value(self.app.options["tools_qrcode_qrdata"]) - self.ui.fill_color_entry.set_value(self.app.defaults['tools_qrcode_fill_color']) + self.ui.fill_color_entry.set_value(self.app.options['tools_qrcode_fill_color']) self.ui.fill_color_button.setStyleSheet("background-color:%s" % - str(self.app.defaults['tools_qrcode_fill_color'])[:7]) + str(self.app.options['tools_qrcode_fill_color'])[:7]) - self.ui.back_color_entry.set_value(self.app.defaults['tools_qrcode_back_color']) + self.ui.back_color_entry.set_value(self.app.options['tools_qrcode_back_color']) self.ui.back_color_button.setStyleSheet("background-color:%s" % - str(self.app.defaults['tools_qrcode_back_color'])[:7]) + str(self.app.options['tools_qrcode_back_color'])[:7]) # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() @@ -180,7 +180,7 @@ class QRCode(AppTool): self.ui.grb_object_combo.set_value(obj_name) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): @@ -418,7 +418,7 @@ class QRCode(AppTool): # I use the len of self.qrcode_geometry instead of the utility one because the complexity of the polygons is # better seen in this (bit what if the sel.qrcode_geometry is just one geo element? len will fail ... - if len(self.qrcode_geometry) <= self.app.defaults["tools_qrcode_sel_limit"]: + if len(self.qrcode_geometry) <= self.app.options["tools_qrcode_sel_limit"]: try: for poly in self.qrcode_utility_geometry: offset_geo.append(translate(poly.exterior, xoff=pos[0], yoff=pos[1])) @@ -511,7 +511,7 @@ class QRCode(AppTool): # w = float(svg_root.get('width')) h = svgparselength(svg_root.get('height'))[0] # TODO: No units support yet units = self.app.app_units if units is None else units - res = self.app.defaults['geometry_circle_steps'] + res = self.app.options['geometry_circle_steps'] factor = svgparse_viewbox(svg_root) geos = getsvggeo(svg_root, object_type, units=units, res=res, factor=factor, app=self.app) diff --git a/appPlugins/ToolReport.py b/appPlugins/ToolReport.py index 14d9508d..973a048b 100644 --- a/appPlugins/ToolReport.py +++ b/appPlugins/ToolReport.py @@ -171,7 +171,7 @@ class ObjectReport(AppTool): font = QtGui.QFont() font.setBold(True) - p_color = QtGui.QColor("#000000") if self.app.defaults['global_gray_icons'] is False \ + p_color = QtGui.QColor("#000000") if self.app.options['global_gray_icons'] is False \ else QtGui.QColor("#FFFFFF") # main Items categories diff --git a/appPlugins/ToolRulesCheck.py b/appPlugins/ToolRulesCheck.py index a9bc51d9..872a6ac7 100644 --- a/appPlugins/ToolRulesCheck.py +++ b/appPlugins/ToolRulesCheck.py @@ -165,26 +165,26 @@ class RulesCheck(AppTool): self.ui.e1_object.setDisabled(True) self.ui.e2_object.setDisabled(True) - self.ui.trace_size_cb.set_value(self.app.defaults["tools_cr_trace_size"]) - self.ui.trace_size_entry.set_value(float(self.app.defaults["tools_cr_trace_size_val"])) - self.ui.clearance_copper2copper_cb.set_value(self.app.defaults["tools_cr_c2c"]) - self.ui.clearance_copper2copper_entry.set_value(float(self.app.defaults["tools_cr_c2c_val"])) - self.ui.clearance_copper2ol_cb.set_value(self.app.defaults["tools_cr_c2o"]) - self.ui.clearance_copper2ol_entry.set_value(float(self.app.defaults["tools_cr_c2o_val"])) - self.ui.clearance_silk2silk_cb.set_value(self.app.defaults["tools_cr_s2s"]) - self.ui.clearance_silk2silk_entry.set_value(float(self.app.defaults["tools_cr_s2s_val"])) - self.ui.clearance_silk2sm_cb.set_value(self.app.defaults["tools_cr_s2sm"]) - self.ui.clearance_silk2sm_entry.set_value(float(self.app.defaults["tools_cr_s2sm_val"])) - self.ui.clearance_silk2ol_cb.set_value(self.app.defaults["tools_cr_s2o"]) - self.ui.clearance_silk2ol_entry.set_value(float(self.app.defaults["tools_cr_s2o_val"])) - self.ui.clearance_sm2sm_cb.set_value(self.app.defaults["tools_cr_sm2sm"]) - self.ui.clearance_sm2sm_entry.set_value(float(self.app.defaults["tools_cr_sm2sm_val"])) - self.ui.ring_integrity_cb.set_value(self.app.defaults["tools_cr_ri"]) - self.ui.ring_integrity_entry.set_value(float(self.app.defaults["tools_cr_ri_val"])) - self.ui.clearance_d2d_cb.set_value(self.app.defaults["tools_cr_h2h"]) - self.ui.clearance_d2d_entry.set_value(float(self.app.defaults["tools_cr_h2h_val"])) - self.ui.drill_size_cb.set_value(self.app.defaults["tools_cr_dh"]) - self.ui.drill_size_entry.set_value(float(self.app.defaults["tools_cr_dh_val"])) + self.ui.trace_size_cb.set_value(self.app.options["tools_cr_trace_size"]) + self.ui.trace_size_entry.set_value(float(self.app.options["tools_cr_trace_size_val"])) + self.ui.clearance_copper2copper_cb.set_value(self.app.options["tools_cr_c2c"]) + self.ui.clearance_copper2copper_entry.set_value(float(self.app.options["tools_cr_c2c_val"])) + self.ui.clearance_copper2ol_cb.set_value(self.app.options["tools_cr_c2o"]) + self.ui.clearance_copper2ol_entry.set_value(float(self.app.options["tools_cr_c2o_val"])) + self.ui.clearance_silk2silk_cb.set_value(self.app.options["tools_cr_s2s"]) + self.ui.clearance_silk2silk_entry.set_value(float(self.app.options["tools_cr_s2s_val"])) + self.ui.clearance_silk2sm_cb.set_value(self.app.options["tools_cr_s2sm"]) + self.ui.clearance_silk2sm_entry.set_value(float(self.app.options["tools_cr_s2sm_val"])) + self.ui.clearance_silk2ol_cb.set_value(self.app.options["tools_cr_s2o"]) + self.ui.clearance_silk2ol_entry.set_value(float(self.app.options["tools_cr_s2o_val"])) + self.ui.clearance_sm2sm_cb.set_value(self.app.options["tools_cr_sm2sm"]) + self.ui.clearance_sm2sm_entry.set_value(float(self.app.options["tools_cr_sm2sm_val"])) + self.ui.ring_integrity_cb.set_value(self.app.options["tools_cr_ri"]) + self.ui.ring_integrity_entry.set_value(float(self.app.options["tools_cr_ri_val"])) + self.ui.clearance_d2d_cb.set_value(self.app.options["tools_cr_h2h"]) + self.ui.clearance_d2d_entry.set_value(float(self.app.options["tools_cr_h2h_val"])) + self.ui.drill_size_cb.set_value(self.app.options["tools_cr_dh"]) + self.ui.drill_size_entry.set_value(float(self.app.options["tools_cr_dh_val"])) self.reset_fields() diff --git a/appPlugins/ToolShell.py b/appPlugins/ToolShell.py index 02dd6bbe..6931f398 100644 --- a/appPlugins/ToolShell.py +++ b/appPlugins/ToolShell.py @@ -322,7 +322,7 @@ class FCShell(TermWidget): self.setWindowIcon(app_icon) self.setWindowTitle(_("FlatCAM Evo Shell")) - self.resize(*self.app.defaults["global_shell_shape"]) + self.resize(*self.app.options["global_shell_shape"]) self._append_to_browser('in', "FlatCAM Evo %s - " % version) self.append_output('%s\n\n' % _("Type >help< to get started")) @@ -530,7 +530,7 @@ class FCShell(TermWidget): if not isinstance(error, self.TclErrorException): show_trace = 1 else: - show_trace = int(self.app.defaults['global_verbose_error_level']) + show_trace = int(self.app.options['global_verbose_error_level']) if show_trace > 0: trc = traceback.format_list(traceback.extract_tb(exc_traceback)) diff --git a/appPlugins/ToolSolderPaste.py b/appPlugins/ToolSolderPaste.py index 6ae47446..feb11482 100644 --- a/appPlugins/ToolSolderPaste.py +++ b/appPlugins/ToolSolderPaste.py @@ -192,7 +192,7 @@ class SolderPaste(AppTool): self.init_context_menu() # either originally it was a string or not, xy_end will be made string - dias_option = self.app.defaults["tools_solderpaste_tools"] + dias_option = self.app.options["tools_solderpaste_tools"] dias_option = re.sub('[()\[\]]', '', str(dias_option)) if dias_option else None try: dias = [float(eval(dia)) for dia in dias_option.split(",") if dia != ''] @@ -475,8 +475,8 @@ class SolderPaste(AppTool): :return: """ for key in self.form_fields: - if key in self.app.defaults: - self.form_fields[key].set_value(self.app.defaults[key]) + if key in self.app.options: + self.form_fields[key].set_value(self.app.options[key]) def set_form(self, val): """ @@ -1000,8 +1000,8 @@ class SolderPaste(AppTool): tool_dia = tooluid_value['tooldia'] tool_cnc_dict = deepcopy(tooluid_value) - new_obj.coords_decimals = self.app.defaults["cncjob_coords_decimals"] - new_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] + new_obj.coords_decimals = self.app.options["cncjob_coords_decimals"] + new_obj.fr_decimals = self.app.options["cncjob_fr_decimals"] new_obj.tool = int(tooluid_key) # Propagate options @@ -1180,7 +1180,7 @@ class SolderPaste(AppTool): "Most likely another app is holding the file open and not accessible.")) return 'fail' - if self.app.defaults["global_open_style"] is False: + if self.app.options["global_open_style"] is False: self.app.file_opened.emit("gcode", filename) self.app.file_saved.emit("gcode", filename) self.app.inform.emit('[success] %s: %s' % (_("Solder paste dispenser GCode file saved to"), filename)) diff --git a/appPlugins/ToolSub.py b/appPlugins/ToolSub.py index 5bbba663..cb7adcd4 100644 --- a/appPlugins/ToolSub.py +++ b/appPlugins/ToolSub.py @@ -207,8 +207,8 @@ class ToolSub(AppTool): self.connect_signals_at_init() self.ui.tools_frame.show() - self.ui.close_paths_cb.setChecked(self.app.defaults["tools_sub_close_paths"]) - self.ui.delete_sources_cb.setChecked(self.app.defaults["tools_sub_delete_sources"]) + self.ui.close_paths_cb.setChecked(self.app.options["tools_sub_close_paths"]) + self.ui.delete_sources_cb.setChecked(self.app.options["tools_sub_delete_sources"]) # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() @@ -217,7 +217,7 @@ class ToolSub(AppTool): self.ui.target_gerber_combo.set_value(obj_name) # Show/Hide Advanced Options - app_mode = self.app.defaults["global_app_level"] + app_mode = self.app.options["global_app_level"] self.change_level(app_mode) def change_level(self, level): diff --git a/appPlugins/ToolTransform.py b/appPlugins/ToolTransform.py index a086cfff..786334e5 100644 --- a/appPlugins/ToolTransform.py +++ b/appPlugins/ToolTransform.py @@ -124,25 +124,25 @@ class ToolTransform(AppTool): self.connect_signals_at_init() # ## Initialize form - self.ui.ref_combo.set_value(self.app.defaults["tools_transform_reference"]) - self.ui.type_obj_combo.set_value(self.app.defaults["tools_transform_ref_object"]) - self.ui.point_entry.set_value(self.app.defaults["tools_transform_ref_point"]) - self.ui.rotate_entry.set_value(self.app.defaults["tools_transform_rotate"]) + self.ui.ref_combo.set_value(self.app.options["tools_transform_reference"]) + self.ui.type_obj_combo.set_value(self.app.options["tools_transform_ref_object"]) + self.ui.point_entry.set_value(self.app.options["tools_transform_ref_point"]) + self.ui.rotate_entry.set_value(self.app.options["tools_transform_rotate"]) - self.ui.skewx_entry.set_value(self.app.defaults["tools_transform_skew_x"]) - self.ui.skewy_entry.set_value(self.app.defaults["tools_transform_skew_y"]) - self.ui.skew_link_cb.set_value(self.app.defaults["tools_transform_skew_link"]) + self.ui.skewx_entry.set_value(self.app.options["tools_transform_skew_x"]) + self.ui.skewy_entry.set_value(self.app.options["tools_transform_skew_y"]) + self.ui.skew_link_cb.set_value(self.app.options["tools_transform_skew_link"]) - self.ui.scalex_entry.set_value(self.app.defaults["tools_transform_scale_x"]) - self.ui.scaley_entry.set_value(self.app.defaults["tools_transform_scale_y"]) - self.ui.scale_link_cb.set_value(self.app.defaults["tools_transform_scale_link"]) + self.ui.scalex_entry.set_value(self.app.options["tools_transform_scale_x"]) + self.ui.scaley_entry.set_value(self.app.options["tools_transform_scale_y"]) + self.ui.scale_link_cb.set_value(self.app.options["tools_transform_scale_link"]) - self.ui.offx_entry.set_value(self.app.defaults["tools_transform_offset_x"]) - self.ui.offy_entry.set_value(self.app.defaults["tools_transform_offset_y"]) + self.ui.offx_entry.set_value(self.app.options["tools_transform_offset_x"]) + self.ui.offy_entry.set_value(self.app.options["tools_transform_offset_y"]) - self.ui.buffer_entry.set_value(self.app.defaults["tools_transform_buffer_dis"]) - self.ui.buffer_factor_entry.set_value(self.app.defaults["tools_transform_buffer_factor"]) - self.ui.buffer_rounded_cb.set_value(self.app.defaults["tools_transform_buffer_corner"]) + self.ui.buffer_entry.set_value(self.app.options["tools_transform_buffer_dis"]) + self.ui.buffer_factor_entry.set_value(self.app.options["tools_transform_buffer_factor"]) + self.ui.buffer_rounded_cb.set_value(self.app.options["tools_transform_buffer_corner"]) # initial state is hidden self.ui.point_label.hide() diff --git a/appTool.py b/appTool.py index 21924b1f..c956de0f 100644 --- a/appTool.py +++ b/appTool.py @@ -138,12 +138,12 @@ class AppTool(QtWidgets.QWidget): if 'color' in kwargs: color = kwargs['color'] else: - color = self.app.defaults['global_sel_line'] + color = self.app.options['global_sel_line'] if 'face_color' in kwargs: face_color = kwargs['face_color'] else: - face_color = self.app.defaults['global_sel_fill'] + face_color = self.app.options['global_sel_fill'] if 'face_alpha' in kwargs: face_alpha = kwargs['face_alpha'] @@ -184,12 +184,12 @@ class AppTool(QtWidgets.QWidget): if 'color' in kwargs: color = kwargs['color'] else: - color = self.app.defaults['global_sel_line'] + color = self.app.options['global_sel_line'] if 'face_color' in kwargs: face_color = kwargs['face_color'] else: - face_color = self.app.defaults['global_sel_fill'] + face_color = self.app.options['global_sel_fill'] if 'face_alpha' in kwargs: face_alpha = kwargs['face_alpha'] @@ -242,12 +242,12 @@ class AppTool(QtWidgets.QWidget): if 'color' in kwargs: color = kwargs['color'] else: - color = self.app.defaults['global_sel_line'] + color = self.app.options['global_sel_line'] if 'face_color' in kwargs: face_color = kwargs['face_color'] else: - face_color = self.app.defaults['global_sel_fill'] + face_color = self.app.options['global_sel_fill'] if 'face_alpha' in kwargs: face_alpha = kwargs['face_alpha'] diff --git a/app_Main.py b/app_Main.py index bf385f2b..76cb7131 100644 --- a/app_Main.py +++ b/app_Main.py @@ -7,7 +7,6 @@ # Modified by Marius Stanciu (2019) # # ########################################################### import os.path -import sys import urllib.request import urllib.parse import urllib.error @@ -18,7 +17,6 @@ import simplejson as json import shutil import lzma from datetime import datetime -# import time import ctypes import traceback @@ -605,14 +603,28 @@ class App(QtCore.QObject): if user_defaults: self.defaults.load(filename=current_defaults_path, inform=self.inform) - self.app_units = self.defaults["units"] + # ########################################################################################################### + # ######################################## UPDATE THE OPTIONS ############################################### + # ########################################################################################################### + self.options = LoudDict() + # ----------------------------------------------------------------------------------------------------------- + # Update the self.options from the self.defaults + # The self.options holds the application defaults while the self.options holds the object defaults + # ----------------------------------------------------------------------------------------------------------- + # Copy app defaults to project options + for def_key, def_val in self.defaults.items(): + self.options[def_key] = deepcopy(def_val) + + # self.preferencesUiManager.show_preferences_gui() + + self.app_units = self.options["units"] if self.app_units == 'MM': - self.decimals = int(self.defaults['decimals_metric']) + self.decimals = int(self.options['decimals_metric']) else: - self.decimals = int(self.defaults['decimals_inch']) + self.decimals = int(self.options['decimals_inch']) - if self.defaults["global_gray_icons"] is False: + if self.options["global_gray_icons"] is False: self.resource_location = 'assets/resources' else: self.resource_location = 'assets/resources/dark_resources' @@ -620,7 +632,7 @@ class App(QtCore.QObject): # ############################################################################################################# # ######################################### DARK THEME ######################################################## # ############################################################################################################# - if self.defaults["global_gray_icons"] is True: + if self.options["global_gray_icons"] is True: qdarksheet.STYLE_SHEET = style_sheet.D_STYLE_SHEET # patching so I can do my own changes to the theme self.qapp.setStyleSheet(qdarktheme.load_stylesheet()) @@ -649,7 +661,7 @@ class App(QtCore.QObject): 'version', 'write_gcode' ] - # those need to be duplicated in self.defaults["util_autocomplete_keywords"] but within a string + # those need to be duplicated in self.options["util_autocomplete_keywords"] but within a string self.default_keywords = ['Berta_CNC', 'Default_no_M6', 'Desktop', 'Documents', 'FlatConfig', 'FlatPrj', 'False', 'GRBL_11', 'GRL_11_no_M6', 'GRBL_laser', 'grbl_laser_eleks_drd', 'GRBL_laser_z', 'ISEL_CNC', 'ISEL_ICP_CNC', @@ -864,17 +876,17 @@ class App(QtCore.QObject): 'unload', 'unset', 'update', 'uplevel', 'upvar', 'variable', 'vwait', 'while', 'yield', 'yieldto', 'zlib' ] - self.autocomplete_kw_list = self.defaults['util_autocomplete_keywords'].replace(' ', '').split(',') + self.autocomplete_kw_list = self.options['util_autocomplete_keywords'].replace(' ', '').split(',') self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords # ############################################################################################################ # ################################### Set LOG verbosity ###################################################### # ############################################################################################################ - if self.defaults["global_log_verbose"] == 2: + if self.options["global_log_verbose"] == 2: self.log.handlers.pop() self.log = AppLogging(app=self, log_level=2) - if self.defaults["global_log_verbose"] == 0: + if self.options["global_log_verbose"] == 0: self.log.handlers.pop() self.log = AppLogging(app=self, log_level=0) @@ -891,7 +903,7 @@ class App(QtCore.QObject): # ########################################################################################################### # ###################################### Clear GUI Settings - once at first start ########################### # ########################################################################################################### - if self.defaults["first_run"] is True: + if self.options["first_run"] is True: # on first run clear the previous QSettings, therefore clearing the GUI settings qsettings = QSettings("Open Source", "FlatCAM") for key in qsettings.allKeys(): @@ -942,7 +954,7 @@ class App(QtCore.QObject): aval_languages = [] for name in sorted(self.languages.values()): aval_languages.append(name) - self.defaults["global_languages"] = aval_languages + self.options["global_languages"] = aval_languages # ########################################################################################################### # ####################################### APPLY APP LANGUAGE ################################################ @@ -955,7 +967,7 @@ class App(QtCore.QObject): self.log.debug("Could not find the Language files. The App strings are missing.") else: # make the current language the current selection on the language combobox - self.defaults["global_language_current"] = ret_val + self.options["global_language_current"] = ret_val self.log.debug("App.__init__() --> Applied %s language." % str(ret_val).capitalize()) # ########################################################################################################### @@ -987,22 +999,22 @@ class App(QtCore.QObject): self.preprocessors = deepcopy(new_ppp_dict) # populate the Plugins Preprocessors - self.defaults["tools_drill_preprocessor_list"] = [] - self.defaults["tools_mill_preprocessor_list"] = [] - self.defaults["tools_solderpaste_preprocessor_list"] = [] + self.options["tools_drill_preprocessor_list"] = [] + self.options["tools_mill_preprocessor_list"] = [] + self.options["tools_solderpaste_preprocessor_list"] = [] for name in list(self.preprocessors.keys()): lowered_name = name.lower() # 'Paste' preprocessors are to be used only in the Solder Paste Dispensing Plugin if 'paste' in lowered_name: - self.defaults["tools_solderpaste_preprocessor_list"].append(name) + self.options["tools_solderpaste_preprocessor_list"].append(name) continue - self.defaults["tools_mill_preprocessor_list"].append(name) + self.options["tools_mill_preprocessor_list"].append(name) # HPGL preprocessor is only for Geometry objects therefore it should not be in the Excellon Preferences if 'hpgl' not in lowered_name: - self.defaults["tools_drill_preprocessor_list"].append(name) + self.options["tools_drill_preprocessor_list"].append(name) # ########################################################################################################### # ######################################### Initialize GUI ################################################## @@ -1020,8 +1032,8 @@ class App(QtCore.QObject): else: theme = 'white' - if self.defaults["global_cursor_color_enabled"]: - self.cursor_color_3D = self.defaults["global_cursor_color"] + if self.options["global_cursor_color_enabled"]: + self.cursor_color_3D = self.options["global_cursor_color"] else: if theme == 'white': self.cursor_color_3D = 'black' @@ -1029,7 +1041,7 @@ class App(QtCore.QObject): self.cursor_color_3D = 'gray' # update the defaults dict with the setting in QSetting - self.defaults['global_theme'] = theme + self.options['global_theme'] = theme # ######################## self.ui = MainGUI(self) @@ -1039,7 +1051,7 @@ class App(QtCore.QObject): self.set_screen_units(self.app_units) # decide if to show or hide the Notebook side of the screen at startup - if self.defaults["global_project_at_startup"] is True: + if self.options["global_project_at_startup"] is True: self.ui.splitter.setSizes([1, 1]) else: self.ui.splitter.setSizes([0, 1]) @@ -1064,22 +1076,20 @@ class App(QtCore.QObject): # ########################################################################################################### # ##################################### UPDATE PREFERENCES GUI FORMS ######################################## # ########################################################################################################### - self.preferencesUiManager = PreferencesUIManager(defaults=self.defaults, data_path=self.data_path, ui=self.ui, - inform=self.inform) + inform=self.inform, options=self.options) self.preferencesUiManager.defaults_write_form() - # When the self.defaults dictionary changes will update the Preferences GUI forms - self.defaults.set_change_callback(self.on_defaults_dict_change) + # When the self.options dictionary changes will update the Preferences GUI forms + self.options.set_change_callback(self.on_defaults_dict_change) # set the value used in the Windows Title - self.engine = self.defaults["global_graphic_engine"] + self.engine = self.options["global_graphic_engine"] # ########################################################################################################### # ###################################### CREATE UNIQUE SERIAL NUMBER ######################################## # ########################################################################################################### - chars = 'abcdefghijklmnopqrstuvwxyz0123456789' if self.defaults['global_serial'] == 0 or len(str(self.defaults['global_serial'])) < 10: self.defaults['global_serial'] = ''.join([random.choice(chars) for __ in range(20)]) @@ -1087,21 +1097,6 @@ class App(QtCore.QObject): self.defaults.propagate_defaults() - # ########################################################################################################### - # ######################################## UPDATE THE OPTIONS ############################################### - # ########################################################################################################### - - self.options = LoudDict() - # ----------------------------------------------------------------------------------------------------------- - # Update the self.options from the self.defaults - # The self.defaults holds the application defaults while the self.options holds the object defaults - # ----------------------------------------------------------------------------------------------------------- - # Copy app defaults to project options - for def_key, def_val in self.defaults.items(): - self.options[def_key] = deepcopy(def_val) - - # self.preferencesUiManager.show_preferences_gui() - # ########################################################################################################### # #################################### SETUP OBJECT COLLECTION ############################################## # ########################################################################################################### @@ -1128,7 +1123,7 @@ class App(QtCore.QObject): self.use_3d_engine = True # determine if the Legacy Graphic Engine is to be used or the OpenGL one - if self.defaults["global_graphic_engine"] == '2D': + if self.options["global_graphic_engine"] == '2D': self.use_3d_engine = False # PlotCanvas Event signals disconnect id holders @@ -1158,11 +1153,9 @@ class App(QtCore.QObject): self.splash.finish(self.ui) self.log.debug("Failed to start the Canvas.") - # terminate workers - # self.workers.__del__() self.clear_pool() - - raise BaseException("Failed to start the Canvas") + self.log.error("Failed to start the Canvas") + raise SystemError("Failed to start the Canvas") # add he PlotCanvas setup to the UI self.on_plotcanvas_add(self.plotcanvas, self.ui.right_layout) @@ -1199,7 +1192,7 @@ class App(QtCore.QObject): # ########################################################################################################### # ############################################### Worker SETUP ############################################## # ########################################################################################################### - w_number = int(self.defaults["global_worker_number"]) if self.defaults["global_worker_number"] else 2 + w_number = int(self.options["global_worker_number"]) if self.options["global_worker_number"] else 2 self.workers = WorkerStack(workers_number=w_number) self.worker_task.connect(self.workers.add_task) @@ -1275,7 +1268,7 @@ class App(QtCore.QObject): # install Bookmark Manager and populate bookmarks in the Help -> Bookmarks self.install_bookmarks() - self.book_dialog_tab = BookmarkManager(app=self, storage=self.defaults["global_bookmarks"]) + self.book_dialog_tab = BookmarkManager(app=self, storage=self.options["global_bookmarks"]) # ########################################################################################################### # ########################################### Tools Database ################################################ @@ -1291,7 +1284,7 @@ class App(QtCore.QObject): # ############################################## Shell SETUP ################################################ # ########################################################################################################### # show TCL shell at start-up based on the Menu -? Edit -> Preferences setting. - if self.defaults["global_shell_at_startup"]: + if self.options["global_shell_at_startup"]: self.ui.shell_dock.show() else: self.ui.shell_dock.hide() @@ -1302,7 +1295,7 @@ class App(QtCore.QObject): # Separate thread (Not worker) # Check for updates on startup but only if the user consent and the app is not in Beta version - if (self.beta is False or self.beta is None) and self.defaults["global_version_check"] is True: + if (self.beta is False or self.beta is None) and self.options["global_version_check"] is True: self.log.info("Checking for updates in backgroud (this is version %s)." % str(self.version)) # self.thr2 = QtCore.QThread() @@ -1313,7 +1306,7 @@ class App(QtCore.QObject): # ##################################### Register files with FlatCAM; ####################################### # ################################### It works only for Windows for now #################################### # ########################################################################################################### - if sys.platform == 'win32' and self.defaults["first_run"] is True: + if sys.platform == 'win32' and self.options["first_run"] is True: self.on_register_files() # ########################################################################################################### @@ -1359,13 +1352,13 @@ class App(QtCore.QObject): self.f_handlers = MenuFileHandlers(app=self) # this is calculated in the class above (somehow?) - self.defaults["root_folder_path"] = self.app_home + self.options["root_folder_path"] = self.app_home # ########################################################################################################### # ##################################### FIRST RUN SECTION ################################################### # ################################ It's done only once after install ##################################### # ########################################################################################################### - if self.defaults["first_run"] is True: + if self.options["first_run"] is True: # ONLY AT FIRST STARTUP INIT THE GUI LAYOUT TO 'minimal' self.log.debug("-> First Run: Setting up the first Layout") initial_lay = 'minimal' @@ -1376,7 +1369,7 @@ class App(QtCore.QObject): self.ui.general_pref_form.general_gui_group.layout_combo.setCurrentIndex(idx) # after the first run, this object should be False - self.defaults["first_run"] = False + self.options["first_run"] = False self.log.debug("-> First Run: Updating the Defaults file with Factory Defaults") self.preferencesUiManager.save_defaults(silent=True) @@ -1392,7 +1385,7 @@ class App(QtCore.QObject): headless=True, parent=self.parent_w) else: - if self.defaults["global_systray_icon"]: + if self.options["global_systray_icon"]: self.trayIcon = FlatCAMSystemTray(app=self, icon=QtGui.QIcon(self.resource_location + '/flatcam_icon32_green.png'), @@ -1428,7 +1421,7 @@ class App(QtCore.QObject): self.file_saved.connect(lambda kind, filename: self.register_save_folder(filename)) # when the defaults dictionary values change - self.defaults.defaults.set_change_callback(callback=self.on_defaults_value_changed) + self.options.set_change_callback(callback=self.on_options_value_changed) # ########################################################################################################### # ########################################## Standard signals ############################################### @@ -1606,13 +1599,13 @@ class App(QtCore.QObject): else: self.ui.show() - if self.defaults["global_systray_icon"]: + if self.options["global_systray_icon"]: self.trayIcon.show() else: try: self.trayIcon.show() - except Exception as err: - self.log.error("App.__init__() Running headless and trying to show the systray got: %s" % str(err)) + except Exception as t_err: + self.log.error("App.__init__() Running headless and trying to show the systray got: %s" % str(t_err)) self.log.warning("******************* RUNNING HEADLESS *******************") # ########################################################################################################### @@ -1783,7 +1776,7 @@ class App(QtCore.QObject): if silent is False: self.inform.emit(_("Open Excellon file failed.")) else: - self.f_handlers.on_fileopenexcellon(name=file_name, signal=None) + self.f_handlers.on_fileopenexcellon(name=file_name) return gco_list = self.ui.util_pref_form.fa_gcode_group.gco_list_text.get_value().split(',') @@ -1796,7 +1789,7 @@ class App(QtCore.QObject): if silent is False: self.inform.emit(_("Open GCode file failed.")) else: - self.f_handlers.on_fileopengcode(name=file_name, signal=None) + self.f_handlers.on_fileopengcode(name=file_name) return grb_list = self.ui.util_pref_form.fa_gerber_group.grb_list_text.get_value().split(',') @@ -1809,7 +1802,7 @@ class App(QtCore.QObject): if silent is False: self.inform.emit(_("Open Gerber file failed.")) else: - self.f_handlers.on_fileopengerber(name=file_name, signal=None) + self.f_handlers.on_fileopengerber(name=file_name) return # if it reached here without already returning then the app was registered with a file that it does not @@ -1843,7 +1836,7 @@ class App(QtCore.QObject): def log_path(self): return os.path.join(self.data_path, 'log.txt') - def on_defaults_value_changed(self, key_changed): + def on_options_value_changed(self, key_changed): # when changing those properties the associated keys change so we get an updated Properties default Tab if key_changed in [ "global_grid_lines", "global_grid_snap", "global_axis", "global_workspace", "global_workspaceT", @@ -2021,8 +2014,8 @@ class App(QtCore.QObject): self.image_tool.install(icon=QtGui.QIcon(self.resource_location + '/image32.png'), pos=self.ui.menufileimport, separator=True) - except Exception as err: - self.log.error("Image Import plugin could not be started due of: %s" % str(err)) + except Exception as im_err: + self.log.error("Image Import plugin could not be started due of: %s" % str(im_err)) self.image_tool = lambda x: None self.pcb_wizard_tool = PcbWizard(self) @@ -2142,11 +2135,11 @@ class App(QtCore.QObject): self.ui.menufilenewexc.triggered.connect(lambda: self.app_obj.new_excellon_object()) self.ui.menufilenewdoc.triggered.connect(lambda: self.app_obj.new_document_object()) - self.ui.menufileopengerber.triggered.connect(self.f_handlers.on_fileopengerber) - self.ui.menufileopenexcellon.triggered.connect(self.f_handlers.on_fileopenexcellon) - self.ui.menufileopengcode.triggered.connect(self.f_handlers.on_fileopengcode) - self.ui.menufileopenproject.triggered.connect(self.f_handlers.on_file_openproject) - self.ui.menufileopenconfig.triggered.connect(self.f_handlers.on_file_openconfig) + self.ui.menufileopengerber.triggered.connect(lambda: self.f_handlers.on_fileopengerber()) + self.ui.menufileopenexcellon.triggered.connect(lambda: self.f_handlers.on_fileopenexcellon()) + self.ui.menufileopengcode.triggered.connect(lambda: self.f_handlers.on_fileopengcode()) + self.ui.menufileopenproject.triggered.connect(lambda: self.f_handlers.on_file_openproject()) + self.ui.menufileopenconfig.triggered.connect(lambda: self.f_handlers.on_file_openconfig()) self.ui.menufilenewscript.triggered.connect(self.f_handlers.on_filenewscript) self.ui.menufileopenscript.triggered.connect(self.f_handlers.on_fileopenscript) @@ -2159,7 +2152,7 @@ class App(QtCore.QObject): self.ui.menufileimportdxf.triggered.connect(lambda: self.f_handlers.on_file_importdxf("geometry")) self.ui.menufileimportdxf_as_gerber.triggered.connect(lambda: self.f_handlers.on_file_importdxf("gerber")) - self.ui.menufileimport_hpgl2_as_geo.triggered.connect(self.f_handlers.on_fileopenhpgl2) + self.ui.menufileimport_hpgl2_as_geo.triggered.connect(lambda: self.f_handlers.on_fileopenhpgl2()) self.ui.menufileexportsvg.triggered.connect(self.f_handlers.on_file_exportsvg) self.ui.menufileexportpng.triggered.connect(self.f_handlers.on_file_exportpng) self.ui.menufileexportexcellon.triggered.connect(self.f_handlers.on_file_exportexcellon) @@ -2210,7 +2203,7 @@ class App(QtCore.QObject): def connect_optionsmenu_signals(self): # self.ui.menuoptions_transfer_a2o.triggered.connect(self.on_options_app2object) - # self.ui.menuoptions_transfer_a2p.triggered.connect(self.on_options_app2project) + # self.ui.menuoptions_transfer_a2p.triggered.connect(self.on_defaults2options) # self.ui.menuoptions_transfer_o2a.triggered.connect(self.on_options_object2app) # self.ui.menuoptions_transfer_p2a.triggered.connect(self.on_options_project2app) # self.ui.menuoptions_transfer_o2p.triggered.connect(self.on_options_object2project) @@ -2263,7 +2256,7 @@ class App(QtCore.QObject): self.ui.menuhelp_shortcut_list.triggered.connect(self.ui.on_shortcut_list) def connect_project_context_signals(self): - self.ui.menuprojectenable.triggered.connect(self.on_enable_sel_plots) + self.ui.menuprojectenable.triggered.connect(lambda: self.on_enable_sel_plots()) self.ui.menuprojectdisable.triggered.connect(self.on_disable_sel_plots) self.ui.menuprojectviewsource.triggered.connect(self.on_view_source) @@ -2368,10 +2361,10 @@ class App(QtCore.QObject): # File Toolbar Signals # ui.file_new_btn.triggered.connect(self.on_file_new_project) - self.ui.file_open_btn.triggered.connect(self.f_handlers.on_file_openproject) - self.ui.file_save_btn.triggered.connect(self.f_handlers.on_file_saveproject) - self.ui.file_open_gerber_btn.triggered.connect(self.f_handlers.on_fileopengerber) - self.ui.file_open_excellon_btn.triggered.connect(self.f_handlers.on_fileopenexcellon) + self.ui.file_open_btn.triggered.connect(lambda: self.f_handlers.on_file_openproject()) + self.ui.file_save_btn.triggered.connect(lambda: self.f_handlers.on_file_saveproject()) + self.ui.file_open_gerber_btn.triggered.connect(lambda: self.f_handlers.on_fileopengerber()) + self.ui.file_open_excellon_btn.triggered.connect(lambda: self.f_handlers.on_fileopenexcellon()) # View Toolbar Signals self.ui.clear_plot_btn.triggered.connect(self.clear_plots) @@ -2404,8 +2397,8 @@ class App(QtCore.QObject): # Tools Toolbar Signals try: self.connect_tools_signals_to_toolbar() - except Exception as err: - self.log.error("App.connect_toolbar_signals() tools signals -> %s" % str(err)) + except Exception as c_err: + self.log.error("App.connect_toolbar_signals() tools signals -> %s" % str(c_err)) def on_layout(self, index=None, lay=None, connect_signals=True): """ @@ -2559,17 +2552,17 @@ class App(QtCore.QObject): # Editor Toolbars Signals try: self.connect_editors_toolbar_signals() - except Exception as err: - self.log.error("App.on_layout() - connect editor signals -> %s" % str(err)) + except Exception as m_err: + self.log.error("App.on_layout() - connect editor signals -> %s" % str(m_err)) self.ui.grid_snap_btn.setChecked(True) self.ui.corner_snap_btn.setVisible(False) self.ui.snap_magnet.setVisible(False) - self.ui.grid_gap_x_entry.setText(str(self.defaults["global_gridx"])) - self.ui.grid_gap_y_entry.setText(str(self.defaults["global_gridy"])) - self.ui.snap_max_dist_entry.setText(str(self.defaults["global_snap_max"])) + self.ui.grid_gap_x_entry.setText(str(self.options["global_gridx"])) + self.ui.grid_gap_y_entry.setText(str(self.options["global_gridy"])) + self.ui.snap_max_dist_entry.setText(str(self.options["global_snap_max"])) self.ui.grid_gap_link_cb.setChecked(True) def object2editor(self): @@ -2987,16 +2980,16 @@ class App(QtCore.QObject): Get the folder path from where the last file was opened. :return: String, last opened folder path """ - return self.defaults["global_last_folder"] + return self.options["global_last_folder"] def get_last_save_folder(self): """ Get the folder path from where the last file was saved. :return: String, last saved folder path """ - loc = self.defaults["global_last_save_folder"] + loc = self.options["global_last_save_folder"] if loc is None: - loc = self.defaults["global_last_folder"] + loc = self.options["global_last_folder"] if loc is None: loc = os.path.dirname(__file__) return loc @@ -3083,8 +3076,8 @@ class App(QtCore.QObject): date = date.replace(' ', '_') filter__ = "HTML File .html (*.html);;TXT File .txt (*.txt);;All Files (*.*)" - path_to_save = self.defaults["global_last_save_folder"] if \ - self.defaults["global_last_save_folder"] is not None else self.data_path + path_to_save = self.options["global_last_save_folder"] if \ + self.options["global_last_save_folder"] is not None else self.data_path final_path = os.path.join(path_to_save, 'file_%s' % str(date)) try: @@ -3162,10 +3155,10 @@ class App(QtCore.QObject): else: self.recent.insert(0, record) - if len(self.recent) > self.defaults['global_recent_limit']: # Limit reached + if len(self.recent) > self.options['global_recent_limit']: # Limit reached self.recent.pop() - if len(self.recent_projects) > self.defaults['global_recent_limit']: # Limit reached + if len(self.recent_projects) > self.options['global_recent_limit']: # Limit reached self.recent_projects.pop() try: @@ -3206,8 +3199,8 @@ class App(QtCore.QObject): beta = self.beta class AboutDialog(QtWidgets.QDialog): - def __init__(self, app, parent=None): - QtWidgets.QDialog.__init__(self, parent) + def __init__(self, app, parent): + QtWidgets.QDialog.__init__(self, parent=parent) self.app = app @@ -3707,8 +3700,8 @@ class App(QtCore.QObject): """ class HowtoDialog(QtWidgets.QDialog): - def __init__(self, app, parent=None): - QtWidgets.QDialog.__init__(self, parent) + def __init__(self, app, parent): + QtWidgets.QDialog.__init__(self, parent=parent) self.app = app @@ -3885,15 +3878,15 @@ class App(QtCore.QObject): """ if book_dict is None: - self.defaults["global_bookmarks"].update( + self.options["global_bookmarks"].update( { '1': ['FlatCAM', "http://flatcam.org"], '2': [_('Backup Site'), ""] } ) else: - self.defaults["global_bookmarks"].clear() - self.defaults["global_bookmarks"].update(book_dict) + self.options["global_bookmarks"].clear() + self.options["global_bookmarks"].update(book_dict) # first try to disconnect if somehow they get connected from elsewhere for act in self.ui.menuhelp_bookmarks.actions(): @@ -3908,18 +3901,18 @@ class App(QtCore.QObject): else: self.ui.menuhelp_bookmarks.removeAction(act) - bm_limit = int(self.defaults["global_bookmarks_limit"]) - if self.defaults["global_bookmarks"]: + bm_limit = int(self.options["global_bookmarks_limit"]) + if self.options["global_bookmarks"]: - # order the self.defaults["global_bookmarks"] dict keys by the value as integer - # the whole convoluted things is because when serializing the self.defaults (on app close or save) + # order the self.options["global_bookmarks"] dict keys by the value as integer + # the whole convoluted things is because when serializing the self.options (on app close or save) # the JSON is first making the keys as strings (therefore I have to use strings too # or do the conversion :( # ) # and it is ordering them (actually I want that to make the defaults easy to search within) but making # the '10' entry just after '1' therefore ordering as strings - sorted_bookmarks = sorted(list(self.defaults["global_bookmarks"].items())[:bm_limit], + sorted_bookmarks = sorted(list(self.options["global_bookmarks"].items())[:bm_limit], key=lambda x: int(x[0])) for entry, bookmark in sorted_bookmarks: title = bookmark[0] @@ -3949,8 +3942,8 @@ class App(QtCore.QObject): # there can be only one instance of Bookmark Manager at one time return - # BookDialog(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui).exec() - self.book_dialog_tab = BookmarkManager(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui) + # BookDialog(app=self, storage=self.options["global_bookmarks"], parent=self.ui).exec() + self.book_dialog_tab = BookmarkManager(app=self, storage=self.options["global_bookmarks"], parent=self.ui) self.book_dialog_tab.setObjectName("bookmarks_tab") # add the tab if it was closed @@ -4322,15 +4315,15 @@ class App(QtCore.QObject): set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.defaults["fa_excellon"].replace(' ', '').split(','): + for ext in self.options["fa_excellon"].replace(' ', '').split(','): if ext not in exc_list: delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) - # now write the updated extensions to the self.defaults + # now write the updated extensions to the self.options # new_ext = '' # for ext in exc_list: # new_ext = new_ext + ext + ', ' - # self.defaults["fa_excellon"] = new_ext + # self.options["fa_excellon"] = new_ext self.inform.emit('[success] %s' % _("Selected Excellon file extensions registered with FlatCAM.")) if obj_type is None or obj_type == 'gcode': @@ -4343,7 +4336,7 @@ class App(QtCore.QObject): set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.defaults["fa_gcode"].replace(' ', '').split(','): + for ext in self.options["fa_gcode"].replace(' ', '').split(','): if ext not in gco_list: delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) @@ -4360,7 +4353,7 @@ class App(QtCore.QObject): set_reg('', root_pth=root_path, new_reg_path_par=new_k, value='FlatCAM') # and unregister those that are no longer in the Preferences windows but are in the file - for ext in self.defaults["fa_gerber"].replace(' ', '').split(','): + for ext in self.options["fa_gerber"].replace(' ', '').split(','): if ext not in grb_list: delete_reg(root_pth=root_path, reg_path=new_reg_path, key_to_del='.%s' % ext) @@ -4511,7 +4504,7 @@ class App(QtCore.QObject): # update the self.myKeywords so the model is updated self.autocomplete_kw_list = self.default_keywords self.myKeywords = self.tcl_commands_list + self.autocomplete_kw_list + self.tcl_keywords - self.shell.commnad_line().set_model_data(self.myKeywords) + self.shell.command_line().set_model_data(self.myKeywords) def delete_all_extensions(self, ext_type): """ @@ -4569,7 +4562,7 @@ class App(QtCore.QObject): "Check the generated GCODE.")) return - fuse_tools = self.defaults["geometry_merge_fuse_tools"] + fuse_tools = self.options["geometry_merge_fuse_tools"] # if at least one True object is in the list then due of the previous check, all list elements are True objects if True in geo_type_set: @@ -4618,7 +4611,7 @@ class App(QtCore.QObject): (_("At least two objects are required for join. Objects currently selected"), len(objs))) return 'fail' - fuse_tools = self.defaults["excellon_merge_fuse_tools"] + fuse_tools = self.options["excellon_merge_fuse_tools"] def initialize(exc_obj, app): ExcellonObject.merge(exc_list=objs, exc_final=exc_obj, decimals=self.decimals, fuse_tools=fuse_tools, @@ -4732,10 +4725,10 @@ class App(QtCore.QObject): def on_defaults_dict_change(self, field): """ - Called whenever a key changed in the self.defaults dictionary. It will set the required GUI element in the + Called whenever a key changed in the self.options dictionary. It will set the required GUI element in the Edit -> Preferences tab window. - :param field: the key of the self.defaults dictionary that was changed. + :param field: the key of the self.options dictionary that was changed. :return: None """ self.preferencesUiManager.defaults_write_form_field(field=field) @@ -4766,7 +4759,7 @@ class App(QtCore.QObject): pref_factor = 25.4 if new_units == 'MM' else 1 / 25.4 self.scale_preferences(pref_factor, new_units) - self.defaults["units"] = new_units + self.options["units"] = new_units # update th new units in the preferences storage self.app_units = new_units @@ -4775,9 +4768,9 @@ class App(QtCore.QObject): self.preferencesUiManager.defaults_read_form() # update the defaults from form, some may assume that the conversion is enough and it's not - self.on_options_app2project() + self.on_defaults2options() - # Keys in self.defaults for which to scale their values + # Keys in self.options for which to scale their values dimensions = [ # Global 'global_gridx', 'global_gridy', 'global_snap_max', "global_tolerance", @@ -4896,24 +4889,24 @@ class App(QtCore.QObject): 'tools_paint_tooldia', 'tools_transform_ref_point', 'tools_cal_toolchange_xy', 'gerber_editor_newdim', 'tools_drill_toolchangexy', 'tools_drill_endxy', 'tools_mill_toolchangexy', 'tools_mill_endxy', 'tools_solderpaste_xy_toolchange']: - if not self.defaults[dim] or self.defaults[dim] == '': + if not self.options[dim] or self.options[dim] == '': continue - if isinstance(self.defaults[dim], str): + if isinstance(self.options[dim], str): try: - tools_diameters = eval(self.defaults[dim]) + tools_diameters = eval(self.options[dim]) except Exception as e: self.log.error("App.on_toggle_units().scale_defaults() lists --> %s" % str(e)) continue - elif isinstance(self.defaults[dim], (float, int)): - tools_diameters = [self.defaults[dim]] + elif isinstance(self.options[dim], (float, int)): + tools_diameters = [self.options[dim]] else: - tools_diameters = list(self.defaults[dim]) + tools_diameters = list(self.options[dim]) if isinstance(tools_diameters, (tuple, list)): pass elif isinstance(tools_diameters, (int, float)): - tools_diameters = [self.defaults[dim]] + tools_diameters = [self.options[dim]] else: continue @@ -4922,28 +4915,28 @@ class App(QtCore.QObject): for t in range(td_len): conv_list.append(self.dec_format(float(tools_diameters[t]) * sfactor, self.decimals)) - self.defaults[dim] = conv_list + self.options[dim] = conv_list elif dim in ['global_gridx', 'global_gridy']: # format the number of decimals to the one specified in self.decimals try: - val = float(self.defaults[dim]) * sfactor + val = float(self.options[dim]) * sfactor except Exception as e: self.log.error('App.on_toggle_units().scale_defaults() grids --> %s' % str(e)) continue - self.defaults[dim] = self.dec_format(val, self.decimals) + self.options[dim] = self.dec_format(val, self.decimals) else: # the number of decimals for the rest is kept unchanged - if self.defaults[dim]: + if self.options[dim]: try: - val = float(self.defaults[dim]) * sfactor + val = float(self.options[dim]) * sfactor except Exception as e: self.log.error( 'App.on_toggle_units().scale_defaults() standard --> Value: %s %s' % (str(dim), str(e)) ) continue - self.defaults[dim] = self.dec_format(val, self.decimals) + self.options[dim] = self.dec_format(val, self.decimals) self.preferencesUiManager.defaults_write_form(fl_units=new_units) @@ -5005,13 +4998,13 @@ class App(QtCore.QObject): obj.build_ui() # update workspace if active - if self.defaults['global_workspace'] is True: - self.plotcanvas.draw_workspace(pagesize=self.defaults['global_workspaceT']) + if self.options['global_workspace'] is True: + self.plotcanvas.draw_workspace(pagesize=self.options['global_workspaceT']) # adjust the grid values on the main toolbar - val_x = round(float(self.defaults['global_gridx']) * factor, self.decimals) + val_x = round(float(self.options['global_gridx']) * factor, self.decimals) val_y = val_x if self.ui.grid_gap_link_cb.isChecked() else \ - round(float(self.defaults['global_gridy']) * factor, self.decimals) + round(float(self.options['global_gridy']) * factor, self.decimals) # update Object UI forms current = self.collection.get_active() @@ -5032,16 +5025,16 @@ class App(QtCore.QObject): factor = 1 # store the grid values so they are not changed in the next step - val_x = float(self.defaults['global_gridx']) - val_y = float(self.defaults['global_gridy']) + val_x = float(self.options['global_gridx']) + val_y = float(self.options['global_gridy']) self.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled.")) self.preferencesUiManager.defaults_read_form() # update the Grid snap values - self.defaults['global_gridx'] = val_x - self.defaults['global_gridy'] = val_y + self.options['global_gridx'] = val_x + self.options['global_gridy'] = val_y self.ui.grid_gap_x_entry.set_value(val_x, decimals=self.decimals) self.ui.grid_gap_y_entry.set_value(val_y, decimals=self.decimals) @@ -5056,11 +5049,11 @@ class App(QtCore.QObject): self.plotcanvas.delete_workspace() self.preferencesUiManager.defaults_read_form() - self.plotcanvas.draw_workspace(workspace_size=self.defaults['global_workspaceT']) + self.plotcanvas.draw_workspace(workspace_size=self.options['global_workspaceT']) def on_workspace(self): if self.ui.general_pref_form.general_app_set_group.workspace_cb.get_value(): - self.plotcanvas.draw_workspace(workspace_size=self.defaults['global_workspaceT']) + self.plotcanvas.draw_workspace(workspace_size=self.options['global_workspaceT']) self.inform[str, bool].emit(_("Workspace enabled."), False) else: self.plotcanvas.delete_workspace() @@ -5120,7 +5113,7 @@ class App(QtCore.QObject): if notebook_widget_name == 'properties_tab': if self.collection.get_active().kind == 'geometry': # Tool add works for Geometry only if Advanced is True in Preferences - if self.defaults["global_app_level"] == 'a': + if self.options["global_app_level"] == 'a': tool_add_popup = FCInputSpinner(title='%s...' % _("New Tool"), text='%s:' % _('Enter a Tool Diameter'), min=0.0000, max=100.0000, decimals=self.decimals, step=0.1) @@ -5135,8 +5128,8 @@ class App(QtCore.QObject): return try: self.collection.get_active().on_tool_add(clicked_state=False, dia=float(val)) - except Exception as err: - self.log.debug("App.on_tool_add_keypress() --> %s" % str(err)) + except Exception as tadd_err: + self.log.debug("App.on_tool_add_keypress() --> %s" % str(tadd_err)) else: self.inform.emit('[WARNING_NOTCL] %s...' % _("Adding Tool cancelled")) else: @@ -5230,7 +5223,7 @@ class App(QtCore.QObject): # Make sure that the deletion will happen only after the Editor is no longer active otherwise we might delete # a geometry object before we update it. if self.call_source == 'app': - if self.defaults["global_delete_confirmation"] is True and force_deletion is False: + if self.options["global_delete_confirmation"] is True and force_deletion is False: msgbox = FCMessageBox(parent=self.ui) title = _("Delete objects") txt = _("Are you sure you want to permanently delete\n" @@ -5248,7 +5241,7 @@ class App(QtCore.QObject): msgbox.exec() response = msgbox.clickedButton() - if self.defaults["global_delete_confirmation"] is False or force_deletion is True: + if self.options["global_delete_confirmation"] is False or force_deletion is True: response = bt_ok if response == bt_ok: @@ -5699,7 +5692,7 @@ class App(QtCore.QObject): label=_("Enter the coordinates in format X,Y:"), icon=QtGui.QIcon(self.resource_location + '/jump_to16.png'), initial_text=dia_box_location, - reference=self.defaults['global_jump_ref']) + reference=self.options['global_jump_ref']) if dia_box.ok is True: try: @@ -5713,7 +5706,7 @@ class App(QtCore.QObject): rel_x = self.mouse[0] + location[0] rel_y = self.mouse[1] + location[1] location = (rel_x, rel_y) - self.defaults['global_jump_ref'] = dia_box.reference + self.options['global_jump_ref'] = dia_box.reference except Exception: return else: @@ -5763,7 +5756,7 @@ class App(QtCore.QObject): ) cursor.setPos(j_pos[0], j_pos[1]) self.plotcanvas.mouse = [location[0], location[1]] - if self.defaults["global_cursor_color_enabled"] is True: + if self.options["global_cursor_color_enabled"] is True: self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1], color=self.cursor_color_3D) else: self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1]) @@ -5772,8 +5765,8 @@ class App(QtCore.QObject): # Update cursor self.app_cursor.set_data(np.asarray([(location[0], location[1])]), symbol='++', edge_color=self.cursor_color_3D, - edge_width=self.defaults["global_cursor_width"], - size=self.defaults["global_cursor_size"]) + edge_width=self.options["global_cursor_width"], + size=self.options["global_cursor_size"]) # Set the relative position label dx = location[0] - float(self.rel_point1[0]) @@ -5842,12 +5835,12 @@ class App(QtCore.QObject): dia_box = DialogBoxChoice(title=_("Locate ..."), icon=QtGui.QIcon(self.resource_location + '/locate16.png'), - choice=self.defaults['global_locate_pt']) + choice=self.options['global_locate_pt']) if dia_box.ok is True: try: location_point = dia_box.location_point - self.defaults['global_locate_pt'] = dia_box.location_point + self.options['global_locate_pt'] = dia_box.location_point except Exception: return else: @@ -5910,7 +5903,7 @@ class App(QtCore.QObject): ) cursor.setPos(j_pos[0], j_pos[1]) self.plotcanvas.mouse = [location[0], location[1]] - if self.defaults["global_cursor_color_enabled"] is True: + if self.options["global_cursor_color_enabled"] is True: self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1], color=self.cursor_color_3D) else: self.plotcanvas.draw_cursor(x_pos=location[0], y_pos=location[1]) @@ -5919,8 +5912,8 @@ class App(QtCore.QObject): # Update cursor self.app_cursor.set_data(np.asarray([(location[0], location[1])]), symbol='++', edge_color=self.cursor_color_3D, - edge_width=self.defaults["global_cursor_width"], - size=self.defaults["global_cursor_size"]) + edge_width=self.options["global_cursor_width"], + size=self.options["global_cursor_size"]) # Set the relative position label self.dx = location[0] - float(self.rel_point1[0]) @@ -5973,8 +5966,9 @@ class App(QtCore.QObject): try: if obj.tools: obj_init.tools = deepcopy(obj.tools) - except Exception as err: - app_obj.error("App.on_copy_command() --> %s" % str(err)) + except Exception as cerr: + app_obj.log.error("App.on_copy_command() --> %s" % str(cerr)) + return "fail" try: obj_init.source_file = deepcopy(obj.source_file) @@ -5993,9 +5987,11 @@ class App(QtCore.QObject): return 'fail' def initialize_script(new_obj, app_obj): + app_obj.log.debug("Script copied.") new_obj.source_file = deepcopy(obj.source_file) def initialize_document(new_obj, app_obj): + app_obj.log.debug("Document copied.") new_obj.source_file = deepcopy(obj.source_file) for obj in self.collection.get_selected(): @@ -6013,7 +6009,7 @@ class App(QtCore.QObject): elif obj.kind == 'document': self.app_obj.new_object("document", str(obj_name) + "_copy", initialize_document) except Exception as e: - return "Operation failed: %s" % str(e) + self.log.error("Copy operation failed: %s for object: %s" % (str(e), str(obj_name))) def on_copy_object2(self, custom_name): @@ -6103,11 +6099,11 @@ class App(QtCore.QObject): else: default_data[opt_key] = self.options[opt_key] - if type(self.defaults["tools_mill_tooldia"]) == float: - tools_diameters = [self.defaults["tools_mill_tooldia"]] + if type(self.options["tools_mill_tooldia"]) == float: + tools_diameters = [self.options["tools_mill_tooldia"]] else: try: - dias = str(self.defaults["tools_mill_tooldia"]).strip('[').strip(']') + dias = str(self.options["tools_mill_tooldia"]).strip('[').strip(']') tools_string = dias.split(",") tools_diameters = [eval(a) for a in tools_string if a != ''] except Exception as e: @@ -6129,7 +6125,8 @@ class App(QtCore.QObject): } tools[t_id] = deepcopy(new_tool) - def initialize_from_gerber(new_obj, app): + def initialize_from_gerber(new_obj, app_obj): + app_obj.log.debug("Gerber converted to Geometry: %s" % str(obj.obj_options["name"])) new_obj.solid_geometry = deepcopy(obj.solid_geometry) try: new_obj.follow_geometry = obj.follow_geometry @@ -6143,6 +6140,7 @@ class App(QtCore.QObject): new_obj.tools[k]['solid_geometry'] = deepcopy(obj.solid_geometry) def initialize_from_excellon(new_obj, app_obj): + app_obj.log.debug("Excellon converted to Geometry: %s" % str(obj.obj_options["name"])) solid_geo = [] for tool in obj.tools: for geo in obj.tools[tool]['solid_geometry']: @@ -6172,9 +6170,8 @@ class App(QtCore.QObject): if obj.kind == 'gerber': self.app_obj.new_object("geometry", outname, initialize_from_gerber) - except Exception as e: - self.log.error("Convert any 2 geo operation failed: %s" % str(e)) + self.log.error("Convert any2geo operation failed: %s" % str(e)) def convert_any2gerber(self): """ @@ -6489,12 +6486,12 @@ class App(QtCore.QObject): self.collection.set_active(name) curr_sel_obj = self.collection.get_by_name(name) # create the selection box around the selected object - if self.defaults['global_selection_shape'] is True: + if self.options['global_selection_shape'] is True: try: self.draw_selection_shape(curr_sel_obj) - except Exception as err: + except Exception as gerr: self.log.error( - "App.on_select_all(). Object %s can't be selected on canvas. Error: %s" % (name, str(err))) + "App.on_select_all(). Object %s can't be selected on canvas. Error: %s" % (name, str(gerr))) def on_toggle_preferences(self): pref_open = False @@ -6705,7 +6702,7 @@ class App(QtCore.QObject): # So it can receive key presses plotcanvas3d.native.setFocus() - pan_button = 2 if self.defaults["global_pan_button"] == '2' else 3 + pan_button = 2 if self.options["global_pan_button"] == '2' else 3 # Set the mouse button for panning plotcanvas3d.view.camera.pan_button_setting = pan_button @@ -6834,8 +6831,8 @@ class App(QtCore.QObject): pass # restore the coords toolbars - self.ui.toggle_coords(checked=self.defaults["global_coordsbar_show"]) - self.ui.toggle_delta_coords(checked=self.defaults["global_delta_coordsbar_show"]) + self.ui.toggle_coords(checked=self.options["global_coordsbar_show"]) + self.ui.toggle_delta_coords(checked=self.options["global_delta_coordsbar_show"]) def on_notebook_closed(self, tab_obj_name): @@ -7028,7 +7025,7 @@ class App(QtCore.QObject): if silent is False: rotatebox = FCInputDoubleSpinner(title=_("Transform"), text=_("Enter the Angle value:"), min=-360, max=360, decimals=4, - init_val=float(self.defaults['tools_transform_rotate']), + init_val=float(self.options['tools_transform_rotate']), parent=self.ui) rotatebox.setWindowIcon(QtGui.QIcon(self.resource_location + '/rotate.png')) @@ -7082,7 +7079,7 @@ class App(QtCore.QObject): else: skewxbox = FCInputDoubleSpinner(title=_("Transform"), text=_("Enter the Angle value:"), min=-360, max=360, decimals=4, - init_val=float(self.defaults['tools_transform_skew_x']), + init_val=float(self.options['tools_transform_skew_x']), parent=self.ui) skewxbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/skewX.png')) @@ -7130,7 +7127,7 @@ class App(QtCore.QObject): else: skewybox = FCInputDoubleSpinner(title=_("Transform"), text=_("Enter the Angle value:"), min=-360, max=360, decimals=4, - init_val=float(self.defaults['tools_transform_skew_y']), + init_val=float(self.options['tools_transform_skew_y']), parent=self.ui) skewybox.setWindowIcon(QtGui.QIcon(self.resource_location + '/skewY.png')) @@ -7196,7 +7193,7 @@ class App(QtCore.QObject): # act.triggered.disconnect() self.ui.cmenu_gridmenu.clear() - sorted_list = sorted(self.defaults["global_grid_context_menu"][str(units)]) + sorted_list = sorted(self.options["global_grid_context_menu"][str(units)]) grid_toggle = self.ui.cmenu_gridmenu.addAction(QtGui.QIcon(self.resource_location + '/grid32_menu.png'), _("Grid On/Off")) @@ -7242,8 +7239,8 @@ class App(QtCore.QObject): _("Please enter a grid value with non-zero value, in Float format.")) return else: - if val not in self.defaults["global_grid_context_menu"][str(units)]: - self.defaults["global_grid_context_menu"][str(units)].append(val) + if val not in self.options["global_grid_context_menu"][str(units)]: + self.options["global_grid_context_menu"][str(units)].append(val) self.inform.emit('[success] %s...' % _("New Grid added")) else: self.inform.emit('[WARNING_NOTCL] %s...' % _("Grid already exists")) @@ -7268,7 +7265,7 @@ class App(QtCore.QObject): return else: try: - self.defaults["global_grid_context_menu"][str(units)].remove(val) + self.options["global_grid_context_menu"][str(units)].remove(val) except ValueError: self.inform.emit('[ERROR_NOTCL]%s...' % _("Grid Value does not exist")) return @@ -7338,12 +7335,12 @@ class App(QtCore.QObject): if self.use_3d_engine: event_pos = event.pos - pan_button = 2 if self.defaults["global_pan_button"] == '2' else 3 + pan_button = 2 if self.options["global_pan_button"] == '2' else 3 self.event_is_dragging = event.is_dragging else: event_pos = (event.xdata, event.ydata) # Matplotlib has the middle and right buttons mapped in reverse compared with VisPy - pan_button = 3 if self.defaults["global_pan_button"] == '2' else 2 + pan_button = 3 if self.options["global_pan_button"] == '2' else 2 self.event_is_dragging = self.plotcanvas.is_dragging # So it can receive key presses but not when the Tcl Shell is active @@ -7380,8 +7377,8 @@ class App(QtCore.QObject): # Update cursor self.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), symbol='++', edge_color=self.cursor_color_3D, - edge_width=self.defaults["global_cursor_width"], - size=self.defaults["global_cursor_size"]) + edge_width=self.options["global_cursor_width"], + size=self.options["global_cursor_size"]) else: pos = (pos_canvas[0], pos_canvas[1]) @@ -7393,7 +7390,7 @@ class App(QtCore.QObject): self.mouse = [pos[0], pos[1]] - if self.defaults['global_selection_shape'] is False: + if self.options['global_selection_shape'] is False: self.selection_type = None return @@ -7406,8 +7403,8 @@ class App(QtCore.QObject): if self.event_is_dragging == 1 and event.button == 1: self.delete_selection_shape() if self.dx < 0: - self.draw_moving_selection_shape(self.pos, pos, color=self.defaults['global_alt_sel_line'], - face_color=self.defaults['global_alt_sel_fill']) + self.draw_moving_selection_shape(self.pos, pos, color=self.options['global_alt_sel_line'], + face_color=self.options['global_alt_sel_fill']) self.selection_type = False elif self.dx >= 0: self.draw_moving_selection_shape(self.pos, pos) @@ -7418,7 +7415,7 @@ class App(QtCore.QObject): self.selection_type = None # hover effect - enabled in Preferences -> General -> appGUI Settings - if self.defaults['global_hover_shape']: + if self.options['global_hover_shape']: for obj in self.collection.get_list(): try: # select the object(s) only if it is enabled (plotted) @@ -7533,7 +7530,7 @@ class App(QtCore.QObject): try: if self.command_active is None: - if mod_key == self.defaults["global_mselect_key"]: + if mod_key == self.options["global_mselect_key"]: # If the modifier key is pressed when the LMB is clicked then if the object is selected it will # deselect, and if it's not selected then it will be selected self.select_objects(key='multisel') @@ -7582,10 +7579,8 @@ class App(QtCore.QObject): # do not auto open the Project Tab self.click_noproject = True - self.clipboard.setText( - self.defaults["global_point_clipboard_format"] % - (self.decimals,position[0], self.decimals, position[1]) - ) + self.clipboard.setText(self.options["global_point_clipboard_format"] % + (self.decimals, position[0], self.decimals, position[1])) self.inform.emit('[success] %s' % _("Copied to clipboard.")) elif modifiers == QtCore.Qt.KeyboardModifier.ControlModifier | QtCore.Qt.KeyboardModifier.ShiftModifier: try: @@ -7667,13 +7662,13 @@ class App(QtCore.QObject): if sel_type is True: if poly_obj.within(poly_selection): # create the selection box around the selected object - if self.defaults['global_selection_shape'] is True: + if self.options['global_selection_shape'] is True: self.draw_selection_shape(obj) self.collection.set_active(obj.obj_options['name']) else: if poly_selection.intersects(poly_obj): # create the selection box around the selected object - if self.defaults['global_selection_shape'] is True: + if self.options['global_selection_shape'] is True: self.draw_selection_shape(obj) self.collection.set_active(obj.obj_options['name']) obj.selection_shape_drawn = True @@ -7728,7 +7723,7 @@ class App(QtCore.QObject): curr_sel_obj = self.collection.get_active() # create the selection box around the selected object - if self.defaults['global_selection_shape'] is True: + if self.options['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) curr_sel_obj.selection_shape_drawn = True elif curr_sel_obj.obj_options['name'] not in self.objects_under_the_click_list: @@ -7739,12 +7734,12 @@ class App(QtCore.QObject): self.collection.set_active(self.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: + if self.options['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: + if self.options['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) curr_sel_obj.selection_shape_drawn = True else: @@ -7782,7 +7777,7 @@ class App(QtCore.QObject): curr_sel_obj.selection_shape_drawn = False # create the selection box around the selected object - if self.defaults['global_selection_shape'] is True: + if self.options['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) @@ -7937,16 +7932,16 @@ class App(QtCore.QObject): # face.alpha = 0.2 # outline = Color(color, alpha=0.8) # else: - # face = Color(self.defaults['global_sel_fill']) + # face = Color(self.options['global_sel_fill']) # face.alpha = 0.2 - # outline = self.defaults['global_sel_line'] + # outline = self.options['global_sel_line'] if color: face = color[:-2] + str(hex(int(0.2 * 255)))[2:] outline = color[:-2] + str(hex(int(0.8 * 255)))[2:] else: - face = self.defaults['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] - outline = self.defaults['global_sel_line'] + face = self.options['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] + outline = self.options['global_sel_line'] self.hover_shapes.add(hover_rect, color=outline, face_color=face, update=True, layer=0, tolerance=None) @@ -8001,11 +7996,11 @@ class App(QtCore.QObject): outline = color[:-2] + str(hex(int(0.8 * 255)))[2:] else: if self.use_3d_engine: - face = self.defaults['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] - outline = self.defaults['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] + face = self.options['global_sel_fill'][:-2] + str(hex(int(0.2 * 255)))[2:] + outline = self.options['global_sel_line'][:-2] + str(hex(int(0.8 * 255)))[2:] else: - face = self.defaults['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] - outline = self.defaults['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] + face = self.options['global_sel_fill'][:-2] + str(hex(int(0.4 * 255)))[2:] + outline = self.options['global_sel_line'][:-2] + str(hex(int(1.0 * 255)))[2:] self.sel_objects_list.append(self.move_tool.sel_shapes.add(b_sel_rect, color=outline, @@ -8029,12 +8024,12 @@ class App(QtCore.QObject): if 'color' in kwargs: color = kwargs['color'] else: - color = self.defaults['global_sel_line'] + color = self.options['global_sel_line'] if 'face_color' in kwargs: face_color = kwargs['face_color'] else: - face_color = self.defaults['global_sel_fill'] + face_color = self.options['global_sel_fill'] if 'face_alpha' in kwargs: face_alpha = kwargs['face_alpha'] @@ -8088,7 +8083,7 @@ class App(QtCore.QObject): if len_objects == cnt: # all selected objects are of type CNCJOB therefore we issue a multiple save - _filter_ = self.defaults['cncjob_save_filters'] + \ + _filter_ = self.options['cncjob_save_filters'] + \ ";;RML1 Files .rol (*.rol);;HPGL Files .plt (*.plt);;KNC Files .knc (*.knc)" dir_file_to_save = self.get_last_save_folder() + '/multi_save' @@ -8320,8 +8315,8 @@ class App(QtCore.QObject): try: dia = obj.ui.tooldia_entry.get_value() except AttributeError: - dia = self.defaults["cncjob_tooldia"] - obj.plot(kind=self.defaults["cncjob_plot_kind"], dia=dia) + dia = self.options["cncjob_tooldia"] + obj.plot(kind=self.options["cncjob_plot_kind"], dia=dia) else: obj.plot() if fit_view is True: @@ -8340,7 +8335,7 @@ class App(QtCore.QObject): :param filename: the last folder is extracted from the filename :return: None """ - self.defaults["global_last_folder"] = os.path.split(str(filename))[0] + self.options["global_last_folder"] = os.path.split(str(filename))[0] def register_save_folder(self, filename): """ @@ -8349,7 +8344,7 @@ class App(QtCore.QObject): :param filename: the last folder is extracted from the filename :return: None """ - self.defaults["global_last_save_folder"] = os.path.split(str(filename))[0] + self.options["global_last_save_folder"] = os.path.split(str(filename))[0] # def set_progress_bar(self, percentage, text=""): # """ @@ -8411,7 +8406,7 @@ class App(QtCore.QObject): try: self.recent = json.load(f) - except json.errors.JSONDecodeError: + except json.JSONDecodeError: self.log.error("Failed to parse recent item list.") self.inform.emit('[ERROR_NOTCL] %s' % _("Failed to parse recent item list.")) f.close() @@ -8428,7 +8423,7 @@ class App(QtCore.QObject): try: self.recent_projects = json.load(fp) - except json.errors.JSONDecodeError: + except json.JSONDecodeError: self.log.error("Failed to parse recent project item list.") self.inform.emit('[ERROR_NOTCL] %s' % _("Failed to parse recent project item list.")) fp.close() @@ -8569,7 +8564,7 @@ class App(QtCore.QObject): root = d_properties_tw.invisibleRootItem() font = QtGui.QFont() font.setBold(True) - p_color = QtGui.QColor("#000000") if self.defaults['global_gray_icons'] is False else QtGui.QColor("#FFFFFF") + p_color = QtGui.QColor("#000000") if self.options['global_gray_icons'] is False else QtGui.QColor("#FFFFFF") # main Items categories general_cat = d_properties_tw.addParent(root, _('General'), expanded=True, color=p_color, font=font) @@ -8582,10 +8577,10 @@ class App(QtCore.QObject): grid_cat = d_properties_tw.addParent(root, _('Grid'), expanded=True, color=p_color, font=font) d_properties_tw.addChild(parent=grid_cat, - title=['%s:' % _("Displayed"), '%s' % str(self.defaults['global_grid_lines'])], + title=['%s:' % _("Displayed"), '%s' % str(self.options['global_grid_lines'])], column1=True) d_properties_tw.addChild(parent=grid_cat, - title=['%s:' % _("Snap"), '%s' % str(self.defaults['global_grid_snap'])], + title=['%s:' % _("Snap"), '%s' % str(self.options['global_grid_snap'])], column1=True) d_properties_tw.addChild(parent=grid_cat, title=['%s:' % _("X value"), '%s' % str(self.ui.grid_gap_x_entry.get_value())], @@ -8596,24 +8591,24 @@ class App(QtCore.QObject): canvas_cat = d_properties_tw.addParent(root, _('Canvas'), expanded=True, color=p_color, font=font) d_properties_tw.addChild(parent=canvas_cat, - title=['%s:' % _("Axis"), '%s' % str(self.defaults['global_axis'])], + title=['%s:' % _("Axis"), '%s' % str(self.options['global_axis'])], column1=True) d_properties_tw.addChild(parent=canvas_cat, title=['%s:' % _("Workspace active"), - '%s' % str(self.defaults['global_workspace'])], + '%s' % str(self.options['global_workspace'])], column1=True) d_properties_tw.addChild(parent=canvas_cat, title=['%s:' % _("Workspace size"), - '%s' % str(self.defaults['global_workspaceT'])], + '%s' % str(self.options['global_workspaceT'])], column1=True) d_properties_tw.addChild(parent=canvas_cat, title=['%s:' % _("Workspace orientation"), - '%s' % _("Portrait") if self.defaults[ + '%s' % _("Portrait") if self.options[ 'global_workspace_orientation'] == 'p' else _("Landscape")], column1=True) d_properties_tw.addChild(parent=canvas_cat, - title=['%s:' % _("HUD"), '%s' % str(self.defaults['global_hud'])], + title=['%s:' % _("HUD"), '%s' % str(self.options['global_hud'])], column1=True) self.ui.properties_scroll_area.setWidget(d_properties_tw) @@ -8648,18 +8643,18 @@ class App(QtCore.QObject): if self.ui.general_pref_form.general_app_group.send_stats_cb.get_value() is True: full_url = "%s?s=%s&v=%s&os=%s&%s" % ( App.version_url, - str(self.defaults['global_serial']), + str(self.options['global_serial']), str(self.version), str(self.os), - urllib.parse.urlencode(self.defaults["global_stats"]) + urllib.parse.urlencode(self.options["global_stats"]) ) - # full_url = App.version_url + "?s=" + str(self.defaults['global_serial']) + \ + # full_url = App.version_url + "?s=" + str(self.options['global_serial']) + \ # "&v=" + str(self.version) + "&os=" + str(self.os) + "&" + \ - # urllib.parse.urlencode(self.defaults["global_stats"]) + # urllib.parse.urlencode(self.options["global_stats"]) else: # no_stats dict; just so it won't break things on website no_ststs_dict = {"global_ststs": {}} - full_url = App.version_url + "?s=" + str(self.defaults['global_serial']) + "&v=" + str(self.version) + full_url = App.version_url + "?s=" + str(self.options['global_serial']) + "&v=" + str(self.version) full_url += "&os=" + str(self.os) + "&" + urllib.parse.urlencode(no_ststs_dict["global_ststs"]) self.log.debug("Checking for updates @ %s" % full_url) @@ -8698,23 +8693,18 @@ class App(QtCore.QObject): ) self.message.emit(title, msg, "info") - def on_plotcanvas_setup(self, container=None): + def on_plotcanvas_setup(self): """ This is doing the setup for the plot area (canvas). - :param container: QT Widget where to install the canvas :return: None """ - # if container: - # plot_container = container - # else: - # plot_container = self.ui.right_layout modifier = QtWidgets.QApplication.queryKeyboardModifiers() if modifier == QtCore.Qt.KeyboardModifier.ControlModifier: - self.defaults["global_graphic_engine"] = "2D" + self.options["global_graphic_engine"] = "2D" - self.log.debug("Setting up canvas: %s" % str(self.defaults["global_graphic_engine"])) + self.log.debug("Setting up canvas: %s" % str(self.options["global_graphic_engine"])) if modifier == QtCore.Qt.KeyboardModifier.ControlModifier: self.use_3d_engine = False @@ -8742,7 +8732,7 @@ class App(QtCore.QObject): plotcanvas.native.setFocus() if self.use_3d_engine: - pan_button = 2 if self.defaults["global_pan_button"] == '2' else 3 + pan_button = 2 if self.options["global_pan_button"] == '2' else 3 # Set the mouse button for panning plotcanvas.view.camera.pan_button_setting = pan_button @@ -8754,7 +8744,7 @@ class App(QtCore.QObject): # Keys over plot enabled self.kp = plotcanvas.graph_event_connect('key_press', self.ui.keyPressEvent) - if self.defaults['global_cursor_type'] == 'small': + if self.options['global_cursor_type'] == 'small': self.app_cursor = plotcanvas.new_cursor() else: self.app_cursor = plotcanvas.new_cursor(big=True) @@ -8804,7 +8794,7 @@ class App(QtCore.QObject): Callback for zoom-in request. :return: """ - self.plotcanvas.zoom(1 / float(self.defaults['global_zoom_ratio'])) + self.plotcanvas.zoom(1 / float(self.options['global_zoom_ratio'])) def on_zoom_out(self): """ @@ -8812,7 +8802,7 @@ class App(QtCore.QObject): :return: """ - self.plotcanvas.zoom(float(self.defaults['global_zoom_ratio'])) + self.plotcanvas.zoom(float(self.options['global_zoom_ratio'])) def disable_all_plots(self): self.defaults.report_usage("disable_all_plots()") @@ -8838,7 +8828,7 @@ class App(QtCore.QObject): self.enable_plots(self.collection.get_non_selected()) self.inform.emit('[success] %s' % _("All non selected plots enabled.")) - def on_enable_sel_plots(self, par=None, silent=False): + def on_enable_sel_plots(self, silent=False): if silent is False: self.log.debug("App.on_enable_sel_plots()") object_list = self.collection.get_selected() @@ -8898,7 +8888,7 @@ class App(QtCore.QObject): for plot_obj in objs: # obj.obj_options['plot'] = True if isinstance(plot_obj, CNCJobObject): - plot_obj.plot(visible=True, kind=self.defaults["cncjob_plot_kind"]) + plot_obj.plot(visible=True, kind=self.options["cncjob_plot_kind"]) else: plot_obj.plot(visible=True) @@ -8951,7 +8941,7 @@ class App(QtCore.QObject): for plot_obj in objs: # obj.obj_options['plot'] = True if isinstance(plot_obj, CNCJobObject): - plot_obj.plot(visible=False, kind=self.defaults["cncjob_plot_kind"]) + plot_obj.plot(visible=False, kind=self.options["cncjob_plot_kind"]) else: plot_obj.plot(visible=False) @@ -9020,8 +9010,8 @@ class App(QtCore.QObject): :return: """ - new_color = self.defaults['gerber_plot_fill'] - new_line_color = self.defaults['gerber_plot_line'] + new_color = self.options['gerber_plot_fill'] + new_line_color = self.options['gerber_plot_line'] clicked_action = self.sender() @@ -9039,9 +9029,9 @@ class App(QtCore.QObject): alpha_level = sel_obj.alpha_level else: if sel_obj.kind == 'excellon': - alpha_level = str(hex(int(self.defaults['excellon_plot_fill'][7:9], 16))[2:]) + alpha_level = str(hex(int(self.options['excellon_plot_fill'][7:9], 16))[2:]) elif sel_obj.kind == 'gerber': - alpha_level = str(hex(int(self.defaults['gerber_plot_fill'][7:9], 16))[2:]) + alpha_level = str(hex(int(self.options['gerber_plot_fill'][7:9], 16))[2:]) elif sel_obj.kind == 'geometry': alpha_level = 'FF' else: @@ -9073,7 +9063,7 @@ class App(QtCore.QObject): # selection of a custom color will open a QColor dialog if act_name == _('Custom'): - new_color = QtGui.QColor(self.defaults['gerber_plot_fill'][:7]) + new_color = QtGui.QColor(self.options['gerber_plot_fill'][:7]) c_dialog = QtWidgets.QColorDialog() plot_fill_color = c_dialog.getColor(initial=new_color) @@ -9086,14 +9076,14 @@ class App(QtCore.QObject): if act_name == _("Default"): for sel_obj in sel_obj_list: if sel_obj.kind == 'excellon': - new_color = self.defaults['excellon_plot_fill'] - new_line_color = self.defaults['excellon_plot_line'] + new_color = self.options['excellon_plot_fill'] + new_line_color = self.options['excellon_plot_line'] elif sel_obj.kind == 'gerber': - new_color = self.defaults['gerber_plot_fill'] - new_line_color = self.defaults['gerber_plot_line'] + new_color = self.options['gerber_plot_fill'] + new_line_color = self.options['gerber_plot_line'] elif sel_obj.kind == 'geometry': - new_color = self.defaults['geometry_plot_line'] - new_line_color = self.defaults['geometry_plot_line'] + new_color = self.options['geometry_plot_line'] + new_line_color = self.options['geometry_plot_line'] else: self.log.debug( "App.on_set_color_action_triggered() --> Default color for this object type not supported yet") @@ -9137,10 +9127,10 @@ class App(QtCore.QObject): idx = item_index.row() new_c = (new_line_color, new_color, '%s_%d' % (_("Layer"), int(idx+1))) try: - self.defaults["gerber_color_list"][idx] = new_c - except Exception as err: + self.options["gerber_color_list"][idx] = new_c + except Exception as err_msg: self.inform.emit('[ERROR_NOTCL] %s' % _("Failed.")) - self.log.error(str(err)) + self.log.error(str(err_msg)) return new_line_color = color_variant(new_color[:7], 0.7) @@ -9174,7 +9164,7 @@ class App(QtCore.QObject): :rtype: None """ - # make sure to set the color in the Gerber colors storage self.defaults["gerber_color_list"] + # make sure to set the color in the Gerber colors storage self.options["gerber_color_list"] group_gerber = self.collection.group_items["gerber"] group_gerber_index = self.collection.index(group_gerber.row(), 0, QtCore.QModelIndex()) all_gerber_list = [x for x in self.collection.get_list() if x.kind == 'gerber'] @@ -9186,19 +9176,19 @@ class App(QtCore.QObject): idx = item_index.row() new_c = (outline_color, fill_color, '%s_%d' % (_("Layer"), int(idx+1))) try: - self.defaults["gerber_color_list"][idx] = new_c + self.options["gerber_color_list"][idx] = new_c except IndexError: - for x in range(len(self.defaults["gerber_color_list"]), len(all_gerber_list)): - self.defaults["gerber_color_list"].append( + for x in range(len(self.options["gerber_color_list"]), len(all_gerber_list)): + self.options["gerber_color_list"].append( ( - self.defaults["gerber_plot_fill"], # content color - self.defaults["gerber_plot_line"], # outline color + self.options["gerber_plot_fill"], # content color + self.options["gerber_plot_line"], # outline color '%s_%d' % (_("Layer"), int(idx+1))) # layer name ) - self.defaults["gerber_color_list"][idx] = new_c + self.options["gerber_color_list"][idx] = new_c elif sel_obj.kind == 'excellon': new_c = (outline_color, fill_color) - self.defaults["excellon_color"] = new_c + self.options["excellon_color"] = new_c def start_delayed_quit(self, delay, filename, should_quit=None): """ @@ -9255,13 +9245,13 @@ class App(QtCore.QObject): except Exception: pass - if self.defaults['global_autosave'] is True: - self.autosave_timer.setInterval(int(self.defaults['global_autosave_timeout'])) + if self.options['global_autosave'] is True: + self.autosave_timer.setInterval(int(self.options['global_autosave_timeout'])) self.autosave_timer.start() - def on_options_app2project(self): + def on_defaults2options(self): """ - Callback for Options->Transfer Options->App=>Project. Copies options + Callback for Options->Transfer Options->App=>Project. Copy options from application defaults to project defaults. :return: None @@ -9309,10 +9299,6 @@ class App(QtCore.QObject): self.shell.open_processing() # Disables input box. - # make sure that the pixmaps are not updated when running this as they will crash - # TODO find why the pixmaps for the whole app load crash when run from this object (perhaps another thread?) - # self.ui.fcinfo.lock_pmaps = True - old_line = '' # set tcl info script to actual scriptfile @@ -9429,8 +9415,8 @@ class ArgsThread(QtCore.QObject): while True: conn = self.listener.accept() self.serve(conn) - except Exception as err: - print(str(err)) + except Exception as gen_err: + print(str(gen_err)) def serve(self, conn): while self.thread_exit is False: @@ -9475,17 +9461,16 @@ class MenuFileHandlers(QtCore.QObject): self.inform = self.app.inform self.splash = self.app.splash self.worker_task = self.app.worker_task - self.defaults = self.app.defaults + self.options = self.app.options self.app_units = self.app.app_units self.pagesize = {} self.app.new_project_signal.connect(self.on_new_project_house_keeping) - def on_fileopengerber(self, signal, name=None): + def on_fileopengerber(self, name=None): """ File menu callback for opening a Gerber. - :param signal: required because clicking the entry will generate a checked signal which needs a container :param name: :return: None """ @@ -9531,11 +9516,10 @@ class MenuFileHandlers(QtCore.QObject): if filename != '': self.worker_task.emit({'fcn': self.open_gerber, 'params': [filename]}) - def on_fileopenexcellon(self, signal, name=None): + def on_fileopenexcellon(self, name=None): """ File menu callback for opening an Excellon file. - :param signal: required because clicking the entry will generate a checked signal which needs a container :param name: :return: None """ @@ -9570,12 +9554,11 @@ class MenuFileHandlers(QtCore.QObject): if filename != '': self.worker_task.emit({'fcn': self.open_excellon, 'params': [filename]}) - def on_fileopengcode(self, signal, name=None): + def on_fileopengcode(self, name=None): """ File menu call back for opening gcode. - :param signal: required because clicking the entry will generate a checked signal which needs a container :param name: :return: """ @@ -9614,11 +9597,10 @@ class MenuFileHandlers(QtCore.QObject): if filename != '': self.worker_task.emit({'fcn': self.open_gcode, 'params': [filename, None, True]}) - def on_file_openproject(self, signal): + def on_file_openproject(self): """ File menu callback for opening a project. - :param signal: required because clicking the entry will generate a checked signal which needs a container :return: None """ @@ -9642,11 +9624,10 @@ class MenuFileHandlers(QtCore.QObject): # thread safe. The new_project() self.open_project(filename) - def on_fileopenhpgl2(self, signal, name=None): + def on_fileopenhpgl2(self, name=None): """ File menu callback for opening a HPGL2. - :param signal: required because clicking the entry will generate a checked signal which needs a container :param name: :return: None """ @@ -9680,11 +9661,10 @@ class MenuFileHandlers(QtCore.QObject): if filename != '': self.worker_task.emit({'fcn': self.open_hpgl2, 'params': [filename]}) - def on_file_openconfig(self, signal): + def on_file_openconfig(self): """ File menu callback for opening a config file. - :param signal: required because clicking the entry will generate a checked signal which needs a container :return: None """ @@ -9754,7 +9734,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.export_svg(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("SVG", filename) self.app.file_saved.emit("SVG", filename) @@ -9796,7 +9776,7 @@ class MenuFileHandlers(QtCore.QObject): else: self.app.plotcanvas.figure.savefig(filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("png", filename) self.app.file_saved.emit("png", filename) @@ -9838,7 +9818,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.save_source_file(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Gerber", filename) self.app.file_saved.emit("Gerber", filename) @@ -9880,7 +9860,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.save_source_file(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Script", filename) self.app.file_saved.emit("Script", filename) @@ -9922,7 +9902,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.save_source_file(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Document", filename) self.app.file_saved.emit("Document", filename) @@ -9963,7 +9943,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.save_source_file(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Excellon", filename) self.app.file_saved.emit("Excellon", filename) @@ -9987,7 +9967,7 @@ class MenuFileHandlers(QtCore.QObject): name = self.app.collection.get_active().obj_options["name"] - _filter = self.defaults["excellon_save_filters"] + _filter = self.options["excellon_save_filters"] try: filename, _f = FCFileSaveDialog.get_saved_filename( caption=_("Export Excellon"), @@ -10008,7 +9988,7 @@ class MenuFileHandlers(QtCore.QObject): obj.update_filters(last_ext=used_extension, filter_string='excellon_save_filters') self.export_excellon(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Excellon", filename) self.app.file_saved.emit("Excellon", filename) @@ -10032,7 +10012,7 @@ class MenuFileHandlers(QtCore.QObject): name = self.app.collection.get_active().obj_options["name"] - _filter_ = self.defaults['gerber_save_filters'] + _filter_ = self.options['gerber_save_filters'] try: filename, _f = FCFileSaveDialog.get_saved_filename( caption=_("Export Gerber"), @@ -10053,7 +10033,7 @@ class MenuFileHandlers(QtCore.QObject): obj.update_filters(last_ext=used_extension, filter_string='gerber_save_filters') self.export_gerber(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Gerber", filename) self.app.file_saved.emit("Gerber", filename) @@ -10108,7 +10088,7 @@ class MenuFileHandlers(QtCore.QObject): return else: self.export_dxf(name, filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("DXF", filename) self.app.file_saved.emit("DXF", filename) @@ -10179,6 +10159,7 @@ class MenuFileHandlers(QtCore.QObject): :return: """ + self.log.debug("on_file_new_click()") if self.app.collection.get_list() and self.app.should_we_save: msgbox = FCMessageBox(parent=self.app.ui) @@ -10222,9 +10203,6 @@ class MenuFileHandlers(QtCore.QObject): :return: None """ - self.defaults.report_usage("on_file_new_project") - - # Remove everything from memory self.log.debug("on_file_new_project()") t0 = time.time() @@ -10277,12 +10255,12 @@ class MenuFileHandlers(QtCore.QObject): # Clear project filename self.app.project_filename = None - default_file = self.app.defaults_path() + default_file = self.app.options_path() # Load the application defaults - self.defaults.load(filename=default_file, inform=self.inform) + self.options.load(filename=default_file, inform=self.inform) # Re-fresh project options - self.app.on_options_app2project() + self.app.on_defaults2options() if use_thread is True: self.app.new_project_signal.emit() @@ -10335,6 +10313,8 @@ class MenuFileHandlers(QtCore.QObject): if response == bt_yes: self.app.preferencesUiManager.save_defaults() + if response == bt_no: + pass # take the focus of the Notebook on Project Tab. self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) @@ -10367,6 +10347,8 @@ class MenuFileHandlers(QtCore.QObject): :param silent: if True will not display status messages :return: None """ + self.log.debug("on_filenewscript()") + if silent is False: self.inform.emit('[success] %s' % _("New TCL script file created in Code Editor.")) @@ -10510,12 +10492,13 @@ class MenuFileHandlers(QtCore.QObject): :param silent: if True will not display status messages :return: None """ + self.log.debug("on_file_saveproject()") if self.app.project_filename is None: self.on_file_saveprojectas() else: self.worker_task.emit({'fcn': self.save_project, 'params': [self.app.project_filename, silent]}) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("project", self.app.project_filename) self.app.file_saved.emit("project", self.app.project_filename) @@ -10534,6 +10517,7 @@ class MenuFileHandlers(QtCore.QObject): :param quit_action: if to be followed by quiting the application; boolean :return: None """ + self.log.debug("on_file_saveprojectas()") date = str(datetime.today()).rpartition('.')[0] date = ''.join(c for c in date if c not in ':-') @@ -10564,7 +10548,7 @@ class MenuFileHandlers(QtCore.QObject): self.save_project(filename, quit_action) # self.save_project(filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("project", filename) self.app.file_saved.emit("project", filename) @@ -10575,6 +10559,8 @@ class MenuFileHandlers(QtCore.QObject): self.app.should_we_save = False def on_file_save_objects_pdf(self, use_thread=True): + self.log.debug("on_file_save_objects_pdf()") + date = str(datetime.today()).rpartition('.')[0] date = ''.join(c for c in date if c not in ':-') date = date.replace(' ', '_') @@ -10585,8 +10571,8 @@ class MenuFileHandlers(QtCore.QObject): obj_name = str(obj_selection[0].obj_options['name']) else: obj_name = _("FlatCAM objects print") - except AttributeError as err: - self.log.debug("App.on_file_save_object_pdf() --> %s" % str(err)) + except AttributeError as att_err: + self.log.debug("App.on_file_save_object_pdf() --> %s" % str(att_err)) self.inform.emit('[ERROR_NOTCL] %s' % _("No object is selected.")) return @@ -10621,14 +10607,15 @@ class MenuFileHandlers(QtCore.QObject): self.save_pdf(filename, obj_selection) # self.save_project(filename) - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("pdf", filename) self.app.file_saved.emit("pdf", filename) def save_pdf(self, file_name, obj_selection): + self.log.debug("save_pdf()") - p_size = self.defaults['global_workspaceT'] - orientation = self.defaults['global_workspace_orientation'] + p_size = self.options['global_workspaceT'] + orientation = self.options['global_workspace_orientation'] color = 'black' transparency_level = 1.0 @@ -10693,7 +10680,7 @@ class MenuFileHandlers(QtCore.QObject): color = obj.fill_color[:-2] transparency_level = obj.fill_color[-2:] elif obj.kind.lower() == 'geometry': - color = self.defaults["global_draw_color"] + color = self.options["global_draw_color"] # Change the attributes of the exported SVG # We don't need stroke-width @@ -10807,8 +10794,8 @@ class MenuFileHandlers(QtCore.QObject): :return: """ if filename is None: - filename = self.defaults["global_last_save_folder"] if self.defaults["global_last_save_folder"] \ - is not None else self.defaults["global_last_folder"] + filename = self.options["global_last_save_folder"] if self.options["global_last_save_folder"] \ + is not None else self.options["global_last_folder"] self.log.debug("export_svg()") @@ -10857,7 +10844,7 @@ class MenuFileHandlers(QtCore.QObject): "Most likely another app is holding the file open and not accessible.")) return 'fail' - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("SVG", filename) self.app.file_saved.emit("SVG", filename) self.inform.emit('[success] %s: %s' % (_("SVG file exported to"), filename)) @@ -10865,7 +10852,7 @@ class MenuFileHandlers(QtCore.QObject): def on_import_preferences(self): """ Loads the application default settings from a saved file into - ``self.defaults`` dictionary. + ``self.options`` dictionary. :return: None """ @@ -10887,7 +10874,7 @@ class MenuFileHandlers(QtCore.QObject): return # Load in the defaults from the chosen file - self.defaults.load(filename=filename, inform=self.inform) + self.options.load(filename=filename, inform=self.inform) self.app.preferencesUiManager.on_preferences_edited() self.inform.emit('[success] %s: %s' % (_("Imported Defaults from"), filename)) @@ -10923,16 +10910,16 @@ class MenuFileHandlers(QtCore.QObject): # Update options self.app.preferencesUiManager.defaults_read_form() - self.defaults.propagate_defaults() + self.options.propagate_defaults() # Save update options try: - self.defaults.write(filename=filename) + self.options.write(filename=filename) except Exception: self.inform.emit('[ERROR_NOTCL] %s %s' % (_("Failed to write defaults to file."), str(filename))) return - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("preferences", filename) self.app.file_saved.emit("preferences", filename) self.inform.emit('[success] %s: %s' % (_("Exported preferences to"), filename)) @@ -10949,15 +10936,15 @@ class MenuFileHandlers(QtCore.QObject): """ if filename is None: - if self.defaults["global_last_save_folder"]: - filename = self.defaults["global_last_save_folder"] + '/' + 'exported_excellon' + if self.options["global_last_save_folder"]: + filename = self.options["global_last_save_folder"] + '/' + 'exported_excellon' else: - filename = self.defaults["global_last_folder"] + '/' + 'exported_excellon' + filename = self.options["global_last_folder"] + '/' + 'exported_excellon' self.log.debug("export_excellon()") - format_exc = ';FILE_FORMAT=%d:%d\n' % (self.defaults["excellon_exp_integer"], - self.defaults["excellon_exp_decimals"] + format_exc = ';FILE_FORMAT=%d:%d\n' % (self.options["excellon_exp_integer"], + self.options["excellon_exp_decimals"] ) if local_use is None: @@ -10974,12 +10961,12 @@ class MenuFileHandlers(QtCore.QObject): return # updated units - eunits = self.defaults["excellon_exp_units"] - ewhole = self.defaults["excellon_exp_integer"] - efract = self.defaults["excellon_exp_decimals"] - ezeros = self.defaults["excellon_exp_zeros"] - eformat = self.defaults["excellon_exp_format"] - slot_type = self.defaults["excellon_exp_slot_type"] + eunits = self.options["excellon_exp_units"] + ewhole = self.options["excellon_exp_integer"] + efract = self.options["excellon_exp_decimals"] + ezeros = self.options["excellon_exp_zeros"] + eformat = self.options["excellon_exp_format"] + slot_type = self.options["excellon_exp_slot_type"] fc_units = self.app_units.upper() if fc_units == 'MM': @@ -11065,7 +11052,7 @@ class MenuFileHandlers(QtCore.QObject): "Most likely another app is holding the file open and not accessible.")) return 'fail' - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Excellon", filename) self.app.file_saved.emit("Excellon", filename) self.inform.emit('[success] %s: %s' % (_("Excellon file exported to"), filename)) @@ -11107,8 +11094,8 @@ class MenuFileHandlers(QtCore.QObject): :return: """ if filename is None: - filename = self.defaults["global_last_save_folder"] if self.defaults["global_last_save_folder"] \ - is not None else self.defaults["global_last_folder"] + filename = self.options["global_last_save_folder"] if self.options["global_last_save_folder"] \ + is not None else self.options["global_last_folder"] self.log.debug("export_gerber()") @@ -11121,10 +11108,10 @@ class MenuFileHandlers(QtCore.QObject): obj = local_use # updated units - gunits = self.defaults["gerber_exp_units"] - gwhole = self.defaults["gerber_exp_integer"] - gfract = self.defaults["gerber_exp_decimals"] - gzeros = self.defaults["gerber_exp_zeros"] + gunits = self.options["gerber_exp_units"] + gwhole = self.options["gerber_exp_integer"] + gfract = self.options["gerber_exp_decimals"] + gzeros = self.options["gerber_exp_zeros"] fc_units = self.app_units.upper() if fc_units == 'MM': @@ -11200,7 +11187,7 @@ class MenuFileHandlers(QtCore.QObject): "Most likely another app is holding the file open and not accessible.")) return 'fail' - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("Gerber", filename) self.app.file_saved.emit("Gerber", filename) self.inform.emit('[success] %s: %s' % (_("Gerber file exported to"), filename)) @@ -11241,8 +11228,8 @@ class MenuFileHandlers(QtCore.QObject): :return: """ if filename is None: - filename = self.defaults["global_last_save_folder"] if self.defaults["global_last_save_folder"] \ - is not None else self.defaults["global_last_folder"] + filename = self.options["global_last_save_folder"] if self.options["global_last_save_folder"] \ + is not None else self.options["global_last_folder"] self.log.debug("export_dxf()") @@ -11266,7 +11253,7 @@ class MenuFileHandlers(QtCore.QObject): "Most likely another app is holding the file open and not accessible.")) return 'fail' - if self.defaults["global_open_style"] is False: + if self.options["global_open_style"] is False: self.app.file_opened.emit("DXF", filename) self.app.file_saved.emit("DXF", filename) self.inform.emit('[success] %s: %s' % (_("DXF file exported to"), filename)) @@ -11438,9 +11425,9 @@ class MenuFileHandlers(QtCore.QObject): except IOError: app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Failed to open file"), filename)) return "fail" - except ParseError as err: - app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(err))) - app_obj.log.error(str(err)) + except ParseError as parse_err: + app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(parse_err))) + app_obj.log.error(str(parse_err)) return "fail" except Exception as e: app_obj.log.error("App.open_gerber() --> %s" % str(e)) @@ -11470,7 +11457,7 @@ class MenuFileHandlers(QtCore.QObject): ret_val = self.app.app_obj.new_object("gerber", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': if from_tcl: - filename = self.defaults['global_tcl_path'] + '/' + name + filename = self.options['global_tcl_path'] + '/' + name ret_val = self.app.app_obj.new_object("gerber", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': self.inform.emit('[ERROR_NOTCL]%s' % _('Open Gerber failed. Probable not a Gerber file.')) @@ -11496,6 +11483,7 @@ class MenuFileHandlers(QtCore.QObject): """ self.log.debug("open_excellon()") + if not os.path.exists(filename): self.inform.emit('[ERROR_NOTCL] %s. %s' % (filename, _("File no longer available."))) return @@ -11537,7 +11525,7 @@ class MenuFileHandlers(QtCore.QObject): ret_val = self.app.app_obj.new_object("excellon", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': if from_tcl: - filename = self.defaults['global_tcl_path'] + '/' + name + filename = self.options['global_tcl_path'] + '/' + name ret_val = self.app.app_obj.new_object("excellon", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': self.inform.emit('[ERROR_NOTCL] %s' % @@ -11563,6 +11551,7 @@ class MenuFileHandlers(QtCore.QObject): :return: None """ self.log.debug("open_gcode()") + if not os.path.exists(filename): self.inform.emit('[ERROR_NOTCL] %s' % _("File no longer available.")) return @@ -11603,7 +11592,7 @@ class MenuFileHandlers(QtCore.QObject): ret_val = self.app.app_obj.new_object("cncjob", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': if from_tcl: - filename = self.defaults['global_tcl_path'] + '/' + name + filename = self.options['global_tcl_path'] + '/' + name ret_val = self.app.app_obj.new_object("cncjob", name, obj_init, autoselected=False, plot=plot) if ret_val == 'fail': self.inform.emit('[ERROR_NOTCL] %s' % @@ -11643,9 +11632,9 @@ class MenuFileHandlers(QtCore.QObject): except IOError: app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Failed to open file"), filename)) return "fail" - except ParseError as err: - app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(err))) - app_obj.log.error(str(err)) + except ParseError as parse_err: + app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(parse_err))) + app_obj.log.error(str(parse_err)) return "fail" except Exception as e: app_obj.log.error("App.open_hpgl2() --> %s" % str(e)) @@ -11708,9 +11697,9 @@ class MenuFileHandlers(QtCore.QObject): except IOError: app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Failed to open file"), filename)) return "fail" - except ParseError as err: - app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(err))) - app_obj.log.error(str(err)) + except ParseError as parse_err: + app_obj.inform.emit('[ERROR_NOTCL] %s: %s. %s' % (_("Failed to parse file"), filename, str(parse_err))) + app_obj.log.error(str(parse_err)) return "fail" except Exception as e: app_obj.log.error("App.open_script() -> %s" % str(e)) @@ -11732,7 +11721,7 @@ class MenuFileHandlers(QtCore.QObject): # Object creation ret_val = self.app.app_obj.new_object("script", script_name, obj_init, autoselected=False, plot=False) if ret_val == 'fail': - filename = self.defaults['global_tcl_path'] + '/' + script_name + filename = self.options['global_tcl_path'] + '/' + script_name ret_val = self.app.app_obj.new_object("script", script_name, obj_init, autoselected=False, plot=False) if ret_val == 'fail': self.inform.emit('[ERROR_NOTCL]%s' % _('Failed to open TCL Script.')) @@ -11778,7 +11767,7 @@ class MenuFileHandlers(QtCore.QObject): try: if filename: f = QtCore.QFile(filename) - if f.open(QtCore.QIODevice.ReadOnly): + if f.open(QtCore.QIODevice.OpenModeFlag.ReadOnly): stream = QtCore.QTextStream(f) code_edited = stream.readAll() self.app.text_editor_tab.load_text(code_edited, clear_text=True, move_to_start=True) @@ -11833,7 +11822,7 @@ class MenuFileHandlers(QtCore.QObject): except IOError: if from_tcl: name = filename.split('/')[-1].split('\\')[-1] - filename = self.defaults['global_tcl_path'] + '/' + name + filename = self.options['global_tcl_path'] + '/' + name try: f = open(filename, 'r') except IOError: @@ -11976,14 +11965,14 @@ class MenuFileHandlers(QtCore.QObject): "version": self.app.version } - if self.defaults["global_save_compressed"] is True: + if self.options["global_save_compressed"] is True: try: project_as_json = json.dumps(d, default=to_dict, indent=2, sort_keys=True).encode('utf-8') - # with lzma.open(filename, "w", preset=int(self.defaults['global_compression_level'])) as f: + # with lzma.open(filename, "w", preset=int(self.options['global_compression_level'])) as f: # # # Write # f.write(project_as_json) - compressor_obj = lzma.LZMACompressor(preset=int(self.defaults['global_compression_level'])) + compressor_obj = lzma.LZMACompressor(preset=int(self.options['global_compression_level'])) out1 = compressor_obj.compress(project_as_json) out2 = compressor_obj.flush() project_zipped = b"".join([out1, out2]) @@ -12075,10 +12064,10 @@ class MenuFileHandlers(QtCore.QObject): """ if filename is None: - filename = self.defaults["global_last_save_folder"] if self.defaults["global_last_save_folder"] \ - is not None else self.defaults["global_last_folder"] + filename = self.options["global_last_save_folder"] if self.options["global_last_save_folder"] \ + is not None else self.options["global_last_folder"] - self.log.debug("save source file()") + self.log.debug("save_source_file()") obj = self.app.collection.get_by_name(obj_name) @@ -12109,7 +12098,7 @@ class MenuFileHandlers(QtCore.QObject): def on_file_savedefaults(self): """ Callback for menu item File->Save Defaults. Saves application default options - ``self.defaults`` to current_defaults.FlatConfig. + ``self.options`` to current_defaults.FlatConfig. :return: None """ diff --git a/camlib.py b/camlib.py index 683577da..8ac5984d 100644 --- a/camlib.py +++ b/camlib.py @@ -565,7 +565,7 @@ class Geometry(object): self.plot_temp_shapes(sub_el) except TypeError: # Element is not iterable... # self.add_shape(shape=element, color=color, visible=visible, layer=0) - self.temp_shapes.add(tolerance=float(self.app.defaults["global_tolerance"]), + self.temp_shapes.add(tolerance=float(self.app.options["global_tolerance"]), shape=element, color=color, visible=True, layer=0) def make_index(self): @@ -1226,7 +1226,7 @@ class Geometry(object): return units = self.app.app_units if units is None else units - res = self.app.defaults['geometry_circle_steps'] + res = self.app.options['geometry_circle_steps'] factor = svgparse_viewbox(svg_root) if svg_units == 'cm': @@ -1295,7 +1295,7 @@ class Geometry(object): if geos_text_f: self.solid_geometry = self.solid_geometry + geos_text_f - tooldia = float(self.app.defaults["tools_mill_tooldia"]) + tooldia = float(self.app.options["tools_mill_tooldia"]) tooldia = float('%.*f' % (self.decimals, tooldia)) new_data = {k: v for k, v in self.obj_options.items()} @@ -1364,7 +1364,7 @@ class Geometry(object): else: # It's shapely geometry self.solid_geometry = [self.solid_geometry, geos] - tooldia = float(self.app.defaults["tools_mill_tooldia"]) + tooldia = float(self.app.options["tools_mill_tooldia"]) tooldia = float('%.*f' % (self.decimals, tooldia)) new_data = {k: v for k, v in self.obj_options.items()} @@ -2726,7 +2726,7 @@ class CNCjob(Geometry): # Used when parsing G-code arcs self.steps_per_circle = steps_per_circle if steps_per_circle is not None else \ - int(self.app.defaults['cncjob_steps_per_circle']) + int(self.app.options['cncjob_steps_per_circle']) Geometry.__init__(self, geo_steps_per_circle=self.steps_per_circle) @@ -2769,7 +2769,7 @@ class CNCjob(Geometry): self.feedminutecode = "G94" # self.absolutecode = "G90" # self.incrementalcode = "G91" - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] self.gcode = "" self.gcode_parsed = None @@ -2809,13 +2809,13 @@ class CNCjob(Geometry): self.input_geometry_bounds = None # compensation for CNC bed not square - self._bed_limit_x = self.app.defaults["cncjob_bed_max_x"] - self._bed_limit_y = self.app.defaults["cncjob_bed_max_y"] + self._bed_limit_x = self.app.options["cncjob_bed_max_x"] + self._bed_limit_y = self.app.options["cncjob_bed_max_y"] - self._bed_offset_x = self.app.defaults["cncjob_bed_offset_x"] - self._bed_offset_y = self.app.defaults["cncjob_bed_offset_y"] - self._bed_skew_x = self.app.defaults["cncjob_bed_skew_x"] - self._bed_skew_y = self.app.defaults["cncjob_bed_skew_y"] + self._bed_offset_x = self.app.options["cncjob_bed_offset_x"] + self._bed_offset_y = self.app.options["cncjob_bed_offset_y"] + self._bed_skew_x = self.app.options["cncjob_bed_skew_x"] + self._bed_skew_y = self.app.options["cncjob_bed_skew_y"] # coordinates used by the preprocessors position_code() method; updated when creating gcode self.x = 0.0 @@ -3406,7 +3406,7 @@ class CNCjob(Geometry): # if there are no locations then go to the next tool if not locations: return 'fail' - opt_time = self.app.defaults["excellon_search_time"] + opt_time = self.app.options["excellon_search_time"] optimized_path = self.optimized_ortools_meta(locations=locations, opt_time=opt_time) elif opt_type == 'B': locations = self.create_tool_data_array(points=points) @@ -3481,7 +3481,7 @@ class CNCjob(Geometry): z_offset = 0 self.z_cut = z_offset + old_zcut - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # Drillling! for Absolute coordinates type G90 # variables to display the percentage of work done @@ -3776,7 +3776,7 @@ class CNCjob(Geometry): self.multidepth = tool_dict['tools_mill_multidepth'] self.z_depthpercut = float(tool_dict['tools_mill_depthperpass']) self.z_move = float(tool_dict['tools_mill_travelz']) - self.f_plunge = self.app.defaults["tools_mill_f_plunge"] + self.f_plunge = self.app.options["tools_mill_f_plunge"] self.feedrate = float(tool_dict['tools_mill_feedrate']) self.z_feedrate = float(tool_dict['tools_mill_feedrate_z']) @@ -3792,12 +3792,12 @@ class CNCjob(Geometry): try: self.spindledir = tool_dict['tools_mill_spindledir'] except KeyError: - self.spindledir = self.app.defaults["tools_mill_spindledir"] + self.spindledir = self.app.options["tools_mill_spindledir"] try: self.spindledir = tool_dict['tools_mill_spindledir'] except KeyError: - self.spindledir = self.app.defaults["tools_mill_spindledir"] + self.spindledir = self.app.options["tools_mill_spindledir"] self.dwell = tool_dict['tools_mill_dwell'] self.dwelltime = float(tool_dict['tools_mill_dwelltime']) @@ -4368,7 +4368,7 @@ class CNCjob(Geometry): # if there are no locations then go to the next tool if not locations: continue - opt_time = self.app.defaults["excellon_search_time"] + opt_time = self.app.options["excellon_search_time"] optimized_path = self.optimized_ortools_meta(locations=locations, opt_time=opt_time) elif used_excellon_optimization_type == 'B': if tool in points: @@ -4439,7 +4439,7 @@ class CNCjob(Geometry): z_offset = 0 self.z_cut = z_offset + old_zcut - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # Drillling! for Absolute coordinates type G90 # variables to display the percentage of work done @@ -4627,7 +4627,7 @@ class CNCjob(Geometry): # if there are no locations then go to the next tool if not locations: return 'fail' - opt_time = self.app.defaults["excellon_search_time"] + opt_time = self.app.options["excellon_search_time"] optimized_path = self.optimized_ortools_meta(locations=locations, opt_time=opt_time) elif used_excellon_optimization_type == 'B': if all_points: @@ -4690,7 +4690,7 @@ class CNCjob(Geometry): z_offset = 0 self.z_cut = z_offset + old_zcut - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # Drillling! for Absolute coordinates type G90 # variables to display the percentage of work done @@ -4920,7 +4920,7 @@ class CNCjob(Geometry): # z_offset = 0 # self.z_cut = z_offset + old_zcut # - # self.coordinates_type = self.app.defaults["cncjob_coords_type"] + # self.coordinates_type = self.app.options["cncjob_coords_type"] # if self.coordinates_type == "G90": # # Drillling! for Absolute coordinates type G90 # # variables to display the percentage of work done @@ -5126,7 +5126,7 @@ class CNCjob(Geometry): # z_offset = 0 # self.z_cut = z_offset + old_zcut # - # self.coordinates_type = self.app.defaults["cncjob_coords_type"] + # self.coordinates_type = self.app.options["cncjob_coords_type"] # if self.coordinates_type == "G90": # # Drillling! for Absolute coordinates type G90 # # variables to display the percentage of work done @@ -5330,7 +5330,7 @@ class CNCjob(Geometry): # z_offset = 0 # self.z_cut = z_offset + old_zcut # - # self.coordinates_type = self.app.defaults["cncjob_coords_type"] + # self.coordinates_type = self.app.options["cncjob_coords_type"] # if self.coordinates_type == "G90": # # Drillling! for Absolute coordinates type G90 # # variables to display the percentage of work done @@ -5547,19 +5547,19 @@ class CNCjob(Geometry): self.z_cut = float(z_cut) if z_cut else None self.z_move = float(z_move) if z_move is not None else None - self.feedrate = float(feedrate) if feedrate else self.app.defaults["geometry_feedrate"] - self.z_feedrate = float(feedrate_z) if feedrate_z is not None else self.app.defaults["geometry_feedrate_z"] - self.feedrate_rapid = float(feedrate_rapid) if feedrate_rapid else self.app.defaults["geometry_feedrate_rapid"] + self.feedrate = float(feedrate) if feedrate else self.app.options["geometry_feedrate"] + self.z_feedrate = float(feedrate_z) if feedrate_z is not None else self.app.options["geometry_feedrate_z"] + self.feedrate_rapid = float(feedrate_rapid) if feedrate_rapid else self.app.options["geometry_feedrate_rapid"] self.spindlespeed = int(spindlespeed) if spindlespeed != 0 else None self.spindledir = spindledir self.dwell = dwell - self.dwelltime = float(dwelltime) if dwelltime else self.app.defaults["geometry_dwelltime"] + self.dwelltime = float(dwelltime) if dwelltime else self.app.options["geometry_dwelltime"] - self.startz = float(startz) if startz is not None else self.app.defaults["geometry_startz"] - self.z_end = float(endz) if endz is not None else self.app.defaults["geometry_endz"] + self.startz = float(startz) if startz is not None else self.app.options["geometry_startz"] + self.z_end = float(endz) if endz is not None else self.app.options["geometry_endz"] - self.xy_end = re.sub('[()\[\]]', '', str(endxy)) if endxy else self.app.defaults["geometry_endxy"] + self.xy_end = re.sub('[()\[\]]', '', str(endxy)) if endxy else self.app.options["geometry_endxy"] if self.xy_end and self.xy_end != '': self.xy_end = [float(eval(a)) for a in self.xy_end.split(",")] @@ -5569,10 +5569,10 @@ class CNCjob(Geometry): "in the format (x, y) but now there is only one value, not two.")) return 'fail' - self.z_depthpercut = float(depthpercut) if depthpercut else self.app.defaults["geometry_depthperpass"] + self.z_depthpercut = float(depthpercut) if depthpercut else self.app.options["geometry_depthperpass"] self.multidepth = multidepth - self.z_toolchange = float(toolchangez) if toolchangez is not None else self.app.defaults["geometry_toolchangez"] + self.z_toolchange = float(toolchangez) if toolchangez is not None else self.app.options["geometry_toolchangez"] # it servers in the preprocessor file self.tool = tool_no @@ -5582,7 +5582,7 @@ class CNCjob(Geometry): self.xy_toolchange = None else: self.xy_toolchange = re.sub('[()\[\]]', '', str(toolchangexy)) \ - if toolchangexy else self.app.defaults["geometry_toolchangexy"] + if toolchangexy else self.app.options["geometry_toolchangexy"] if self.xy_toolchange and self.xy_toolchange != '': self.xy_toolchange = [float(eval(a)) for a in self.xy_toolchange.split(",")] @@ -5597,7 +5597,7 @@ class CNCjob(Geometry): pass self.pp_geometry_name = pp_geometry_name if pp_geometry_name else 'default' - self.f_plunge = self.app.defaults["geometry_f_plunge"] + self.f_plunge = self.app.options["geometry_f_plunge"] if self.z_cut is None: if 'laser' not in self.pp_geometry_name: @@ -5944,11 +5944,11 @@ class CNCjob(Geometry): temp_solid_geometry = flat_geometry default_dia = None - if isinstance(self.app.defaults["tools_mill_tooldia"], float): - default_dia = self.app.defaults["tools_mill_tooldia"] + if isinstance(self.app.options["tools_mill_tooldia"], float): + default_dia = self.app.options["tools_mill_tooldia"] else: try: - tools_string = self.app.defaults["tools_mill_tooldia"].split(",") + tools_string = self.app.options["tools_mill_tooldia"].split(",") tools_diameters = [eval(a) for a in tools_string if a != ''] default_dia = tools_diameters[0] if tools_diameters else 0.0 except Exception as e: @@ -5963,26 +5963,26 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("Failed.")) return 'fail' - self.z_cut = float(z_cut) if z_cut is not None else self.app.defaults["tools_mill_cutz"] - self.z_move = float(z_move) if z_move is not None else self.app.defaults["tools_mill_travelz"] + self.z_cut = float(z_cut) if z_cut is not None else self.app.options["tools_mill_cutz"] + self.z_move = float(z_move) if z_move is not None else self.app.options["tools_mill_travelz"] - self.feedrate = float(feedrate) if feedrate is not None else self.app.defaults["tools_mill_feedrate"] - self.z_feedrate = float(feedrate_z) if feedrate_z is not None else self.app.defaults["tools_mill_feedrate_z"] + self.feedrate = float(feedrate) if feedrate is not None else self.app.options["tools_mill_feedrate"] + self.z_feedrate = float(feedrate_z) if feedrate_z is not None else self.app.options["tools_mill_feedrate_z"] self.feedrate_rapid = float(feedrate_rapid) if feedrate_rapid is not None else \ - self.app.defaults["tools_mill_feedrate_rapid"] + self.app.options["tools_mill_feedrate_rapid"] self.spindlespeed = int(spindlespeed) if spindlespeed != 0 and spindlespeed is not None else None self.spindledir = spindledir self.dwell = dwell - self.dwelltime = float(dwelltime) if dwelltime is not None else self.app.defaults["tools_mill_dwelltime"] + self.dwelltime = float(dwelltime) if dwelltime is not None else self.app.options["tools_mill_dwelltime"] self.laser_min_power = int(laser_min_power) - self.startz = float(startz) if startz is not None and startz != '' else self.app.defaults["tools_mill_startz"] + self.startz = float(startz) if startz is not None and startz != '' else self.app.options["tools_mill_startz"] - self.z_end = float(endz) if endz is not None else self.app.defaults["tools_mill_endz"] + self.z_end = float(endz) if endz is not None else self.app.options["tools_mill_endz"] - self.xy_end = endxy if endxy != '' and endxy else self.app.defaults["tools_mill_endxy"] + self.xy_end = endxy if endxy != '' and endxy else self.app.options["tools_mill_endxy"] self.xy_end = re.sub('[()\[\]]', '', str(self.xy_end)) if self.xy_end else None if self.xy_end is not None and self.xy_end != '': @@ -5998,9 +5998,9 @@ class CNCjob(Geometry): self.z_depthpercut = abs(self.z_depthpercut) self.multidepth = multidepth self.z_toolchange = float(toolchangez) if toolchangez is not None else \ - self.app.defaults["tools_mill_toolchangez"] + self.app.options["tools_mill_toolchangez"] self.extracut_length = float(extracut_length) if extracut_length is not None else \ - self.app.defaults["tools_mill_extracut_length"] + self.app.options["tools_mill_extracut_length"] try: if toolchangexy == '': @@ -6019,7 +6019,7 @@ class CNCjob(Geometry): pass self.pp_geometry_name = pp_geometry_name if pp_geometry_name else 'default' - self.f_plunge = self.app.defaults["tools_mill_f_plunge"] + self.f_plunge = self.app.options["tools_mill_f_plunge"] if self.z_cut is None: if 'laser' not in self.pp_geometry_name: @@ -6301,7 +6301,7 @@ class CNCjob(Geometry): self.postdata['toolC'] = kwargs['tooldia'] self.pp_solderpaste_name = kwargs['data']['tools_solderpaste_pp'] if kwargs['data']['tools_solderpaste_pp'] \ - else self.app.defaults['tools_solderpaste_pp'] + else self.app.options['tools_solderpaste_pp'] p = self.app.preprocessors[self.pp_solderpaste_name] # ## Flatten the geometry. Only linear elements (no polygons) remain. @@ -6381,7 +6381,7 @@ class CNCjob(Geometry): gcode = '' path = geometry.coords - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # For Absolute coordinates type G90 first_x = path[0][0] @@ -6675,8 +6675,8 @@ class CNCjob(Geometry): current = {'X': 0.0, 'Y': 0.0, 'Z': 0.0, 'G': 0} if tool_data is None: - toolchange_xy_mill = self.app.defaults["tools_mill_toolchangexy"] - toolchange_xy_drill = self.app.defaults["tools_drill_toolchangexy"] + toolchange_xy_mill = self.app.options["tools_mill_toolchangexy"] + toolchange_xy_drill = self.app.options["tools_drill_toolchangexy"] else: if "tools_drill_toolchange" in tool_data and tool_data["tools_mill_toolchange"] is True: toolchange_xy_mill = tool_data["tools_mill_toolchangexy"] @@ -7054,8 +7054,8 @@ class CNCjob(Geometry): if color is None: color = { - "T": [self.app.defaults["cncjob_travel_fill"], self.app.defaults["cncjob_travel_line"]], - "C": [self.app.defaults["cncjob_plot_fill"], self.app.defaults["cncjob_plot_line"]] + "T": [self.app.options["cncjob_travel_fill"], self.app.options["cncjob_travel_line"]], + "C": [self.app.options["cncjob_plot_fill"], self.app.options["cncjob_plot_line"]] } gcode_parsed = gcode_parsed if gcode_parsed else self.gcode_parsed @@ -7080,7 +7080,7 @@ class CNCjob(Geometry): else: path_num = 0 - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # For Absolute coordinates type G90 for geo in gcode_parsed: @@ -7176,13 +7176,13 @@ class CNCjob(Geometry): return try: - if self.app.defaults['global_theme'] == 'white': + if self.app.options['global_theme'] == 'white': obj.annotation.set(text=text, pos=pos, visible=obj.obj_options['plot'], - font_size=self.app.defaults["cncjob_annotation_fontsize"], - color=self.app.defaults["cncjob_annotation_fontcolor"]) + font_size=self.app.options["cncjob_annotation_fontsize"], + color=self.app.options["cncjob_annotation_fontcolor"]) else: # invert the color - old_color = self.app.defaults["cncjob_annotation_fontcolor"].lower() + old_color = self.app.options["cncjob_annotation_fontcolor"].lower() new_color = '' code = {} l1 = "#;0123456789abcdef" @@ -7194,7 +7194,7 @@ class CNCjob(Geometry): new_color += code[old_color[x]] obj.annotation.set(text=text, pos=pos, visible=obj.obj_options['plot'], - font_size=self.app.defaults["cncjob_annotation_fontsize"], + font_size=self.app.options["cncjob_annotation_fontsize"], color=new_color) except Exception as e: self.app.log.error("CNCJob.plot2() --> annotations --> %s" % str(e)) @@ -7344,7 +7344,7 @@ class CNCjob(Geometry): p = self.pp_geometry - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # For Absolute coordinates type G90 first_x = path[0][0] @@ -7489,7 +7489,7 @@ class CNCjob(Geometry): path = self.segment(target_linear.coords) p = self.pp_geometry - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # For Absolute coordinates type G90 first_x = path[0][0] @@ -7725,7 +7725,7 @@ class CNCjob(Geometry): path = list(point.coords) p = self.pp_geometry - self.coordinates_type = self.app.defaults["cncjob_coords_type"] + self.coordinates_type = self.app.options["cncjob_coords_type"] if self.coordinates_type == "G90": # For Absolute coordinates type G90 first_x = path[0][0] @@ -8032,7 +8032,7 @@ class CNCjob(Geometry): for nr in numbers_in_header: new_nr = float(nr) * xfactor # replace the updated string - line = line.replace(nr, ('%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_nr)) + line = line.replace(nr, ('%.*f' % (self.app.options["cncjob_coords_decimals"], new_nr)) ) # this scales all the X and Y and Z and F values and also the Tool Dia in the toolchange message @@ -8052,7 +8052,7 @@ class CNCjob(Geometry): # replace the updated string line = line.replace( match_x.group(1), - 'X%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_x) + 'X%.*f' % (self.app.options["cncjob_coords_decimals"], new_x) ) # find the Y group match_y = self.g_y_re.search(line) @@ -8061,7 +8061,7 @@ class CNCjob(Geometry): new_y = float(match_y.group(1)[1:]) * yfactor line = line.replace( match_y.group(1), - 'Y%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_y) + 'Y%.*f' % (self.app.options["cncjob_coords_decimals"], new_y) ) # find the Z group match_z = self.g_z_re.search(line) @@ -8070,7 +8070,7 @@ class CNCjob(Geometry): new_z = float(match_z.group(1)[1:]) * xfactor line = line.replace( match_z.group(1), - 'Z%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_z) + 'Z%.*f' % (self.app.options["cncjob_coords_decimals"], new_z) ) # find the F group @@ -8080,7 +8080,7 @@ class CNCjob(Geometry): new_f = float(match_f.group(1)[1:]) * xfactor line = line.replace( match_f.group(1), - 'F%.*f' % (self.app.defaults["cncjob_fr_decimals"], new_f) + 'F%.*f' % (self.app.options["cncjob_fr_decimals"], new_f) ) # find the T group (tool dia on toolchange) match_t = self.g_t_re.search(line) @@ -8089,7 +8089,7 @@ class CNCjob(Geometry): new_t = float(match_t.group(1)[1:]) * xfactor line = line.replace( match_t.group(1), - '= %.*f' % (self.app.defaults["cncjob_coords_decimals"], new_t) + '= %.*f' % (self.app.options["cncjob_coords_decimals"], new_t) ) temp_gcode += line @@ -8192,7 +8192,7 @@ class CNCjob(Geometry): # replace the updated string line = line.replace( match_x.group(1), - 'X%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_x) + 'X%.*f' % (self.app.options["cncjob_coords_decimals"], new_x) ) match_y = self.g_y_re.search(line) if match_y: @@ -8200,7 +8200,7 @@ class CNCjob(Geometry): new_y = float(match_y.group(1)[1:]) + dy line = line.replace( match_y.group(1), - 'Y%.*f' % (self.app.defaults["cncjob_coords_decimals"], new_y) + 'Y%.*f' % (self.app.options["cncjob_coords_decimals"], new_y) ) temp_gcode += line lines.close() diff --git a/tclCommands/TclCommand.py b/tclCommands/TclCommand.py index f27651eb..f40bb5bb 100644 --- a/tclCommands/TclCommand.py +++ b/tclCommands/TclCommand.py @@ -409,7 +409,7 @@ class TclCommandSignaled(TclCommand): passed_timeout = args['timeout'] args.pop('timeout', None) else: - passed_timeout = self.app.defaults['global_background_timeout'] + passed_timeout = self.app.options['global_background_timeout'] # set detail for processing, it will be there until next open or close self.app.shell.open_processing(self.get_current_command()) diff --git a/tclCommands/TclCommandBbox.py b/tclCommands/TclCommandBbox.py index 34dfec3f..d61bee1a 100644 --- a/tclCommands/TclCommandBbox.py +++ b/tclCommands/TclCommandBbox.py @@ -75,7 +75,7 @@ class TclCommandBbox(TclCommand): _("Expected GerberObject or GeometryObject, got"), name, type(obj))) if 'margin' not in args: - args['margin'] = float(self.app.defaults["gerber_bboxmargin"]) + args['margin'] = float(self.app.options["gerber_bboxmargin"]) margin = args['margin'] if 'rounded' in args: @@ -85,7 +85,7 @@ class TclCommandBbox(TclCommand): par = args['rounded'] rounded = bool(eval(par)) else: - rounded = bool(eval(self.app.defaults["gerber_bboxrounded"])) + rounded = bool(eval(self.app.options["gerber_bboxrounded"])) args.pop('name', None) diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index cf729b9d..71bdbf9c 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/tclCommands/TclCommandCncjob.py @@ -135,25 +135,25 @@ class TclCommandCncjob(TclCommandSignaled): else: return - args["dia"] = args["dia"] if "dia" in args and args["dia"] else self.app.defaults["tools_mill_tooldia"] + args["dia"] = args["dia"] if "dia" in args and args["dia"] else self.app.options["tools_mill_tooldia"] - args["z_cut"] = args["z_cut"] if "z_cut" in args and args["z_cut"] else self.app.defaults["tools_mill_cutz"] + args["z_cut"] = args["z_cut"] if "z_cut" in args and args["z_cut"] else self.app.options["tools_mill_cutz"] args["z_move"] = args["z_move"] if "z_move" in args and args["z_move"] else \ - self.app.defaults["tools_mill_travelz"] + self.app.options["tools_mill_travelz"] args["pp"] = args["pp"] if "pp" in args and isinstance(args["pp"], str) else \ - self.app.defaults["tools_mill_ppname_g"] + self.app.options["tools_mill_ppname_g"] args["feedrate"] = args["feedrate"] if "feedrate" in args and args["feedrate"] else \ - self.app.defaults["tools_mill_feedrate"] + self.app.options["tools_mill_feedrate"] if 'laser' in args["pp"] and "feedrate_z" not in args: args["feedrate_z"] = args["feedrate"] else: args["feedrate_z"] = args["feedrate_z"] if "feedrate_z" in args and args["feedrate_z"] else \ - self.app.defaults["tools_mill_feedrate_z"] + self.app.options["tools_mill_feedrate_z"] args["feedrate_rapid"] = args["feedrate_rapid"] if "feedrate_rapid" in args and args["feedrate_rapid"] else \ - self.app.defaults["tools_mill_feedrate_rapid"] + self.app.options["tools_mill_feedrate_rapid"] if "extracut_length" in args: args["extracut"] = True @@ -162,28 +162,28 @@ class TclCommandCncjob(TclCommandSignaled): else: args["extracut_length"] = float(args["extracut_length"]) else: - args["extracut"] = self.app.defaults["tools_mill_extracut"] - args["extracut_length"] = self.app.defaults["tools_mill_extracut_length"] + args["extracut"] = self.app.options["tools_mill_extracut"] + args["extracut_length"] = self.app.options["tools_mill_extracut_length"] if "dpp" in args: args["multidepth"] = True if args["dpp"] is None: - args["dpp"] = self.app.defaults["tools_mill_depthperpass"] + args["dpp"] = self.app.options["tools_mill_depthperpass"] else: args["dpp"] = float(args["dpp"]) else: - args["multidepth"] = self.app.defaults["tools_mill_multidepth"] - args["dpp"] = self.app.defaults["tools_mill_depthperpass"] + args["multidepth"] = self.app.options["tools_mill_multidepth"] + args["dpp"] = self.app.options["tools_mill_depthperpass"] args["startz"] = args["startz"] if "startz" in args and args["startz"] else \ - self.app.defaults["tools_mill_startz"] - args["endz"] = args["endz"] if "endz" in args and args["endz"] else self.app.defaults["tools_mill_endz"] + self.app.options["tools_mill_startz"] + args["endz"] = args["endz"] if "endz" in args and args["endz"] else self.app.options["tools_mill_endz"] if "endxy" in args and args["endxy"]: args["endxy"] = args["endxy"] else: - if self.app.defaults["tools_mill_endxy"]: - args["endxy"] = str(self.app.defaults["tools_mill_endxy"]) + if self.app.options["tools_mill_endxy"]: + args["endxy"] = str(self.app.options["tools_mill_endxy"]) else: args["endxy"] = '0, 0' if len(eval(args["endxy"])) != 2: @@ -207,24 +207,24 @@ class TclCommandCncjob(TclCommandSignaled): else: args["dwelltime"] = float(args['dwelltime']) else: - args["dwell"] = self.app.defaults["tools_mill_dwell"] - args["dwelltime"] = self.app.defaults["tools_mill_dwelltime"] + args["dwell"] = self.app.options["tools_mill_dwell"] + args["dwelltime"] = self.app.options["tools_mill_dwelltime"] if "toolchangez" in args: args["toolchange"] = True if args["toolchangez"] is not None: args["toolchangez"] = args["toolchangez"] else: - args["toolchangez"] = self.app.defaults["tools_mill_toolchangez"] + args["toolchangez"] = self.app.options["tools_mill_toolchangez"] else: - args["toolchange"] = self.app.defaults["tools_mill_toolchange"] - args["toolchangez"] = self.app.defaults["tools_mill_toolchangez"] + args["toolchange"] = self.app.options["tools_mill_toolchange"] + args["toolchangez"] = self.app.options["tools_mill_toolchangez"] if "toolchangexy" in args and args["toolchangexy"]: args["toolchangexy"] = args["toolchangexy"] else: - if self.app.defaults["tools_mill_toolchangexy"]: - args["toolchangexy"] = str(self.app.defaults["tools_mill_toolchangexy"]) + if self.app.options["tools_mill_toolchangexy"]: + args["toolchangexy"] = str(self.app.options["tools_mill_toolchangexy"]) else: args["toolchangexy"] = '0, 0' if len(eval(args["toolchangexy"])) != 2: @@ -256,8 +256,8 @@ class TclCommandCncjob(TclCommandSignaled): for tool_uid in list(local_tools_dict.keys()): if 'data' in local_tools_dict[tool_uid]: - local_tools_dict[tool_uid]['data']['segx'] = self.app.defaults['geometry_segx'] - local_tools_dict[tool_uid]['data']['segy'] = self.app.defaults['geometry_segx'] + local_tools_dict[tool_uid]['data']['segx'] = self.app.options['geometry_segx'] + local_tools_dict[tool_uid]['data']['segy'] = self.app.options['geometry_segx'] local_tools_dict[tool_uid]['data']['tools_mill_tooldia'] = args["dia"] local_tools_dict[tool_uid]['data']['tools_mill_cutz'] = args["z_cut"] local_tools_dict[tool_uid]['data']['tools_mill_travelz'] = args["z_move"] diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index c2c572ae..5f2f3481 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -103,22 +103,22 @@ class TclCommandCopperClear(TclCommand): if 'tooldia' in args: tooldia = str(args['tooldia']) else: - tooldia = str(self.app.defaults["tools_ncc_tools"]) + tooldia = str(self.app.options["tools_ncc_tools"]) if 'overlap' in args: overlap = float(args['overlap']) / 100.0 else: - overlap = float(self.app.defaults["tools_ncc_overlap"]) / 100.0 + overlap = float(self.app.options["tools_ncc_overlap"]) / 100.0 if 'order' in args: order = args['order'] else: - order = str(self.app.defaults["tools_ncc_order"]) + order = str(self.app.options["tools_ncc_order"]) if 'margin' in args: margin = float(args['margin']) else: - margin = float(self.app.defaults["tools_ncc_margin"]) + margin = float(self.app.options["tools_ncc_margin"]) if 'method' in args: method = args['method'] @@ -132,7 +132,7 @@ class TclCommandCopperClear(TclCommand): return "Method not supported or typo.\n" \ "Supported methods are: 'standard', 'seed' and 'lines'." else: - method = str(self.app.defaults["tools_ncc_method"]) + method = str(self.app.options["tools_ncc_method"]) method_data = method if 'connect' in args: @@ -142,7 +142,7 @@ class TclCommandCopperClear(TclCommand): par = args['connect'] connect = bool(eval(par)) else: - connect = bool(eval(str(self.app.defaults["tools_ncc_connect"]))) + connect = bool(eval(str(self.app.options["tools_ncc_connect"]))) if 'contour' in args: try: @@ -151,7 +151,7 @@ class TclCommandCopperClear(TclCommand): par = args['contour'] contour = bool(eval(par)) else: - contour = bool(eval(str(self.app.defaults["tools_ncc_contour"]))) + contour = bool(eval(str(self.app.options["tools_ncc_contour"]))) offset = 0.0 if 'offset' in args: @@ -172,7 +172,7 @@ class TclCommandCopperClear(TclCommand): par = args['rest'] rest = bool(eval(par)) else: - rest = bool(eval(str(self.app.defaults["tools_ncc_rest"]))) + rest = bool(eval(str(self.app.options["tools_ncc_rest"]))) if 'outname' in args: outname = args['outname'] @@ -202,8 +202,8 @@ class TclCommandCopperClear(TclCommand): "tools_ncc_contour": contour, "tools_ncc_overlap": overlap, - "segx": self.app.defaults["geometry_segx"], - "segy": self.app.defaults["geometry_segy"] + "segx": self.app.options["geometry_segx"], + "segy": self.app.options["geometry_segy"] }) ncc_tools = {} diff --git a/tclCommands/TclCommandCutout.py b/tclCommands/TclCommandCutout.py index a367d718..362d6382 100644 --- a/tclCommands/TclCommandCutout.py +++ b/tclCommands/TclCommandCutout.py @@ -74,12 +74,12 @@ class TclCommandCutout(TclCommand): if 'margin' in args: margin_par = float(args['margin']) else: - margin_par = float(self.app.defaults["tools_cutout_margin"]) + margin_par = float(self.app.options["tools_cutout_margin"]) if 'dia' in args: dia_par = float(args['dia']) else: - dia_par = float(self.app.defaults["tools_cutout_tooldia"]) + dia_par = float(self.app.options["tools_cutout_tooldia"]) if 'gaps' in args: if args['gaps'] not in ["tb", "lr", "4", 4]: @@ -88,12 +88,12 @@ class TclCommandCutout(TclCommand): return "fail" gaps_par = str(args['gaps']) else: - gaps_par = str(self.app.defaults["tools_cutout_gaps_ff"]) + gaps_par = str(self.app.options["tools_cutout_gaps_ff"]) if 'gapsize' in args: gapsize_par = float(args['gapsize']) else: - gapsize_par = float(self.app.defaults["tools_cutout_gapsize"]) + gapsize_par = float(self.app.options["tools_cutout_gapsize"]) if 'outname' in args: outname = args['outname'] diff --git a/tclCommands/TclCommandDrillcncjob.py b/tclCommands/TclCommandDrillcncjob.py index c409c119..96661ea0 100644 --- a/tclCommands/TclCommandDrillcncjob.py +++ b/tclCommands/TclCommandDrillcncjob.py @@ -236,7 +236,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): drillz = args["drillz"] if "drillz" in args and args["drillz"] is not None else \ obj.obj_options["tools_drill_cutz"] - toolchange = self.app.defaults["tools_drill_toolchange"] + toolchange = self.app.options["tools_drill_toolchange"] if "toolchangez" in args: toolchange = True if args["toolchangez"] is not None: @@ -244,14 +244,14 @@ class TclCommandDrillcncjob(TclCommandSignaled): else: toolchangez = obj.obj_options["tools_drill_toolchangez"] else: - toolchangez = float(self.app.defaults["tools_drill_toolchangez"]) + toolchangez = float(self.app.options["tools_drill_toolchangez"]) if "toolchangexy" in args and args["toolchangexy"]: toolchange = True xy_toolchange = args["toolchangexy"] else: - if self.app.defaults["tools_drill_toolchangexy"]: - xy_toolchange = str(self.app.defaults["tools_drill_toolchangexy"]) + if self.app.options["tools_drill_toolchangexy"]: + xy_toolchange = str(self.app.options["tools_drill_toolchangexy"]) else: xy_toolchange = '0, 0' if len(eval(xy_toolchange)) != 2: @@ -262,13 +262,13 @@ class TclCommandDrillcncjob(TclCommandSignaled): return "fail" endz = args["endz"] if "endz" in args and args["endz"] is not None else \ - self.app.defaults["tools_drill_endz"] + self.app.options["tools_drill_endz"] if "endxy" in args and args["endxy"]: xy_end = args["endxy"] else: - if self.app.defaults["tools_drill_endxy"]: - xy_end = str(self.app.defaults["tools_drill_endxy"]) + if self.app.options["tools_drill_endxy"]: + xy_end = str(self.app.options["tools_drill_endxy"]) else: xy_end = '0, 0' @@ -291,7 +291,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): cnc_job_obj.used_tools = use_tools # preprocessor - pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["tools_drill_ppname_e"] + pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.options["tools_drill_ppname_e"] cnc_job_obj.pp_excellon_name = pp_excellon_name cnc_job_obj.obj_options['ppname_e'] = pp_excellon_name @@ -303,19 +303,19 @@ class TclCommandDrillcncjob(TclCommandSignaled): else: cnc_job_obj.z_depthpercut = abs(float(obj.obj_options["dpp"])) else: - cnc_job_obj.multidepth = self.app.defaults["tools_drill_multidepth"] - cnc_job_obj.z_depthpercut = self.app.defaults["tools_drill_depthperpass"] + cnc_job_obj.multidepth = self.app.options["tools_drill_multidepth"] + cnc_job_obj.z_depthpercut = self.app.options["tools_drill_depthperpass"] # travel Z cnc_job_obj.z_move = float(args["travelz"]) if "travelz" in args and args["travelz"] else \ - self.app.defaults["tools_drill_travelz"] + self.app.options["tools_drill_travelz"] # Feedrate cnc_job_obj.feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \ - self.app.defaults["tools_drill_feedrate_z"] + self.app.options["tools_drill_feedrate_z"] cnc_job_obj.z_feedrate = float(args["feedrate_z"]) if "feedrate_z" in args and args["feedrate_z"] else \ - self.app.defaults["tools_drill_feedrate_z"] + self.app.options["tools_drill_feedrate_z"] cnc_job_obj.feedrate_rapid = float(args["feedrate_rapid"]) \ if "feedrate_rapid" in args and args["feedrate_rapid"] else \ - self.app.defaults["tools_drill_feedrate_rapid"] + self.app.options["tools_drill_feedrate_rapid"] # SpindleSpped / Laser Power if 'laser' not in pp_excellon_name: @@ -327,20 +327,20 @@ class TclCommandDrillcncjob(TclCommandSignaled): cnc_job_obj.laser_min_power = float(args["las_min_pwr"]) if "las_min_pwr" in args else 0.0 # spindle direction - cnc_job_obj.spindledir = self.app.defaults["tools_drill_spindledir"] + cnc_job_obj.spindledir = self.app.options["tools_drill_spindledir"] # dwell and dwelltime if 'dwelltime' in args: cnc_job_obj.dwell = True if args['dwelltime'] is not None: cnc_job_obj.dwelltime = float(args['dwelltime']) else: - cnc_job_obj.dwelltime = float(self.app.defaults["tools_drill_dwelltime"]) + cnc_job_obj.dwelltime = float(self.app.options["tools_drill_dwelltime"]) else: - cnc_job_obj.dwell = self.app.defaults["tools_drill_dwell"] - cnc_job_obj.dwelltime = self.app.defaults["tools_drill_dwelltime"] + cnc_job_obj.dwell = self.app.options["tools_drill_dwell"] + cnc_job_obj.dwelltime = self.app.options["tools_drill_dwelltime"] - cnc_job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"]) - cnc_job_obj.fr_decimals = int(self.app.defaults["cncjob_fr_decimals"]) + cnc_job_obj.coords_decimals = int(self.app.options["cncjob_coords_decimals"]) + cnc_job_obj.fr_decimals = int(self.app.options["cncjob_fr_decimals"]) cnc_job_obj.obj_options['xmin'] = xmin cnc_job_obj.obj_options['ymin'] = ymin @@ -359,10 +359,10 @@ class TclCommandDrillcncjob(TclCommandSignaled): if "startz" in args and args["startz"] is not None: cnc_job_obj.startz = float(args["startz"]) else: - if self.app.defaults["tools_drill_startz"]: - cnc_job_obj.startz = self.app.defaults["tools_drill_startz"] + if self.app.options["tools_drill_startz"]: + cnc_job_obj.startz = self.app.options["tools_drill_startz"] else: - cnc_job_obj.startz = self.app.defaults["tools_drill_travelz"] + cnc_job_obj.startz = self.app.options["tools_drill_travelz"] # end Z cnc_job_obj.z_end = float(endz) # end X-Y location diff --git a/tclCommands/TclCommandExportDXF.py b/tclCommands/TclCommandExportDXF.py index 9b255473..4e20a7d7 100644 --- a/tclCommands/TclCommandExportDXF.py +++ b/tclCommands/TclCommandExportDXF.py @@ -61,7 +61,7 @@ class TclCommandExportDXF(TclCommand): source_obj_name = args['name'] if 'filename' not in args: - filename = self.app.defaults["global_last_save_folder"] + '/' + args['name'] + filename = self.app.options["global_last_save_folder"] + '/' + args['name'] else: filename = args['filename'] diff --git a/tclCommands/TclCommandExportExcellon.py b/tclCommands/TclCommandExportExcellon.py index 4c20a65f..9b78bc05 100644 --- a/tclCommands/TclCommandExportExcellon.py +++ b/tclCommands/TclCommandExportExcellon.py @@ -48,5 +48,5 @@ class TclCommandExportExcellon(TclCommand): :return: """ if 'filename' not in args: - args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name'] + args['filename'] = self.app.options["global_last_save_folder"] + '/' + args['name'] self.app.f_handlers.export_excellon(use_thread=False, **args) diff --git a/tclCommands/TclCommandExportGerber.py b/tclCommands/TclCommandExportGerber.py index 64a9c046..de219ebe 100644 --- a/tclCommands/TclCommandExportGerber.py +++ b/tclCommands/TclCommandExportGerber.py @@ -48,5 +48,5 @@ class TclCommandExportGerber(TclCommand): :return: """ if 'filename' not in args: - args['filename'] = self.app.defaults["global_last_save_folder"] + '/' + args['name'] + args['filename'] = self.app.options["global_last_save_folder"] + '/' + args['name'] self.app.f_handlers.export_gerber(use_thread=False, **args) diff --git a/tclCommands/TclCommandExportSVG.py b/tclCommands/TclCommandExportSVG.py index 7e310c89..3c2d9ef4 100644 --- a/tclCommands/TclCommandExportSVG.py +++ b/tclCommands/TclCommandExportSVG.py @@ -56,7 +56,7 @@ class TclCommandExportSVG(TclCommand): source_obj_name = args['name'] if 'filename' not in args: - filename = self.app.defaults["global_last_save_folder"] + '/' + args['name'] + filename = self.app.options["global_last_save_folder"] + '/' + args['name'] else: filename = args['filename'] diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index 39bcf47b..a67aef70 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -146,22 +146,22 @@ class TclCommandGeoCutout(TclCommandSignaled): if 'margin' in args: margin = float(args['margin']) else: - margin = float(self.app.defaults["tools_cutout_margin"]) + margin = float(self.app.options["tools_cutout_margin"]) if 'dia' in args: dia = float(args['dia']) else: - dia = float(self.app.defaults["tools_cutout_tooldia"]) + dia = float(self.app.options["tools_cutout_tooldia"]) if 'gaps' in args: gaps = args['gaps'] else: - gaps = str(self.app.defaults["tools_cutout_gaps_ff"]) + gaps = str(self.app.options["tools_cutout_gaps_ff"]) if 'gapsize' in args: gapsize = float(args['gapsize']) else: - gapsize = float(self.app.defaults["tools_cutout_gapsize"]) + gapsize = float(self.app.options["tools_cutout_gapsize"]) if 'outname' in args: outname = args['outname'] diff --git a/tclCommands/TclCommandGetPath.py b/tclCommands/TclCommandGetPath.py index 527b6c2b..aade09ac 100644 --- a/tclCommands/TclCommandGetPath.py +++ b/tclCommands/TclCommandGetPath.py @@ -61,5 +61,5 @@ class TclCommandGetPath(TclCommand): """ self.app.shell.append_output("Current default Tcl Shell path is: ") - path = self.app.defaults["global_tcl_path"] + path = self.app.options["global_tcl_path"] return path diff --git a/tclCommands/TclCommandGetSys.py b/tclCommands/TclCommandGetSys.py index e5adca87..ab60ce80 100644 --- a/tclCommands/TclCommandGetSys.py +++ b/tclCommands/TclCommandGetSys.py @@ -55,7 +55,7 @@ class TclCommandGetSys(TclCommand): name = args['name'] - if name in self.app.defaults: - return self.app.defaults[name] + if name in self.app.options: + return self.app.options[name] else: return "The keyword: %s does not exist as a parameter" % str(name) diff --git a/tclCommands/TclCommandIsolate.py b/tclCommands/TclCommandIsolate.py index 918f02ed..f4032415 100644 --- a/tclCommands/TclCommandIsolate.py +++ b/tclCommands/TclCommandIsolate.py @@ -84,7 +84,7 @@ class TclCommandIsolate(TclCommandSignaled): par = args['combine'] args['combine'] = bool(eval(str(par))) else: - args['combine'] = bool(eval(str(self.app.defaults["tools_iso_combine_passes"]))) + args['combine'] = bool(eval(str(self.app.options["tools_iso_combine_passes"]))) obj = self.app.collection.get_by_name(name) if obj is None: diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py index d9e359c8..a262f8bf 100644 --- a/tclCommands/TclCommandListSys.py +++ b/tclCommands/TclCommandListSys.py @@ -60,8 +60,8 @@ class TclCommandListSys(TclCommand): """ if 'selection' in args: argument = args['selection'] - return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))]) + return str([k for k in self.app.options.keys() if str(k).startswith(str(argument))]) else: - ret_val = list(self.app.defaults.keys()) + ret_val = list(self.app.options.keys()) return str(ret_val) - # return str([*self.app.defaults]) + # return str([*self.app.options]) diff --git a/tclCommands/TclCommandNregions.py b/tclCommands/TclCommandNregions.py index 8fd8753e..1f1f1b26 100644 --- a/tclCommands/TclCommandNregions.py +++ b/tclCommands/TclCommandNregions.py @@ -74,7 +74,7 @@ class TclCommandNregions(TclCommand): self.raise_tcl_error('%s %s: %s.' % (_("Expected GerberObject or GeometryObject, got"), name, type(obj))) if 'margin' not in args: - args['margin'] = float(self.app.defaults["gerber_noncoppermargin"]) + args['margin'] = float(self.app.options["gerber_noncoppermargin"]) margin = float(args['margin']) if 'rounded' in args: @@ -84,7 +84,7 @@ class TclCommandNregions(TclCommand): par = args['rounded'] rounded = bool(eval(par)) else: - rounded = bool(eval(self.app.defaults["gerber_noncopperrounded"])) + rounded = bool(eval(self.app.options["gerber_noncopperrounded"])) args.pop('name', None) diff --git a/tclCommands/TclCommandOpenDXF.py b/tclCommands/TclCommandOpenDXF.py index 6de1bd32..82b9bb6f 100644 --- a/tclCommands/TclCommandOpenDXF.py +++ b/tclCommands/TclCommandOpenDXF.py @@ -92,7 +92,7 @@ class TclCommandOpenDXF(TclCommandSignaled): # Object creation ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False) if ret_val == 'fail': - filename = self.app.defaults['global_tcl_path'] + '/' + outname + filename = self.app.options['global_tcl_path'] + '/' + outname ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False) # self.app.shell.append_output( # "No path provided or path is wrong. Using the default Path... \n") diff --git a/tclCommands/TclCommandOpenSVG.py b/tclCommands/TclCommandOpenSVG.py index e1d4e9c9..e0556ab5 100644 --- a/tclCommands/TclCommandOpenSVG.py +++ b/tclCommands/TclCommandOpenSVG.py @@ -87,7 +87,7 @@ class TclCommandOpenSVG(TclCommandSignaled): # Object creation ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False) if ret_val == 'fail': - filename = self.app.defaults['global_tcl_path'] + '/' + outname + filename = self.app.options['global_tcl_path'] + '/' + outname ret_val = self.app.app_obj.new_object(obj_type, outname, obj_init, plot=False) self.app.shell.append_output( "No path provided or path is wrong. Using the default Path... \n") diff --git a/tclCommands/TclCommandPaint.py b/tclCommands/TclCommandPaint.py index 2e743703..808b985d 100644 --- a/tclCommands/TclCommandPaint.py +++ b/tclCommands/TclCommandPaint.py @@ -103,22 +103,22 @@ class TclCommandPaint(TclCommand): if 'tooldia' in args: tooldia = str(args['tooldia']) else: - tooldia = str(self.app.defaults["tools_paint_tooldia"]) + tooldia = str(self.app.options["tools_paint_tooldia"]) if 'overlap' in args: overlap = float(args['overlap']) else: - overlap = float(self.app.defaults["tools_paint_overlap"]) + overlap = float(self.app.options["tools_paint_overlap"]) if 'order' in args: order = args['order'] else: - order = str(self.app.defaults["tools_paint_order"]) + order = str(self.app.options["tools_paint_order"]) if 'offset' in args: offset = float(args['offset']) else: - offset = float(self.app.defaults["tools_paint_offset"]) + offset = float(self.app.options["tools_paint_offset"]) if 'method' in args: method = args['method'] @@ -138,7 +138,7 @@ class TclCommandPaint(TclCommand): self.app.log.error(msg) return "fail" else: - method = str(self.app.defaults["tools_paint_method"]) + method = str(self.app.options["tools_paint_method"]) if 'connect' in args: try: @@ -147,7 +147,7 @@ class TclCommandPaint(TclCommand): par = args['connect'] connect = bool(eval(par)) else: - connect = bool(eval(str(self.app.defaults["tools_paint_connect"]))) + connect = bool(eval(str(self.app.options["tools_paint_connect"]))) if 'contour' in args: try: @@ -156,7 +156,7 @@ class TclCommandPaint(TclCommand): par = args['contour'] contour = bool(eval(par)) else: - contour = bool(eval(str(self.app.defaults["tools_paint_contour"]))) + contour = bool(eval(str(self.app.options["tools_paint_contour"]))) if 'outname' in args: outname = args['outname'] @@ -181,17 +181,17 @@ class TclCommandPaint(TclCommand): "name": outname, "plot": False, "tooldia": tooldia, - "tools_mill_cutz": self.app.defaults["tools_mill_cutz"], - "tools_paint_tipdia": float(self.app.defaults["tools_paint_tipdia"]), - "tools_paint_tipangle": float(self.app.defaults["tools_paint_tipangle"]), + "tools_mill_cutz": self.app.options["tools_mill_cutz"], + "tools_paint_tipdia": float(self.app.options["tools_paint_tipdia"]), + "tools_paint_tipangle": float(self.app.options["tools_paint_tipangle"]), "tools_paint_offset": offset, "tools_paint_method": method, "tools_paint_selectmethod": select, "tools_paint_connect": connect, "tools_paint_contour": contour, "tools_paint_overlap": overlap, - "segx": self.app.defaults["geometry_segx"], - "segy": self.app.defaults["geometry_segy"] + "segx": self.app.options["geometry_segx"], + "segy": self.app.options["geometry_segy"] }) # create a `tools` dict diff --git a/tclCommands/TclCommandSetPath.py b/tclCommands/TclCommandSetPath.py index 4050c4a9..c0d0ba4c 100644 --- a/tclCommands/TclCommandSetPath.py +++ b/tclCommands/TclCommandSetPath.py @@ -89,6 +89,6 @@ class TclCommandSetPath(TclCommand): cd_command = 'cd %s' % path self.app.shell.exec_command(cd_command, no_echo=False) - self.app.defaults["global_tcl_path"] = str(path) + self.app.options["global_tcl_path"] = str(path) msg = '[success] %s: %s' % ("Relative path set to", str(path)) self.app.inform_shell.emit(msg) diff --git a/tclCommands/TclCommandSetSys.py b/tclCommands/TclCommandSetSys.py index df211817..a70849d4 100644 --- a/tclCommands/TclCommandSetSys.py +++ b/tclCommands/TclCommandSetSys.py @@ -75,15 +75,15 @@ class TclCommandSetSys(TclCommand): "MM": "MM" } - if param in self.app.defaults: + if param in self.app.options: try: value = tcl2py[value] except KeyError: pass - self.app.defaults[param] = value - self.app.defaults.propagate_defaults() + self.app.options[param] = value + self.app.options.propagate_defaults() else: self.raise_tcl_error("No such system parameter \"{}\".".format(param))