From 1681b327eda0096b19f3febfb348aac06bfd0565 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 16 Feb 2022 10:47:12 +0200 Subject: [PATCH] - refactoring all the references to object `options` property to `obj_options` to make a difference with the application `options` property --- CHANGELOG.md | 4 + appEditors/AppExcEditor.py | 28 ++-- appEditors/AppGeoEditor.py | 60 ++++---- appEditors/AppGerberEditor.py | 34 ++--- appEditors/AppTextEditor.py | 2 +- appEditors/appGCodeEditor.py | 26 ++-- appGUI/MainGUI.py | 10 +- appGUI/PlotCanvasLegacy.py | 8 +- appObjects/AppObject.py | 62 ++++---- appObjects/FlatCAMCNCJob.py | 72 +++++----- appObjects/FlatCAMDocument.py | 4 +- appObjects/FlatCAMExcellon.py | 54 +++---- appObjects/FlatCAMGeometry.py | 172 +++++++++++------------ appObjects/FlatCAMGerber.py | 66 ++++----- appObjects/FlatCAMObj.py | 40 +++--- appObjects/FlatCAMScript.py | 12 +- appObjects/ObjectCollection.py | 54 +++---- appPlugins/ToolAlignObjects.py | 8 +- appPlugins/ToolCalibration.py | 2 +- appPlugins/ToolCopperThieving.py | 32 ++--- appPlugins/ToolCutOut.py | 88 ++++++------ appPlugins/ToolDblSided.py | 8 +- appPlugins/ToolDrilling.py | 36 ++--- appPlugins/ToolEtchCompensation.py | 10 +- appPlugins/ToolExtract.py | 10 +- appPlugins/ToolFiducials.py | 32 ++--- appPlugins/ToolFilm.py | 8 +- appPlugins/ToolFollow.py | 6 +- appPlugins/ToolInvertGerber.py | 10 +- appPlugins/ToolIsolation.py | 32 ++--- appPlugins/ToolLevelling.py | 18 +-- appPlugins/ToolMarkers.py | 48 +++---- appPlugins/ToolMilling.py | 148 ++++++++++---------- appPlugins/ToolMove.py | 14 +- appPlugins/ToolNCC.py | 12 +- appPlugins/ToolOptimal.py | 2 +- appPlugins/ToolPaint.py | 24 ++-- appPlugins/ToolPanelize.py | 8 +- appPlugins/ToolPunchGerber.py | 76 +++++----- appPlugins/ToolQRCode.py | 12 +- appPlugins/ToolReport.py | 10 +- appPlugins/ToolRulesCheck.py | 2 +- appPlugins/ToolSolderPaste.py | 46 +++--- appPlugins/ToolSub.py | 14 +- appPlugins/ToolTransform.py | 30 ++-- app_Main.py | 202 +++++++++++++-------------- camlib.py | 72 +++++----- tclCommands/TclCommandCncjob.py | 2 +- tclCommands/TclCommandDrillcncjob.py | 30 ++-- tclCommands/TclCommandGeoCutout.py | 16 +-- tclCommands/TclCommandOptions.py | 2 +- tclCommands/TclCommandPanelize.py | 6 +- tclCommands/TclCommandPlotAll.py | 2 +- tclCommands/TclCommandPlotObjects.py | 2 +- 54 files changed, 896 insertions(+), 892 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38226ad5..12d0fe57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +16.02.2022 + +- refactoring all the references to object `options` property to `obj_options` to make a difference with the application `options` property + 15.02.2022 - fixed an issue with the moving shape when creating an exclusion area diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index 5976b256..b2aa2ebd 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -1833,7 +1833,7 @@ class AppExcEditor(QtCore.QObject): self.complete = False - self.options = { + self.editor_options = { "global_gridx": 0.1, "global_gridy": 0.1, "snap_max": 0.05, @@ -1841,11 +1841,11 @@ class AppExcEditor(QtCore.QObject): "corner_snap": False, "grid_gap_link": True } - self.options.update(self.app.options) + self.editor_options.update(self.app.options) - for option in self.options: + for option in self.editor_options: if option in self.app.options: - self.options[option] = self.app.options[option] + self.editor_options[option] = self.app.options[option] self.data_defaults = {} @@ -1866,7 +1866,7 @@ class AppExcEditor(QtCore.QObject): self.tool_row = 0 # def entry2option(option, entry): - # self.options[option] = float(entry.text()) + # self.editor_options[option] = float(entry.text()) # Event signals disconnect id holders self.mp = None @@ -2045,7 +2045,7 @@ class AppExcEditor(QtCore.QObject): self.units = self.app.app_units.upper() # make a new name for the new Excellon object (the one with edited content) - self.edited_obj_name = self.edited_obj.options['name'] + self.edited_obj_name = self.edited_obj.obj_options['name'] self.ui.name_entry.set_value(self.edited_obj_name) sort_temp = [] @@ -2758,7 +2758,7 @@ class AppExcEditor(QtCore.QObject): edited_obj.visible = False if self.edited_obj: - outname = self.edited_obj.options['name'] + outname = self.edited_obj.obj_options['name'] else: outname = '' @@ -2812,7 +2812,7 @@ class AppExcEditor(QtCore.QObject): "tools_drill_area_overz": self.app.defaults["tools_drill_area_overz"], } - # fill in self.default_data values from self.options + # fill in self.default_data values from self.obj_options for opt_key, opt_val in self.app.options.items(): if opt_key.find('excellon_') == 0: self.data_defaults[opt_key] = deepcopy(opt_val) @@ -3090,13 +3090,13 @@ class AppExcEditor(QtCore.QObject): @staticmethod def update_options(obj): try: - if not obj.options: - obj.options = {'xmin': 0, 'ymin': 0, 'xmax': 0, 'ymax': 0} + if not obj.obj_options: + obj.obj_options = {'xmin': 0, 'ymin': 0, 'xmax': 0, 'ymax': 0} return True else: return False except AttributeError: - obj.options = {} + obj.obj_options = {} return True def new_edited_excellon(self, outname, n_tools): @@ -3112,7 +3112,7 @@ class AppExcEditor(QtCore.QObject): """ self.app.log.debug("Update the Excellon object with edited content. Source is %s" % - self.edited_obj.options['name']) + self.edited_obj.obj_options['name']) new_tools = n_tools @@ -3120,7 +3120,7 @@ class AppExcEditor(QtCore.QObject): def obj_init(new_obj, app_obj): new_obj.tools = deepcopy(new_tools) - new_obj.options['name'] = outname + new_obj.obj_options['name'] = outname # add a 'data' dict for each tool with the default values for tool in new_obj.tools: @@ -3144,7 +3144,7 @@ class AppExcEditor(QtCore.QObject): try: edited_obj = self.app.app_obj.new_object("excellon", outname, obj_init) - edited_obj.source_file = self.app.f_handlers.export_excellon(obj_name=edited_obj.options['name'], + edited_obj.source_file = self.app.f_handlers.export_excellon(obj_name=edited_obj.obj_options['name'], local_use=edited_obj, filename=None, use_thread=False) diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index fc4e3ff3..3b3ea9a3 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -3702,7 +3702,7 @@ class AppGeoEditor(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 - self.options = { + self.editor_options = { "global_gridx": 0.1, "global_gridy": 0.1, "global_snap_max": 0.05, @@ -3710,15 +3710,15 @@ class AppGeoEditor(QtCore.QObject): "corner_snap": False, "grid_gap_link": True } - self.options.update(self.app.options) + self.editor_options.update(self.app.options) - for option in self.options: + for option in self.editor_options: if option in self.app.options: - self.options[option] = self.app.options[option] + self.editor_options[option] = self.app.options[option] - self.app.ui.grid_gap_x_entry.setText(str(self.options["global_gridx"])) - self.app.ui.grid_gap_y_entry.setText(str(self.options["global_gridy"])) - self.app.ui.snap_max_dist_entry.setText(str(self.options["global_snap_max"])) + self.app.ui.grid_gap_x_entry.setText(str(self.editor_options["global_gridx"])) + self.app.ui.grid_gap_y_entry.setText(str(self.editor_options["global_gridy"])) + self.app.ui.snap_max_dist_entry.setText(str(self.editor_options["global_snap_max"])) self.app.ui.grid_gap_link_cb.setChecked(True) self.rtree_index = rtindex.Index() @@ -3840,7 +3840,7 @@ class AppGeoEditor(QtCore.QObject): def entry2option(self, opt, entry): """ - :param opt: A option from the self.options dictionary + :param opt: A option from the self.editor_options dictionary :param entry: A GUI element which text value is used :return: """ @@ -3848,7 +3848,7 @@ class AppGeoEditor(QtCore.QObject): text_value = entry.text() if ',' in text_value: text_value = text_value.replace(',', '.') - self.options[opt] = float(text_value) + self.editor_options[opt] = float(text_value) except Exception as e: entry.set_value(self.app.defaults[opt]) self.app.log.error("AppGeoEditor.__init__().entry2option() --> %s" % str(e)) @@ -4587,14 +4587,14 @@ class AppGeoEditor(QtCore.QObject): """ It is used as a slot by the Snap buttons. - :param key: Key in the self.options dictionary that is to be updated + :param key: Key in the self.editor_options dictionary that is to be updated :return: Boolean. Status of the checkbox that toggled the Editor Tool """ cb_widget = self.sender() assert isinstance(cb_widget, QtGui.QAction), "Expected a QAction got %s" % type(cb_widget) - self.options[key] = cb_widget.isChecked() + self.editor_options[key] = cb_widget.isChecked() - return 1 if self.options[key] is True else 0 + return 1 if self.editor_options[key] is True else 0 def clear(self): """ @@ -4656,7 +4656,7 @@ class AppGeoEditor(QtCore.QObject): self.toolbar_tool_toggle("grid_snap") # make sure that the cursor shape is enabled/disabled, too - if self.options['grid_snap'] is True: + if self.editor_options['grid_snap'] is True: self.app.defaults['global_grid_snap'] = True self.app.inform[str, bool].emit(_("Grid Snap enabled."), False) self.app.app_cursor.enabled = True @@ -5253,22 +5253,22 @@ class AppGeoEditor(QtCore.QObject): # # ## Object (corner?) snap # # ## No need for the objects, just the coordinates # # ## in the index. - if self.options["corner_snap"]: + if self.editor_options["corner_snap"]: try: nearest_pt, shape = self.storage.nearest((x, y)) nearest_pt_distance = distance((x, y), nearest_pt) - if nearest_pt_distance <= float(self.options["global_snap_max"]): + if nearest_pt_distance <= float(self.editor_options["global_snap_max"]): snap_distance = nearest_pt_distance snap_x, snap_y = nearest_pt except (StopIteration, AssertionError): pass # # ## Grid snap - if self.options["grid_snap"]: - if self.options["global_gridx"] != 0: + if self.editor_options["grid_snap"]: + if self.editor_options["global_gridx"] != 0: try: - snap_x_ = round(x / float(self.options["global_gridx"])) * float(self.options['global_gridx']) + snap_x_ = round(x / float(self.editor_options["global_gridx"])) * float(self.editor_options['global_gridx']) except TypeError: snap_x_ = x else: @@ -5277,17 +5277,17 @@ class AppGeoEditor(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.options["global_gridx"] != 0: + if self.editor_options["global_gridx"] != 0: try: - snap_y_ = round(y / float(self.options["global_gridx"])) * float(self.options['global_gridx']) + snap_y_ = round(y / float(self.editor_options["global_gridx"])) * float(self.editor_options['global_gridx']) except TypeError: snap_y_ = y else: snap_y_ = y else: - if self.options["global_gridy"] != 0: + if self.editor_options["global_gridy"] != 0: try: - snap_y_ = round(y / float(self.options["global_gridy"])) * float(self.options['global_gridy']) + snap_y_ = round(y / float(self.editor_options["global_gridy"])) * float(self.editor_options['global_gridy']) except TypeError: snap_y_ = y else: @@ -5389,7 +5389,7 @@ class AppGeoEditor(QtCore.QObject): self.tooldia_entry.set_value( float(fcgeometry.tools[self.multigeo_tool]['data']['tools_mill_tooldia'])) else: - self.tooldia_entry.set_value(float(fcgeometry.options['tools_mill_tooldia'])) + self.tooldia_entry.set_value(float(fcgeometry.obj_options['tools_mill_tooldia'])) self.app.worker_task.emit({'fcn': task_job, 'params': [self]}) @@ -5425,11 +5425,11 @@ class AppGeoEditor(QtCore.QObject): fcgeometry.tools[self.multigeo_tool]['solid_geometry'].append(new_geo) editor_obj.multigeo_tool = None else: - edited_dia = float(fcgeometry.options['tools_mill_tooldia']) + edited_dia = float(fcgeometry.obj_options['tools_mill_tooldia']) new_dia = self.tooldia_entry.get_value() if new_dia != edited_dia: - fcgeometry.options['tools_mill_tooldia'] = new_dia + fcgeometry.obj_options['tools_mill_tooldia'] = new_dia fcgeometry.solid_geometry = [] # for shape in self.shape_buffer: @@ -5443,10 +5443,10 @@ class AppGeoEditor(QtCore.QObject): try: bounds = fcgeometry.bounds() - fcgeometry.options['xmin'] = bounds[0] - fcgeometry.options['ymin'] = bounds[1] - fcgeometry.options['xmax'] = bounds[2] - fcgeometry.options['ymax'] = bounds[3] + fcgeometry.obj_options['xmin'] = bounds[0] + fcgeometry.obj_options['ymin'] = bounds[1] + fcgeometry.obj_options['xmax'] = bounds[2] + fcgeometry.obj_options['ymax'] = bounds[3] except Exception: pass @@ -5457,7 +5457,7 @@ class AppGeoEditor(QtCore.QObject): def update_options(self, obj): if self.paint_tooldia: - obj.options['tools_mill_tooldia'] = deepcopy(str(self.paint_tooldia)) + obj.obj_options['tools_mill_tooldia'] = deepcopy(str(self.paint_tooldia)) self.paint_tooldia = None return True else: diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index 1dfc64ed..2f2c0b1f 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -3013,8 +3013,8 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): for obj in self.app.collection.get_list(): # only Gerber objects and only those that are active and not the edited object - if obj.kind == 'gerber' and obj.options['plot'] is True and \ - obj.options['name'] != self.draw_app.gerber_obj.options['name']: + if obj.kind == 'gerber' and obj.obj_options['plot'] is True and \ + obj.obj_options['name'] != self.draw_app.gerber_obj.obj_options['name']: for apid in obj.tools: if 'geometry' in obj.tools[apid]: for geo_el in obj.tools[apid]['geometry']: @@ -3073,8 +3073,8 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): for obj in self.app.collection.get_list(): # only Gerber objects and only those that are active and not the edited object - if obj.kind == 'gerber' and obj.options['plot'] is True and \ - obj.options['name'] != self.draw_app.gerber_obj.options['name']: + if obj.kind == 'gerber' and obj.obj_options['plot'] is True and \ + obj.obj_options['name'] != self.draw_app.gerber_obj.obj_options['name']: for apid in obj.tools: if 'geometry' in obj.tools[apid]: for geo_el in obj.tools[apid]['geometry']: @@ -3351,7 +3351,7 @@ class AppGerberEditor(QtCore.QObject): self.tolerance = def_tol_val if self.units == 'MM' else def_tol_val / 25.4 # options of this widget (AppGerberEditor class is a widget) - self.options = { + self.editor_options = { "global_gridx": 0.1, "global_gridy": 0.1, "snap_max": 0.05, @@ -3360,11 +3360,11 @@ class AppGerberEditor(QtCore.QObject): "grid_gap_link": True } # fill it with the application options (application preferences) - self.options.update(self.app.options) + self.editor_options.update(self.app.options) - for option in self.options: + for option in self.editor_options: if option in self.app.options: - self.options[option] = self.app.options[option] + self.editor_options[option] = self.app.options[option] # flag to show if the object was modified self.is_modified = False @@ -3384,7 +3384,7 @@ class AppGerberEditor(QtCore.QObject): self.thread = QtCore.QThread() # def entry2option(option, entry): - # self.options[option] = float(entry.text()) + # self.editor_options[option] = float(entry.text()) self.transform_tool = TransformEditorTool(self.app, self) @@ -3579,7 +3579,7 @@ class AppGerberEditor(QtCore.QObject): self.units = self.app.app_units.upper() # make a new name for the new Excellon object (the one with edited content) - self.edited_obj_name = self.gerber_obj.options['name'] + self.edited_obj_name = self.gerber_obj.obj_options['name'] self.ui.name_entry.set_value(self.edited_obj_name) self.apertures_row = 0 @@ -4537,7 +4537,7 @@ class AppGerberEditor(QtCore.QObject): # create a reference to the source object self.gerber_obj = orig_grb_obj - self.gerber_obj_options = orig_grb_obj.options + self.gerber_obj_options = orig_grb_obj.obj_options file_units = self.gerber_obj.units if self.gerber_obj.units else 'IN' app_units = self.app.app_units @@ -4832,13 +4832,13 @@ class AppGerberEditor(QtCore.QObject): @staticmethod def update_options(obj): try: - if not obj.options: - obj.options = {'xmin': 0, 'ymin': 0, 'xmax': 0, 'ymax': 0} + if not obj.obj_options: + obj.obj_options = {'xmin': 0, 'ymin': 0, 'xmax': 0, 'ymax': 0} return True else: return False except AttributeError: - obj.options = {} + obj.obj_options = {} return True def new_edited_gerber(self, outname, aperture_storage): @@ -4853,7 +4853,7 @@ class AppGerberEditor(QtCore.QObject): """ self.app.log.debug("Update the Gerber object with edited content. Source is: %s" % - self.gerber_obj.options['name'].upper()) + self.gerber_obj.obj_options['name'].upper()) out_name = outname storage_dict = aperture_storage @@ -4921,9 +4921,9 @@ class AppGerberEditor(QtCore.QObject): for k, v in self.gerber_obj_options.items(): if k == 'name': - grb_obj.options[k] = out_name + grb_obj.obj_options[k] = out_name else: - grb_obj.options[k] = deepcopy(v) + grb_obj.obj_options[k] = deepcopy(v) grb_obj.multigeo = False grb_obj.follow = False diff --git a/appEditors/AppTextEditor.py b/appEditors/AppTextEditor.py index a715304e..51735687 100644 --- a/appEditors/AppTextEditor.py +++ b/appEditors/AppTextEditor.py @@ -244,7 +244,7 @@ class AppTextEditor(QtWidgets.QWidget): obj_name = name else: try: - obj_name = self.app.collection.get_active().options['name'] + obj_name = self.app.collection.get_active().obj_options['name'] except AttributeError: obj_name = 'file' if filt is None: diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index 9f133d04..53175490 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -115,7 +115,7 @@ class AppGCodeEditor(QtCore.QObject): self.app.ui.notebook.setCurrentWidget(self.app.ui.properties_tab) # make a new name for the new Excellon object (the one with edited content) - self.edited_obj_name = self.gcode_obj.options['name'] + self.edited_obj_name = self.gcode_obj.obj_options['name'] self.ui.name_entry.set_value(self.edited_obj_name) self.activate() @@ -135,12 +135,12 @@ class AppGCodeEditor(QtCore.QObject): # if the FlatCAM object is Excellon don't build the CNC Tools Table but hide it self.ui.cnc_tools_table.hide() - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': self.ui.cnc_tools_table.show() self.build_cnc_tools_table() self.ui.exc_cnc_tools_table.hide() - if self.gcode_obj.options['type'].lower() == 'excellon': + if self.gcode_obj.obj_options['type'].lower() == 'excellon': self.ui.exc_cnc_tools_table.show() self.build_excellon_cnc_tools() @@ -345,11 +345,11 @@ class AppGCodeEditor(QtCore.QObject): :rtype: """ # rows selected - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': self.ui.cnc_tools_table.clicked.connect(self.on_row_selection_change) self.ui.cnc_tools_table.horizontalHeader().sectionClicked.connect(self.on_toggle_all_rows) - if self.gcode_obj.options['type'].lower() == 'excellon': + if self.gcode_obj.obj_options['type'].lower() == 'excellon': self.ui.exc_cnc_tools_table.clicked.connect(self.on_row_selection_change) self.ui.exc_cnc_tools_table.horizontalHeader().sectionClicked.connect(self.on_toggle_all_rows) @@ -360,7 +360,7 @@ class AppGCodeEditor(QtCore.QObject): :rtype: """ # rows selected - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': try: self.ui.cnc_tools_table.clicked.disconnect(self.on_row_selection_change) except (TypeError, AttributeError): @@ -370,7 +370,7 @@ class AppGCodeEditor(QtCore.QObject): except (TypeError, AttributeError): pass - if self.gcode_obj.options['type'].lower() == 'excellon': + if self.gcode_obj.obj_options['type'].lower() == 'excellon': try: self.ui.exc_cnc_tools_table.clicked.disconnect(self.on_row_selection_change) except (TypeError, AttributeError): @@ -389,9 +389,9 @@ class AppGCodeEditor(QtCore.QObject): flags = QtGui.QTextDocument.FindFlag.FindCaseSensitively self.edit_area.moveCursor(QtGui.QTextCursor.MoveOperation.Start) - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': t_table = self.ui.cnc_tools_table - elif self.gcode_obj.options['type'].lower() == 'excellon': + elif self.gcode_obj.obj_options['type'].lower() == 'excellon': t_table = self.ui.exc_cnc_tools_table else: return @@ -455,9 +455,9 @@ class AppGCodeEditor(QtCore.QObject): tool_no = int(t_table.item(row, 0).text()) text_to_be_found = None - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': text_to_be_found = self.gcode_obj.tools[tool_no]['gcode'] - elif self.gcode_obj.options['type'].lower() == 'excellon': + elif self.gcode_obj.obj_options['type'].lower() == 'excellon': tool_dia = self.app.dec_format(float(t_table.item(row, 1).text()), dec=self.decimals) for tool_id in self.gcode_obj.tools: tool_d = self.gcode_obj.tools[tool_id]['tooldia'] @@ -565,9 +565,9 @@ class AppGCodeEditor(QtCore.QObject): :return: :rtype: """ - if self.gcode_obj.options['type'].lower() == 'geometry': + if self.gcode_obj.obj_options['type'].lower() == 'geometry': t_table = self.ui.cnc_tools_table - elif self.gcode_obj.options['type'].lower() == 'excellon': + elif self.gcode_obj.obj_options['type'].lower() == 'excellon': t_table = self.ui.exc_cnc_tools_table else: return diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 51d8a5fb..0687a506 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -3273,7 +3273,7 @@ class MainGUI(QtWidgets.QMainWindow): self.app.collection.set_all_inactive() if active is None: return - active_name = active.options['name'] + active_name = active.obj_options['name'] active_index = names_list.index(active_name) if active_index == 0: self.app.collection.set_active(names_list[-1]) @@ -3288,7 +3288,7 @@ class MainGUI(QtWidgets.QMainWindow): self.app.collection.set_all_inactive() if active is None: return - active_name = active.options['name'] + active_name = active.obj_options['name'] active_index = names_list.index(active_name) if active_index == len(names_list) - 1: self.app.collection.set_active(names_list[0]) @@ -3536,7 +3536,7 @@ class MainGUI(QtWidgets.QMainWindow): self.app.ui.grid_snap_btn.trigger() # make sure that the cursor shape is enabled/disabled, too - if self.app.geo_editor.options['grid_snap'] is True: + if self.app.geo_editor.obj_options['grid_snap'] is True: self.app.app_cursor.enabled = True else: self.app.app_cursor.enabled = False @@ -3841,7 +3841,7 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key.Key_G or key == 'G': self.app.grb_editor.launched_from_shortcuts = True # make sure that the cursor shape is enabled/disabled, too - if self.app.grb_editor.options['grid_snap'] is True: + if self.app.grb_editor.obj_options['grid_snap'] is True: self.app.app_cursor.enabled = False else: self.app.app_cursor.enabled = True @@ -4014,7 +4014,7 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key.Key_G or key == 'G': self.app.exc_editor.launched_from_shortcuts = True # make sure that the cursor shape is enabled/disabled, too - if self.app.exc_editor.options['grid_snap'] is True: + if self.app.exc_editor.obj_options['grid_snap'] is True: self.app.app_cursor.enabled = False else: self.app.app_cursor.enabled = True diff --git a/appGUI/PlotCanvasLegacy.py b/appGUI/PlotCanvasLegacy.py index 42516a7c..d7aab5da 100644 --- a/appGUI/PlotCanvasLegacy.py +++ b/appGUI/PlotCanvasLegacy.py @@ -1288,7 +1288,7 @@ class ShapeCollectionLegacy: self._linewidth = linewidth if name is None: - axes_name = self.obj.options['name'] + axes_name = self.obj.obj_options['name'] else: axes_name = name @@ -1433,7 +1433,7 @@ class ShapeCollectionLegacy: if local_shapes[element]['visible'] is True: if obj_type == 'excellon': # Plot excellon (All polygons?) - if self.obj.options["solid"] and isinstance(local_shapes[element]['shape'], Polygon): + if self.obj.obj_options["solid"] and isinstance(local_shapes[element]['shape'], Polygon): try: patch = PolygonPatch(local_shapes[element]['shape'], facecolor=local_shapes[element]['face_color'], @@ -1483,12 +1483,12 @@ class ShapeCollectionLegacy: except Exception as e: self.app.log.error("ShapeCollectionLegacy.redraw() geometry no poly --> %s" % str(e)) elif obj_type == 'gerber': - if self.obj.options["multicolored"]: + if self.obj.obj_options["multicolored"]: linespec = '-' else: linespec = 'k-' - if self.obj.options["solid"]: + if self.obj.obj_options["solid"]: if update_colors: gerber_fill_color = update_colors[0] gerber_outline_color = update_colors[1] diff --git a/appObjects/AppObject.py b/appObjects/AppObject.py index 2ad7e0db..54af32a4 100644 --- a/appObjects/AppObject.py +++ b/appObjects/AppObject.py @@ -119,12 +119,12 @@ class AppObject(QtCore.QObject): obj.notHovering = True # IMPORTANT - # The key names in defaults and options dictionary's are not random: + # The key names in defaults and options dictionaries are not random: # they have to have in name first the type of the object (geometry, excellon, cncjob and gerber) or how it's # called here, the 'kind' followed by an underline. Above the App default values from self.defaults are - # copied to self.options. After that, below, depending on the type of + # copied to self.obj_options. After that, below, depending on the type of # object that is created, it will strip the name of the object and the underline (if the original key was - # let's say "excellon_toolchange", it will strip the excellon_) and to the obj.options the key will become + # let's say "excellon_toolchange", it will strip the excellon_) and to the obj.obj_options the key will become # "toolchange" # ############################################################################################################ @@ -133,27 +133,27 @@ class AppObject(QtCore.QObject): for option in self.app.options: if option.find(kind + "_") == 0: oname = option[len(kind) + 1:] - obj.options[oname] = self.app.options[option] + obj.obj_options[oname] = self.app.options[option] # add some of the FlatCAM Tools related properties # it is done like this to preserve some kind of order in the keys if kind == 'excellon': for option in self.app.options: if option.find('tools_drill_') == 0: - obj.options[option] = self.app.options[option] + obj.obj_options[option] = self.app.options[option] if kind == 'gerber': for option in self.app.options: if option.find('tools_iso_') == 0: - obj.options[option] = self.app.options[option] + obj.obj_options[option] = self.app.options[option] # the milling options should be inherited by all manufacturing objects if kind in ['excellon', 'gerber', 'geometry', 'cncjob']: for option in self.app.options: if option.find('tools_mill_') == 0: - obj.options[option] = self.app.options[option] + obj.obj_options[option] = self.app.options[option] for option in self.app.options: if option.find('tools_') == 0: - obj.options[option] = self.app.options[option] + obj.obj_options[option] = self.app.options[option] # ############################################################################################################ # ############################################################################################################ @@ -193,16 +193,16 @@ class AppObject(QtCore.QObject): self.app.log.debug("%f seconds converting units." % (t3 - t2)) # ############################################################################################################ - # Create the bounding box for the object and then add the results to the obj.options + # Create the bounding box for the object and then add the results to the obj.obj_options # But not for Scripts or for Documents # ############################################################################################################ if kind != 'document' and kind != 'script': try: xmin, ymin, xmax, ymax = obj.bounds() - obj.options['xmin'] = xmin - obj.options['ymin'] = ymin - obj.options['xmax'] = xmax - obj.options['ymax'] = ymax + obj.obj_options['xmin'] = xmin + obj.obj_options['ymin'] = ymin + obj.obj_options['xmax'] = xmax + obj.obj_options['ymax'] = ymax except Exception as e: self.app.log.error("AppObject.new_object() -> The object has no bounds properties. %s" % str(e)) return "fail" @@ -252,7 +252,7 @@ class AppObject(QtCore.QObject): self.app.all_objects_list = self.app.collection.get_list() # self.app.inform.emit('[selected] %s created & selected: %s' % - # (str(obj.kind).capitalize(), str(obj.options['name']))) + # (str(obj.kind).capitalize(), str(obj.obj_options['name']))) # ############################################################################################################# # ###################### Set colors for the message in the Status Bar ####################################### @@ -261,37 +261,37 @@ class AppObject(QtCore.QObject): self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='green', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) elif obj.kind == 'excellon': self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='brown', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) elif obj.kind == 'cncjob': self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='blue', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) elif obj.kind == 'geometry': self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='red', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) elif obj.kind == 'script': self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='orange', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) elif obj.kind == 'document': self.app.inform.emit('[selected] {kind} {tx}: {name}'.format( kind=obj.kind.capitalize(), color='darkCyan', - name=str(obj.options['name']), tx=_("created/selected")) + name=str(obj.obj_options['name']), tx=_("created/selected")) ) # ############################################################################################################ @@ -344,7 +344,7 @@ class AppObject(QtCore.QObject): if auto_select or self.app.ui.notebook.currentWidget() is self.app.ui.properties_tab: # select the just opened object but deselect the previous ones self.app.collection.set_all_inactive() - self.app.collection.set_active(obj.options["name"]) + self.app.collection.set_active(obj.obj_options["name"]) else: self.app.collection.set_all_inactive() @@ -380,7 +380,7 @@ class AppObject(QtCore.QObject): """ Called whenever the geometry of the object was changed in some way. This require the update of it's bounding values so it can be the selected on canvas. - Update the bounding box data from obj.options + Update the bounding box data from obj.obj_options :param obj: the object that was changed :return: None @@ -390,12 +390,12 @@ class AppObject(QtCore.QObject): xmin, ymin, xmax, ymax = obj.bounds() except TypeError: return - obj.options['xmin'] = xmin - obj.options['ymin'] = ymin - obj.options['xmax'] = xmax - obj.options['ymax'] = ymax + obj.obj_options['xmin'] = xmin + obj.obj_options['ymin'] = ymin + obj.obj_options['xmax'] = xmax + obj.obj_options['ymax'] = ymax - self.app.log.debug("Object changed, updating the bounding box data on self.options") + self.app.log.debug("Object changed, updating the bounding box data on self.obj_options") # delete the old selection shape self.app.delete_selection_shape() self.app.should_we_save = True @@ -489,10 +489,10 @@ class AppObject(QtCore.QObject): new_obj.follow_geometry = [] try: - new_obj.options['xmin'] = 0 - new_obj.options['ymin'] = 0 - new_obj.options['xmax'] = 0 - new_obj.options['ymax'] = 0 + new_obj.obj_options['xmin'] = 0 + new_obj.obj_options['ymin'] = 0 + new_obj.obj_options['xmax'] = 0 + new_obj.obj_options['ymax'] = 0 except KeyError: pass diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index a0e8cfea..6e1c0b04 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -56,7 +56,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.kind = "cncjob" - self.options.update({ + self.obj_options.update({ "plot": True, "tooldia": 0.03937, # 0.4mm in inches "append": "", @@ -191,11 +191,11 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.cnc_tools_table.hide() self.ui.exc_cnc_tools_table.hide() - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': self.build_cnc_tools_table() self.ui.cnc_tools_table.show() - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': try: self.build_excellon_cnc_tools() except Exception as err: @@ -651,7 +651,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.app.defaults.report_usage("cncjob_on_exportgcode_button") self.read_form() - name = self.app.collection.get_active().options['name'] + name = self.app.collection.get_active().obj_options['name'] save_gcode = False if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name: @@ -833,7 +833,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): start_comment = comment_start_symbol if comment_start_symbol is not None else '(' stop_comment = comment_stop_symbol if comment_stop_symbol is not None else ')' - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': try: for key in self.tools: ppg = self.tools[key]['data']['tools_mill_ppname_g'] @@ -853,22 +853,22 @@ class CNCJobObject(FlatCAMObj, CNCjob): pass try: - if 'marlin' in self.options['tools_drill_ppname_e'].lower() or \ - 'repetier' in self.options['tools_drill_ppname_e'].lower(): + if 'marlin' in self.obj_options['tools_drill_ppname_e'].lower() or \ + 'repetier' in self.obj_options['tools_drill_ppname_e'].lower(): marlin = True except KeyError: # self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) pass try: - if "toolchange_probe" in self.options['tools_drill_ppname_e'].lower(): + if "toolchange_probe" in self.obj_options['tools_drill_ppname_e'].lower(): probe_pp = True except KeyError: # self.app.log.debug("FlatCAMCNCJob.gcode_header(): --> There is no such self.option: %s" % str(e)) pass try: - if 'nccad' in self.options['tools_drill_ppname_e'].lower(): + if 'nccad' in self.obj_options['tools_drill_ppname_e'].lower(): nccad_pp = True except KeyError: pass @@ -877,8 +877,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): gcode += ';Marlin(Repetier) G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \ (str(self.app.version), str(self.app.version_date)) + '\n' - gcode += ';Name: ' + str(self.options['name']) + '\n' - gcode += ';Type: ' + "G-code from " + str(self.options['type']) + '\n' + gcode += ';Name: ' + str(self.obj_options['name']) + '\n' + gcode += ';Type: ' + "G-code from " + str(self.obj_options['type']) + '\n' gcode += ';Units: ' + self.units.upper() + '\n' + "\n" gcode += ';Created on ' + time_str + '\n' + '\n' @@ -886,8 +886,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): gcode += 'CO "HPGL CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s' % \ (str(self.app.version), str(self.app.version_date)) + '";\n' - gcode += 'CO "Name: ' + str(self.options['name']) + '";\n' - gcode += 'CO "Type: ' + "HPGL code from " + str(self.options['type']) + '";\n' + gcode += 'CO "Name: ' + str(self.obj_options['name']) + '";\n' + gcode += 'CO "Type: ' + "HPGL code from " + str(self.obj_options['type']) + '";\n' gcode += 'CO "Units: ' + self.units.upper() + '";\n' gcode += 'CO "Created on ' + time_str + '";\n' @@ -901,8 +901,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): '(mount the probe and adjust the Z so more or less the probe tip touch the plate. ' \ 'Then zero the Z axis.)\n' + '\n' - gcode += '(Name: ' + str(self.options['name']) + ')\n' - gcode += '(Type: ' + "G-code from " + str(self.options['type']) + ')\n' + gcode += '(Name: ' + str(self.obj_options['name']) + ')\n' + gcode += '(Type: ' + "G-code from " + str(self.obj_options['type']) + ')\n' gcode += '(Units: ' + self.units.upper() + ')\n' + "\n" gcode += '(Created on ' + time_str + ')\n' + '\n' @@ -910,8 +910,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): gcode += ';NCCAD9 G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s\n' % \ (str(self.app.version), str(self.app.version_date)) + '\n' - gcode += ';Name: ' + str(self.options['name']) + '\n' - gcode += ';Type: ' + "G-code from " + str(self.options['type']) + '\n' + gcode += ';Name: ' + str(self.obj_options['name']) + '\n' + gcode += ';Type: ' + "G-code from " + str(self.obj_options['type']) + '\n' gcode += ';Units: ' + self.units.upper() + '\n' + "\n" gcode += ';Created on ' + time_str + '\n' + '\n' @@ -919,8 +919,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): gcode += '%sG-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s%s\n' % \ (start_comment, str(self.app.version), str(self.app.version_date), stop_comment) + '\n' - gcode += '%sName: ' % start_comment + str(self.options['name']) + '%s\n' % stop_comment - gcode += '%sType: ' % start_comment + "G-code from " + str(self.options['type']) + '%s\n' % stop_comment + gcode += '%sName: ' % start_comment + str(self.obj_options['name']) + '%s\n' % stop_comment + gcode += '%sType: ' % start_comment + "G-code from " + str(self.obj_options['type']) + '%s\n' % stop_comment gcode += '%sUnits: ' % start_comment + self.units.upper() + '%s\n' % stop_comment + "\n" gcode += '%sCreated on ' % start_comment + time_str + '%s\n' % stop_comment + '\n' @@ -974,7 +974,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): pass # if this dict is not empty then the object is a Geometry object - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': # for the case that self.tools is empty: old projects try: first_key = list(self.tools.keys())[0] @@ -984,7 +984,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): include_header = self.app.preprocessors['default'].include_header # if this dict is not empty then the object is an Excellon object - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': # for the case that self.tools is empty: old projects try: first_key = list(self.tools.keys())[0] @@ -1006,7 +1006,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # detect if using multi-tool and make the Gcode summation correctly for each case if self.multitool is True: try: - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': for tooluid_key in self.tools: for key, value in self.tools[tooluid_key].items(): if key == 'gcode': @@ -1033,7 +1033,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): if self.multitool is True: # for the case that self.tools is empty: old projects try: - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': for tooluid_key in self.tools: for key, value in self.tools[tooluid_key].items(): if key == 'gcode' and value: @@ -1057,13 +1057,13 @@ class CNCJobObject(FlatCAMObj, CNCjob): hpgl = False # for the case that self.tools is empty: old projects try: - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': for key in self.tools: if 'tools_mill_ppname_g' in self.tools[key]['data']: if 'hpgl' in self.tools[key]['data']['tools_mill_ppname_g']: hpgl = True break - elif self.options['type'].lower() == 'excellon': + elif self.obj_options['type'].lower() == 'excellon': for key in self.tools: if 'ppname_e' in self.tools[key]['data']: if 'hpgl' in self.tools[key]['data']['ppname_e']: @@ -1176,7 +1176,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): # """ # # try: - # if 'toolchange_custom' not in str(self.options['ppname_e']).lower(): + # if 'toolchange_custom' not in str(self.obj_options['ppname_e']).lower(): # if self.ui.toolchange_cb.get_value(): # self.ui.toolchange_cb.set_value(False) # self.app.inform.emit('[WARNING_NOTCL] %s' % @@ -1252,7 +1252,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): kind = self.ui.cncplot_method_combo.get_value() self.shapes.clear(update=True) - if self.options['type'].lower() == "excellon": + if self.obj_options['type'].lower() == "excellon": for r in range(self.ui.exc_cnc_tools_table.rowCount()): row_dia = float('%.*f' % (self.decimals, float(self.ui.exc_cnc_tools_table.item(r, 1).text()))) for tooluid_key in self.tools: @@ -1302,35 +1302,35 @@ class CNCJobObject(FlatCAMObj, CNCjob): if not FlatCAMObj.plot(self): return - visible = visible if visible else self.options['plot'] + visible = visible if visible else self.obj_options['plot'] # Geometry shapes plotting try: if self.multitool is False: # single tool usage dia_plot = dia if dia_plot is None: - if self.options['type'].lower() == "excellon": + if self.obj_options['type'].lower() == "excellon": try: - dia_plot = float(self.options["tooldia"]) + dia_plot = float(self.obj_options["tooldia"]) except ValueError: # we may have a tuple with only one element and a comma - dia_plot = [float(el) for el in self.options["tooldia"].split(',') if el != ''][0] + dia_plot = [float(el) for el in self.obj_options["tooldia"].split(',') if el != ''][0] else: # try: - # dia_plot = float(self.options["tools_mill_tooldia"]) + # dia_plot = float(self.obj_options["tools_mill_tooldia"]) # except ValueError: # # we may have a tuple with only one element and a comma # dia_plot = [ - # float(el) for el in self.options["tools_mill_tooldia"].split(',') if el != '' + # float(el) for el in self.obj_options["tools_mill_tooldia"].split(',') if el != '' # ][0] - dia_plot = float(self.options["cncjob_tooldia"]) + dia_plot = float(self.obj_options["cncjob_tooldia"]) self.plot2(tooldia=dia_plot, obj=self, visible=visible, kind=kind) else: # I do this so the travel lines thickness will reflect the tool diameter # may work only for objects created within the app and not Gcode imported from elsewhere for which we # don't know the origin - if self.options['type'].lower() == "excellon": + if self.obj_options['type'].lower() == "excellon": if self.tools: for toolid_key in self.tools: dia_plot = self.app.dec_format(float(self.tools[toolid_key]['tooldia']), self.decimals) @@ -1406,7 +1406,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.app.log.debug("FlatCAMObj.FlatCAMECNCjob.convert_units()") factor = CNCjob.convert_units(self, units) - self.options["tooldia"] = float(self.options["tooldia"]) * factor + self.obj_options["tooldia"] = float(self.obj_options["tooldia"]) * factor param_list = ['cutz', 'depthperpass', 'travelz', 'feedrate', 'feedrate_z', 'feedrate_rapid', 'endz', 'toolchangez'] diff --git a/appObjects/FlatCAMDocument.py b/appObjects/FlatCAMDocument.py index e8c5b754..a0ca68df 100644 --- a/appObjects/FlatCAMDocument.py +++ b/appObjects/FlatCAMDocument.py @@ -162,14 +162,14 @@ class DocumentObject(FlatCAMObj): # try to not add too many times a tab that it is already installed for idx in range(self.app.ui.plot_tab_area.count()): - if self.app.ui.plot_tab_area.widget(idx).objectName() == self.options['name'] + "_editor_tab": + if self.app.ui.plot_tab_area.widget(idx).objectName() == self.obj_options['name'] + "_editor_tab": tab_here = True break # add the tab if it is not already added if tab_here is False: self.app.ui.plot_tab_area.addTab(self.document_editor_tab, '%s' % _("Document Editor")) - self.document_editor_tab.setObjectName(self.options['name'] + "_editor_tab") + self.document_editor_tab.setObjectName(self.obj_options['name'] + "_editor_tab") # Switch plot_area to CNCJob tab self.app.ui.plot_tab_area.setCurrentWidget(self.document_editor_tab) diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index 88466eb4..cd1deaf8 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -47,7 +47,7 @@ class ExcellonObject(FlatCAMObj, Excellon): self.kind = "excellon" - self.options.update({ + self.obj_options.update({ "plot": True, "solid": False, "multicolored": False, @@ -123,12 +123,12 @@ class ExcellonObject(FlatCAMObj, Excellon): self.units = self.app.app_units.upper() - # # fill in self.options values for the Drilling Tool from self.app.options + # # fill in self.obj_options values for the Drilling Tool from self.app.options # for opt_key, opt_val in self.app.options.items(): # if opt_key.find('tools_drill_') == 0: - # self.options[opt_key] = deepcopy(opt_val) + # self.obj_options[opt_key] = deepcopy(opt_val) # - # # fill in self.default_data values from self.options + # # fill in self.default_data values from self.obj_options # for opt_key, opt_val in self.app.options.items(): # if opt_key.find('excellon_') == 0 or opt_key.find('tools_drill_') == 0: # self.default_data[opt_key] = deepcopy(opt_val) @@ -282,8 +282,8 @@ class ExcellonObject(FlatCAMObj, Excellon): tools = [i[0] for i in sorted_tools] new_options = {} - for opt in self.options: - new_options[opt] = self.options[opt] + for opt in self.obj_options: + new_options[opt] = self.obj_options[opt] for tool_no in tools: try: @@ -919,7 +919,7 @@ class ExcellonObject(FlatCAMObj, Excellon): tools = self.get_selected_tools_list() if outname is None: - outname = self.options["name"] + "_mill" + outname = self.obj_options["name"] + "_mill" if tooldia is None: tooldia = self.ui.tooldia_entry.get_value() @@ -962,9 +962,9 @@ class ExcellonObject(FlatCAMObj, Excellon): # ## Add properties to the object - geo_obj.options['type'] = 'Excellon Geometry' - geo_obj.options["tools_mill_tooldia"] = str(tooldia) - geo_obj.options["multidepth"] = app_obj.defaults["tools_mill_multidepth"] + geo_obj.obj_options['type'] = 'Excellon Geometry' + geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia) + geo_obj.obj_options["multidepth"] = app_obj.defaults["tools_mill_multidepth"] geo_obj.solid_geometry = [] # in case that the tool used has the same diameter with the hole, and since the maximum resolution @@ -1024,10 +1024,10 @@ class ExcellonObject(FlatCAMObj, Excellon): tools = self.get_selected_tools_list() if outname is None: - outname = self.options["name"] + "_mill" + outname = self.obj_options["name"] + "_mill" if tooldia is None: - tooldia = float(self.options["slot_tooldia"]) + tooldia = float(self.obj_options["slot_tooldia"]) # Sort tools by diameter. items() -> [('name', diameter), ...] # sorted_tools = sorted(list(self.tools.items()), key=lambda tl: tl[1]) # no longer works in Python3 @@ -1059,9 +1059,9 @@ class ExcellonObject(FlatCAMObj, Excellon): # ## Add properties to the object - geo_obj.options['type'] = 'Excellon Geometry' - geo_obj.options["tools_mill_tooldia"] = str(tooldia) - geo_obj.options["tools_mill_multidepth"] = app_obj.defaults["tools_mill_multidepth"] + geo_obj.obj_options['type'] = 'Excellon Geometry' + geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia) + geo_obj.obj_options["tools_mill_multidepth"] = app_obj.defaults["tools_mill_multidepth"] geo_obj.solid_geometry = [] # in case that the tool used has the same diameter with the hole, and since the maximum resolution @@ -1122,14 +1122,14 @@ class ExcellonObject(FlatCAMObj, Excellon): Excellon.convert_units(self, units) # factor = Excellon.convert_units(self, units) - # self.options['drillz'] = float(self.options['drillz']) * factor - # self.options['travelz'] = float(self.options['travelz']) * factor - # self.options['feedrate'] = float(self.options['feedrate']) * factor - # self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor - # self.options['toolchangez'] = float(self.options['toolchangez']) * factor + # self.obj_options['drillz'] = float(self.obj_options['drillz']) * factor + # self.obj_options['travelz'] = float(self.obj_options['travelz']) * factor + # self.obj_options['feedrate'] = float(self.obj_options['feedrate']) * factor + # 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"] == '': - # self.options['toolchangexy'] = "0.0, 0.0" + # self.obj_options['toolchangexy'] = "0.0, 0.0" # else: # coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")] # if len(coords_xy) < 2: @@ -1139,11 +1139,11 @@ class ExcellonObject(FlatCAMObj, Excellon): # return 'fail' # coords_xy[0] *= factor # coords_xy[1] *= factor - # self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) + # self.obj_options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) # - # if self.options['startz'] is not None: - # self.options['startz'] = float(self.options['startz']) * factor - # self.options['endz'] = float(self.options['endz']) * factor + # if self.obj_options['startz'] is not None: + # self.obj_options['startz'] = float(self.obj_options['startz']) * factor + # self.obj_options['endz'] = float(self.obj_options['endz']) * factor def on_solid_cb_click(self): if self.muted_ui: @@ -1332,10 +1332,10 @@ class ExcellonObject(FlatCAMObj, Excellon): for exc in flattened_list: # copy options of the current excellon obj to the final excellon obj # only the last object options will survive - for option in exc.options: + for option in exc.obj_options: if option != 'name': try: - exc_final.options[option] = deepcopy(exc.options[option]) + exc_final.obj_options[option] = deepcopy(exc.obj_options[option]) except Exception: if log: log.warning("Failed to copy option.", option) diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 2ecf71af..f7bd554d 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -54,7 +54,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.kind = "geometry" - self.options.update({ + self.obj_options.update({ "plot": True, "multicolored": False, @@ -88,18 +88,18 @@ class GeometryObject(FlatCAMObj, Geometry): "tools_mill_feedrate_probe": 3.0, }) - if "tools_mill_tooldia" not in self.options: + if "tools_mill_tooldia" not in self.obj_options: if type(self.app.defaults["tools_mill_tooldia"]) == float: - self.options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"] + self.obj_options["tools_mill_tooldia"] = self.app.defaults["tools_mill_tooldia"] else: try: tools_string = self.app.defaults["tools_mill_tooldia"].split(",") tools_diameters = [eval(a) for a in tools_string if a != ''] - self.options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 + 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.options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"] + self.obj_options["tools_mill_startz"] = self.app.defaults["tools_mill_startz"] # this will hold the tool unique ID that is useful when having multiple tools with same diameter self.tooluid = 0 @@ -311,14 +311,14 @@ class GeometryObject(FlatCAMObj, Geometry): # store here the default data for Geometry Data self.default_data = {} - # fill in self.default_data values from self.options - self.default_data.update(self.options) + # fill in self.default_data values from self.obj_options + self.default_data.update(self.obj_options) - if type(self.options["tools_mill_tooldia"]) == float: - tools_list = [self.options["tools_mill_tooldia"]] + if type(self.obj_options["tools_mill_tooldia"]) == float: + tools_list = [self.obj_options["tools_mill_tooldia"]] else: try: - temp_tools = self.options["tools_mill_tooldia"].split(",") + temp_tools = self.obj_options["tools_mill_tooldia"].split(",") tools_list = [ float(eval(dia)) for dia in temp_tools if dia != '' ] @@ -635,17 +635,17 @@ class GeometryObject(FlatCAMObj, Geometry): """ # use the name of the first tool selected in self.geo_tools_table which has the diameter passed as tool_dia - outname = "%s_%s" % (self.options["name"], 'cnc') if outname is None else outname + 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']) try: - xmin = self.options['xmin'] - ymin = self.options['ymin'] - xmax = self.options['xmax'] - ymax = self.options['ymax'] + xmin = self.obj_options['xmin'] + ymin = self.obj_options['ymin'] + xmax = self.obj_options['xmax'] + ymax = self.obj_options['ymax'] except Exception as e: self.app.log.error("FlatCAMObj.GeometryObject.mtool_gen_cncjob() --> %s\n" % str(e)) @@ -664,10 +664,10 @@ class GeometryObject(FlatCAMObj, Geometry): self.app.log.debug("Creating a CNCJob out of a single-geometry") assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj) - job_obj.options['xmin'] = xmin - job_obj.options['ymin'] = ymin - job_obj.options['xmax'] = xmax - job_obj.options['ymax'] = ymax + job_obj.obj_options['xmin'] = xmin + job_obj.obj_options['ymin'] = ymin + job_obj.obj_options['xmax'] = xmax + job_obj.obj_options['ymax'] = ymax # count the tools tool_cnt = 0 @@ -736,7 +736,7 @@ class GeometryObject(FlatCAMObj, Geometry): toolchangexy = tools_dict[tooluid_key]['data']["tools_mill_toolchangexy"] startz = tools_dict[tooluid_key]['data']["tools_mill_startz"] endz = tools_dict[tooluid_key]['data']["tools_mill_endz"] - endxy = self.options["tools_mill_endxy"] + endxy = self.obj_options["tools_mill_endxy"] spindlespeed = tools_dict[tooluid_key]['data']["tools_mill_spindlespeed"] dwell = tools_dict[tooluid_key]['data']["tools_mill_dwell"] dwelltime = tools_dict[tooluid_key]['data']["tools_mill_dwelltime"] @@ -749,9 +749,9 @@ class GeometryObject(FlatCAMObj, Geometry): job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] # Propagate options - job_obj.options["tooldia"] = tooldia_val - job_obj.options['type'] = 'Geometry' - job_obj.options['tool_dia'] = tooldia_val + job_obj.obj_options["tooldia"] = tooldia_val + job_obj.obj_options['type'] = 'Geometry' + job_obj.obj_options['tool_dia'] = tooldia_val tool_lst = list(tools_dict.keys()) is_first = True if tooluid_key == tool_lst[0] else False @@ -806,10 +806,10 @@ class GeometryObject(FlatCAMObj, Geometry): self.app.log.debug("Creating a CNCJob out of a multi-geometry") assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj) - job_obj.options['xmin'] = xmin - job_obj.options['ymin'] = ymin - job_obj.options['xmax'] = xmax - job_obj.options['ymax'] = ymax + job_obj.obj_options['xmin'] = xmin + job_obj.obj_options['ymin'] = ymin + job_obj.obj_options['xmax'] = xmax + job_obj.obj_options['ymax'] = ymax # count the tools tool_cnt = 0 @@ -890,7 +890,7 @@ class GeometryObject(FlatCAMObj, Geometry): # toolchangexy = tools_dict[tooluid_key]['data']["toolchangexy"] # startz = tools_dict[tooluid_key]['data']["startz"] # endz = tools_dict[tooluid_key]['data']["endz"] - # endxy = self.options["endxy"] + # endxy = self.obj_options["endxy"] # spindlespeed = tools_dict[tooluid_key]['data']["spindlespeed"] # dwell = tools_dict[tooluid_key]['data']["dwell"] # dwelltime = tools_dict[tooluid_key]['data']["dwelltime"] @@ -903,9 +903,9 @@ class GeometryObject(FlatCAMObj, Geometry): job_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] # Propagate options - job_obj.options["tooldia"] = tooldia_val - job_obj.options['type'] = 'Geometry' - job_obj.options['tool_dia'] = tooldia_val + job_obj.obj_options["tooldia"] = tooldia_val + job_obj.obj_options['type'] = 'Geometry' + job_obj.obj_options['tool_dia'] = tooldia_val # 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 @@ -1020,55 +1020,55 @@ class GeometryObject(FlatCAMObj, Geometry): self.app.log.debug("FlatCAMGeometry.GeometryObject.generatecncjob()") - tooldia = dia if dia else float(self.options["tools_mill_tooldia"]) - outname = outname if outname is not None else self.options["name"] + tooldia = dia if dia else float(self.obj_options["tools_mill_tooldia"]) + outname = outname if outname is not None else self.obj_options["name"] - z_cut = z_cut if z_cut is not None else float(self.options["tools_mill_cutz"]) - z_move = z_move if z_move is not None else float(self.options["tools_mill_travelz"]) + z_cut = z_cut if z_cut is not None else float(self.obj_options["tools_mill_cutz"]) + z_move = z_move if z_move is not None else float(self.obj_options["tools_mill_travelz"]) - feedrate = feedrate if feedrate is not None else float(self.options["tools_mill_feedrate"]) - feedrate_z = feedrate_z if feedrate_z is not None else float(self.options["tools_mill_feedrate_z"]) - feedrate_rapid = feedrate_rapid if feedrate_rapid is not None else float(self.options[ + feedrate = feedrate if feedrate is not None else float(self.obj_options["tools_mill_feedrate"]) + feedrate_z = feedrate_z if feedrate_z is not None else float(self.obj_options["tools_mill_feedrate_z"]) + feedrate_rapid = feedrate_rapid if feedrate_rapid is not None else float(self.obj_options[ "tools_mill_feedrate_rapid"]) - multidepth = multidepth if multidepth is not None else self.options["tools_mill_multidepth"] - depthperpass = dpp if dpp is not None else float(self.options["tools_mill_depthperpass"]) + 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']) - extracut = extracut if extracut is not None else float(self.options["tools_mill_extracut"]) - extracut_length = extracut_length if extracut_length is not None else float(self.options[ + 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[ "tools_mill_extracut_length"]) - startz = startz if startz is not None else self.options["tools_mill_startz"] - endz = endz if endz is not None else float(self.options["tools_mill_endz"]) + startz = startz if startz is not None else self.obj_options["tools_mill_startz"] + endz = endz if endz is not None else float(self.obj_options["tools_mill_endz"]) - endxy = endxy if endxy else self.options["tools_mill_endxy"] + endxy = endxy if endxy else self.obj_options["tools_mill_endxy"] if isinstance(endxy, str): endxy = re.sub('[()\[\]]', '', endxy) if endxy and endxy != '': endxy = [float(eval(a)) for a in endxy.split(",")] - toolchangez = toolchangez if toolchangez else float(self.options["tools_mill_toolchangez"]) + toolchangez = toolchangez if toolchangez else float(self.obj_options["tools_mill_toolchangez"]) - toolchangexy = toolchangexy if toolchangexy else self.options["tools_mill_toolchangexy"] + toolchangexy = toolchangexy if toolchangexy else self.obj_options["tools_mill_toolchangexy"] if isinstance(toolchangexy, str): toolchangexy = re.sub('[()\[\]]', '', toolchangexy) if toolchangexy and toolchangexy != '': toolchangexy = [float(eval(a)) for a in toolchangexy.split(",")] - toolchange = toolchange if toolchange else self.options["tools_mill_toolchange"] + toolchange = toolchange if toolchange else self.obj_options["tools_mill_toolchange"] offset = offset if offset else 0.0 # int or None. - spindlespeed = spindlespeed if spindlespeed else self.options['tools_mill_spindlespeed'] - las_min_pwr = las_min_pwr if las_min_pwr else self.options['tools_mill_min_power'] - dwell = dwell if dwell else self.options["tools_mill_dwell"] - dwelltime = dwelltime if dwelltime else float(self.options["tools_mill_dwelltime"]) + spindlespeed = spindlespeed if spindlespeed else self.obj_options['tools_mill_spindlespeed'] + las_min_pwr = las_min_pwr if las_min_pwr else self.obj_options['tools_mill_min_power'] + dwell = dwell if dwell else self.obj_options["tools_mill_dwell"] + dwelltime = dwelltime if dwelltime else float(self.obj_options["tools_mill_dwelltime"]) - ppname_g = pp if pp else self.options["tools_mill_ppname_g"] + ppname_g = pp if pp else self.obj_options["tools_mill_ppname_g"] # Object initialization function for app.app_obj.new_object() # RUNNING ON SEPARATE THREAD! @@ -1076,25 +1076,25 @@ class GeometryObject(FlatCAMObj, Geometry): assert job_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(job_obj) # Propagate options - job_obj.options["tooldia"] = tooldia - job_obj.options["tools_mill_tooldia"] = tooldia + 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.options['type'] = 'Geometry' - job_obj.options['tool_dia'] = tooldia + job_obj.obj_options['type'] = 'Geometry' + job_obj.obj_options['tool_dia'] = tooldia job_obj.segx = segx job_obj.segy = segy - job_obj.z_pdepth = float(self.options["tools_mill_z_pdepth"]) - job_obj.feedrate_probe = float(self.options["tools_mill_feedrate_probe"]) + job_obj.z_pdepth = float(self.obj_options["tools_mill_z_pdepth"]) + job_obj.feedrate_probe = float(self.obj_options["tools_mill_feedrate_probe"]) - job_obj.options['xmin'] = self.options['xmin'] - job_obj.options['ymin'] = self.options['ymin'] - job_obj.options['xmax'] = self.options['xmax'] - job_obj.options['ymax'] = self.options['ymax'] + job_obj.obj_options['xmin'] = self.obj_options['xmin'] + job_obj.obj_options['ymin'] = self.obj_options['ymin'] + job_obj.obj_options['xmax'] = self.obj_options['xmax'] + job_obj.obj_options['ymax'] = self.obj_options['ymax'] # 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 @@ -1305,22 +1305,22 @@ class GeometryObject(FlatCAMObj, Geometry): factor = Geometry.convert_units(self, units) - self.options['cutz'] = float(self.options['cutz']) * factor - self.options['depthperpass'] = float(self.options['depthperpass']) * factor - self.options['travelz'] = float(self.options['travelz']) * factor - self.options['feedrate'] = float(self.options['feedrate']) * factor - self.options['feedrate_z'] = float(self.options['feedrate_z']) * factor - self.options['feedrate_rapid'] = float(self.options['feedrate_rapid']) * factor - self.options['endz'] = float(self.options['endz']) * factor - # self.options['tools_mill_tooldia'] *= factor - # self.options['painttooldia'] *= factor - # self.options['paintmargin'] *= factor - # self.options['paintoverlap'] *= factor + self.obj_options['cutz'] = float(self.obj_options['cutz']) * factor + self.obj_options['depthperpass'] = float(self.obj_options['depthperpass']) * factor + self.obj_options['travelz'] = float(self.obj_options['travelz']) * factor + self.obj_options['feedrate'] = float(self.obj_options['feedrate']) * factor + self.obj_options['feedrate_z'] = float(self.obj_options['feedrate_z']) * factor + self.obj_options['feedrate_rapid'] = float(self.obj_options['feedrate_rapid']) * factor + self.obj_options['endz'] = float(self.obj_options['endz']) * factor + # self.obj_options['tools_mill_tooldia'] *= factor + # self.obj_options['painttooldia'] *= factor + # self.obj_options['paintmargin'] *= factor + # self.obj_options['paintoverlap'] *= factor - self.options["toolchangez"] = float(self.options["toolchangez"]) * factor + self.obj_options["toolchangez"] = float(self.obj_options["toolchangez"]) * factor if self.app.defaults["tools_mill_toolchangexy"] == '': - self.options['toolchangexy'] = "0.0, 0.0" + self.obj_options['toolchangexy'] = "0.0, 0.0" else: coords_xy = [float(eval(coord)) for coord in self.app.defaults["tools_mill_toolchangexy"].split(",")] if len(coords_xy) < 2: @@ -1332,10 +1332,10 @@ class GeometryObject(FlatCAMObj, Geometry): return 'fail' coords_xy[0] *= factor coords_xy[1] *= factor - self.options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) + self.obj_options['toolchangexy'] = "%f, %f" % (coords_xy[0], coords_xy[1]) - if self.options['startz'] is not None: - self.options['startz'] = float(self.options['startz']) * factor + if self.obj_options['startz'] is not None: + self.obj_options['startz'] = float(self.obj_options['startz']) * factor param_list = ['cutz', 'depthperpass', 'travelz', 'feedrate', 'feedrate_z', 'feedrate_rapid', 'endz', 'toolchangez'] @@ -1404,7 +1404,7 @@ class GeometryObject(FlatCAMObj, Geometry): if color is None: color = '#FF0000FF' - visible = visible if visible else self.options['plot'] + visible = visible if visible else self.obj_options['plot'] try: if isinstance(element, (MultiPolygon, MultiLineString)): for sub_el in element.geoms: @@ -1464,7 +1464,7 @@ class GeometryObject(FlatCAMObj, Geometry): if 'override_color' in self.tools[tooluid_key]['data']: color = self.tools[tooluid_key]['data']['override_color'] else: - color = random_color() if self.options['multicolored'] else \ + color = random_color() if self.obj_options['multicolored'] else \ self.app.defaults["geometry_plot_line"] self.plot_element(solid_geometry, visible=visible, color=color) @@ -1473,7 +1473,7 @@ class GeometryObject(FlatCAMObj, Geometry): if 'override_color' in self.tools[plot_tool]['data']: color = self.tools[plot_tool]['data']['override_color'] else: - color = random_color() if self.options['multicolored'] else \ + color = random_color() if self.obj_options['multicolored'] else \ self.app.defaults["geometry_plot_line"] self.plot_element(solid_geometry, visible=visible, color=color) @@ -1486,7 +1486,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.plot_element(solid_geometry, visible=visible, color=color) - # self.plot_element(self.solid_geometry, visible=self.options['plot']) + # self.plot_element(self.solid_geometry, visible=self.obj_options['plot']) self.shapes.redraw() @@ -1581,10 +1581,10 @@ class GeometryObject(FlatCAMObj, Geometry): new_tools = {} for geo_obj in geo_list: - for option in geo_obj.options: + for option in geo_obj.obj_options: if option != 'name': try: - new_options[option] = deepcopy(geo_obj.options[option]) + new_options[option] = deepcopy(geo_obj.obj_options[option]) except Exception as e: if log: log.error("Failed to copy option %s. Error: %s" % (str(option), str(e))) @@ -1619,7 +1619,7 @@ class GeometryObject(FlatCAMObj, Geometry): max_uid += 1 new_tools[max_uid] = deepcopy(geo_obj.tools[tool_uid]) - geo_final.options.update(new_options) + geo_final.obj_options.update(new_options) geo_final.solid_geometry = new_solid_geometry if new_tools and fuse_tools is True: diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index e79a28cc..4c455aca 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -50,9 +50,9 @@ class GerberObject(FlatCAMObj, Gerber): self.kind = "gerber" - # The 'name' is already in self.options from FlatCAMObj + # The 'name' is already in self.obj_options from FlatCAMObj # Automatically updates the UI - self.options.update({ + self.obj_options.update({ "plot": True, "multicolored": False, "solid": False, @@ -444,7 +444,7 @@ class GerberObject(FlatCAMObj, Gerber): self.app.defaults.report_usage("gerber_on_generatenoncopper_button") self.read_form() - name = self.options["name"] + "_noncopper" + name = self.obj_options["name"] + "_noncopper" def geo_init(geo_obj, app_obj): assert geo_obj.kind == 'geometry', "Expected a Geometry object got %s" % type(geo_obj) @@ -455,8 +455,8 @@ class GerberObject(FlatCAMObj, Gerber): except Exception: self.solid_geometry = unary_union(self.solid_geometry) - bounding_box = self.solid_geometry.envelope.buffer(float(self.options["noncoppermargin"])) - if not self.options["noncopperrounded"]: + bounding_box = self.solid_geometry.envelope.buffer(float(self.obj_options["noncoppermargin"])) + if not self.obj_options["noncopperrounded"]: bounding_box = bounding_box.envelope non_copper = bounding_box.difference(self.solid_geometry) non_copper = flatten_shapely_geometry(non_copper) @@ -471,7 +471,7 @@ class GerberObject(FlatCAMObj, Gerber): def on_generatebb_button_click(self, *args): self.app.defaults.report_usage("gerber_on_generatebb_button") self.read_form() - name = self.options["name"] + "_bbox" + name = self.obj_options["name"] + "_bbox" def geo_init(geo_obj, app_obj): assert geo_obj.kind == 'geometry', "Expected a Geometry object got %s" % type(geo_obj) @@ -482,7 +482,7 @@ class GerberObject(FlatCAMObj, Gerber): except Exception: self.solid_geometry = unary_union(self.solid_geometry) - distance = float(self.options["bboxmargin"]) + distance = float(self.obj_options["bboxmargin"]) # Bounding box with rounded corners if distance >= 0: @@ -507,7 +507,7 @@ class GerberObject(FlatCAMObj, Gerber): bounding_box = self.solid_geometry.envelope.buffer(abs(distance*2)).interiors bounding_box = unary_union(bounding_box).buffer(-distance).exterior - if not self.options["bboxrounded"]: # Remove rounded corners + if not self.obj_options["bboxrounded"]: # Remove rounded corners bounding_box = bounding_box.envelope if bounding_box is None or bounding_box.is_empty: @@ -562,7 +562,7 @@ class GerberObject(FlatCAMObj, Gerber): else: iso_t = iso_type - base_name = self.options["name"] + base_name = self.obj_options["name"] if combine: if outname is None: @@ -577,7 +577,7 @@ class GerberObject(FlatCAMObj, Gerber): def iso_init(geo_obj, app_obj): # Propagate options - geo_obj.options["tools_mill_tooldia"] = str(dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(dia) geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"] geo_obj.multigeo = True @@ -585,7 +585,7 @@ class GerberObject(FlatCAMObj, Gerber): # store here the default data for Geometry Data default_data = {} - for opt_key, opt_val in app_obj.options.items(): + for opt_key, opt_val in app_obj.obj_options.items(): if opt_key.find('geometry' + "_") == 0: oname = opt_key[len('geometry') + 1:] default_data[oname] = self.app.options[opt_key] @@ -637,7 +637,7 @@ class GerberObject(FlatCAMObj, Gerber): if empty_cnt == len(w_geo): raise ValidationError("Empty Geometry", None) elif plot: - msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"]) + msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"]) app_obj.inform.emit(msg) # ############################################################ @@ -675,7 +675,7 @@ class GerberObject(FlatCAMObj, Gerber): def iso_init(geo_obj, app_obj): # Propagate options - geo_obj.options["tools_mill_tooldia"] = str(dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(dia) geo_obj.tool_type = self.app.defaults["tools_iso_tool_shape"] geo_obj.multigeo = True @@ -692,7 +692,7 @@ class GerberObject(FlatCAMObj, Gerber): # store here the default data for Geometry Data default_data = {} - for opt_key, opt_val in app_obj.options.items(): + for opt_key, opt_val in app_obj.obj_options.items(): if opt_key.find('geometry' + "_") == 0: oname = opt_key[len('geometry') + 1:] default_data[oname] = self.app.options[opt_key] @@ -728,7 +728,7 @@ class GerberObject(FlatCAMObj, Gerber): if empty_cnt == len(w_geo): raise ValidationError("Empty Geometry", None) elif plot: - msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"]) + msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"]) app_obj.inform.emit(msg) # ############################################################ @@ -786,7 +786,7 @@ class GerberObject(FlatCAMObj, Gerber): """ if outname is None: - follow_name = self.options["name"] + "_follow" + follow_name = self.obj_options["name"] + "_follow" else: follow_name = outname @@ -805,14 +805,14 @@ class GerberObject(FlatCAMObj, Gerber): # Propagate options new_obj.multigeo = True - # new_obj.options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"]) + # new_obj.obj_options["tools_mill_tooldia"] = str(self.app.defaults["tools_iso_tooldia"]) new_obj.solid_geometry = deepcopy(self.follow_geometry) - new_obj.options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] + new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] # store here the default data for Geometry Data default_data = {} - for opt_key, opt_val in app_obj.options.items(): + for opt_key, opt_val in app_obj.obj_options.items(): if opt_key.find('geometry' + "_") == 0: oname = opt_key[len('geometry') + 1:] default_data[oname] = self.app.options[opt_key] @@ -903,8 +903,8 @@ class GerberObject(FlatCAMObj, Gerber): Gerber.convert_units(self, units) - # self.options['isotooldia'] = float(self.options['isotooldia']) * factor - # self.options['bboxmargin'] = float(self.options['bboxmargin']) * factor + # self.obj_options['isotooldia'] = float(self.obj_options['isotooldia']) * factor + # self.obj_options['bboxmargin'] = float(self.obj_options['bboxmargin']) * factor def plot(self, kind=None, **kwargs): """ @@ -931,7 +931,7 @@ class GerberObject(FlatCAMObj, Gerber): face_color = self.fill_color if 'visible' not in kwargs: - visible = self.options['plot'] + visible = self.obj_options['plot'] else: visible = kwargs['visible'] @@ -966,11 +966,11 @@ class GerberObject(FlatCAMObj, Gerber): plot_geometry = geometry.geoms if isinstance(geometry, (MultiPolygon, MultiLineString)) else geometry try: for g in plot_geometry: - if self.options["solid"]: + if self.obj_options["solid"]: used_color = color - used_face_color = random_color() if self.options['multicolored'] else face_color + used_face_color = random_color() if self.obj_options['multicolored'] else face_color else: - used_color = random_color() if self.options['multicolored'] else 'black' + 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: @@ -981,11 +981,11 @@ class GerberObject(FlatCAMObj, Gerber): g = LineString(g) self.add_shape(shape=g, color=used_color, face_color=used_face_color, visible=visible) except TypeError: - if self.options["solid"]: + if self.obj_options["solid"]: used_color = color - used_face_color = random_color() if self.options['multicolored'] else face_color + used_face_color = random_color() if self.obj_options['multicolored'] else face_color else: - used_color = random_color() if self.options['multicolored'] else 'black' + 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: @@ -1707,10 +1707,10 @@ class GerberObject(FlatCAMObj, Gerber): if type(grb) is list: GerberObject.merge(grb_list=grb, grb_final=grb_final) else: # If not list, just append - for option in grb.options: + for option in grb.obj_options: if option != 'name': try: - grb_final.options[option] = grb.options[option] + grb_final.obj_options[option] = grb.obj_options[option] except KeyError: self.app.log.warning("Failed to copy option.", option) @@ -1758,12 +1758,12 @@ class GerberObject(FlatCAMObj, Gerber): Gerber.skew(self, angle_x=angle_x, angle_y=angle_y, point=point) self.replotApertures.emit() - def buffer(self, distance, join=2, factor=None): - Gerber.buffer(self, distance=distance, join=join, factor=factor) + def buffer(self, distance, join=2, factor=None, only_exterior=False): + Gerber.buffer(self, distance=distance, join=join, factor=factor, only_exterior=only_exterior) self.replotApertures.emit() def serialize(self): return { - "options": self.options, + "obj_options": self.obj_options, "kind": self.kind } diff --git a/appObjects/FlatCAMObj.py b/appObjects/FlatCAMObj.py index 442260cc..5e04285e 100644 --- a/appObjects/FlatCAMObj.py +++ b/appObjects/FlatCAMObj.py @@ -79,8 +79,8 @@ class FlatCAMObj(QtCore.QObject): # set True by the collection.append() when the object load is complete self.load_complete = None - self.options = LoudDict(name=name) - self.options.set_change_callback(self.on_options_change) + self.obj_options = LoudDict(name=name) + self.obj_options.set_change_callback(self.on_options_change) self.form_fields = {} @@ -128,14 +128,14 @@ class FlatCAMObj(QtCore.QObject): pass def __str__(self): - return "".format(self.kind, self.options["name"]) + return "".format(self.kind, self.obj_options["name"]) def from_dict(self, d): """ This supersedes ``from_dict`` in derived classes. Derived classes must inherit from FlatCAMObj first, then from derivatives of Geometry. - ``self.options`` is only updated, not overwritten. This ensures that + ``self.obj_options`` is only updated, not overwritten. This ensures that options set by the app do not vanish when reading the objects from a project file. @@ -146,7 +146,7 @@ class FlatCAMObj(QtCore.QObject): for attr in self.ser_attrs: if attr == 'options': - self.options.update(d[attr]) + self.obj_options.update(d[attr]) else: try: setattr(self, attr, d[attr]) @@ -162,7 +162,7 @@ class FlatCAMObj(QtCore.QObject): # Set object visibility for objects that are edited if key == 'plot' and self.app.call_source != 'app': - self.visible = self.options['plot'] + self.visible = self.obj_options['plot'] self.optionChanged.emit(key) @@ -325,7 +325,7 @@ class FlatCAMObj(QtCore.QObject): self.muted_ui = False def on_name_activate(self, silent=None): - old_name = copy(self.options["name"]) + old_name = copy(self.obj_options["name"]) new_name = self.ui.name_entry.get_value() if new_name != old_name: @@ -339,7 +339,7 @@ class FlatCAMObj(QtCore.QObject): self.app.log.debug( "on_name_activate() --> Could not remove the old object name from auto-completer model list") - self.options["name"] = self.ui.name_entry.get_value() + self.obj_options["name"] = self.ui.name_entry.get_value() self.default_data["name"] = self.ui.name_entry.get_value() self.app.collection.update_view() if silent: @@ -418,7 +418,7 @@ class FlatCAMObj(QtCore.QObject): :return: None """ self.app.log.debug(str(inspect.stack()[1][3]) + " --> FlatCAMObj.to_form()") - for option in self.options: + for option in self.obj_options: try: self.set_form_item(option) except Exception as err: @@ -426,13 +426,13 @@ class FlatCAMObj(QtCore.QObject): def read_form(self): """ - Reads form into ``self.options``. + Reads form into ``self.obj_options``. :return: None :rtype: None """ self.app.log.debug(str(inspect.stack()[1][3]) + "--> FlatCAMObj.read_form()") - for option in self.options: + for option in self.obj_options: try: self.read_form_item(option) except Exception: @@ -442,27 +442,27 @@ class FlatCAMObj(QtCore.QObject): """ Copies the specified option to the UI form. - :param option: Name of the option (Key in ``self.options``). + :param option: Name of the option (Key in ``self.obj_options``). :type option: str :return: None """ try: - self.form_fields[option].set_value(self.options[option]) + self.form_fields[option].set_value(self.obj_options[option]) except KeyError: # self.app.log.warn("Tried to set an option or field that does not exist: %s" % option) pass def read_form_item(self, option): """ - Reads the specified option from the UI form into ``self.options``. + Reads the specified option from the UI form into ``self.obj_options``. :param option: Name of the option. :type option: str :return: None """ try: - self.options[option] = self.form_fields[option].get_value() + self.obj_options[option] = self.form_fields[option].get_value() except KeyError: pass # self.app.log.warning("Failed to read option from field: %s" % option) @@ -701,10 +701,10 @@ class FlatCAMObj(QtCore.QObject): self.app.worker_task.emit({'fcn': job_thread, 'params': [obj]}) # Options items - for option in obj.options: + for option in obj.obj_options: if option == 'name': continue - self.treeWidget.addChild(options, [str(option), str(obj.options[option])], True) + self.treeWidget.addChild(options, [str(option), str(obj.obj_options[option])], True) # Items that depend on the object type if obj.kind.lower() == 'gerber' and obj.tools: @@ -809,7 +809,7 @@ class FlatCAMObj(QtCore.QObject): self.treeWidget.addChild(geo_tool, [str(k), str(v)], True) elif obj.kind.lower() == 'cncjob': # for CNCJob objects made from Gerber or Geometry - if obj.options['type'].lower() == 'geometry': + if obj.obj_options['type'].lower() == 'geometry': for tool, value in obj.tools.items(): geo_tool = self.treeWidget.addParent( tools, str(tool), expanded=False, color=p_color, font=font) @@ -835,7 +835,7 @@ class FlatCAMObj(QtCore.QObject): self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True) # for CNCJob objects made from Excellon - if obj.options['type'].lower() == 'excellon': + if obj.obj_options['type'].lower() == 'excellon': for tool_id, value in obj.tools.items(): tool_dia = value['tooldia'] exc_tool = self.treeWidget.addParent( @@ -994,7 +994,7 @@ class FlatCAMObj(QtCore.QObject): def delete(self): # Free resources del self.ui - del self.options + del self.obj_options # Set flag self.deleted = True diff --git a/appObjects/FlatCAMScript.py b/appObjects/FlatCAMScript.py index 2ab85a1c..7e3080b5 100644 --- a/appObjects/FlatCAMScript.py +++ b/appObjects/FlatCAMScript.py @@ -38,7 +38,7 @@ class ScriptObject(FlatCAMObj): self.kind = "script" - self.options.update({ + self.obj_options.update({ "plot": True, "type": 'Script', "source_file": '', @@ -82,17 +82,17 @@ class ScriptObject(FlatCAMObj): # tab_here = False # # try to not add too many times a tab that it is already installed # for idx in range(self.app.ui.plot_tab_area.count()): - # if self.app.ui.plot_tab_area.widget(idx).objectName() == self.options['name']: + # if self.app.ui.plot_tab_area.widget(idx).objectName() == self.obj_options['name']: # tab_here = True # break # # # add the tab if it is not already added # if tab_here is False: # self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor")) - # self.script_editor_tab.setObjectName(self.options['name']) + # self.script_editor_tab.setObjectName(self.obj_options['name']) # self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor")) - # self.script_editor_tab.setObjectName(self.options['name']) + # self.script_editor_tab.setObjectName(self.obj_options['name']) # first clear previous text in text editor (if any) # self.script_editor_tab.code_editor.clear() @@ -148,14 +148,14 @@ class ScriptObject(FlatCAMObj): tab_here = False # try to not add too many times a tab that it is already installed for idx in range(self.app.ui.plot_tab_area.count()): - if self.app.ui.plot_tab_area.widget(idx).objectName() == (self.options['name'] + "_editor_tab"): + if self.app.ui.plot_tab_area.widget(idx).objectName() == (self.obj_options['name'] + "_editor_tab"): tab_here = True break # add the tab if it is not already added if tab_here is False: self.app.ui.plot_tab_area.addTab(self.script_editor_tab, '%s' % _("Script Editor")) - self.script_editor_tab.setObjectName(self.options['name'] + "_editor_tab") + self.script_editor_tab.setObjectName(self.obj_options['name'] + "_editor_tab") self.app.ui.plot_tab_area.setCurrentWidget(self.script_editor_tab) def change_level(self, level): diff --git a/appObjects/ObjectCollection.py b/appObjects/ObjectCollection.py index a1b6c036..bbc13d48 100644 --- a/appObjects/ObjectCollection.py +++ b/appObjects/ObjectCollection.py @@ -111,7 +111,7 @@ class EventSensitiveListView(QtWidgets.QTreeView): # if self.current_group == new_group: # # # delete it from the model - # deleted_obj_name = self.dropped_obj.options['name'] + # deleted_obj_name = self.dropped_obj.obj_options['name'] # self.model().delete_by_name(deleted_obj_name) # # # add the object to the new index @@ -477,7 +477,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): if role in [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole]: obj = index.internalPointer().obj if obj: - return obj.options["name"] + return obj.obj_options["name"] else: return index.internalPointer().data(index.column()) @@ -486,7 +486,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): color_disabled = QColor(self.app.defaults['global_proj_item_dis_color'][:-2]) obj = index.internalPointer().obj if obj: - return QtGui.QBrush(color) if obj.options["plot"] else QtGui.QBrush(color_disabled) + return QtGui.QBrush(color) if obj.obj_options["plot"] else QtGui.QBrush(color_disabled) else: return index.internalPointer().data(index.column()) @@ -503,7 +503,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): return None if obj: - text = obj.options['name'] + text = obj.obj_options['name'] return text else: QtWidgets.QToolTip.hideText() @@ -516,11 +516,11 @@ class ObjectCollection(QtCore.QAbstractItemModel): obj = index.internalPointer().obj if obj: - old_name = deepcopy(obj.options['name']) + old_name = deepcopy(obj.obj_options['name']) new_name = str(data) if old_name != new_name and new_name != '': # rename the object - obj.options["name"] = deepcopy(data) + obj.obj_options["name"] = deepcopy(data) self.app.object_status_changed.emit(obj, 'rename', old_name) @@ -565,7 +565,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): def append(self, obj, active=False, to_index=None): self.app.log.debug(str(inspect.stack()[1][3]) + " --> OC.append()") - name = obj.options["name"] + name = obj.obj_options["name"] # Check promises and clear if exists if name in self.promises: @@ -585,7 +585,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): name = base + str(num + 1) else: # No: add a number! name += "_1" - obj.options["name"] = name + obj.obj_options["name"] = name # ############################################################################################################ # update the KeyWords list with the name of the file @@ -640,7 +640,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): """ # log.debug(str(inspect.stack()[1][3]) + " --> OC.get_names()") - return [x.options['name'] for x in self.get_list()] + return [x.obj_options['name'] for x in self.get_list()] def get_bounds(self): """ @@ -685,11 +685,11 @@ class ObjectCollection(QtCore.QAbstractItemModel): if isCaseSensitive is None or isCaseSensitive is True: for obj in self.get_list(): - if obj.options['name'] == name: + if obj.obj_options['name'] == name: return obj else: for obj in self.get_list(): - if obj.options['name'].lower() == name.lower(): + if obj.obj_options['name'].lower() == name.lower(): return obj return None @@ -707,12 +707,12 @@ class ObjectCollection(QtCore.QAbstractItemModel): # some objects add a Tab on creation, close it here for idx in range(self.app.ui.plot_tab_area.count()): widget_name = self.app.ui.plot_tab_area.widget(idx).objectName() - if widget_name == active.obj.options['name'] or widget_name == (active.obj.options['name'] + "_editor_tab"): + if widget_name == active.obj.obj_options['name'] or widget_name == (active.obj.obj_options['name'] + "_editor_tab"): self.app.ui.plot_tab_area.removeTab(idx) break # update the SHELL auto-completer model data - name = active.obj.options['name'] + name = active.obj.obj_options['name'] try: self.app.myKeywords.remove(name) self.app.shell._edit.set_model_data(self.app.myKeywords) @@ -761,12 +761,12 @@ class ObjectCollection(QtCore.QAbstractItemModel): # some objects add a Tab on creation, close it here for idx in range(self.app.ui.plot_tab_area.count()): wdg_name = self.app.ui.plot_tab_area.widget(idx).objectName() - if wdg_name == deleted.obj.options['name'] or wdg_name == (deleted.obj.options['name'] + "_editor_tab"): + if wdg_name == deleted.obj.obj_options['name'] or wdg_name == (deleted.obj.obj_options['name'] + "_editor_tab"): self.app.ui.plot_tab_area.removeTab(idx) break # update the SHELL auto-completer model data - name = deleted.obj.options['name'] + name = deleted.obj.obj_options['name'] try: self.app.myKeywords.remove(name) self.app.shell._edit.set_model_data(self.app.myKeywords) @@ -952,42 +952,42 @@ class ObjectCollection(QtCore.QAbstractItemModel): try: obj = current.indexes()[0].internalPointer().obj - self.item_selected.emit(obj.options['name']) + self.item_selected.emit(obj.obj_options['name']) if obj.kind == 'gerber': self.app.inform.emit('[selected]{name} {tx}'.format( color='green', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) elif obj.kind == 'excellon': self.app.inform.emit('[selected]{name} {tx}'.format( color='brown', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) elif obj.kind == 'cncjob': self.app.inform.emit('[selected]{name} {tx}'.format( color='blue', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) elif obj.kind == 'geometry': self.app.inform.emit('[selected]{name} {tx}'.format( color='red', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) elif obj.kind == 'script': self.app.inform.emit('[selected]{name} {tx}'.format( color='orange', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) elif obj.kind == 'document': self.app.inform.emit('[selected]{name} {tx}'.format( color='darkCyan', - name=str(obj.options['name']), + name=str(obj.obj_options['name']), tx=_("selected")) ) except IndexError: @@ -1074,7 +1074,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): # get the name of the selected objects and add them to a list name_list = [] for obj in self.get_selected(): - name_list.append(obj.options['name']) + name_list.append(obj.obj_options['name']) # set all actions as unchecked but the ones selected make them checked for act in self.app.ui.menuobjects.actions(): @@ -1178,7 +1178,7 @@ class ObjectCollection(QtCore.QAbstractItemModel): elif state == 'delete': for act in self.app.ui.menuobjects.actions(): - if act.text() == obj.options['name']: + if act.text() == obj.obj_options['name']: try: act.triggered.disconnect() except TypeError: @@ -1189,11 +1189,11 @@ class ObjectCollection(QtCore.QAbstractItemModel): for act in self.app.ui.menuobjects.actions(): if act.text() == old_name: add_action = QtGui.QAction(parent=self.app.ui.menuobjects) - add_action.setText(obj.options['name']) + add_action.setText(obj.obj_options['name']) add_action.setIcon(QtGui.QIcon(icon_files[obj.kind])) add_action.triggered.connect( - lambda: self.set_active(obj.options['name']) if add_action.isChecked() is True else - self.set_inactive(obj.options['name'])) + lambda: self.set_active(obj.obj_options['name']) if add_action.isChecked() is True else + self.set_inactive(obj.obj_options['name'])) self.app.ui.menuobjects.insertAction(act, add_action) diff --git a/appPlugins/ToolAlignObjects.py b/appPlugins/ToolAlignObjects.py index 60cfccdb..1f8069b3 100644 --- a/appPlugins/ToolAlignObjects.py +++ b/appPlugins/ToolAlignObjects.py @@ -321,10 +321,10 @@ class AlignObjects(AppTool): # Update the object bounding box options a, b, c, d = self.aligned_obj.bounds() - self.aligned_obj.options['xmin'] = a - self.aligned_obj.options['ymin'] = b - self.aligned_obj.options['xmax'] = c - self.aligned_obj.options['ymax'] = d + self.aligned_obj.obj_options['xmin'] = a + self.aligned_obj.obj_options['ymin'] = b + self.aligned_obj.obj_options['xmax'] = c + self.aligned_obj.obj_options['ymax'] = d def align_rotate(self): dx = self.clicked_points[1][0] - self.clicked_points[0][0] diff --git a/appPlugins/ToolCalibration.py b/appPlugins/ToolCalibration.py index 20fd1ecb..012cd929 100644 --- a/appPlugins/ToolCalibration.py +++ b/appPlugins/ToolCalibration.py @@ -638,7 +638,7 @@ class ToolCalibration(AppTool): self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return - obj_name = self.cal_object.options["name"] + "_calibrated" + obj_name = self.cal_object.obj_options["name"] + "_calibrated" self.app.worker_task.emit({'fcn': self.new_calibrated_object, 'params': [obj_name]}) diff --git a/appPlugins/ToolCopperThieving.py b/appPlugins/ToolCopperThieving.py index a6b046ad..a70824ce 100644 --- a/appPlugins/ToolCopperThieving.py +++ b/appPlugins/ToolCopperThieving.py @@ -198,7 +198,7 @@ class ToolCopperThieving(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.grb_object_combo.set_value(obj_name) if obj is None: @@ -327,14 +327,14 @@ class ToolCopperThieving(AppTool): elif isinstance(geo_obj, Polygon): geo_obj = MultiPolygon([geo_obj, deepcopy(self.robber_geo)]) - outname = '%s_%s' % (str(self.grb_object.options['name']), 'robber') + outname = '%s_%s' % (str(self.grb_object.obj_options['name']), 'robber') def initialize(grb_obj, app_obj): - grb_obj.options = LoudDict() - for opt in self.grb_object.options: + grb_obj.obj_options = LoudDict() + for opt in self.grb_object.obj_options: if opt != 'name': - grb_obj.options[opt] = deepcopy(self.grb_object.options[opt]) - grb_obj.options['name'] = outname + grb_obj.obj_options[opt] = deepcopy(self.grb_object.obj_options[opt]) + grb_obj.obj_options['name'] = outname grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(self.grb_object.follow) @@ -922,14 +922,14 @@ class ToolCopperThieving(AppTool): # prepare also the solid_geometry for the new object having the thieving geometry new_solid_geo = MultiPolygon(geo_list).buffer(0.0000001).buffer(-0.0000001) - outname = '%s_%s' % (str(self.grb_object.options['name']), 'thief') + outname = '%s_%s' % (str(self.grb_object.obj_options['name']), 'thief') def initialize(grb_obj, app_obj): - grb_obj.options = LoudDict() - for opt in self.grb_object.options: + grb_obj.obj_options = LoudDict() + for opt in self.grb_object.obj_options: if opt != 'name': - grb_obj.options[opt] = deepcopy(self.grb_object.options[opt]) - grb_obj.options['name'] = outname + grb_obj.obj_options[opt] = deepcopy(self.grb_object.obj_options[opt]) + grb_obj.obj_options['name'] = outname grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(self.grb_object.follow) @@ -1132,11 +1132,11 @@ class ToolCopperThieving(AppTool): new_solid_geometry = MultiPolygon(geo_list).buffer(0.0000001).buffer(-0.0000001) def obj_init(grb_obj, app_obj): - grb_obj.options = LoudDict() - for opt in self.sm_object.options: + grb_obj.obj_options = LoudDict() + for opt in self.sm_object.obj_options: if opt != 'name': - grb_obj.options[opt] = deepcopy(self.sm_object.options[opt]) - grb_obj.options['name'] = outname + grb_obj.obj_options[opt] = deepcopy(self.sm_object.obj_options[opt]) + grb_obj.obj_options['name'] = outname grb_obj.multitool = False grb_obj.source_file = [] grb_obj.multigeo = False @@ -1152,7 +1152,7 @@ class ToolCopperThieving(AppTool): app_obj.proc_container.update_view_text(' %s' % '') # Object name - obj_name, separatpr, obj_extension = self.sm_object.options['name'].rpartition('.') + obj_name, separatpr, obj_extension = self.sm_object.obj_options['name'].rpartition('.') outname = '%s_%s.%s' % (obj_name, 'plating_mask', obj_extension) ret_val = self.app.app_obj.new_object('gerber', outname, obj_init, autoselected=False) diff --git a/appPlugins/ToolCutOut.py b/appPlugins/ToolCutOut.py index b6feadcc..c0fd60dc 100644 --- a/appPlugins/ToolCutOut.py +++ b/appPlugins/ToolCutOut.py @@ -121,7 +121,7 @@ class CutOut(AppTool): if found_idx: try: found_obj = current.indexes()[0].internalPointer().obj - name = found_obj.options['name'] + name = found_obj.obj_options['name'] kind = found_obj.kind if kind in ['gerber', 'geometry']: @@ -241,7 +241,7 @@ class CutOut(AppTool): else: self.on_type_obj_changed(val='geo') - self.ui.obj_combo.set_value(active.options['name']) + self.ui.obj_combo.set_value(active.obj_options['name']) else: kind = 'gerber' self.ui.type_obj_radio.set_value('grb') @@ -788,11 +788,11 @@ class CutOut(AppTool): return proc_geometry, rest_geometry with self.app.proc_container.new("Generating Cutout ..."): - formatted_name = cutout_obj.options["name"].rpartition('.')[0] + formatted_name = cutout_obj.obj_options["name"].rpartition('.')[0] if formatted_name != '': outname = "%s_cutout" % formatted_name else: - outname = "%s_cutout" % cutout_obj.options["name"] + outname = "%s_cutout" % cutout_obj.obj_options["name"] self.app.collection.promise(outname) @@ -972,15 +972,15 @@ class CutOut(AppTool): geo_obj.tools[99]['data']['override_color'] = "#29a3a3fa" xmin, ymin, xmax, ymax = CutOut.recursive_bounds(geo_obj.solid_geometry) - geo_obj.options['xmin'] = xmin - geo_obj.options['ymin'] = ymin - geo_obj.options['xmax'] = xmax - geo_obj.options['ymax'] = ymax + geo_obj.obj_options['xmin'] = xmin + geo_obj.obj_options['ymin'] = ymin + geo_obj.obj_options['xmax'] = xmax + geo_obj.obj_options['ymax'] = ymax - geo_obj.options['tools_mill_tooldia'] = str(cut_dia) - geo_obj.options['tools_mill_cutz'] = self.ui.cutz_entry.get_value() - geo_obj.options['tools_mill_multidepth'] = self.ui.mpass_cb.get_value() - geo_obj.options['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value() + geo_obj.obj_options['tools_mill_tooldia'] = str(cut_dia) + geo_obj.obj_options['tools_mill_cutz'] = self.ui.cutz_entry.get_value() + geo_obj.obj_options['tools_mill_multidepth'] = self.ui.mpass_cb.get_value() + geo_obj.obj_options['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value() def excellon_init(exc_obj, app_o): if not holes: @@ -997,15 +997,15 @@ class CutOut(AppTool): exc_obj.multigeo = True exc_obj.tools = tools exc_obj.create_geometry() - exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.options['name'], + exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.obj_options['name'], local_use=exc_obj, filename=None, use_thread=False) # calculate the bounds xmin, ymin, xmax, ymax = CutOut.recursive_bounds(exc_obj.solid_geometry) - exc_obj.options['xmin'] = xmin - exc_obj.options['ymin'] = ymin - exc_obj.options['xmax'] = xmax - exc_obj.options['ymax'] = ymax + exc_obj.obj_options['xmin'] = xmin + exc_obj.obj_options['ymin'] = ymin + exc_obj.obj_options['xmax'] = xmax + exc_obj.obj_options['ymax'] = ymax try: if self.ui.gaptype_combo.get_value() == 2: # "mouse bytes" @@ -1078,11 +1078,11 @@ class CutOut(AppTool): thin_entry_val = self.ui.thin_depth_entry.get_value() has_mouse_bites_val = True if self.ui.gaptype_combo.get_value() == 2 else False # "mouse bytes" - formatted_name = cutout_obj.options["name"].rpartition('.')[0] - outname = "%s_cutout" % formatted_name if formatted_name != '' else "%s_cutout" % cutout_obj.options["name"] + formatted_name = cutout_obj.obj_options["name"].rpartition('.')[0] + outname = "%s_cutout" % formatted_name if formatted_name != '' else "%s_cutout" % cutout_obj.obj_options["name"] self.app.collection.promise(outname) - outname_exc = cutout_obj.options["name"] + "_mouse_bites" + outname_exc = cutout_obj.obj_options["name"] + "_mouse_bites" if has_mouse_bites_val is True: self.app.collection.promise(outname_exc) @@ -1281,15 +1281,15 @@ class CutOut(AppTool): geo_obj.tools[99]['data']['override_color'] = "#29a3a3fa" xmin, ymin, xmax, ymax = CutOut.recursive_bounds(geo_obj.solid_geometry) - geo_obj.options['xmin'] = xmin - geo_obj.options['ymin'] = ymin - geo_obj.options['xmax'] = xmax - geo_obj.options['ymax'] = ymax + geo_obj.obj_options['xmin'] = xmin + geo_obj.obj_options['ymin'] = ymin + geo_obj.obj_options['xmax'] = xmax + geo_obj.obj_options['ymax'] = ymax - geo_obj.options['tools_mill_tooldia'] = str(cut_dia) - geo_obj.options['tools_mill_cutz'] = self_c.ui.cutz_entry.get_value() - geo_obj.options['tools_mill_multidepth'] = self_c.ui.mpass_cb.get_value() - geo_obj.options['tools_mill_depthperpass'] = self_c.ui.maxdepth_entry.get_value() + geo_obj.obj_options['tools_mill_tooldia'] = str(cut_dia) + geo_obj.obj_options['tools_mill_cutz'] = self_c.ui.cutz_entry.get_value() + geo_obj.obj_options['tools_mill_multidepth'] = self_c.ui.mpass_cb.get_value() + geo_obj.obj_options['tools_mill_depthperpass'] = self_c.ui.maxdepth_entry.get_value() def excellon_init(exc_obj, app_o): if not holes: @@ -1305,16 +1305,16 @@ class CutOut(AppTool): exc_obj.tools = tools exc_obj.create_geometry() - exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.options['name'], + exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.obj_options['name'], local_use=exc_obj, filename=None, use_thread=False) # calculate the bounds e_xmin, e_ymin, e_xmax, e_ymax = CutOut.recursive_bounds(exc_obj.solid_geometry) - exc_obj.options['xmin'] = e_xmin - exc_obj.options['ymin'] = e_ymin - exc_obj.options['xmax'] = e_xmax - exc_obj.options['ymax'] = e_ymax + exc_obj.obj_options['xmin'] = e_xmin + exc_obj.obj_options['ymin'] = e_ymin + exc_obj.obj_options['xmax'] = e_xmax + exc_obj.obj_options['ymax'] = e_ymax try: if self_c.ui.gaptype_combo.get_value() == 2: # "mouse bytes" @@ -1488,9 +1488,9 @@ class CutOut(AppTool): } } - formatted_name = obj.options['name'].rpartition('.')[0] + formatted_name = obj.obj_options['name'].rpartition('.')[0] if formatted_name == '': - formatted_name = obj.options['name'] + formatted_name = obj.obj_options['name'] outname = '%s_drillcut' % formatted_name def obj_init(obj_inst, app_inst): @@ -1627,7 +1627,7 @@ class CutOut(AppTool): self.man_cutout_obj.multigeo = True self.man_cutout_obj.tools[1]['solid_geometry'] = new_solid_geometry - self.man_cutout_obj.tools[1]['data']['name'] = self.man_cutout_obj.options['name'] + '_cutout' + self.man_cutout_obj.tools[1]['data']['name'] = self.man_cutout_obj.obj_options['name'] + '_cutout' self.man_cutout_obj.tools[1]['data']['tools_mill_cutz'] = self.ui.cutz_entry.get_value() self.man_cutout_obj.tools[1]['data']['tools_mill_multidepth'] = self.ui.mpass_cb.get_value() self.man_cutout_obj.tools[1]['data']['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value() @@ -1644,7 +1644,7 @@ class CutOut(AppTool): self.man_cutout_obj.tools[99]['tooldia'] = str(dia) self.man_cutout_obj.tools[99]['solid_geometry'] = [gaps_solid_geo] - self.man_cutout_obj.tools[99]['data']['name'] = self.man_cutout_obj.options['name'] + '_cutout' + self.man_cutout_obj.tools[99]['data']['name'] = self.man_cutout_obj.obj_options['name'] + '_cutout' self.man_cutout_obj.tools[99]['data']['tools_mill_cutz'] = self.ui.thin_depth_entry.get_value() self.man_cutout_obj.tools[99]['data']['tools_mill_multidepth'] = self.ui.mpass_cb.get_value() self.man_cutout_obj.tools[99]['data']['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value() @@ -1758,7 +1758,7 @@ class CutOut(AppTool): geo_obj.tools[1]['data']['tools_mill_multidepth'] = self.ui.mpass_cb.get_value() geo_obj.tools[1]['data']['tools_mill_depthperpass'] = self.ui.maxdepth_entry.get_value() - outname = cutout_obj.options["name"] + "_cutout" + outname = cutout_obj.obj_options["name"] + "_cutout" self.app.app_obj.new_object('geometry', outname, geo_init, autoselected=False) def cutting_geo(self, pos): @@ -1844,7 +1844,7 @@ class CutOut(AppTool): # mouse bytes if self.ui.gaptype_combo.get_value() == 2: # "mouse bytes" with self.app.proc_container.new("Generating Excellon ..."): - outname_exc = self.man_cutout_obj.options["name"] + "_mouse_bites" + outname_exc = self.man_cutout_obj.obj_options["name"] + "_mouse_bites" self.app.collection.promise(outname_exc) def job_thread(app_obj): @@ -1873,16 +1873,16 @@ class CutOut(AppTool): exc_obj.tools = tools exc_obj.create_geometry() - exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.options['name'], + exc_obj.source_file = app_o.f_handlers.export_excellon(obj_name=exc_obj.obj_options['name'], local_use=exc_obj, filename=None, use_thread=False) # calculate the bounds xmin, ymin, xmax, ymax = CutOut.recursive_bounds(exc_obj.solid_geometry) - exc_obj.options['xmin'] = xmin - exc_obj.options['ymin'] = ymin - exc_obj.options['xmax'] = xmax - exc_obj.options['ymax'] = ymax + exc_obj.obj_options['xmin'] = xmin + exc_obj.obj_options['ymin'] = ymin + exc_obj.obj_options['xmax'] = xmax + exc_obj.obj_options['ymax'] = ymax ret = app_obj.app_obj.new_object('excellon', outname_exc, excellon_init, autoselected=False) if ret == 'fail': diff --git a/appPlugins/ToolDblSided.py b/appPlugins/ToolDblSided.py index 9c50bf39..21298174 100644 --- a/appPlugins/ToolDblSided.py +++ b/appPlugins/ToolDblSided.py @@ -173,7 +173,7 @@ class DblSidedTool(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj: - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] if obj.kind == 'gerber': # run once to make sure that the obj_type attribute is updated in the FCComboBox self.ui.object_type_combo.set_value(0) @@ -279,7 +279,7 @@ class DblSidedTool(AppTool): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'excellon', 'geometry']: @@ -363,7 +363,7 @@ class DblSidedTool(AppTool): def obj_init(obj_inst, app_inst): obj_inst.tools = deepcopy(tools) obj_inst.create_geometry() - obj_inst.source_file = app_inst.f_handlers.export_excellon(obj_name=obj_inst.options['name'], + obj_inst.source_file = app_inst.f_handlers.export_excellon(obj_name=obj_inst.obj_options['name'], local_use=obj_inst, filename=None, use_thread=False) @@ -542,7 +542,7 @@ class DblSidedTool(AppTool): fcobj.mirror(axis, [px, py]) self.app.app_obj.object_changed.emit(fcobj) fcobj.plot() - self.app.inform.emit('[success] %s: %s' % (_("Object was mirrored"), str(fcobj.options['name']))) + 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"] % \ diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index c1b5889e..801f9c7a 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -335,7 +335,7 @@ class ToolDrilling(AppTool, Excellon): try: selected_obj = self.app.collection.get_active() if selected_obj.kind == 'excellon': - current_name = selected_obj.options['name'] + current_name = selected_obj.obj_options['name'] self.ui.object_combo.set_value(current_name) except Exception: pass @@ -430,7 +430,7 @@ class ToolDrilling(AppTool, Excellon): # reset the Excellon preprocessor combo self.ui.pp_excellon_name_cb.clear() # populate Excellon preprocessor combobox list - if loaded_obj and loaded_obj.options['tools_drill_ppname_e'] == 'Check_points': + if loaded_obj and loaded_obj.obj_options['tools_drill_ppname_e'] == 'Check_points': pp_list = ['Check_points'] else: pp_list = [] @@ -453,14 +453,14 @@ class ToolDrilling(AppTool, Excellon): self.ui.order_combo.set_value(self.app.defaults["tools_drill_tool_order"]) if loaded_obj: - outname = loaded_obj.options['name'] + outname = loaded_obj.obj_options['name'] else: outname = '' # init the working variables self.default_data.clear() - # fill in self.default_data values from self.options + # fill in self.default_data values from self.obj_options # for opt_key, opt_val in self.app.options.items(): # if opt_key.find('excellon_') == 0: # oname = opt_key[len('excellon_'):] @@ -471,7 +471,7 @@ class ToolDrilling(AppTool, Excellon): # self.default_data[opt_key] = deepcopy(opt_val) # if loaded_obj: - self.default_data.update(loaded_obj.options) + self.default_data.update(loaded_obj.obj_options) else: self.default_data.update(self.app.options) @@ -611,7 +611,7 @@ class ToolDrilling(AppTool, Excellon): # Tool parameters section if loaded_obj: - options = loaded_obj.options + options = loaded_obj.obj_options for tool in loaded_obj.tools: tool_data = loaded_obj.tools[tool]['data'] @@ -987,7 +987,7 @@ class ToolDrilling(AppTool, Excellon): if found_idx: try: sel_obj = current.indexes()[0].internalPointer().obj - name = sel_obj.options['name'] + name = sel_obj.obj_options['name'] kind = sel_obj.kind if kind in ['geometry', 'excellon']: self.ui.object_combo.set_value(name) @@ -1968,12 +1968,12 @@ class ToolDrilling(AppTool, Excellon): # we don't do it here since it will break any changes we've done in the Drilling Tool UI # self.excellon_tools = obj.tools - xmin = obj.options['xmin'] - ymin = obj.options['ymin'] - xmax = obj.options['xmax'] - ymax = obj.options['ymax'] + xmin = obj.obj_options['xmin'] + ymin = obj.obj_options['ymin'] + xmax = obj.obj_options['xmax'] + ymax = obj.obj_options['ymax'] - job_name = obj.options["name"] + "_cnc" + job_name = obj.obj_options["name"] + "_cnc" obj.pp_excellon_name = self.ui.pp_excellon_name_cb.get_value() if self.is_valid_excellon() is False: @@ -2168,13 +2168,13 @@ class ToolDrilling(AppTool, Excellon): job_obj.pp_excellon_name = self.ui.pp_excellon_name_cb.get_value() job_obj.pp_excellon = self.app.preprocessors[job_obj.pp_excellon_name] - job_obj.options['type'] = 'Excellon' - job_obj.options['ppname_e'] = obj.pp_excellon_name + job_obj.obj_options['type'] = 'Excellon' + job_obj.obj_options['ppname_e'] = obj.pp_excellon_name - job_obj.options['xmin'] = xmin - job_obj.options['ymin'] = ymin - job_obj.options['xmax'] = xmax - job_obj.options['ymax'] = ymax + job_obj.obj_options['xmin'] = xmin + job_obj.obj_options['ymin'] = ymin + job_obj.obj_options['xmax'] = xmax + job_obj.obj_options['ymax'] = ymax job_obj.use_ui = True diff --git a/appPlugins/ToolEtchCompensation.py b/appPlugins/ToolEtchCompensation.py index 2715133a..a3e28dbf 100644 --- a/appPlugins/ToolEtchCompensation.py +++ b/appPlugins/ToolEtchCompensation.py @@ -123,7 +123,7 @@ class ToolEtchCompensation(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.gerber_combo.set_value(obj_name) def on_ratio_change(self, val): @@ -234,8 +234,8 @@ class ToolEtchCompensation(AppTool): new_solid_geometry = unary_union(new_solid_geometry) new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) new_apertures = deepcopy(grb_obj.tools) @@ -276,8 +276,8 @@ class ToolEtchCompensation(AppTool): :return: None :rtype: """ - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index 610d8e37..6c63c52d 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -69,7 +69,7 @@ class ToolExtract(AppTool): for ap_code in grb_obj.tools: grb_obj.mark_shapes_storage[ap_code] = [] - self.old_name = grb_obj.options['name'] + self.old_name = grb_obj.obj_options['name'] def install(self, icon=None, separator=None, **kwargs): AppTool.install(self, icon, separator, shortcut='Alt+I', **kwargs) @@ -212,7 +212,7 @@ class ToolExtract(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.gerber_object_combo.set_value(obj_name) def build_tool_ui(self): @@ -384,7 +384,7 @@ class ToolExtract(AppTool): except Exception: self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return - outname = "%s_%s" % (fcobj.options['name'].rpartition('.')[0], _("extracted")) + outname = "%s_%s" % (fcobj.obj_options['name'].rpartition('.')[0], _("extracted")) # selected codes in the apertures UI table sel_g_tools = [int(it.text()) for it in self.ui.apertures_table.selectedItems()] @@ -699,7 +699,7 @@ class ToolExtract(AppTool): except Exception: self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return - outname = '%s_esm' % obj.options['name'].rpartition('.')[0] + outname = '%s_esm' % obj.obj_options['name'].rpartition('.')[0] # new_apertures = deepcopy(obj.tools) new_apertures = {} @@ -803,7 +803,7 @@ class ToolExtract(AppTool): self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return - outname = '%s_ecut' % obj.options['name'].rpartition('.')[0] + outname = '%s_ecut' % obj.obj_options['name'].rpartition('.')[0] cut_solid_geometry = obj.solid_geometry if isinstance(obj.solid_geometry, list): diff --git a/appPlugins/ToolFiducials.py b/appPlugins/ToolFiducials.py index 881e5854..1ee2036d 100644 --- a/appPlugins/ToolFiducials.py +++ b/appPlugins/ToolFiducials.py @@ -186,7 +186,7 @@ class ToolFiducials(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.grb_object_combo.set_value(obj_name) if obj is None: @@ -294,7 +294,7 @@ class ToolFiducials(AppTool): self.app.call_source = "app" return - self.copper_obj_set.add(self.grb_object.options['name']) + self.copper_obj_set.add(self.grb_object.obj_options['name']) if self.mode_method == 'auto': xmin, ymin, xmax, ymax = self.grb_object.bounds() @@ -558,14 +558,14 @@ class ToolFiducials(AppTool): for poly in geo_buff_list: s_list.append(poly) - outname = '%s_%s' % (str(g_obj.options['name']), 'fid') + outname = '%s_%s' % (str(g_obj.obj_options['name']), 'fid') def initialize(grb_obj, app_obj): - grb_obj.options = LoudDict() - for opt in g_obj.options: + grb_obj.obj_options = LoudDict() + for opt in g_obj.obj_options: if opt != 'name': - grb_obj.options[opt] = deepcopy(g_obj.options[opt]) - grb_obj.options['name'] = outname + grb_obj.obj_options[opt] = deepcopy(g_obj.obj_options[opt]) + grb_obj.obj_options['name'] = outname grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(g_obj.follow) @@ -594,7 +594,7 @@ class ToolFiducials(AppTool): self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return - self.sm_obj_set.add(self.sm_object.options['name']) + self.sm_obj_set.add(self.sm_object.obj_options['name']) ret_val = self.add_fiducials_geo( self.click_points, g_obj=self.sm_object, fid_size=sm_opening_dia, fid_type='circular') self.app.call_source = "app" @@ -706,10 +706,10 @@ class ToolFiducials(AppTool): # update the bounding box values try: a, b, c, d = copper_obj.bounds() - copper_obj.options['xmin'] = a - copper_obj.options['ymin'] = b - copper_obj.options['xmax'] = c - copper_obj.options['ymax'] = d + copper_obj.obj_options['xmin'] = a + copper_obj.obj_options['ymin'] = b + copper_obj.obj_options['xmax'] = c + copper_obj.obj_options['ymax'] = d except Exception as e: self.app.log.error("ToolFiducials.on_exit() copper_obj bounds error --> %s" % str(e)) @@ -726,10 +726,10 @@ class ToolFiducials(AppTool): # update the bounding box values try: a, b, c, d = sm_obj.bounds() - sm_obj.options['xmin'] = a - sm_obj.options['ymin'] = b - sm_obj.options['xmax'] = c - sm_obj.options['ymax'] = d + sm_obj.obj_options['xmin'] = a + sm_obj.obj_options['ymin'] = b + sm_obj.obj_options['xmax'] = c + sm_obj.obj_options['ymax'] = d except Exception as e: self.app.log.error("ToolFiducials.on_exit() sm_obj bounds error --> %s" % str(e)) diff --git a/appPlugins/ToolFilm.py b/appPlugins/ToolFilm.py index 4fc5dfa1..3b1ba9a6 100644 --- a/appPlugins/ToolFilm.py +++ b/appPlugins/ToolFilm.py @@ -87,7 +87,7 @@ class Film(AppTool): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'geometry']: @@ -223,7 +223,7 @@ class Film(AppTool): obj = self.app.collection.get_active() if obj: - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] if obj.kind == 'gerber': # run once to make sure that the obj_type attribute is updated in the FCComboBox self.ui.tf_type_obj_combo.set_value('grb') @@ -639,7 +639,7 @@ class Film(AppTool): p_size = self.ui.pagesize_combo.get_value() orientation = self.ui.orientation_radio.get_value() - color = obj.options['tools_film_color'] + color = obj.obj_options['tools_film_color'] transparency_level = opacity_val def make_negative_film(color, transparency_level, scale_factor_x, scale_factor_y, use_convex_hull, rounded_box): @@ -972,7 +972,7 @@ class Film(AppTool): p_size = self.ui.pagesize_combo.get_value() orientation = self.ui.orientation_radio.get_value() - color = obj.options['tools_film_color'] + color = obj.obj_options['tools_film_color'] transparency_level = opacity_val def make_positive_film(color, transparency_level, scale_factor_x, scale_factor_y): diff --git a/appPlugins/ToolFollow.py b/appPlugins/ToolFollow.py index 683f2f56..0ce765b2 100644 --- a/appPlugins/ToolFollow.py +++ b/appPlugins/ToolFollow.py @@ -153,7 +153,7 @@ class ToolFollow(AppTool, Gerber): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.object_combo.set_value(obj_name) # Show/Hide Advanced Options @@ -321,7 +321,7 @@ class ToolFollow(AppTool, Gerber): new_obj.multigeo = True # Propagate options - new_obj.options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] + new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] new_obj.solid_geometry = follow_geo new_obj.tools = { 1: { @@ -374,7 +374,7 @@ class ToolFollow(AppTool, Gerber): new_data[opt_key] = app_obj.options[opt_key] # Propagate options - new_obj.options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] + new_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] new_data["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] target_geo = unary_union(followed_obj.follow_geometry) diff --git a/appPlugins/ToolInvertGerber.py b/appPlugins/ToolInvertGerber.py index d04a158b..909a0965 100644 --- a/appPlugins/ToolInvertGerber.py +++ b/appPlugins/ToolInvertGerber.py @@ -119,7 +119,7 @@ class ToolInvertGerber(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.gerber_combo.set_value(obj_name) def on_grb_invert(self): @@ -160,8 +160,8 @@ class ToolInvertGerber(AppTool): new_solid_geometry = flatten_shapely_geometry(new_solid_geometry) new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) new_apertures = {} @@ -181,8 +181,8 @@ class ToolInvertGerber(AppTool): new_apertures[0]['geometry'].append(new_el) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index 943a7fb8..73e18ad4 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -304,7 +304,7 @@ class ToolIsolation(AppTool, Gerber): try: selected_obj = self.app.collection.get_active() if selected_obj is not None and selected_obj.kind == 'gerber': - current_name = selected_obj.options['name'] + current_name = selected_obj.obj_options['name'] self.ui.object_combo.set_value(current_name) if selected_obj is None and [self.ui.object_combo.itemText(i) for i in range(self.ui.object_combo.count())]: self.ui.object_combo.setCurrentIndex(0) @@ -355,7 +355,7 @@ class ToolIsolation(AppTool, Gerber): # loaded_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value()) # if loaded_obj: - # outname = loaded_obj.options['name'] + # outname = loaded_obj.obj_options['name'] # else: # outname = '' @@ -1808,7 +1808,7 @@ class ToolIsolation(AppTool, Gerber): if negative_dia: iso_offset = -iso_offset - outname = "%s_%.*f" % (isolated_obj.options["name"], self.decimals, float(tool_dia)) + outname = "%s_%.*f" % (isolated_obj.obj_options["name"], self.decimals, float(tool_dia)) if passes > 1: iso_name = outname + "_iso" + str(i + 1) @@ -1884,7 +1884,7 @@ class ToolIsolation(AppTool, Gerber): def iso_init(geo_obj, fc_obj): # Propagate options - geo_obj.options["tools_mill_tooldia"] = str(tool_dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool_dia) tool_data["tools_mill_tooldia"] = float(tool_dia) geo_obj.solid_geometry = deepcopy(new_solid_geo) @@ -1919,11 +1919,11 @@ class ToolIsolation(AppTool, Gerber): empty_cnt += 1 if empty_cnt == len(geo_obj.solid_geometry): - msg = '[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.options["name"]) + msg = '[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.obj_options["name"]) fc_obj.inform.emit(msg) return 'fail' else: - msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"]) + msg = '[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"]) fc_obj.inform.emit(msg) geo_obj.multigeo = True @@ -1964,7 +1964,7 @@ class ToolIsolation(AppTool, Gerber): total_solid_geometry = [] - iso_name = iso_obj.options["name"] + '_iso_rest' + iso_name = iso_obj.obj_options["name"] + '_iso_rest' work_geo = iso_obj.solid_geometry if iso2geo is None else iso2geo # sorted_tools = [] @@ -2024,7 +2024,7 @@ class ToolIsolation(AppTool, Gerber): forced_rest = self.ui.forced_rest_iso_cb.get_value() iso_except = self.ui.except_cb.get_value() - outname = "%s_%.*f" % (iso_obj.options["name"], self.decimals, float(tool_dia)) + outname = "%s_%.*f" % (iso_obj.obj_options["name"], self.decimals, float(tool_dia)) internal_name = outname + "_iso" if iso_t == 0: internal_name = outname + "_ext_iso" @@ -2081,7 +2081,7 @@ class ToolIsolation(AppTool, Gerber): tools_storage.pop(tool, None) def iso_init(geo_obj, app_obj): - geo_obj.options["tools_mill_tooldia"] = str(tool_dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool_dia) geo_obj.tools = dict(tools_storage) geo_obj.solid_geometry = total_solid_geometry @@ -2116,10 +2116,10 @@ class ToolIsolation(AppTool, Gerber): empty_cnt += 1 if empty_cnt == len(geo_obj.solid_geometry): - app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.options["name"])) + app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.obj_options["name"])) return 'fail' else: - app_obj.inform.emit('[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])) + app_obj.inform.emit('[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"])) self.app.app_obj.new_object("geometry", iso_name, iso_init, plot=plot) @@ -2168,7 +2168,7 @@ class ToolIsolation(AppTool, Gerber): total_solid_geometry = [] - iso_name = iso_obj.options["name"] + '_iso_combined' + iso_name = iso_obj.obj_options["name"] + '_iso_combined' geometry = iso2geo if prog_plot is None: prog_plot = self.app.defaults["tools_iso_plotting"] @@ -2196,7 +2196,7 @@ class ToolIsolation(AppTool, Gerber): milling_type = tool_data['tools_iso_milling_type'] - outname = "%s_%.*f" % (iso_obj.options["name"], self.decimals, float(tool_dia)) + outname = "%s_%.*f" % (iso_obj.obj_options["name"], self.decimals, float(tool_dia)) internal_name = outname + "_iso" if iso_t == 0: @@ -2292,7 +2292,7 @@ class ToolIsolation(AppTool, Gerber): tools_storage.pop(tool, None) def iso_init(geo_obj, app_obj): - geo_obj.options["tools_mill_tooldia"] = str(tool_dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool_dia) geo_obj.tools = dict(tools_storage) geo_obj.solid_geometry = total_solid_geometry @@ -2324,10 +2324,10 @@ class ToolIsolation(AppTool, Gerber): empty_cnt += 1 if empty_cnt == len(geo_obj.solid_geometry): - app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.options["name"])) + app_obj.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Empty Geometry in"), geo_obj.obj_options["name"])) return 'fail' else: - app_obj.inform.emit('[success] %s: %s' % (_("Isolation geometry created"), geo_obj.options["name"])) + app_obj.inform.emit('[success] %s: %s' % (_("Isolation geometry created"), geo_obj.obj_options["name"])) self.app.app_obj.new_object("geometry", iso_name, iso_init, plot=plot) diff --git a/appPlugins/ToolLevelling.py b/appPlugins/ToolLevelling.py index 1ce2df63..1070f475 100644 --- a/appPlugins/ToolLevelling.py +++ b/appPlugins/ToolLevelling.py @@ -250,14 +250,14 @@ class ToolLevelling(AppTool, CNCjob): try: selected_obj = self.app.collection.get_active() if selected_obj.kind == 'cncjob': - current_name = selected_obj.options['name'] + current_name = selected_obj.obj_options['name'] self.ui.object_combo.set_value(current_name) except Exception: pass loaded_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value()) if loaded_obj and loaded_obj.kind == 'cncjob': - name = loaded_obj.options['name'] + name = loaded_obj.obj_options['name'] else: name = '' @@ -311,13 +311,13 @@ class ToolLevelling(AppTool, CNCjob): self.ui.al_method_radio.setDisabled(True) self.ui.al_method_radio.set_value('v') - if loaded_obj and loaded_obj.is_segmented_gcode is True and loaded_obj.options["type"] == 'Geometry': + if loaded_obj and loaded_obj.is_segmented_gcode is True and loaded_obj.obj_options["type"] == 'Geometry': self.ui.al_frame.setDisabled(False) - self.ui.al_mode_radio.set_value(loaded_obj.options['tools_al_mode']) + self.ui.al_mode_radio.set_value(loaded_obj.obj_options['tools_al_mode']) self.on_controller_change() - self.on_mode_radio(val=loaded_obj.options['tools_al_mode']) - self.on_method_radio(val=loaded_obj.options['tools_al_method']) + self.on_mode_radio(val=loaded_obj.obj_options['tools_al_mode']) + self.on_method_radio(val=loaded_obj.obj_options['tools_al_method']) else: self.ui.al_frame.setDisabled(True) @@ -346,7 +346,7 @@ class ToolLevelling(AppTool, CNCjob): return if target_obj is not None and target_obj.is_segmented_gcode is True and \ - target_obj.options["type"] == 'Geometry': + target_obj.obj_options["type"] == 'Geometry': self.ui.al_frame.setDisabled(False) @@ -369,7 +369,7 @@ class ToolLevelling(AppTool, CNCjob): if found_idx: try: sel_obj = current.indexes()[0].internalPointer().obj - name = sel_obj.options['name'] + name = sel_obj.obj_options['name'] kind = sel_obj.kind if kind == 'cncjob': @@ -1395,7 +1395,7 @@ class ToolLevelling(AppTool, CNCjob): header += '(This is a autolevelling probing GCode.)\n' \ '(Make sure that before you start the job you first do a zero for all axis.)\n\n' - header += '(Name: ' + str(target_obj.options['name']) + ')\n' + header += '(Name: ' + str(target_obj.obj_options['name']) + ')\n' header += '(Type: ' + "Autolevelling Probing GCode " + ')\n' header += '(Units: ' + self.units.upper() + ')\n' diff --git a/appPlugins/ToolMarkers.py b/appPlugins/ToolMarkers.py index cc0c4ecc..e40b03e9 100644 --- a/appPlugins/ToolMarkers.py +++ b/appPlugins/ToolMarkers.py @@ -87,7 +87,7 @@ class ToolMarkers(AppTool): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'geometry']: @@ -202,7 +202,7 @@ class ToolMarkers(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.object_combo.set_value(obj_name) if obj is None: @@ -379,7 +379,7 @@ class ToolMarkers(AppTool): return "fail" assert isinstance(geo_list, list), 'Geometry list should be a list but the type is: %s' % str(type(geo_list)) - new_name = '%s_%s' % (str(self.grb_object.options['name']), 'markers') + new_name = '%s_%s' % (str(self.grb_object.obj_options['name']), 'markers') return_val = self.generate_gerber_obj_with_markers(new_grb_obj=g_obj, marker_geometry=geo_list, outname=new_name) @@ -622,11 +622,11 @@ class ToolMarkers(AppTool): s_list.append(geo_buff_list) def initialize(grb_obj, app_obj): - grb_obj.options = LoudDict() - for opt in new_grb_obj.options: + grb_obj.obj_options = LoudDict() + for opt in new_grb_obj.obj_options: if opt != 'name': - grb_obj.options[opt] = deepcopy(new_grb_obj.options[opt]) - grb_obj.options['name'] = outname + grb_obj.obj_options[opt] = deepcopy(new_grb_obj.obj_options[opt]) + grb_obj.obj_options['name'] = outname grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(new_grb_obj.follow) @@ -709,13 +709,13 @@ class ToolMarkers(AppTool): s_list.append(marker_geometry) def initialize(geo_obj, app_obj): - geo_obj.options = LoudDict() - for opt in new_geo_obj.options: - geo_obj.options[opt] = deepcopy(new_geo_obj.options[opt]) - geo_obj.options['name'] = outname + geo_obj.obj_options = LoudDict() + for opt in new_geo_obj.obj_options: + geo_obj.obj_options[opt] = deepcopy(new_geo_obj.obj_options[opt]) + geo_obj.obj_options['name'] = outname # Propagate options - geo_obj.options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] + geo_obj.obj_options["tools_mill_tooldia"] = app_obj.defaults["tools_mill_tooldia"] geo_obj.solid_geometry = flatten_shapely_geometry(s_list) geo_obj.multitool = True @@ -816,17 +816,17 @@ class ToolMarkers(AppTool): } def obj_init(obj_inst, app_inst): - obj_inst.options.update({ + obj_inst.obj_options.update({ 'name': outname }) obj_inst.tools = deepcopy(tools) obj_inst.create_geometry() - obj_inst.source_file = app_inst.f_handlers.export_excellon(obj_name=obj_inst.options['name'], + obj_inst.source_file = app_inst.f_handlers.export_excellon(obj_name=obj_inst.obj_options['name'], local_use=obj_inst, filename=None, use_thread=False) - outname = '%s_%s' % (str(self.grb_object.options['name']), 'corner_drills') + outname = '%s_%s' % (str(self.grb_object.obj_options['name']), 'corner_drills') ret_val = self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False) self.app.call_source = "app" @@ -932,17 +932,17 @@ class ToolMarkers(AppTool): new_obj.tools[tool]['data']['tools_drill_ppname_e'] = 'Check_points' new_obj.create_geometry() - new_obj.options.update({ + new_obj.obj_options.update({ 'name': outname, 'tools_drill_cutz': -0.1, 'tools_drill_ppname_e': 'Check_points' }) - new_obj.source_file = app_inst.f_handlers.export_excellon(obj_name=new_obj.options['name'], + new_obj.source_file = app_inst.f_handlers.export_excellon(obj_name=new_obj.obj_options['name'], local_use=new_obj, filename=None, use_thread=False) - outname = '%s_%s' % (str(self.grb_object.options['name']), 'verification') + outname = '%s_%s' % (str(self.grb_object.obj_options['name']), 'verification') ret_val = self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False) self.app.call_source = "app" @@ -974,7 +974,7 @@ class ToolMarkers(AppTool): self.app.call_source = "app" return - new_name = '%s_%s' % (str(new_grb_obj.options['name']), 'markers') + new_name = '%s_%s' % (str(new_grb_obj.obj_options['name']), 'markers') return_val = self.generate_gerber_obj_with_markers(new_grb_obj=new_grb_obj, marker_geometry=geo_list, outname=new_name) else: @@ -989,7 +989,7 @@ class ToolMarkers(AppTool): self.app.call_source = "app" return - new_name = '%s_%s' % (str(new_geo_obj.options['name']), 'markers') + new_name = '%s_%s' % (str(new_geo_obj.obj_options['name']), 'markers') return_val = self.generate_geo_obj_with_markers(new_geo_obj=new_geo_obj, marker_geometry=geo_list, outname=new_name) if return_val == "fail": @@ -1032,10 +1032,10 @@ class ToolMarkers(AppTool): # update the bounding box values try: a, b, c, d = self.grb_object.bounds() - self.grb_object.options['xmin'] = a - self.grb_object.options['ymin'] = b - self.grb_object.options['xmax'] = c - self.grb_object.options['ymax'] = d + self.grb_object.obj_options['xmin'] = a + self.grb_object.obj_options['ymin'] = b + self.grb_object.obj_options['xmax'] = c + self.grb_object.obj_options['ymax'] = d except Exception as e: self.app.log.error("ToolMarkers.on_exit() copper_obj bounds error --> %s" % str(e)) diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index cf1475f0..4f0985b4 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -59,7 +59,7 @@ class HybridGeoExc: } } """ - self.options = {} + self.obj_options = {} self.tools = {} self.solid_geometry = [] @@ -67,18 +67,18 @@ class HybridGeoExc: for option in self.app.options: if option.find(kind + "_") == 0: oname = option[len(kind) + 1:] - self.options[oname] = self.app.options[option] + self.obj_options[oname] = self.app.options[option] for option in self.app.options: if option.find('tools_mill_') == 0: - self.options[option] = self.app.options[option] + self.obj_options[option] = self.app.options[option] for option in self.app.options: if option.find('tools_') == 0: - self.options[option] = self.app.options[option] + self.obj_options[option] = self.app.options[option] - self.options['xmin'] = 0 - self.options['ymin'] = 0 - self.options['xmax'] = 0 - self.options['ymax'] = 0 + self.obj_options['xmin'] = 0 + self.obj_options['ymin'] = 0 + self.obj_options['xmax'] = 0 + self.obj_options['ymax'] = 0 self.multigeo = True self.multitool = True @@ -479,10 +479,10 @@ class ToolMilling(AppTool, Excellon): else: if selected_obj.kind == 'excellon': self.ui.target_radio.set_value('exc') - self.ui.object_combo.set_value(selected_obj.options['name']) + self.ui.object_combo.set_value(selected_obj.obj_options['name']) elif selected_obj.kind == 'geometry': self.ui.target_radio.set_value('geo') - self.ui.object_combo.set_value(selected_obj.options['name']) + self.ui.object_combo.set_value(selected_obj.obj_options['name']) else: self.ui.target_radio.set_value('geo') self.ui.object_combo.setCurrentIndex(0) @@ -688,11 +688,11 @@ class ToolMilling(AppTool, Excellon): self.ui.plot_cb.stateChanged.connect(self.on_plot_clicked) if self.target_obj is not None: - self.ui.plot_cb.set_value(self.target_obj.options['plot']) + self.ui.plot_cb.set_value(self.target_obj.obj_options['plot']) def on_plot_clicked(self, state): if self.target_obj: - self.target_obj.options['plot'] = True if state else False + self.target_obj.obj_options['plot'] = True if state else False def change_level(self, level): """ @@ -788,7 +788,7 @@ class ToolMilling(AppTool, Excellon): # Tool parameters section if self.ui.target_radio.get_value() == 'geo': if self.target_obj: - app_defaults = self.target_obj.options + app_defaults = self.target_obj.obj_options for tool in self.target_obj.tools: tool_data = self.target_obj.tools[tool]['data'] @@ -1417,7 +1417,7 @@ class ToolMilling(AppTool, Excellon): if found_idx: try: sel_obj = current.indexes()[0].internalPointer().obj - name = sel_obj.options['name'] + name = sel_obj.obj_options['name'] kind = sel_obj.kind if kind == 'excellon': self.ui.target_radio.set_value('exc') @@ -1812,7 +1812,7 @@ class ToolMilling(AppTool, Excellon): except Exception: self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), str(self.obj_name))) return - storage = self.app.options if self.target_obj is None else self.target_obj.options + storage = self.app.options if self.target_obj is None else self.target_obj.obj_options # calculate self.currnet_row for the cellWidgets in the Tools Table if self.ui.target_radio.get_value() == 'geo': @@ -2239,7 +2239,7 @@ class ToolMilling(AppTool, Excellon): } }) - self.target_obj.tools[self.tooluid]['data']['name'] = deepcopy(self.target_obj.options['name']) + self.target_obj.tools[self.tooluid]['data']['name'] = deepcopy(self.target_obj.obj_options['name']) # we do this HACK to make sure the tools attribute to be serialized is updated in the self.ser_attrs list try: @@ -2314,7 +2314,7 @@ class ToolMilling(AppTool, Excellon): } }) - self.target_obj.tools[self.tooluid]['data']['name'] = deepcopy(self.target_obj.options['name']) + self.target_obj.tools[self.tooluid]['data']['name'] = deepcopy(self.target_obj.obj_options['name']) # we do this HACK to make sure the tools attribute to be serialized is updated in the self.ser_attrs list try: @@ -2495,23 +2495,23 @@ class ToolMilling(AppTool, Excellon): # we make it back SingleGeo if self.ui.geo_tools_table.rowCount() <= 0: obj_active.multigeo = False - obj_active.options['xmin'] = 0 - obj_active.options['ymin'] = 0 - obj_active.options['xmax'] = 0 - obj_active.options['ymax'] = 0 + obj_active.obj_options['xmin'] = 0 + obj_active.obj_options['ymin'] = 0 + obj_active.obj_options['xmax'] = 0 + obj_active.obj_options['ymax'] = 0 if obj_active.multigeo is True: try: xmin, ymin, xmax, ymax = obj_active.bounds() - obj_active.options['xmin'] = xmin - obj_active.options['ymin'] = ymin - obj_active.options['xmax'] = xmax - obj_active.options['ymax'] = ymax + obj_active.obj_options['xmin'] = xmin + obj_active.obj_options['ymin'] = ymin + obj_active.obj_options['xmax'] = xmax + obj_active.obj_options['ymax'] = ymax except Exception: - obj_active.options['xmin'] = 0 - obj_active.options['ymin'] = 0 - obj_active.options['xmax'] = 0 - obj_active.options['ymax'] = 0 + obj_active.obj_options['xmin'] = 0 + obj_active.obj_options['ymin'] = 0 + obj_active.obj_options['xmax'] = 0 + obj_active.obj_options['ymax'] = 0 # if there is no tool left in the Tools Table, disable the parameters appGUI if self.ui.geo_tools_table.rowCount() == 0: @@ -2546,10 +2546,10 @@ class ToolMilling(AppTool, Excellon): tools = self.get_selected_tools_list() if outname is None: - outname = self.target_obj.options["name"] + "_mill" + outname = self.target_obj.obj_options["name"] + "_mill" if tooldia is None: - tooldia = float(self.target_obj.options["tooldia"]) + tooldia = float(self.target_obj.obj_options["tooldia"]) # Sort tools by diameter. items() -> [('name', diameter), ...] sorted_tools = sorted(list(self.tools.items()), key=lambda tl: tl[1]['tooldia']) @@ -2595,9 +2595,9 @@ class ToolMilling(AppTool, Excellon): # ## Add properties to the object - geo_obj.options['type'] = 'Excellon Geometry' - geo_obj.options["tools_mill_tooldia"] = str(tooldia) - geo_obj.options["tools_mill_multidepth"] = self.target_obj.options["tools_mill_multidepth"] + geo_obj.obj_options['type'] = 'Excellon Geometry' + geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia) + geo_obj.obj_options["tools_mill_multidepth"] = self.target_obj.obj_options["tools_mill_multidepth"] geo_obj.solid_geometry = [] # in case that the tool used has the same diameter with the hole, and since the maximum resolution @@ -2656,10 +2656,10 @@ class ToolMilling(AppTool, Excellon): tools = self.get_selected_tools_list() if outname is None: - outname = self.target_obj.options["name"] + "_slots" + outname = self.target_obj.obj_options["name"] + "_slots" if tooldia is None: - tooldia = float(self.target_obj.options["slot_tooldia"]) + tooldia = float(self.target_obj.obj_options["slot_tooldia"]) # Sort tools by diameter. items() -> [('name', diameter), ...] sorted_tools = sorted(list(self.tools.items()), key=lambda tl: tl[1]['tooldia']) @@ -2694,9 +2694,9 @@ class ToolMilling(AppTool, Excellon): # ## Add properties to the object - geo_obj.options['type'] = 'Excellon Geometry' - geo_obj.options["tools_mill_tooldia"] = str(tooldia) - geo_obj.options["tools_mill_multidepth"] = self.target_obj.options["tools_mill_multidepth"] + geo_obj.obj_options['type'] = 'Excellon Geometry' + geo_obj.obj_options["tools_mill_tooldia"] = str(tooldia) + geo_obj.obj_options["tools_mill_multidepth"] = self.target_obj.obj_options["tools_mill_multidepth"] geo_obj.solid_geometry = [] # in case that the tool used has the same diameter with the hole, and since the maximum resolution @@ -2818,20 +2818,20 @@ class ToolMilling(AppTool, Excellon): self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed. No tool selected in the tool table ...")) def paint_excellon_cncjpb(self): - outname = "%s_%s" % (self.target_obj.options["name"], 'exc_cnc') + outname = "%s_%s" % (self.target_obj.obj_options["name"], 'exc_cnc') tools_dict = self.sel_tools new_obj = HybridGeoExc(app=self.app) - new_obj.options = dict() - for opt, val in self.target_obj.options.items(): - new_obj.options[opt] = val - new_obj.options['name'] = outname + new_obj.obj_options = dict() + for opt, val in self.target_obj.obj_options.items(): + new_obj.obj_options[opt] = val + new_obj.obj_options['name'] = outname new_obj.units = self.app.options["units"] kind = 'geometry' for option in self.app.options: if option.find(kind + "_") == 0: oname = option[len(kind) + 1:] - new_obj.options[oname] = self.app.options[option] + new_obj.obj_options[oname] = self.app.options[option] for tool in tools_dict: old_disp_number = 0 @@ -3017,13 +3017,13 @@ class ToolMilling(AppTool, Excellon): geo_obj = geo_obj if geo_obj is not None else self.target_obj # use the name of the first tool selected in self.geo_tools_table which has the diameter passed as tool_dia - outname = "%s_%s" % (geo_obj.options["name"], 'cnc') if outname is None else outname + outname = "%s_%s" % (geo_obj.obj_options["name"], 'cnc') if outname is None else outname tools_dict = self.sel_tools if tools_dict is None else tools_dict if not geo_obj.tools: - segx = segx if segx is not None else float(geo_obj.options['segx']) - segy = segy if segy is not None else float(geo_obj.options['segy']) + segx = segx if segx is not None else float(geo_obj.obj_options['segx']) + segy = segy if segy is not None else float(geo_obj.obj_options['segy']) else: tools_list = list(geo_obj.tools.keys()) # the segx and segy values are the same for all tools os we just take the values from the first tool @@ -3036,7 +3036,7 @@ class ToolMilling(AppTool, Excellon): segx = data_dict['geometry_segx'] except KeyError: try: - segx = geo_obj.options['segx'] + segx = geo_obj.obj_options['segx'] except KeyError: segx = self.app.defaults['geometry_segx'] try: @@ -3046,15 +3046,15 @@ class ToolMilling(AppTool, Excellon): segy = data_dict['geometry_segy'] except KeyError: try: - segy = geo_obj.options['segy'] + segy = geo_obj.obj_options['segy'] except KeyError: segy = self.app.defaults['geometry_segy'] try: - xmin = geo_obj.options['xmin'] - ymin = geo_obj.options['ymin'] - xmax = geo_obj.options['xmax'] - ymax = geo_obj.options['ymax'] + xmin = geo_obj.obj_options['xmin'] + ymin = geo_obj.obj_options['ymin'] + xmax = geo_obj.obj_options['xmax'] + ymax = geo_obj.obj_options['ymax'] except Exception as e: self.app.log.error("FlatCAMObj.GeometryObject.mtool_gen_cncjob() --> %s\n" % str(e)) @@ -3075,10 +3075,10 @@ class ToolMilling(AppTool, Excellon): self.app.log.debug("Creating a CNCJob out of a single-geometry") assert new_cncjob_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(new_cncjob_obj) - new_cncjob_obj.options['xmin'] = xmin - new_cncjob_obj.options['ymin'] = ymin - new_cncjob_obj.options['xmax'] = xmax - new_cncjob_obj.options['ymax'] = ymax + new_cncjob_obj.obj_options['xmin'] = xmin + new_cncjob_obj.obj_options['ymin'] = ymin + new_cncjob_obj.obj_options['xmax'] = xmax + new_cncjob_obj.obj_options['ymax'] = ymax # count the tools tool_cnt = 0 @@ -3093,8 +3093,8 @@ class ToolMilling(AppTool, Excellon): new_cncjob_obj.segx = segx new_cncjob_obj.segy = segy - new_cncjob_obj.z_pdepth = float(geo_obj.options["tools_mill_z_pdepth"]) - new_cncjob_obj.feedrate_probe = float(geo_obj.options["tools_mill_feedrate_probe"]) + new_cncjob_obj.z_pdepth = float(geo_obj.obj_options["tools_mill_z_pdepth"]) + new_cncjob_obj.feedrate_probe = float(geo_obj.obj_options["tools_mill_feedrate_probe"]) total_gcode = '' for tooluid_key in list(tools_dict.keys()): @@ -3106,7 +3106,7 @@ class ToolMilling(AppTool, Excellon): dia_cnc_dict['data']['tools_mill_tooldia'] = tooldia_val if "optimization_type" not in tools_dict[tooluid_key]['data']: - def_optimization_type = geo_obj.options["tools_mill_optimization_type"] + def_optimization_type = geo_obj.obj_options["tools_mill_optimization_type"] tools_dict[tooluid_key]['data']["tools_mill_optimization_type"] = def_optimization_type if dia_cnc_dict['data']['tools_mill_offset_type'] == 1: # 'in' @@ -3167,9 +3167,9 @@ class ToolMilling(AppTool, Excellon): new_cncjob_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] # Propagate options - new_cncjob_obj.options["tooldia"] = tooldia_val - new_cncjob_obj.options['type'] = 'Geometry' - new_cncjob_obj.options['tool_dia'] = tooldia_val + new_cncjob_obj.obj_options["tooldia"] = tooldia_val + new_cncjob_obj.obj_options['type'] = 'Geometry' + new_cncjob_obj.obj_options['tool_dia'] = tooldia_val tool_lst = list(tools_dict.keys()) is_first = True if tooluid_key == tool_lst[0] else False @@ -3227,10 +3227,10 @@ class ToolMilling(AppTool, Excellon): self.app.log.debug("Creating a CNCJob out of a multi-geometry") assert new_cncjob_obj.kind == 'cncjob', "Initializer expected a CNCJobObject, got %s" % type(new_cncjob_obj) - new_cncjob_obj.options['xmin'] = xmin - new_cncjob_obj.options['ymin'] = ymin - new_cncjob_obj.options['xmax'] = xmax - new_cncjob_obj.options['ymax'] = ymax + new_cncjob_obj.obj_options['xmin'] = xmin + new_cncjob_obj.obj_options['ymin'] = ymin + new_cncjob_obj.obj_options['xmax'] = xmax + new_cncjob_obj.obj_options['ymax'] = ymax # count the tools tool_cnt = 0 @@ -3245,8 +3245,8 @@ class ToolMilling(AppTool, Excellon): new_cncjob_obj.segx = segx new_cncjob_obj.segy = segy - new_cncjob_obj.z_pdepth = float(geo_obj.options["tools_mill_z_pdepth"]) - new_cncjob_obj.feedrate_probe = float(geo_obj.options["tools_mill_feedrate_probe"]) + new_cncjob_obj.z_pdepth = float(geo_obj.obj_options["tools_mill_z_pdepth"]) + new_cncjob_obj.feedrate_probe = float(geo_obj.obj_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 geo_obj.solid_geometry: @@ -3272,7 +3272,7 @@ class ToolMilling(AppTool, Excellon): # Path optimizations if "optimization_type" not in tools_dict[tooluid_key]['data']: - def_optimization_type = geo_obj.options["tools_mill_optimization_type"] + def_optimization_type = geo_obj.obj_options["tools_mill_optimization_type"] tools_dict[tooluid_key]['data']["tools_mill_optimization_type"] = def_optimization_type # Polishing @@ -3460,9 +3460,9 @@ class ToolMilling(AppTool, Excellon): new_cncjob_obj.fr_decimals = self.app.defaults["cncjob_fr_decimals"] # Propagate options - new_cncjob_obj.options["tooldia"] = tooldia_val - new_cncjob_obj.options['type'] = 'Geometry' - new_cncjob_obj.options['tool_dia'] = tooldia_val + new_cncjob_obj.obj_options["tooldia"] = tooldia_val + new_cncjob_obj.obj_options['type'] = 'Geometry' + new_cncjob_obj.obj_options['tool_dia'] = tooldia_val # 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 diff --git a/appPlugins/ToolMove.py b/appPlugins/ToolMove.py index a18e8d26..a1fe4e03 100644 --- a/appPlugins/ToolMove.py +++ b/appPlugins/ToolMove.py @@ -153,7 +153,7 @@ class ToolMove(AppTool): # move only the objects selected and plotted and visible obj_list = [obj for obj in self.app.collection.get_selected() - if obj.options['plot'] and obj.visible is True] + if obj.obj_options['plot'] and obj.visible is True] def job_move(app_obj): with self.app.proc_container.new('%s...' % _("Moving")): @@ -180,10 +180,10 @@ class ToolMove(AppTool): # Update the object bounding box options a, b, c, d = sel_obj.bounds() - sel_obj.options['xmin'] = a - sel_obj.options['ymin'] = b - sel_obj.options['xmax'] = c - sel_obj.options['ymax'] = d + sel_obj.obj_options['xmin'] = a + sel_obj.obj_options['ymin'] = b + sel_obj.obj_options['xmax'] = c + sel_obj.obj_options['ymax'] = d try: sel_obj.set_offset_values() @@ -193,7 +193,7 @@ class ToolMove(AppTool): # update the source_file with the new positions for sel_obj in obj_list: - out_name = sel_obj.options["name"] + out_name = sel_obj.obj_options["name"] if sel_obj.kind == 'gerber': sel_obj.source_file = self.app.f_handlers.export_gerber( obj_name=out_name, filename=None, local_use=sel_obj, use_thread=False) @@ -278,7 +278,7 @@ class ToolMove(AppTool): # first get a bounding box to fit all for obj in obj_list: # don't move disabled objects, move only plotted objects - if obj.options['plot']: + if obj.obj_options['plot']: xmin, ymin, xmax, ymax = obj.bounds() xminlist.append(xmin) yminlist.append(ymin) diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index d96be80a..2f9ab019 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -315,7 +315,7 @@ class NonCopperClear(AppTool, Gerber): self.on_type_obj_index_changed(val=kind) self.on_reference_combo_changed() - self.ui.object_combo.set_value(active.options['name']) + self.ui.object_combo.set_value(active.obj_options['name']) else: kind = 'gerber' self.ui.type_obj_radio.set_value('gerber') @@ -524,7 +524,7 @@ class NonCopperClear(AppTool, Gerber): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'geometry']: @@ -2518,7 +2518,7 @@ class NonCopperClear(AppTool, Gerber): except KeyError: tools_storage.pop(uid, None) - geo_obj.options["tools_mill_tooldia"] = str(tool) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool) geo_obj.multigeo = True geo_obj.tools = dict(tools_storage) @@ -2780,7 +2780,7 @@ class NonCopperClear(AppTool, Gerber): # area = unary_union(area) geo_obj.multigeo = True - geo_obj.options["tools_mill_tooldia"] = '0.0' + 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': @@ -3365,7 +3365,7 @@ class NonCopperClear(AppTool, Gerber): except KeyError: tools_storage.pop(uid, None) - geo_obj.options["tools_mill_tooldia"] = str(tool) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool) geo_obj.multigeo = True geo_obj.tools.clear() @@ -3765,7 +3765,7 @@ class NonCopperClear(AppTool, Gerber): app_obj.log.debug("There are no geometries in the cleared polygon.") geo_obj.multigeo = True - geo_obj.options["tools_mill_tooldia"] = str(tool) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool) # check to see if geo_obj.tools is empty # it will be updated only if there is a solid_geometry for tools diff --git a/appPlugins/ToolOptimal.py b/appPlugins/ToolOptimal.py index 0e44febb..a557ef21 100644 --- a/appPlugins/ToolOptimal.py +++ b/appPlugins/ToolOptimal.py @@ -206,7 +206,7 @@ class ToolOptimal(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.gerber_object_combo.set_value(obj_name) def find_minimum_distance(self): diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index 3dcb1a91..7b2cb9b6 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -373,7 +373,7 @@ class ToolPaint(AppTool, Gerber): self.on_type_obj_changed(val=kind) self.on_reference_combo_changed() - self.ui.obj_combo.set_value(active.options['name']) + self.ui.obj_combo.set_value(active.obj_options['name']) else: kind = 'geometry' self.ui.type_obj_radio.set_value('geometry') @@ -542,7 +542,7 @@ class ToolPaint(AppTool, Gerber): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'geometry']: @@ -2026,7 +2026,7 @@ class ToolPaint(AppTool, Gerber): if not tools_storage: return 'fail' - geo_obj.options["tools_mill_tooldia"] = str(tool_dia) + geo_obj.obj_options["tools_mill_tooldia"] = str(tool_dia) # this will turn on the FlatCAMCNCJob plot for multiple tools geo_obj.multigeo = True geo_obj.multitool = True @@ -2041,10 +2041,10 @@ class ToolPaint(AppTool, Gerber): else: a, b, c, d = geo_obj.solid_geometry.bounds - geo_obj.options['xmin'] = a - geo_obj.options['ymin'] = b - geo_obj.options['xmax'] = c - geo_obj.options['ymax'] = d + geo_obj.obj_options['xmin'] = a + geo_obj.obj_options['ymin'] = b + geo_obj.obj_options['xmax'] = c + geo_obj.obj_options['ymax'] = d except Exception as ee: self.app.log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) return @@ -2255,7 +2255,7 @@ class ToolPaint(AppTool, Gerber): break geo_obj.multigeo = True - geo_obj.options["tools_mill_tooldia"] = '0.0' + 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': @@ -2297,10 +2297,10 @@ class ToolPaint(AppTool, Gerber): else: a, b, c, d = geo_obj.solid_geometry.bounds - geo_obj.options['xmin'] = a - geo_obj.options['ymin'] = b - geo_obj.options['xmax'] = c - geo_obj.options['ymax'] = d + geo_obj.obj_options['xmin'] = a + geo_obj.obj_options['ymin'] = b + geo_obj.obj_options['xmax'] = c + geo_obj.obj_options['ymax'] = d except Exception as ee: app_obj.log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) return diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index 4644d888..56c037ca 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -138,7 +138,7 @@ class Panelize(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj: - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] if obj.kind == 'gerber': # run once to make sure that the obj_type attribute is updated in the FCComboBox self.ui.type_obj_combo.set_value(_("Gerber")) @@ -250,7 +250,7 @@ class Panelize(AppTool): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind in ['gerber', 'excellon', 'geometry']: @@ -418,10 +418,10 @@ class Panelize(AppTool): obj_fin.tools = copied_tools obj_fin.solid_geometry = [] - for option in panel_source_obj.options: + for option in panel_source_obj.obj_options: if option != 'name': try: - obj_fin.options[option] = panel_source_obj.options[option] + obj_fin.obj_options[option] = panel_source_obj.obj_options[option] except KeyError: app_obj.log.warning("Failed to copy option. %s" % str(option)) diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index 489eeb92..43c7befa 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -98,7 +98,7 @@ class ToolPunchGerber(AppTool, Gerber): for ap_code in grb_obj.tools: grb_obj.mark_shapes_storage[ap_code] = [] - self.old_name = grb_obj.options['name'] + self.old_name = grb_obj.obj_options['name'] def run(self, toggle=True): self.app.defaults.report_usage("ToolPunchGerber()") @@ -244,7 +244,7 @@ class ToolPunchGerber(AppTool, Gerber): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.gerber_object_combo.set_value(obj_name) # Show/Hide Advanced Options @@ -515,9 +515,9 @@ class ToolPunchGerber(AppTool, Gerber): self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return - name = self.grb_obj.options['name'].rpartition('.')[0] + name = self.grb_obj.obj_options['name'].rpartition('.')[0] if name == '': - name = self.grb_obj.options['name'] + name = self.grb_obj.obj_options['name'] outname = name + "_punched" if punch_type == 'a': @@ -581,8 +581,8 @@ class ToolPunchGerber(AppTool, Gerber): return new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) # selected codes in the apertures UI table sel_apid = [] @@ -661,8 +661,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) @@ -686,8 +686,8 @@ class ToolPunchGerber(AppTool, Gerber): return new_options = {} - for opt in self.grb_obj.options: - new_options[opt] = deepcopy(self.grb_obj.options[opt]) + for opt in self.grb_obj.obj_options: + new_options[opt] = deepcopy(self.grb_obj.obj_options[opt]) # selected codes in the apertures UI table sel_apid = [] @@ -782,8 +782,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) @@ -805,8 +805,8 @@ class ToolPunchGerber(AppTool, Gerber): " some of the apertures in the Gerber object.") new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) # selected codes in the apertures UI table sel_apid = [] @@ -915,8 +915,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) @@ -938,8 +938,8 @@ class ToolPunchGerber(AppTool, Gerber): " some of the apertures in the Gerber object.") new_options = {} - for opt in self.grb_obj.options: - new_options[opt] = deepcopy(self.grb_obj.options[opt]) + for opt in self.grb_obj.obj_options: + new_options[opt] = deepcopy(self.grb_obj.obj_options[opt]) # selected codes in the apertures UI table sel_apid = [] @@ -1010,8 +1010,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) @@ -1032,8 +1032,8 @@ class ToolPunchGerber(AppTool, Gerber): dia = None new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) if isinstance(grb_obj.solid_geometry, list): temp_solid_geometry = MultiPolygon(grb_obj.solid_geometry) @@ -1159,8 +1159,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) @@ -1181,8 +1181,8 @@ class ToolPunchGerber(AppTool, Gerber): dia = None new_options = {} - for opt in self.grb_obj.options: - new_options[opt] = deepcopy(self.grb_obj.options[opt]) + for opt in self.grb_obj.obj_options: + new_options[opt] = deepcopy(self.grb_obj.obj_options[opt]) if isinstance(self.grb_obj.solid_geometry, list): temp_solid_geometry = MultiPolygon(self.grb_obj.solid_geometry) @@ -1299,8 +1299,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) @@ -1316,8 +1316,8 @@ class ToolPunchGerber(AppTool, Gerber): prop_factor = self.ui.factor_entry.get_value() / 100.0 dia = None new_options = {} - for opt in grb_obj.options: - new_options[opt] = deepcopy(grb_obj.options[opt]) + for opt in grb_obj.obj_options: + new_options[opt] = deepcopy(grb_obj.obj_options[opt]) if isinstance(grb_obj.solid_geometry, list): temp_solid_geometry = MultiPolygon(grb_obj.solid_geometry) @@ -1443,8 +1443,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) @@ -1460,8 +1460,8 @@ class ToolPunchGerber(AppTool, Gerber): prop_factor = self.ui.factor_entry.get_value() / 100.0 dia = None new_options = {} - for opt in self.grb_obj.options: - new_options[opt] = deepcopy(self.grb_obj.options[opt]) + for opt in self.grb_obj.obj_options: + new_options[opt] = deepcopy(self.grb_obj.obj_options[opt]) if isinstance(self.grb_obj.solid_geometry, list): temp_solid_geometry = MultiPolygon(self.grb_obj.solid_geometry) @@ -1579,8 +1579,8 @@ class ToolPunchGerber(AppTool, Gerber): new_apertures[new_apid] = deepcopy(ap_val) def init_func(new_obj, app_obj): - new_obj.options.update(new_options) - new_obj.options['name'] = outname + new_obj.obj_options.update(new_options) + new_obj.obj_options['name'] = outname new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) @@ -1641,9 +1641,9 @@ class ToolPunchGerber(AppTool, Gerber): 'clear': Shapely Polygon } ''' - name = self.grb_obj.options['name'].rpartition('.')[0] + name = self.grb_obj.obj_options['name'].rpartition('.')[0] if name == '': - name = self.grb_obj.options['name'] + name = self.grb_obj.obj_options['name'] outname = name + "_punched" if punch_method == 'exc': diff --git a/appPlugins/ToolQRCode.py b/appPlugins/ToolQRCode.py index cf2a0b86..d18881a9 100644 --- a/appPlugins/ToolQRCode.py +++ b/appPlugins/ToolQRCode.py @@ -176,7 +176,7 @@ class QRCode(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.grb_object_combo.set_value(obj_name) # Show/Hide Advanced Options @@ -383,10 +383,10 @@ class QRCode(AppTool): try: a, b, c, d = self.grb_object.bounds() - self.grb_object.options['xmin'] = a - self.grb_object.options['ymin'] = b - self.grb_object.options['xmax'] = c - self.grb_object.options['ymax'] = d + self.grb_object.obj_options['xmin'] = a + self.grb_object.obj_options['ymin'] = b + self.grb_object.obj_options['xmax'] = c + self.grb_object.obj_options['ymax'] = d except Exception as e: self.app.log.error("QRCode.make() bounds error --> %s" % str(e)) @@ -402,7 +402,7 @@ class QRCode(AppTool): self.grb_object.tools[new_apid]['geometry'].append(deepcopy(geo_elem)) # update the source file with the new geometry: - self.grb_object.source_file = self.app.f_handlers.export_gerber(obj_name=self.grb_object.options['name'], + self.grb_object.source_file = self.app.f_handlers.export_gerber(obj_name=self.grb_object.obj_options['name'], filename=None, local_use=self.grb_object, use_thread=False) diff --git a/appPlugins/ToolReport.py b/appPlugins/ToolReport.py index 985babb4..14d9508d 100644 --- a/appPlugins/ToolReport.py +++ b/appPlugins/ToolReport.py @@ -218,7 +218,7 @@ class ObjectReport(AppTool): except Exception as e: self.app.log.error("Properties.addItems() --> %s" % str(e)) - self.treeWidget.addChild(obj_name, [obj.options['name']]) + self.treeWidget.addChild(obj_name, [obj.obj_options['name']]) def job_thread(obj_prop): self.app.proc_container.new('%s...' % _("Working")) @@ -377,10 +377,10 @@ class ObjectReport(AppTool): self.treeWidget.addChild(units, ['Object units:', o_unit], True) # Options items - for option in obj.options: + for option in obj.obj_options: if option == 'name': continue - self.treeWidget.addChild(options, [str(option), str(obj.options[option])], True) + self.treeWidget.addChild(options, [str(option), str(obj.obj_options[option])], True) # Items that depend on the object type if obj.kind.lower() == 'gerber': @@ -474,7 +474,7 @@ class ObjectReport(AppTool): self.treeWidget.addChild(geo_tool, [str(k), str(v)], True) elif obj.kind.lower() == 'cncjob': # for CNCJob objects made from Gerber or Geometry objects - if obj.options['type'].lower() == 'geometry': + if obj.obj_options['type'].lower() == 'geometry': for tool, value in obj.tools.items(): geo_tool = self.treeWidget.addParent( tools, str(tool), expanded=True, color=p_color, font=font) @@ -500,7 +500,7 @@ class ObjectReport(AppTool): self.treeWidget.addChild(tool_data, [str(data_k).capitalize(), str(data_v)], True) # for CNCJob objects made from Excellon objects - if obj.options['type'].lower() == 'excellon': + if obj.obj_options['type'].lower() == 'excellon': for tool_id, value in obj.tools.items(): tool_dia = obj.tools[tool_id]['tooldia'] exc_tool = self.treeWidget.addParent( diff --git a/appPlugins/ToolRulesCheck.py b/appPlugins/ToolRulesCheck.py index 4fdf4762..a9bc51d9 100644 --- a/appPlugins/ToolRulesCheck.py +++ b/appPlugins/ToolRulesCheck.py @@ -61,7 +61,7 @@ class RulesCheck(AppTool): self.decimals = 4 # def on_object_loaded(self, index, row): - # print(index.internalPointer().child_items[row].obj.options['name'], index.data()) + # print(index.internalPointer().child_items[row].obj.obj_options['name'], index.data()) def run(self, toggle=True): self.app.defaults.report_usage("ToolRulesCheck()") diff --git a/appPlugins/ToolSolderPaste.py b/appPlugins/ToolSolderPaste.py index b8615108..6ae47446 100644 --- a/appPlugins/ToolSolderPaste.py +++ b/appPlugins/ToolSolderPaste.py @@ -53,7 +53,7 @@ class SolderPaste(AppTool): self.tooltable_tools = {} self.tooluid = 0 - self.options = LoudDict() + self.obj_options = LoudDict() self.form_fields = {} self.units = '' @@ -185,7 +185,7 @@ class SolderPaste(AppTool): for option in self.app.options: if option.find('tools_') == 0: - self.options[option] = deepcopy(self.app.options[option] ) + self.obj_options[option] = deepcopy(self.app.options[option] ) self.read_form_to_options() self.clear_context_menu() @@ -210,7 +210,7 @@ class SolderPaste(AppTool): self.tooltable_tools.update({ int(self.tooluid): { 'tooldia': float('%.*f' % (self.decimals, tool_dia)), - 'data': deepcopy(self.options), + 'data': deepcopy(self.obj_options), 'solid_geometry': [] } }) @@ -231,7 +231,7 @@ class SolderPaste(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.obj_combo.set_value(obj_name) def build_ui(self): @@ -427,7 +427,7 @@ class SolderPaste(AppTool): :return: """ try: - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] except AttributeError: # this happen when the 'delete all' is emitted since in that case the obj is set to None and None has no # attribute named 'options' @@ -448,12 +448,12 @@ class SolderPaste(AppTool): def read_form_to_options(self): """ - Will read all the parameters from Solder Paste Tool UI and update the self.options dictionary + Will read all the parameters from Solder Paste Tool UI and update the self.obj_options dictionary :return: """ for key in self.form_fields: - self.options[key] = self.form_fields[key].get_value() + self.obj_options[key] = self.form_fields[key].get_value() def form_to_storage(self, tooluid=None): """ @@ -558,7 +558,7 @@ class SolderPaste(AppTool): self.tooltable_tools.update({ int(self.tooluid): { 'tooldia': float('%.*f' % (self.decimals, tool_dia)), - 'data': deepcopy(self.options), + 'data': deepcopy(self.obj_options), 'solid_geometry': [] } }) @@ -717,7 +717,7 @@ class SolderPaste(AppTool): return obj = self.app.collection.get_by_name(name) - # update the self.options + # update the self.obj_options self.read_form_to_options() self.on_create_geo(name=name, work_object=obj) @@ -794,7 +794,7 @@ class SolderPaste(AppTool): return def geo_init(geo_obj, app_obj): - geo_obj.options.update(self.options) + geo_obj.obj_options.update(self.obj_options) geo_obj.solid_geometry = [] geo_obj.tools = {} @@ -947,7 +947,7 @@ class SolderPaste(AppTool): return # use the name of the first tool selected in self.geo_tools_table which has the diameter passed as tool_dia - originar_name = obj.options['name'].partition('_')[0] + originar_name = obj.obj_options['name'].partition('_')[0] outname = "%s_%s" % (originar_name, 'cnc_solderpaste') self.on_create_gcode(name=outname, workobject=obj) @@ -964,10 +964,10 @@ class SolderPaste(AppTool): obj = workobject try: - xmin = obj.options['xmin'] - ymin = obj.options['ymin'] - xmax = obj.options['xmax'] - ymax = obj.options['ymax'] + xmin = obj.obj_options['xmin'] + ymin = obj.obj_options['ymin'] + xmax = obj.obj_options['xmax'] + ymax = obj.obj_options['ymax'] except Exception as e: self.app.log.error("SolderPaste.on_create_gcode() --> %s\n" % str(e)) msg = '[ERROR] %s' % _("An internal error has occurred. See shell.\n") @@ -989,10 +989,10 @@ class SolderPaste(AppTool): new_obj.tools.clear() new_obj.special_group = 'solder_paste_tool' - new_obj.options['xmin'] = xmin - new_obj.options['ymin'] = ymin - new_obj.options['xmax'] = xmax - new_obj.options['ymax'] = ymax + new_obj.obj_options['xmin'] = xmin + new_obj.obj_options['ymin'] = ymin + new_obj.obj_options['xmax'] = xmax + new_obj.obj_options['ymax'] = ymax total_gcode = '' for tooluid_key, tooluid_value in obj.tools.items(): @@ -1005,8 +1005,8 @@ class SolderPaste(AppTool): new_obj.tool = int(tooluid_key) # Propagate options - new_obj.options["tooldia"] = tool_dia - new_obj.options['tool_dia'] = tool_dia + new_obj.obj_options["tooldia"] = tool_dia + new_obj.obj_options['tool_dia'] = tool_dia # ## CREATE GCODE # ## res = new_obj.generate_gcode_from_solderpaste_geo(**tooluid_value) @@ -1083,7 +1083,7 @@ class SolderPaste(AppTool): (str(self.app.version), str(self.app.version_date)) + '\n' gcode += '(Name: ' + str(name) + ')\n' - gcode += '(Type: ' + "G-code from " + str(obj.options['type']) + " for Solder Paste dispenser" + ')\n' + gcode += '(Type: ' + "G-code from " + str(obj.obj_options['type']) + " for Solder Paste dispenser" + ')\n' gcode += '(Units: ' + self.units.upper() + ')\n' + "\n" gcode += '(Created on ' + time_str + ')\n' + '\n' @@ -1154,7 +1154,7 @@ class SolderPaste(AppTool): (str(self.app.version), str(self.app.version_date)) + '\n' gcode += '(Name: ' + str(name) + ')\n' - gcode += '(Type: ' + "G-code from " + str(obj.options['type']) + " for Solder Paste dispenser" + ')\n' + gcode += '(Type: ' + "G-code from " + str(obj.obj_options['type']) + " for Solder Paste dispenser" + ')\n' gcode += '(Units: ' + self.units.upper() + ')\n' + "\n" gcode += '(Created on ' + time_str + ')\n' + '\n' diff --git a/appPlugins/ToolSub.py b/appPlugins/ToolSub.py index 44ad16d2..5bbba663 100644 --- a/appPlugins/ToolSub.py +++ b/appPlugins/ToolSub.py @@ -173,7 +173,7 @@ class ToolSub(AppTool): if found_idx: try: - name = current.indexes()[0].internalPointer().obj.options['name'] + name = current.indexes()[0].internalPointer().obj.obj_options['name'] kind = current.indexes()[0].internalPointer().obj.kind if kind == 'gerber': @@ -213,7 +213,7 @@ class ToolSub(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() if obj and obj.kind == 'gerber': - obj_name = obj.options['name'] + obj_name = obj.obj_options['name'] self.ui.target_gerber_combo.set_value(obj_name) # Show/Hide Advanced Options @@ -538,7 +538,7 @@ class ToolSub(AppTool): # create the target_options obj # self.target_options = {} - # for k, v in self.target_geo_obj.options.items(): + # for k, v in self.target_geo_obj.obj_options.items(): # if k != 'name': # self.target_options[k] = v @@ -650,11 +650,11 @@ class ToolSub(AppTool): geo_name = outname def obj_init(geo_obj, app_obj): - # geo_obj.options = self.target_options + # geo_obj.obj_options = self.target_options # create the target_options obj - for k, v in self.target_geo_obj.options.items(): - geo_obj.options[k] = v - geo_obj.options['name'] = geo_name + for k, v in self.target_geo_obj.obj_options.items(): + geo_obj.obj_options[k] = v + geo_obj.obj_options['name'] = geo_name if self.target_geo_obj.multigeo: geo_obj.tools = deepcopy(self.new_tools) diff --git a/appPlugins/ToolTransform.py b/appPlugins/ToolTransform.py index 4cab0b4a..a086cfff 100644 --- a/appPlugins/ToolTransform.py +++ b/appPlugins/ToolTransform.py @@ -345,7 +345,7 @@ class ToolTransform(AppTool): pass # add information to the object that it was changed and how much - sel_obj.options['rotate'] = num + sel_obj.obj_options['rotate'] = num sel_obj.plot() self.app.inform.emit('[success] %s...' % _('Rotate done')) except Exception as e: @@ -372,19 +372,19 @@ class ToolTransform(AppTool): sel_obj.mirror('X', (px, py)) # add information to the object that it was changed and how much # the axis is reversed because of the reference - if 'mirror_y' in sel_obj.options: - sel_obj.options['mirror_y'] = not sel_obj.options['mirror_y'] + if 'mirror_y' in sel_obj.obj_options: + sel_obj.obj_options['mirror_y'] = not sel_obj.obj_options['mirror_y'] else: - sel_obj.options['mirror_y'] = True + sel_obj.obj_options['mirror_y'] = True self.app.inform.emit('[success] %s...' % _('Flip on Y axis done')) elif axis == 'Y': sel_obj.mirror('Y', (px, py)) # add information to the object that it was changed and how much # the axis is reversed because of the reference - if 'mirror_x' in sel_obj.options: - sel_obj.options['mirror_x'] = not sel_obj.options['mirror_x'] + if 'mirror_x' in sel_obj.obj_options: + sel_obj.obj_options['mirror_x'] = not sel_obj.obj_options['mirror_x'] else: - sel_obj.options['mirror_x'] = True + sel_obj.obj_options['mirror_x'] = True self.app.inform.emit('[success] %s...' % _('Flip on X axis done')) self.app.app_obj.object_changed.emit(sel_obj) sel_obj.plot() @@ -414,8 +414,8 @@ class ToolTransform(AppTool): else: sel_obj.skew(xvalue, yvalue, point=(px, py)) # add information to the object that it was changed and how much - sel_obj.options['skew_x'] = xvalue - sel_obj.options['skew_y'] = yvalue + sel_obj.obj_options['skew_x'] = xvalue + sel_obj.obj_options['skew_y'] = yvalue # make sure to update the Offset field in Properties Tab try: @@ -448,8 +448,8 @@ class ToolTransform(AppTool): else: sel_obj.scale(xfactor, yfactor, point=(px, py)) # add information to the object that it was changed and how much - sel_obj.options['scale_x'] = xfactor - sel_obj.options['scale_y'] = yfactor + sel_obj.obj_options['scale_x'] = xfactor + sel_obj.obj_options['scale_y'] = yfactor # make sure to update the Offset field in Properties Tab try: @@ -482,11 +482,11 @@ class ToolTransform(AppTool): if axis == 'X': sel_obj.offset((num, 0)) # add information to the object that it was changed and how much - sel_obj.options['offset_x'] = num + sel_obj.obj_options['offset_x'] = num elif axis == 'Y': sel_obj.offset((0, num)) # add information to the object that it was changed and how much - sel_obj.options['offset_y'] = num + sel_obj.obj_options['offset_y'] = num # make sure to update the Offset field in Properties Tab try: @@ -517,12 +517,12 @@ class ToolTransform(AppTool): self.app.inform.emit(_("CNCJob objects can't be buffered.")) elif sel_obj.kind.lower() == 'gerber': sel_obj.buffer(value, join, factor) - sel_obj.source_file = self.app.f_handlers.export_gerber(obj_name=sel_obj.options['name'], + sel_obj.source_file = self.app.f_handlers.export_gerber(obj_name=sel_obj.obj_options['name'], filename=None, local_use=sel_obj, use_thread=False) elif sel_obj.kind.lower() == 'excellon': sel_obj.buffer(value, join, factor) - sel_obj.source_file = self.app.f_handlers.export_excellon(obj_name=sel_obj.options['name'], + sel_obj.source_file = self.app.f_handlers.export_excellon(obj_name=sel_obj.obj_options['name'], filename=None, local_use=sel_obj, use_thread=False) elif sel_obj.kind.lower() == 'geometry': diff --git a/app_Main.py b/app_Main.py index 9103bf13..294f7347 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2790,10 +2790,10 @@ class App(QtCore.QObject): # update the geo object options so it is including the bounding box values try: xmin, ymin, xmax, ymax = edited_obj.bounds(flatten=True) - edited_obj.options['xmin'] = xmin - edited_obj.options['ymin'] = ymin - edited_obj.options['xmax'] = xmax - edited_obj.options['ymax'] = ymax + edited_obj.obj_options['xmin'] = xmin + edited_obj.obj_options['ymin'] = ymin + edited_obj.obj_options['xmax'] = xmax + edited_obj.obj_options['ymax'] = ymax except (AttributeError, ValueError) as e: self.inform.emit('[WARNING] %s' % _("Object empty after edit.")) self.log.debug("App.editor2object() --> Geometry --> %s" % str(e)) @@ -2810,7 +2810,7 @@ class App(QtCore.QObject): # delete the old object (the source object) if it was an empty one try: if len(edited_obj.solid_geometry) == 0: - old_name = edited_obj.options['name'] + old_name = edited_obj.obj_options['name'] self.collection.delete_by_name(old_name) except TypeError: # if the solid_geometry is a single Polygon the len() will not work @@ -2847,7 +2847,7 @@ class App(QtCore.QObject): has_slots = True break if has_drills is None and has_slots is None: - old_name = edited_obj.options['name'] + old_name = edited_obj.obj_options['name'] self.collection.delete_by_name(name=old_name) self.inform.emit('[success] %s' % _("Editor exited. Editor content saved.")) @@ -5272,7 +5272,7 @@ class App(QtCore.QObject): obj_active.probing_shapes.clear(update=True) except AttributeError as e: self.log.debug( - "App.on_delete() --> CNCJob object: %s. %s" % (str(obj_active.options['name']), + "App.on_delete() --> CNCJob object: %s. %s" % (str(obj_active.obj_options['name']), str(e)) ) @@ -5299,8 +5299,8 @@ class App(QtCore.QObject): else: sel_obj = self.collection.get_active() - name = sel_obj.options["name"] - isPlotted = sel_obj.options["plot"] + name = sel_obj.obj_options["name"] + isPlotted = sel_obj.obj_options["plot"] except AttributeError: self.log.debug("Nothing selected for deletion") return @@ -5382,10 +5382,10 @@ class App(QtCore.QObject): # Update the object bounding box options a, b, c, d = obj.bounds() - obj.options['xmin'] = a - obj.options['ymin'] = b - obj.options['xmax'] = c - obj.options['ymax'] = d + obj.obj_options['xmin'] = a + obj.obj_options['ymin'] = b + obj.obj_options['xmax'] = c + obj.obj_options['ymax'] = d # make sure to update the Offset field in Properties Tab try: @@ -5398,7 +5398,7 @@ class App(QtCore.QObject): # update the source_file container with the new offseted code for obj in obj_list: - out_name = obj.options["name"] + out_name = obj.obj_options["name"] if obj.kind == 'gerber': obj.source_file = app_obj.f_handlers.export_gerber( @@ -5487,10 +5487,10 @@ class App(QtCore.QObject): # Update the object bounding box options a, b, c, d = obj.bounds() - obj.options['xmin'] = a - obj.options['ymin'] = b - obj.options['xmax'] = c - obj.options['ymax'] = d + obj.obj_options['xmin'] = a + obj.obj_options['ymin'] = b + obj.obj_options['xmax'] = c + obj.obj_options['ymax'] = d # make sure to update the Offset field in Properties Tab try: @@ -5504,7 +5504,7 @@ class App(QtCore.QObject): self.plotcanvas.fit_view() for obj in obj_list: - out_name = obj.options["name"] + out_name = obj.obj_options["name"] if obj.kind == 'gerber': obj.source_file = self.f_handlers.export_gerber( @@ -5629,10 +5629,10 @@ class App(QtCore.QObject): # Update the object bounding box options a, b, c, d = obj.bounds() - obj.options['xmin'] = a - obj.options['ymin'] = b - obj.options['xmax'] = c - obj.options['ymax'] = d + obj.obj_options['xmin'] = a + obj.obj_options['ymin'] = b + obj.obj_options['xmax'] = c + obj.obj_options['ymax'] = d # make sure to update the Offset field in Properties Tab try: @@ -5646,7 +5646,7 @@ class App(QtCore.QObject): self.plotcanvas.fit_view() for obj in obj_list: - out_name = obj.options["name"] + out_name = obj.obj_options["name"] if obj.kind == 'gerber': obj.source_file = self.f_handlers.export_gerber( @@ -5999,7 +5999,7 @@ class App(QtCore.QObject): new_obj.source_file = deepcopy(obj.source_file) for obj in self.collection.get_selected(): - obj_name = obj.options["name"] + obj_name = obj.obj_options["name"] try: if obj.kind == 'excellon': @@ -6053,7 +6053,7 @@ class App(QtCore.QObject): filename=None, use_thread=False) for obj in self.collection.get_selected(): - obj_name = obj.options["name"] + obj_name = obj.obj_options["name"] outname = str(obj_name) + custom_name try: @@ -6081,7 +6081,7 @@ class App(QtCore.QObject): self.on_rename_object(text) else: try: - obj.options['name'] = text + obj.obj_options['name'] = text except Exception as e: self.log.error( "App.on_rename_object() --> Could not rename the object in the list. --> %s" % str(e)) @@ -6136,8 +6136,8 @@ class App(QtCore.QObject): except AttributeError: pass - new_obj.options.update(deepcopy(default_data)) - new_obj.options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 + new_obj.obj_options.update(deepcopy(default_data)) + new_obj.obj_options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 new_obj.tools = deepcopy(tools) for k in new_obj.tools: new_obj.tools[k]['solid_geometry'] = deepcopy(obj.solid_geometry) @@ -6152,8 +6152,8 @@ class App(QtCore.QObject): app_obj.log("convert_any2geo() failed") return 'fail' - new_obj.options.update(deepcopy(default_data)) - new_obj.options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 + new_obj.obj_options.update(deepcopy(default_data)) + new_obj.obj_options["tools_mill_tooldia"] = tools_diameters[0] if tools_diameters else 0.0 new_obj.tools = deepcopy(tools) for k in new_obj.tools: new_obj.tools[k]['solid_geometry'] = deepcopy(obj.solid_geometry) @@ -6164,7 +6164,7 @@ class App(QtCore.QObject): return for obj in self.collection.get_selected(): - outname = '%s_conv' % obj.options["name"] + outname = '%s_conv' % obj.obj_options["name"] try: if obj.kind == 'excellon': @@ -6250,7 +6250,7 @@ class App(QtCore.QObject): for obj in self.collection.get_selected(): - outname = '%s_conv' % obj.options["name"] + outname = '%s_conv' % obj.obj_options["name"] try: if obj.kind == 'excellon': @@ -6430,7 +6430,7 @@ class App(QtCore.QObject): for obj in self.collection.get_selected(): - obj_name = obj.options["name"] + obj_name = obj.obj_options["name"] outname = "%s_conv" % str(obj_name) try: if obj.kind == 'gerber': @@ -7281,7 +7281,7 @@ class App(QtCore.QObject): obj = self.collection.get_active() try: - name = obj.options["name"] + name = obj.obj_options["name"] except AttributeError: self.log.debug("on_copy_name() --> No object selected to copy it's name") self.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) @@ -7422,13 +7422,13 @@ class App(QtCore.QObject): for obj in self.collection.get_list(): try: # select the object(s) only if it is enabled (plotted) - if obj.options['plot']: + if obj.obj_options['plot']: if obj not in self.collection.get_selected(): poly_obj = Polygon( - [(obj.options['xmin'], obj.options['ymin']), - (obj.options['xmax'], obj.options['ymin']), - (obj.options['xmax'], obj.options['ymax']), - (obj.options['xmin'], obj.options['ymax'])] + [(obj.obj_options['xmin'], obj.obj_options['ymin']), + (obj.obj_options['xmax'], obj.obj_options['ymin']), + (obj.obj_options['xmax'], obj.obj_options['ymax']), + (obj.obj_options['xmin'], obj.obj_options['ymax'])] ) if Point(pos).within(poly_obj): if obj.isHovering is False: @@ -7650,16 +7650,17 @@ class App(QtCore.QObject): for obj in self.collection.get_list(): try: # select the object(s) only if it is enabled (plotted) - if obj.options['plot']: + if obj.obj_options['plot']: # it's a line without area - if obj.options['xmin'] == obj.options['xmax'] or obj.options['ymin'] == obj.options['ymax']: + if obj.obj_options['xmin'] == obj.obj_options['xmax'] or \ + obj.obj_options['ymin'] == obj.obj_options['ymax']: poly_obj = unary_union(obj.solid_geometry).buffer(0.001) # it's a geometry with area else: - poly_obj = Polygon([(obj.options['xmin'], obj.options['ymin']), - (obj.options['xmax'], obj.options['ymin']), - (obj.options['xmax'], obj.options['ymax']), - (obj.options['xmin'], obj.options['ymax'])]) + poly_obj = Polygon([(obj.obj_options['xmin'], obj.obj_options['ymin']), + (obj.obj_options['xmax'], obj.obj_options['ymin']), + (obj.obj_options['xmax'], obj.obj_options['ymax']), + (obj.obj_options['xmin'], obj.obj_options['ymax'])]) if poly_obj.is_empty or not poly_obj.is_valid: continue @@ -7668,13 +7669,13 @@ class App(QtCore.QObject): # create the selection box around the selected object if self.defaults['global_selection_shape'] is True: self.draw_selection_shape(obj) - self.collection.set_active(obj.options['name']) + 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: self.draw_selection_shape(obj) - self.collection.set_active(obj.options['name']) + self.collection.set_active(obj.obj_options['name']) obj.selection_shape_drawn = True except Exception as e: # the Exception here will happen if we try to select on screen and we have an newly (and empty) @@ -7703,16 +7704,16 @@ class App(QtCore.QObject): if obj.kind == 'script' or obj.kind == 'document': continue - if key == 'multisel' and obj.options['name'] in self.objects_under_the_click_list: + if key == 'multisel' and obj.obj_options['name'] in self.objects_under_the_click_list: continue - if (curr_x >= obj.options['xmin']) and (curr_x <= obj.options['xmax']) and \ - (curr_y >= obj.options['ymin']) and (curr_y <= obj.options['ymax']): - if obj.options['name'] not in self.objects_under_the_click_list: - if obj.options['plot']: + if (curr_x >= obj.obj_options['xmin']) and (curr_x <= obj.obj_options['xmax']) and \ + (curr_y >= obj.obj_options['ymin']) and (curr_y <= obj.obj_options['ymax']): + if obj.obj_options['name'] not in self.objects_under_the_click_list: + if obj.obj_options['plot']: # add objects to the objects_under_the_click list only if the object is plotted # (active and not disabled) - self.objects_under_the_click_list.append(obj.options['name']) + self.objects_under_the_click_list.append(obj.obj_options['name']) except Exception as e: self.log.error( "Something went bad in App.select_objects(). Create a list of objects under click pos%s" % str(e)) @@ -7730,7 +7731,7 @@ class App(QtCore.QObject): if self.defaults['global_selection_shape'] is True: self.draw_selection_shape(curr_sel_obj) curr_sel_obj.selection_shape_drawn = True - elif curr_sel_obj.options['name'] not in self.objects_under_the_click_list: + elif curr_sel_obj.obj_options['name'] not in self.objects_under_the_click_list: self.collection.on_objects_selection(False) self.delete_selection_shape() curr_sel_obj.selection_shape_drawn = False @@ -7762,7 +7763,7 @@ class App(QtCore.QObject): self.collection.set_active(self.objects_under_the_click_list[0]) self.collection.get_by_name(self.objects_under_the_click_list[0]).selection_shape_drawn = True - name_sel_obj = self.collection.get_active().options['name'] + name_sel_obj = self.collection.get_active().obj_options['name'] # In case that there is a selected object but it is not in the overlapped object list # make that object inactive and activate the first element in the overlapped object list if name_sel_obj not in self.objects_under_the_click_list: @@ -7829,25 +7830,25 @@ class App(QtCore.QObject): if curr_sel_obj.kind == 'gerber': self.inform.emit('[selected] {name} {tx}'.format( color='green', - name=str(curr_sel_obj.options['name']), + name=str(curr_sel_obj.obj_options['name']), tx=_("selected")) ) elif curr_sel_obj.kind == 'excellon': self.inform.emit('[selected] {name} {tx}'.format( color='brown', - name=str(curr_sel_obj.options['name']), + name=str(curr_sel_obj.obj_options['name']), tx=_("selected")) ) elif curr_sel_obj.kind == 'cncjob': self.inform.emit('[selected] {name} {tx}'.format( color='blue', - name=str(curr_sel_obj.options['name']), + name=str(curr_sel_obj.obj_options['name']), tx=_("selected")) ) elif curr_sel_obj.kind == 'geometry': self.inform.emit('[selected] {name} {tx}'.format( color='red', - name=str(curr_sel_obj.options['name']), + name=str(curr_sel_obj.obj_options['name']), tx=_("selected")) ) @@ -7917,10 +7918,10 @@ class App(QtCore.QObject): :return: None """ - pt1 = (float(sel_obj.options['xmin']), float(sel_obj.options['ymin'])) - pt2 = (float(sel_obj.options['xmax']), float(sel_obj.options['ymin'])) - pt3 = (float(sel_obj.options['xmax']), float(sel_obj.options['ymax'])) - pt4 = (float(sel_obj.options['xmin']), float(sel_obj.options['ymax'])) + pt1 = (float(sel_obj.obj_options['xmin']), float(sel_obj.obj_options['ymin'])) + pt2 = (float(sel_obj.obj_options['xmax']), float(sel_obj.obj_options['ymin'])) + pt3 = (float(sel_obj.obj_options['xmax']), float(sel_obj.obj_options['ymax'])) + pt4 = (float(sel_obj.obj_options['xmin']), float(sel_obj.obj_options['ymax'])) hover_rect = Polygon([pt1, pt2, pt3, pt4]) if self.app_units.upper() == 'MM': @@ -7969,14 +7970,15 @@ class App(QtCore.QObject): return # it's a line without area - if sel_obj.options['xmin'] == sel_obj.options['xmax'] or sel_obj.options['ymin'] == sel_obj.options['ymax']: + if sel_obj.obj_options['xmin'] == sel_obj.obj_options['xmax'] or \ + sel_obj.obj_options['ymin'] == sel_obj.obj_options['ymax']: sel_rect = unary_union(sel_obj.solid_geometry).buffer(0.100001) # it's a geometry with area else: - pt1 = (float(sel_obj.options['xmin']), float(sel_obj.options['ymin'])) - pt2 = (float(sel_obj.options['xmax']), float(sel_obj.options['ymin'])) - pt3 = (float(sel_obj.options['xmax']), float(sel_obj.options['ymax'])) - pt4 = (float(sel_obj.options['xmin']), float(sel_obj.options['ymax'])) + pt1 = (float(sel_obj.obj_options['xmin']), float(sel_obj.obj_options['ymin'])) + pt2 = (float(sel_obj.obj_options['xmax']), float(sel_obj.obj_options['ymin'])) + pt3 = (float(sel_obj.obj_options['xmax']), float(sel_obj.obj_options['ymax'])) + pt4 = (float(sel_obj.obj_options['xmin']), float(sel_obj.obj_options['ymax'])) sel_rect = Polygon([pt1, pt2, pt3, pt4]) @@ -8107,7 +8109,7 @@ class App(QtCore.QObject): for ob in sel_objects: ob.read_form() - fname = os.path.join(path, '%s.%s' % (ob.options['name'], file_extension)) + fname = os.path.join(path, '%s.%s' % (ob.obj_options['name'], file_extension)) ob.export_gcode_handler(fname, is_gcode=True, rename_object=False) return @@ -8865,10 +8867,10 @@ class App(QtCore.QObject): # self.inform.emit('%s...' % _("Working")) for obj in objects: - if obj.options['plot'] is False: - obj.options.set_change_callback(lambda x: None) + if obj.obj_options['plot'] is False: + obj.obj_options.set_change_callback(lambda x: None) try: - obj.options['plot'] = True + obj.obj_options['plot'] = True obj.ui.plot_cb.stateChanged.disconnect(obj.on_plot_cb_click) # disable this cb while disconnected, # in case the operation takes time the user is not allowed to change it @@ -8888,13 +8890,13 @@ class App(QtCore.QObject): obj.build_ui() # and try again self.enable_plots(objects) - obj.options.set_change_callback(obj.on_options_change) + obj.obj_options.set_change_callback(obj.on_options_change) self.collection.update_view() def worker_task(objs): with self.proc_container.new(_("Enabling plots ...")): for plot_obj in objs: - # obj.options['plot'] = True + # obj.obj_options['plot'] = True if isinstance(plot_obj, CNCJobObject): plot_obj.plot(visible=True, kind=self.defaults["cncjob_plot_kind"]) else: @@ -8914,10 +8916,10 @@ class App(QtCore.QObject): # self.inform.emit('%s...' % _("Working")) for obj in objects: - if obj.options['plot'] is True: - obj.options.set_change_callback(lambda x: None) + if obj.obj_options['plot'] is True: + obj.obj_options.set_change_callback(lambda x: None) try: - obj.options['plot'] = False + obj.obj_options['plot'] = False obj.ui.plot_cb.stateChanged.disconnect(obj.on_plot_cb_click) obj.ui.plot_cb.setDisabled(True) except (AttributeError, TypeError): @@ -8935,7 +8937,7 @@ class App(QtCore.QObject): obj.build_ui() # and try again self.disable_plots(objects) - obj.options.set_change_callback(obj.on_options_change) + obj.obj_options.set_change_callback(obj.on_options_change) try: self.delete_selection_shape() @@ -8947,7 +8949,7 @@ class App(QtCore.QObject): def worker_task(objs): with self.proc_container.new(_("Disabling plots ...")): for plot_obj in objs: - # obj.options['plot'] = True + # obj.obj_options['plot'] = True if isinstance(plot_obj, CNCJobObject): plot_obj.plot(visible=False, kind=self.defaults["cncjob_plot_kind"]) else: @@ -8970,10 +8972,10 @@ class App(QtCore.QObject): self.log.debug("Toggling plots ...") # self.inform.emit('%s...' % _("Working")) for obj in objects: - if obj.options['plot'] is False: - obj.options['plot'] = True + if obj.obj_options['plot'] is False: + obj.obj_options['plot'] = True else: - obj.options['plot'] = False + obj.obj_options['plot'] = False try: self.delete_selection_shape() except Exception: @@ -8997,12 +8999,12 @@ class App(QtCore.QObject): def gerber_redraw(self): # the Gerber redraw should work only if there is only one object of type Gerber and active in the selection - sel_gerb_objs = [o for o in self.collection.get_selected() if o.kind == 'gerber' and o.options['plot']] + sel_gerb_objs = [o for o in self.collection.get_selected() if o.kind == 'gerber' and o.obj_options['plot']] if len(sel_gerb_objs) > 1: return obj = self.collection.get_active() - if not obj or (obj.options['plot'] is False or obj.kind != 'gerber'): + if not obj or (obj.obj_options['plot'] is False or obj.kind != 'gerber'): # we don't replot something that is disabled or if it is not Gerber type return @@ -9265,8 +9267,6 @@ class App(QtCore.QObject): :return: None """ - self.defaults.report_usage("on_options_app2project") - self.preferencesUiManager.defaults_read_form() self.options.update(self.defaults) @@ -9734,7 +9734,7 @@ class MenuFileHandlers(QtCore.QObject): msgbox.exec() return - name = obj.options["name"] + name = obj.obj_options["name"] _filter = "SVG File (*.svg);;All Files (*.*)" try: @@ -9818,7 +9818,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Gerber objects can be saved as Gerber files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter = "Gerber File (*.GBR);;Gerber File (*.GRB);;All Files (*.*)" try: @@ -9860,7 +9860,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Script objects can be saved as TCL Script files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter = "FlatCAM Scripts (*.FlatScript);;All Files (*.*)" try: @@ -9902,7 +9902,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Document objects can be saved as Document files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter = "FlatCAM Documents (*.FlatDoc);;All Files (*.*)" try: @@ -9944,7 +9944,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Excellon objects can be saved as Excellon files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter = "Excellon File (*.DRL);;Excellon File (*.TXT);;All Files (*.*)" try: @@ -9985,7 +9985,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Excellon objects can be saved as Excellon files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter = self.defaults["excellon_save_filters"] try: @@ -10030,7 +10030,7 @@ class MenuFileHandlers(QtCore.QObject): self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Only Gerber objects can be saved as Gerber files...")) return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter_ = self.defaults['gerber_save_filters'] try: @@ -10088,7 +10088,7 @@ class MenuFileHandlers(QtCore.QObject): msgbox.exec() return - name = self.app.collection.get_active().options["name"] + name = self.app.collection.get_active().obj_options["name"] _filter_ = "DXF File .dxf (*.DXF);;All Files (*.*)" try: @@ -10267,7 +10267,7 @@ class MenuFileHandlers(QtCore.QObject): if keep_scripts is True: for prj_obj in self.app.collection.get_list(): if prj_obj.kind != 'script': - self.app.collection.delete_by_name(prj_obj.options['name'], select_project=False) + self.app.collection.delete_by_name(prj_obj.obj_options['name'], select_project=False) else: self.app.collection.delete_all() @@ -10582,7 +10582,7 @@ class MenuFileHandlers(QtCore.QObject): try: obj_selection = self.app.collection.get_selected() if len(obj_selection) == 1: - obj_name = str(obj_selection[0].options['name']) + obj_name = str(obj_selection[0].obj_options['name']) else: obj_name = _("FlatCAM objects print") except AttributeError as err: @@ -11878,7 +11878,7 @@ class MenuFileHandlers(QtCore.QObject): self.app.project_filename = filename # for some reason, setting ui_title does not work when this method is called from Tcl Shell - # it's because the TclCommand is run in another thread (it inherit TclCommandSignaled) + # it's because the TclCommand is run in another thread (it inherits TclCommandSignaled) if cli is None: self.app.set_screen_units(self.app.options["units"]) @@ -11971,9 +11971,9 @@ class MenuFileHandlers(QtCore.QObject): self.log.error("save_project() --> There was no active object. Skipping read_form. %s" % str(e)) d = { - "objs": [obj.to_dict() for obj in self.app.collection.get_list()], - "options": self.app.options, - "version": self.app.version + "objs": [obj.to_dict() for obj in self.app.collection.get_list()], + "options": self.app.options, + "version": self.app.version } if self.defaults["global_save_compressed"] is True: diff --git a/camlib.py b/camlib.py index d7a2c2df..40d51c81 100644 --- a/camlib.py +++ b/camlib.py @@ -611,10 +611,10 @@ class Geometry(object): try: xmin, ymin, xmax, ymax = self.bounds() - self.options['xmin'] = xmin - self.options['ymin'] = ymin - self.options['xmax'] = xmax - self.options['ymax'] = ymax + self.obj_options['xmin'] = xmin + self.obj_options['ymin'] = ymin + self.obj_options['xmax'] = xmax + self.obj_options['ymax'] = ymax except Exception as e: self.app.log.error("Failed. The object has no bounds properties. %s" % str(e)) @@ -652,10 +652,10 @@ class Geometry(object): try: xmin, ymin, xmax, ymax = self.bounds() - self.options['xmin'] = xmin - self.options['ymin'] = ymin - self.options['xmax'] = xmax - self.options['ymax'] = ymax + self.obj_options['xmin'] = xmin + self.obj_options['ymin'] = ymin + self.obj_options['xmax'] = xmax + self.obj_options['ymax'] = ymax except Exception as e: self.app.log.error("Failed. The object has no bounds properties. %s" % str(e)) @@ -693,10 +693,10 @@ class Geometry(object): try: xmin, ymin, xmax, ymax = self.bounds() - self.options['xmin'] = xmin - self.options['ymin'] = ymin - self.options['xmax'] = xmax - self.options['ymax'] = ymax + self.obj_options['xmin'] = xmin + self.obj_options['ymin'] = ymin + self.obj_options['xmax'] = xmax + self.obj_options['ymax'] = ymax except Exception as e: self.app.log.error("Failed. The object has no bounds properties. %s" % str(e)) @@ -1298,7 +1298,7 @@ class Geometry(object): tooldia = float(self.app.defaults["tools_mill_tooldia"]) tooldia = float('%.*f' % (self.decimals, tooldia)) - new_data = {k: v for k, v in self.options.items()} + new_data = {k: v for k, v in self.obj_options.items()} self.tools.update({ 1: { @@ -1312,7 +1312,7 @@ class Geometry(object): } }) - self.tools[1]['data']['name'] = self.options['name'] + self.tools[1]['data']['name'] = self.obj_options['name'] def import_dxf_as_geo(self, filename, units='MM'): """ @@ -1367,7 +1367,7 @@ class Geometry(object): tooldia = float(self.app.defaults["tools_mill_tooldia"]) tooldia = float('%.*f' % (self.decimals, tooldia)) - new_data = {k: v for k, v in self.options.items()} + new_data = {k: v for k, v in self.obj_options.items()} self.tools.update({ 1: { @@ -1381,7 +1381,7 @@ class Geometry(object): } }) - self.tools[1]['data']['name'] = self.options['name'] + self.tools[1]['data']['name'] = self.obj_options['name'] # commented until this function is ready # geos_text = getdxftext(dxf, object_type, units=units) @@ -3746,7 +3746,7 @@ class CNCjob(Geometry): elif self.z_cut == 0 and 'laser' not in self.pp_geometry_name: self.app.inform.emit('[WARNING] %s: %s' % (_("The Cut Z parameter is zero. There will be no cut, skipping file"), - self.options['name'])) + self.obj_options['name'])) return 'fail' if self.z_move is None: @@ -3764,7 +3764,7 @@ class CNCjob(Geometry): elif self.z_move == 0: self.app.inform.emit('[WARNING] %s: %s' % (_("The Z Travel parameter is zero. This is dangerous, skipping file"), - self.options['name'])) + self.obj_options['name'])) return 'fail' # made sure that depth_per_cut is no more then the z_cut @@ -4180,7 +4180,7 @@ class CNCjob(Geometry): z_off = 0 default_data = {} - for k, v in list(self.options.items()): + for k, v in list(self.obj_options.items()): default_data[k] = deepcopy(v) # it[1] is the tool diameter @@ -4339,7 +4339,7 @@ class CNCjob(Geometry): (_( "The Cut Z parameter is zero. There will be no cut, " "skipping file"), - exobj.options['name'])) + exobj.obj_options['name'])) return 'fail' old_zcut = deepcopy(self.z_cut) @@ -4598,7 +4598,7 @@ class CNCjob(Geometry): (_( "The Cut Z parameter is zero. There will be no cut, " "skipping file"), - exobj.options['name'])) + exobj.obj_options['name'])) return 'fail' old_zcut = deepcopy(self.z_cut) @@ -4853,7 +4853,7 @@ class CNCjob(Geometry): # (_( # "The Cut Z parameter is zero. There will be no cut, " # "skipping file"), - # exobj.options['name'])) + # exobj.obj_options['name'])) # return 'fail' # # old_zcut = deepcopy(self.z_cut) @@ -5056,7 +5056,7 @@ class CNCjob(Geometry): # (_( # "The Cut Z parameter is zero. There will be no cut, " # "skipping file"), - # exobj.options['name'])) + # exobj.obj_options['name'])) # return 'fail' # # old_zcut = deepcopy(self.z_cut) @@ -5262,7 +5262,7 @@ class CNCjob(Geometry): # (_( # "The Cut Z parameter is zero. There will be no cut, " # "skipping file"), - # exobj.options['name'])) + # exobj.obj_options['name'])) # return 'fail' # # old_zcut = deepcopy(self.z_cut) @@ -5608,7 +5608,7 @@ class CNCjob(Geometry): elif self.z_cut == 0 and 'laser' not in self.pp_geometry_name: self.app.inform.emit('[WARNING] %s: %s' % (_("The Cut Z parameter is zero. There will be no cut, skipping file"), - self.options['name'])) + self.obj_options['name'])) return 'fail' if self.z_move is None: @@ -5626,7 +5626,7 @@ class CNCjob(Geometry): elif self.z_move == 0: self.app.inform.emit('[WARNING] %s: %s' % (_("The Z Travel parameter is zero. This is dangerous, skipping file"), - self.options['name'])) + self.obj_options['name'])) return 'fail' # made sure that depth_per_cut is no more then the z_cut @@ -6031,7 +6031,7 @@ class CNCjob(Geometry): elif self.z_cut == 0 and 'laser' not in self.pp_geometry_name: self.app.inform.emit( '[WARNING] %s: %s' % (_("The Cut Z parameter is zero. There will be no cut, skipping file"), - geo_obj.options['name']) + geo_obj.obj_options['name']) ) return 'fail' @@ -6051,7 +6051,7 @@ class CNCjob(Geometry): elif self.z_move == 0: self.app.inform.emit( '[WARNING] %s: %s' % (_("The Z Travel parameter is zero. This is dangerous, skipping file"), - self.options['name']) + self.obj_options['name']) ) return 'fail' @@ -6679,7 +6679,7 @@ class CNCjob(Geometry): # Current path: temporary storage until tool is # lifted or lowered. - if self.options['type'].lower() == "excellon": + if self.obj_options['type'].lower() == "excellon": if toolchange_xy_drill == '' or toolchange_xy_drill is None: pos_xy = (0, 0) else: @@ -6748,7 +6748,7 @@ class CNCjob(Geometry): path = [path[-1]] # Start with the last point of last path. # create the geometry for the holes created when drilling Excellon drills - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': if current['Z'] < 0: current_drill_point_coords = ( float('%.*f' % (self.decimals, current['X'])), @@ -7099,7 +7099,7 @@ class CNCjob(Geometry): obj.annotations_dict[tooldia]['text'].append(str(path_num)) # plot the geometry of Excellon objects - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': try: # if the geos are travel lines if geo['kind'][0] == 'T': @@ -7166,7 +7166,7 @@ class CNCjob(Geometry): try: if self.app.defaults['global_theme'] == 'white': - obj.annotation.set(text=text, pos=pos, visible=obj.options['plot'], + 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"]) else: @@ -7182,7 +7182,7 @@ class CNCjob(Geometry): for x in range(len(old_color)): new_color += code[old_color[x]] - obj.annotation.set(text=text, pos=pos, visible=obj.options['plot'], + obj.annotation.set(text=text, pos=pos, visible=obj.obj_options['plot'], font_size=self.app.defaults["cncjob_annotation_fontsize"], color=new_color) except Exception as e: @@ -7802,7 +7802,7 @@ class CNCjob(Geometry): # This is quite a useful feature for svg's used with visicut if scale_stroke_factor <= 0: - scale_stroke_factor = self.options['tooldia'] / 2 + scale_stroke_factor = self.obj_options['tooldia'] / 2 # If still 0 then default to 0.05 # This value appears to work for zooming, and getting the output svg line width @@ -7908,7 +7908,7 @@ class CNCjob(Geometry): maxx = -np.Inf maxy = -np.Inf # for CNCJob objects made from Gerber or Geometry objects - if self.options['type'].lower() == 'geometry': + if self.obj_options['type'].lower() == 'geometry': for k, v in self.tools.items(): minx = np.Inf miny = np.Inf @@ -7934,7 +7934,7 @@ class CNCjob(Geometry): maxx = max(maxx, maxx_) maxy = max(maxy, maxy_) - if self.options['type'].lower() == 'excellon': + if self.obj_options['type'].lower() == 'excellon': for k, v in self.tools.items(): minx = np.Inf miny = np.Inf diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index 212f28ed..cf729b9d 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/tclCommands/TclCommandCncjob.py @@ -203,7 +203,7 @@ class TclCommandCncjob(TclCommandSignaled): if 'dwelltime' in args: args["dwell"] = True if args['dwelltime'] is None: - args["dwelltime"] = float(obj.options["dwelltime"]) + args["dwelltime"] = float(obj.obj_options["dwelltime"]) else: args["dwelltime"] = float(args['dwelltime']) else: diff --git a/tclCommands/TclCommandDrillcncjob.py b/tclCommands/TclCommandDrillcncjob.py index 9e36d361..84a0b975 100644 --- a/tclCommands/TclCommandDrillcncjob.py +++ b/tclCommands/TclCommandDrillcncjob.py @@ -139,10 +139,10 @@ class TclCommandDrillcncjob(TclCommandSignaled): self.app.log.error('Expected ExcellonObject, got %s %s.' % (name, type(obj))) return "fail" - xmin = obj.options['xmin'] - ymin = obj.options['ymin'] - xmax = obj.options['xmax'] - ymax = obj.options['ymax'] + xmin = obj.obj_options['xmin'] + ymin = obj.obj_options['ymin'] + xmax = obj.obj_options['xmax'] + ymax = obj.obj_options['ymax'] def job_init(job_obj, app_obj): # tools = args["tools"] if "tools" in args else 'all' @@ -230,7 +230,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): used_tools_info.append([str(tool_no), str(tool_dia_used), str(drill_cnt), str(slot_cnt)]) drillz = args["drillz"] if "drillz" in args and args["drillz"] is not None else \ - obj.options["tools_drill_cutz"] + obj.obj_options["tools_drill_cutz"] toolchange = self.app.defaults["tools_drill_toolchange"] if "toolchangez" in args: @@ -238,7 +238,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): if args["toolchangez"] is not None: toolchangez = args["toolchangez"] else: - toolchangez = obj.options["tools_drill_toolchangez"] + toolchangez = obj.obj_options["tools_drill_toolchangez"] else: toolchangez = float(self.app.defaults["tools_drill_toolchangez"]) @@ -281,14 +281,14 @@ class TclCommandDrillcncjob(TclCommandSignaled): # ########################################################################################## # ################# Set parameters ######################################################### # ########################################################################################## - job_obj.options['type'] = 'Excellon' + job_obj.obj_options['type'] = 'Excellon' job_obj.multigeo = True job_obj.multitool = True # preprocessor pp_excellon_name = args["pp"] if "pp" in args and args["pp"] else self.app.defaults["tools_drill_ppname_e"] job_obj.pp_excellon_name = pp_excellon_name - job_obj.options['ppname_e'] = pp_excellon_name + job_obj.obj_options['ppname_e'] = pp_excellon_name # multidepth if 'dpp' in args: @@ -296,7 +296,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): if args['dpp'] is not None: job_obj.z_depthpercut = abs(float(args['dpp'])) else: - job_obj.z_depthpercut = abs(float(obj.options["dpp"])) + job_obj.z_depthpercut = abs(float(obj.obj_options["dpp"])) else: job_obj.multidepth = self.app.defaults["tools_drill_multidepth"] job_obj.z_depthpercut = self.app.defaults["tools_drill_depthperpass"] @@ -337,10 +337,10 @@ class TclCommandDrillcncjob(TclCommandSignaled): job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"]) job_obj.fr_decimals = int(self.app.defaults["cncjob_fr_decimals"]) - job_obj.options['xmin'] = xmin - job_obj.options['ymin'] = ymin - job_obj.options['xmax'] = xmax - job_obj.options['ymax'] = ymax + job_obj.obj_options['xmin'] = xmin + job_obj.obj_options['ymin'] = ymin + job_obj.obj_options['xmax'] = xmax + job_obj.obj_options['ymax'] = ymax # Cut Z job_obj.z_cut = float(drillz) @@ -378,7 +378,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): for t_item in job_obj.tools: job_obj.tools[t_item]['data']['tools_drill_offset'] = \ float(job_obj.tools[t_item]['offset_z']) + float(drillz) - job_obj.tools[t_item]['data']['tools_drill_ppname_e'] = job_obj.options['ppname_e'] + job_obj.tools[t_item]['data']['tools_drill_ppname_e'] = job_obj.obj_options['ppname_e'] used_tooldia = obj.tools[t_item]['tooldia'] job_obj.tools[t_item]['tooldia'] = used_tooldia @@ -392,7 +392,7 @@ class TclCommandDrillcncjob(TclCommandSignaled): first_tool = 1 job_obj.tools[first_tool]['data']['tools_drill_offset'] = \ float(job_obj.tools[first_tool]['offset_z']) + float(drillz) - job_obj.tools[first_tool]['data']['tools_drill_ppname_e'] = job_obj.options['ppname_e'] + job_obj.tools[first_tool]['data']['tools_drill_ppname_e'] = job_obj.obj_options['ppname_e'] used_tooldia = obj.tools[first_tool]['tooldia'] job_obj.tools[first_tool]['tooldia'] = used_tooldia diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index 2c2ba576..39bcf47b 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -188,10 +188,10 @@ class TclCommandGeoCutout(TclCommandSignaled): # Get min and max data for each object as we just cut rectangles across X or Y xmin, ymin, xmax, ymax = cutout_obj.bounds() - cutout_obj.options['xmin'] = xmin - cutout_obj.options['ymin'] = ymin - cutout_obj.options['xmax'] = xmax - cutout_obj.options['ymax'] = ymax + cutout_obj.obj_options['xmin'] = xmin + cutout_obj.obj_options['ymin'] = ymin + cutout_obj.obj_options['xmax'] = xmax + cutout_obj.obj_options['ymax'] = ymax px = 0.5 * (xmin + xmax) + margin py = 0.5 * (ymin + ymax) + margin @@ -260,10 +260,10 @@ class TclCommandGeoCutout(TclCommandSignaled): ymax + gapsize) geo_obj.solid_geometry = deepcopy(geo) - geo_obj.options['xmin'] = cutout_obj.options['xmin'] - geo_obj.options['ymin'] = cutout_obj.options['ymin'] - geo_obj.options['xmax'] = cutout_obj.options['xmax'] - geo_obj.options['ymax'] = cutout_obj.options['ymax'] + geo_obj.obj_options['xmin'] = cutout_obj.obj_options['xmin'] + geo_obj.obj_options['ymin'] = cutout_obj.obj_options['ymin'] + geo_obj.obj_options['xmax'] = cutout_obj.obj_options['xmax'] + geo_obj.obj_options['ymax'] = cutout_obj.obj_options['ymax'] if not geo_obj.solid_geometry: app_obj.log("TclCommandGeoCutout.execute(). No geometry after geo-cutout.") diff --git a/tclCommands/TclCommandOptions.py b/tclCommands/TclCommandOptions.py index a6057bdc..6f10fa11 100644 --- a/tclCommands/TclCommandOptions.py +++ b/tclCommands/TclCommandOptions.py @@ -50,5 +50,5 @@ class TclCommandOptions(TclCommandSignaled): name = args['name'] - ops = self.app.collection.get_by_name(str(name)).options + ops = self.app.collection.get_by_name(str(name)).obj_options return '\n'.join(["%s: %s" % (o, ops[o]) for o in ops]) diff --git a/tclCommands/TclCommandPanelize.py b/tclCommands/TclCommandPanelize.py index 2cb2b86e..6e3f4f58 100644 --- a/tclCommands/TclCommandPanelize.py +++ b/tclCommands/TclCommandPanelize.py @@ -198,7 +198,7 @@ class TclCommandPanelize(TclCommand): # # deselect all to avoid delete selected object when run delete from shell # self.app.collection.set_all_inactive() # for delobj in objs: - # self.app.collection.set_active(delobj.options['name']) + # self.app.collection.set_active(delobj.obj_options['name']) # self.app.on_delete() # else: # return "fail" @@ -238,10 +238,10 @@ class TclCommandPanelize(TclCommand): obj_fin.tools = copied_tools obj_fin.solid_geometry = [] - for option in obj.options: + for option in obj.obj_options: if option != 'name': try: - obj_fin.options[option] = obj.options[option] + obj_fin.obj_options[option] = obj.obj_options[option] except Exception as e: app_obj.log.error("Failed to copy option: %s" % str(option)) app_obj.log.error( diff --git a/tclCommands/TclCommandPlotAll.py b/tclCommands/TclCommandPlotAll.py index c9b63e7f..a4a8ad23 100644 --- a/tclCommands/TclCommandPlotAll.py +++ b/tclCommands/TclCommandPlotAll.py @@ -72,7 +72,7 @@ class TclCommandPlotAll(TclCommandSignaled): plot_status = True for obj in self.app.collection.get_list(): - obj.options["plot"] = True if plot_status is True else False + obj.obj_options["plot"] = True if plot_status is True else False if self.app.cmd_line_headless != 1: self.app.plot_all(use_thread=threaded) diff --git a/tclCommands/TclCommandPlotObjects.py b/tclCommands/TclCommandPlotObjects.py index bcf9cc14..6e97959d 100644 --- a/tclCommands/TclCommandPlotObjects.py +++ b/tclCommands/TclCommandPlotObjects.py @@ -68,7 +68,7 @@ class TclCommandPlotObjects(TclCommand): objs = [] for name in names: obj = self.app.collection.get_by_name(name) - obj.options["plot"] = True if plot_status is True else False + obj.obj_options["plot"] = True if plot_status is True else False objs.append(obj) for obj in objs: