diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb640a3..44277e5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +01.03.2021 + +- major rafactoring: replaced the name of the Gerber object data structure from 'apertures' to 'tools' to make the object data structure uniform across the app + 28.02.2021 - fixed Panelize Tool to work with objects made by merging other objects together diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index c83e7c98..29909c3d 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -3011,9 +3011,9 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): # 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']: - for apid in obj.apertures: - if 'geometry' in obj.apertures[apid]: - for geo_el in obj.apertures[apid]['geometry']: + for apid in obj.tools: + if 'geometry' in obj.tools[apid]: + for geo_el in obj.tools[apid]['geometry']: if 'solid' in geo_el: solid_geo = geo_el['solid'] if Point(pos).within(solid_geo): @@ -3026,7 +3026,7 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): 'global_sel_draw_color' ] + 'AF', visible=True) - new_ap_dict = {k: v for k, v in obj.apertures[apid].items() if k != 'geometry'} + new_ap_dict = {k: v for k, v in obj.tools[apid].items() if k != 'geometry'} new_ap_dict['geometry'] = [DrawToolShape(geo_el)] new_ap_dict['shape_id'] = shape_id self.sel_storage.append(new_ap_dict) @@ -3071,9 +3071,9 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): # 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']: - for apid in obj.apertures: - if 'geometry' in obj.apertures[apid]: - for geo_el in obj.apertures[apid]['geometry']: + for apid in obj.tools: + if 'geometry' in obj.tools[apid]: + for geo_el in obj.tools[apid]['geometry']: if 'solid' in geo_el: solid_geo = geo_el['solid'] if selection_type is True: @@ -3086,7 +3086,7 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): face_color=face_color, visible=True) new_ap_dict = { - k: v for k, v in obj.apertures[apid].items() if k != 'geometry' + k: v for k, v in obj.tools[apid].items() if k != 'geometry' } new_ap_dict['geometry'] = [DrawToolShape(geo_el)] new_ap_dict['shape_id'] = shape_id @@ -3107,7 +3107,7 @@ class ImportEditorGrb(QtCore.QObject, DrawTool): face_color=face_color, visible=True) new_ap_dict = { - k: v for k, v in obj.apertures[apid].items() if k != 'geometry' + k: v for k, v in obj.tools[apid].items() if k != 'geometry' } new_ap_dict['geometry'] = [DrawToolShape(geo_el)] new_ap_dict['shape_id'] = shape_id @@ -4494,7 +4494,7 @@ class AppGerberEditor(QtCore.QObject): def edit_fcgerber(self, orig_grb_obj): """ - Imports the geometry found in self.apertures from the given FlatCAM Gerber object + Imports the geometry found in self.tools from the given FlatCAM Gerber object into the editor. :param orig_grb_obj: ExcellonObject @@ -4540,24 +4540,24 @@ class AppGerberEditor(QtCore.QObject): except Exception as e: self.app.log.error("AppGerberEditor.edit_fcgerber() --> %s" % str(e)) - # apply the conversion factor on the obj.apertures - conv_apertures = deepcopy(self.gerber_obj.apertures) - for apcode in self.gerber_obj.apertures: - for key in self.gerber_obj.apertures[apcode]: + # apply the conversion factor on the obj.tools + conv_apertures = deepcopy(self.gerber_obj.tools) + for apcode in self.gerber_obj.tools: + for key in self.gerber_obj.tools[apcode]: if key == 'width': - conv_apertures[apcode]['width'] = self.gerber_obj.apertures[apcode]['width'] * \ + conv_apertures[apcode]['width'] = self.gerber_obj.tools[apcode]['width'] * \ self.conversion_factor elif key == 'height': - conv_apertures[apcode]['height'] = self.gerber_obj.apertures[apcode]['height'] * \ + conv_apertures[apcode]['height'] = self.gerber_obj.tools[apcode]['height'] * \ self.conversion_factor elif key == 'diam': - conv_apertures[apcode]['diam'] = self.gerber_obj.apertures[apcode]['diam'] * self.conversion_factor + conv_apertures[apcode]['diam'] = self.gerber_obj.tools[apcode]['diam'] * self.conversion_factor elif key == 'size': - conv_apertures[apcode]['size'] = self.gerber_obj.apertures[apcode]['size'] * self.conversion_factor + conv_apertures[apcode]['size'] = self.gerber_obj.tools[apcode]['size'] * self.conversion_factor else: - conv_apertures[apcode][key] = self.gerber_obj.apertures[apcode][key] + conv_apertures[apcode][key] = self.gerber_obj.tools[apcode][key] - self.gerber_obj.apertures = conv_apertures + self.gerber_obj.tools = conv_apertures self.gerber_obj.units = app_units # # and then add it to the storage elements (each storage elements is a member of a list @@ -4568,7 +4568,7 @@ class AppGerberEditor(QtCore.QObject): # self.storage_dict[aperture_id] = {} # # # add the Gerber geometry to editor storage - # for k, v in self.gerber_obj.apertures[aperture_id].items(): + # for k, v in self.gerber_obj.tools[aperture_id].items(): # try: # if k == 'geometry': # for geo_el in v: @@ -4576,7 +4576,7 @@ class AppGerberEditor(QtCore.QObject): # self.add_gerber_shape(DrawToolShape(geo_el), storage_elem) # self.storage_dict[aperture_id][k] = storage_elem # else: - # self.storage_dict[aperture_id][k] = self.gerber_obj.apertures[aperture_id][k] + # self.storage_dict[aperture_id][k] = self.gerber_obj.tools[aperture_id][k] # except Exception as e: # self.app.log.error("AppGerberEditor.edit_fcgerber().job_thread() --> %s" % str(e)) # @@ -4590,7 +4590,7 @@ class AppGerberEditor(QtCore.QObject): # # # we create a job work each aperture, job that work in a threaded way to store the geometry in local storage # # as DrawToolShapes - # for ap_code in self.gerber_obj.apertures: + # for ap_code in self.gerber_obj.tools: # self.grb_plot_promises.append(ap_code) # self.app.worker_task.emit({'fcn': job_thread, 'params': [ap_code]}) # @@ -4598,7 +4598,7 @@ class AppGerberEditor(QtCore.QObject): # # # do the delayed plot only if there is something to plot (the gerber is not empty) # try: - # if bool(self.gerber_obj.apertures): + # if bool(self.gerber_obj.tools): # self.start_delayed_plot(check_period=1000) # else: # raise AttributeError @@ -4630,10 +4630,10 @@ class AppGerberEditor(QtCore.QObject): global_clear_geo = [] # create one big geometry made out of all 'negative' (clear) polygons - for aper_id in app_obj.gerber_obj.apertures: + for aper_id in app_obj.gerber_obj.tools: # first check if we have any clear_geometry (LPC) and if yes added it to the global_clear_geo - if 'geometry' in app_obj.gerber_obj.apertures[aper_id]: - for elem in app_obj.gerber_obj.apertures[aper_id]['geometry']: + if 'geometry' in app_obj.gerber_obj.tools[aper_id]: + for elem in app_obj.gerber_obj.tools[aper_id]['geometry']: if 'clear' in elem: global_clear_geo.append(elem['clear']) self.app.log.warning("Found %d clear polygons." % len(global_clear_geo)) @@ -4645,10 +4645,10 @@ class AppGerberEditor(QtCore.QObject): # we subtract the big "negative" (clear) geometry from each solid polygon but only the part of # clear geometry that fits inside the solid. otherwise we may loose the solid - for ap_code in app_obj.gerber_obj.apertures: + for ap_code in app_obj.gerber_obj.tools: temp_solid_geometry = [] - if 'geometry' in app_obj.gerber_obj.apertures[ap_code]: - # for elem in self.gerber_obj.apertures[apcode]['geometry']: + if 'geometry' in app_obj.gerber_obj.tools[ap_code]: + # for elem in self.gerber_obj.tools[apcode]['geometry']: # if 'solid' in elem: # solid_geo = elem['solid'] # for clear_geo in global_clear_geo: @@ -4675,7 +4675,7 @@ class AppGerberEditor(QtCore.QObject): # if 'follow' in elem: # new_elem['follow'] = solid_geo # temp_elem.append(deepcopy(new_elem)) - for elem in app_obj.gerber_obj.apertures[ap_code]['geometry']: + for elem in app_obj.gerber_obj.tools[ap_code]['geometry']: new_elem = {} if 'solid' in elem: solid_geo = elem['solid'] @@ -4698,14 +4698,14 @@ class AppGerberEditor(QtCore.QObject): new_elem['follow'] = elem['follow'] temp_solid_geometry.append(deepcopy(new_elem)) - app_obj.gerber_obj.apertures[ap_code]['geometry'] = deepcopy(temp_solid_geometry) + app_obj.gerber_obj.tools[ap_code]['geometry'] = deepcopy(temp_solid_geometry) self.app.log.warning( - "Polygon difference done for %d apertures." % len(app_obj.gerber_obj.apertures)) + "Polygon difference done for %d apertures." % len(app_obj.gerber_obj.tools)) try: # Loading the Geometry into Editor Storage - for ap_code, ap_dict in app_obj.gerber_obj.apertures.items(): + for ap_code, ap_dict in app_obj.gerber_obj.tools.items(): app_obj.results.append( app_obj.pool.apply_async(app_obj.add_apertures, args=(ap_code, ap_dict)) ) @@ -4835,11 +4835,11 @@ class AppGerberEditor(QtCore.QObject): follow_buffer = [] for storage_apcode, storage_val in local_storage_dict.items(): - grb_obj.apertures[storage_apcode] = {} + grb_obj.tools[storage_apcode] = {} for k, val in storage_val.items(): if k == 'geometry': - grb_obj.apertures[storage_apcode][k] = [] + grb_obj.tools[storage_apcode][k] = [] for geo_el in val: geometric_data = geo_el.geo new_geo_el = {} @@ -4866,9 +4866,9 @@ class AppGerberEditor(QtCore.QObject): new_geo_el['clear'] = geometric_data['clear'] if new_geo_el: - grb_obj.apertures[storage_apcode][k].append(deepcopy(new_geo_el)) + grb_obj.tools[storage_apcode][k].append(deepcopy(new_geo_el)) else: - grb_obj.apertures[storage_apcode][k] = val + grb_obj.tools[storage_apcode][k] = val grb_obj.aperture_macros = deepcopy(self.gerber_obj.aperture_macros) diff --git a/appObjects/AppObject.py b/appObjects/AppObject.py index a45e6529..ab02a8d6 100644 --- a/appObjects/AppObject.py +++ b/appObjects/AppObject.py @@ -471,7 +471,7 @@ class AppObject(QtCore.QObject): new_obj.source_file = '' new_obj.multigeo = False new_obj.follow = False - new_obj.apertures = {} + new_obj.tools = {} new_obj.solid_geometry = [] new_obj.follow_geometry = [] diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 9a949fd8..6eff08e1 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -263,7 +263,7 @@ class GerberObject(FlatCAMObj, Gerber): self.apertures_row = 0 sort = [] - for k in list(self.apertures.keys()): + for k in list(self.tools.keys()): sort.append(int(k)) sorted_apertures = sorted(sort) @@ -283,20 +283,20 @@ class GerberObject(FlatCAMObj, Gerber): ap_code_item.setFlags(QtCore.Qt.ItemIsEnabled) # ------------------------ Aperture TYPE -------------------------------------------------------------- - ap_type_item = QtWidgets.QTableWidgetItem(str(self.apertures[ap_code]['type'])) + ap_type_item = QtWidgets.QTableWidgetItem(str(self.tools[ap_code]['type'])) ap_type_item.setFlags(QtCore.Qt.ItemIsEnabled) - if str(self.apertures[ap_code]['type']) == 'R' or str(self.apertures[ap_code]['type']) == 'O': + if str(self.tools[ap_code]['type']) == 'R' or str(self.tools[ap_code]['type']) == 'O': ap_dim_item = QtWidgets.QTableWidgetItem( - '%.*f, %.*f' % (self.decimals, self.apertures[ap_code]['width'], - self.decimals, self.apertures[ap_code]['height'] + '%.*f, %.*f' % (self.decimals, self.tools[ap_code]['width'], + self.decimals, self.tools[ap_code]['height'] ) ) ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) - elif str(self.apertures[ap_code]['type']) == 'P': + elif str(self.tools[ap_code]['type']) == 'P': ap_dim_item = QtWidgets.QTableWidgetItem( - '%.*f, %.*f' % (self.decimals, self.apertures[ap_code]['diam'], - self.decimals, self.apertures[ap_code]['nVertices']) + '%.*f, %.*f' % (self.decimals, self.tools[ap_code]['diam'], + self.decimals, self.tools[ap_code]['nVertices']) ) ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) else: @@ -305,9 +305,9 @@ class GerberObject(FlatCAMObj, Gerber): # ------------------------ Aperture SIZE -------------------------------------------------------------- try: - if self.apertures[ap_code]['size'] is not None: + if self.tools[ap_code]['size'] is not None: ap_size_item = QtWidgets.QTableWidgetItem( - '%.*f' % (self.decimals, float(self.apertures[ap_code]['size']))) + '%.*f' % (self.decimals, float(self.tools[ap_code]['size']))) else: ap_size_item = QtWidgets.QTableWidgetItem('') except KeyError: @@ -904,7 +904,7 @@ class GerberObject(FlatCAMObj, Gerber): def on_aperture_table_visibility_change(self): if self.ui.aperture_table_visibility_cb.isChecked(): # add the shapes storage for marking apertures - for ap_code in self.apertures: + for ap_code in self.tools: self.mark_shapes_storage[ap_code] = [] self.ui.apertures_table.setVisible(True) @@ -1051,7 +1051,7 @@ class GerberObject(FlatCAMObj, Gerber): except Exception as e: self.app.log.error("GerberObject.plot() --> %s" % str(e)) - # experimental plot() when the solid_geometry is stored in the self.apertures + # experimental plot() when the solid_geometry is stored in the self.tools def plot_aperture(self, only_flashes=False, run_thread=False, **kwargs): """ @@ -1089,8 +1089,8 @@ class GerberObject(FlatCAMObj, Gerber): def job_thread(app_obj): with self.app.proc_container.new('%s ...' % _("Plotting")): try: - if aperture_to_plot_mark in self.apertures: - for elem in app_obj.apertures[aperture_to_plot_mark]['geometry']: + if aperture_to_plot_mark in self.tools: + for elem in app_obj.tools[aperture_to_plot_mark]['geometry']: if 'solid' in elem: if only_flashes and not isinstance(elem['follow'], Point): continue @@ -1204,7 +1204,7 @@ class GerberObject(FlatCAMObj, Gerber): mark_cb.setChecked(mark_all) if mark_all: - for aperture in self.apertures: + for aperture in self.tools: # self.plot_aperture(color='#2d4606bf', marked_aperture=aperture, visible=True) self.plot_aperture(color=self.app.defaults['global_sel_draw_color'] + 'AF', marked_aperture=aperture, visible=True) @@ -1269,9 +1269,9 @@ class GerberObject(FlatCAMObj, Gerber): # apertures processing try: length = whole + fract - if '0' in self.apertures: - if 'geometry' in self.apertures['0']: - for geo_elem in self.apertures['0']['geometry']: + if '0' in self.tools: + if 'geometry' in self.tools['0']: + for geo_elem in self.tools['0']['geometry']: if 'solid' in geo_elem: geo = geo_elem['solid'] if not geo.is_empty and not isinstance(geo, LineString) and \ @@ -1417,12 +1417,12 @@ class GerberObject(FlatCAMObj, Gerber): except Exception as e: self.app.log.error("FlatCAMObj.GerberObject.export_gerber() '0' aperture --> %s" % str(e)) - for apid in self.apertures: + for apid in self.tools: if apid == '0': continue - elif self.apertures[apid]['type'] == 'AM': - if 'geometry' in self.apertures[apid]: - for geo_elem in self.apertures[apid]['geometry']: + elif self.tools[apid]['type'] == 'AM': + if 'geometry' in self.tools[apid]: + for geo_elem in self.tools[apid]['geometry']: if 'solid' in geo_elem: geo = geo_elem['solid'] if not geo.is_empty and not isinstance(geo, LineString) and \ @@ -1569,8 +1569,8 @@ class GerberObject(FlatCAMObj, Gerber): gerber_code += '%LPD*%\n' else: gerber_code += 'D%s*\n' % str(apid) - if 'geometry' in self.apertures[apid]: - for geo_elem in self.apertures[apid]['geometry']: + if 'geometry' in self.tools[apid]: + for geo_elem in self.tools[apid]['geometry']: try: if 'follow' in geo_elem: geo = geo_elem['follow'] @@ -1719,7 +1719,7 @@ class GerberObject(FlatCAMObj, Gerber): except Exception as e: self.app.log.error("FlatCAMObj.GerberObject.export_gerber() 'clear' --> %s" % str(e)) - if not self.apertures: + if not self.tools: self.app.log.debug("FlatCAMObj.GerberObject.export_gerber() --> Gerber Object is empty: no apertures.") return 'fail' @@ -1740,8 +1740,8 @@ class GerberObject(FlatCAMObj, Gerber): grb_final.solid_geometry = [] grb_final.follow_geometry = [] - if not grb_final.apertures: - grb_final.apertures = {} + if not grb_final.tools: + grb_final.tools = {} if type(grb_final.solid_geometry) is not list: grb_final.solid_geometry = [grb_final.solid_geometry] @@ -1768,19 +1768,19 @@ class GerberObject(FlatCAMObj, Gerber): grb_final.solid_geometry.append(grb.solid_geometry) grb_final.follow_geometry.append(grb.solid_geometry) - for ap in grb.apertures: - if ap not in grb_final.apertures: - grb_final.apertures[ap] = grb.apertures[ap] + for ap in grb.tools: + if ap not in grb_final.tools: + grb_final.tools[ap] = grb.tools[ap] else: - # create a list of integers out of the grb.apertures keys and find the max of that value + # create a list of integers out of the grb.tools keys and find the max of that value # then, the aperture duplicate is assigned an id value incremented with 1, # and finally made string because the apertures dict keys are strings - max_ap = str(max([int(k) for k in grb_final.apertures.keys()]) + 1) - grb_final.apertures[max_ap] = {} - grb_final.apertures[max_ap]['geometry'] = [] + max_ap = str(max([int(k) for k in grb_final.tools.keys()]) + 1) + grb_final.tools[max_ap] = {} + grb_final.tools[max_ap]['geometry'] = [] - for k, v in grb.apertures[ap].items(): - grb_final.apertures[max_ap][k] = deepcopy(v) + for k, v in grb.tools[ap].items(): + grb_final.tools[max_ap][k] = deepcopy(v) grb_final.solid_geometry = MultiPolygon(grb_final.solid_geometry) grb_final.follow_geometry = MultiPolygon(grb_final.follow_geometry) diff --git a/appObjects/FlatCAMObj.py b/appObjects/FlatCAMObj.py index b68cc2d6..12164037 100644 --- a/appObjects/FlatCAMObj.py +++ b/appObjects/FlatCAMObj.py @@ -659,21 +659,21 @@ class FlatCAMObj(QtCore.QObject): self.treeWidget.addChild(options, [str(option), str(obj.options[option])], True) # Items that depend on the object type - if obj.kind.lower() == 'gerber' and obj.apertures: + if obj.kind.lower() == 'gerber' and obj.tools: temp_ap = {} - for ap in obj.apertures: + for ap in obj.tools: temp_ap.clear() - temp_ap = deepcopy(obj.apertures[ap]) + temp_ap = deepcopy(obj.tools[ap]) temp_ap.pop('geometry', None) solid_nr = 0 follow_nr = 0 clear_nr = 0 - if 'geometry' in obj.apertures[ap]: - if obj.apertures[ap]['geometry']: + if 'geometry' in obj.tools[ap]: + if obj.tools[ap]['geometry']: font.setBold(True) - for el in obj.apertures[ap]['geometry']: + for el in obj.tools[ap]['geometry']: if 'solid' in el: solid_nr += 1 if 'follow' in el: diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index d667773a..a3af0ca9 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -123,7 +123,7 @@ class Gerber(Geometry): self.units = self.app.defaults['gerber_def_units'] # aperture storage - self.apertures = {} + self.tools = {} # Aperture Macros self.aperture_macros = {} @@ -135,7 +135,7 @@ class Gerber(Geometry): self.follow_geometry = [] # made True when the LPC command is encountered in Gerber parsing - # it allows adding data into the clear_geometry key of the self.apertures[aperture] dict + # it allows adding data into the clear_geometry key of the self.tools[aperture] dict self.is_lpc = False self.source_file = '' @@ -265,35 +265,35 @@ class Gerber(Geometry): paramList = None if apertureType == "C": # Circle, example: %ADD11C,0.1*% - self.apertures[apid] = {"type": "C", + self.tools[apid] = {"type": "C", "size": float(paramList[0])} return apid if apertureType == "R": # Rectangle, example: %ADD15R,0.05X0.12*% - self.apertures[apid] = {"type": "R", + self.tools[apid] = {"type": "R", "width": float(paramList[0]), "height": float(paramList[1]), "size": np.sqrt(float(paramList[0]) ** 2 + float(paramList[1]) ** 2)} # Hack return apid if apertureType == "O": # Obround - self.apertures[apid] = {"type": "O", + self.tools[apid] = {"type": "O", "width": float(paramList[0]), "height": float(paramList[1]), "size": np.sqrt(float(paramList[0]) ** 2 + float(paramList[1]) ** 2)} # Hack return apid if apertureType == "P": # Polygon (regular) - self.apertures[apid] = {"type": "P", + self.tools[apid] = {"type": "P", "diam": float(paramList[0]), "nVertices": int(paramList[1]), "size": float(paramList[0])} # Hack if len(paramList) >= 3: - self.apertures[apid]["rotation"] = float(paramList[2]) + self.tools[apid]["rotation"] = float(paramList[2]) return apid if apertureType in self.aperture_macros: - self.apertures[apid] = {"type": "AM", + self.tools[apid] = {"type": "AM", # "size": 0.0, "macro": self.aperture_macros[apertureType], "modifiers": paramList} @@ -353,7 +353,7 @@ class Gerber(Geometry): # @profile def parse_lines(self, glines): """ - Main Gerber parser. Reads Gerber and populates ``self.paths``, ``self.apertures``, + Main Gerber parser. Reads Gerber and populates ``self.paths``, ``self.tools``, ``self.flashes``, ``self.regions`` and ``self.units``. :param glines: Gerber code as list of strings, each element being @@ -464,7 +464,7 @@ class Gerber(Geometry): # finish the current path and add it to the storage # --- Buffered ---- - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] geo_dict = {} geo_f = LineString(path) @@ -483,11 +483,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) path = [path[-1]] @@ -688,7 +688,7 @@ class Gerber(Geometry): # self.app.log.debug("Bare op-code %d." % current_operation_code) geo_dict = {} flash = self.create_flash_geometry( - Point(current_x, current_y), self.apertures[current_aperture], + Point(current_x, current_y), self.tools[current_aperture], self.steps_per_circle) geo_dict['follow'] = Point([current_x, current_y]) @@ -703,11 +703,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = flash - if current_aperture not in self.apertures: - self.apertures[current_aperture] = {} - if 'geometry' not in self.apertures[current_aperture]: - self.apertures[current_aperture]['geometry'] = [] - self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) + if current_aperture not in self.tools: + self.tools[current_aperture] = {} + if 'geometry' not in self.tools[current_aperture]: + self.tools[current_aperture]['geometry'] = [] + self.tools[current_aperture]['geometry'].append(deepcopy(geo_dict)) except IndexError: self.app.log.warning("Line %d: %s -> Nothing there to flash!" % (line_num, gline)) @@ -728,10 +728,10 @@ class Gerber(Geometry): # so it can be processed by FlatCAM. # But first test to see if the aperture type is "aperture macro". In that case # we should not test for "size" key as it does not exist in this case. - if self.apertures[current_aperture]["type"] != "AM": - if self.apertures[current_aperture]["size"] == 0: - self.apertures[current_aperture]["size"] = 10 ** -self.decimals - # self.app.log.debug(self.apertures[current_aperture]) + if self.tools[current_aperture]["type"] != "AM": + if self.tools[current_aperture]["size"] == 0: + self.tools[current_aperture]["size"] = 10 ** -self.decimals + # self.app.log.debug(self.tools[current_aperture]) # Take care of the current path with the previous tool try: @@ -740,7 +740,7 @@ class Gerber(Geometry): path_length = 1 if path_length > 1: - if self.apertures[last_path_aperture]["type"] == 'R': + if self.tools[last_path_aperture]["type"] == 'R': # do nothing because 'R' type moving aperture is none at once pass else: @@ -751,7 +751,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f # --- Buffered ---- - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) if self.app.defaults['gerber_simplification']: geo_s = geo_s.simplify(s_tol) @@ -763,11 +763,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) path = [path[-1]] continue @@ -791,7 +791,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f # --- Buffered ---- - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) if not geo_s.is_valid: self.app.log.warning( @@ -802,10 +802,10 @@ class Gerber(Geometry): self.app.log.warning( "Failed to fix the invalid Geometry found at line: %s" % str(line_num)) else: - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] try: for pol in geo_s: if not pol.is_empty: @@ -820,7 +820,7 @@ class Gerber(Geometry): geo_dict['solid'] = pol if not pol.is_empty: - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) except TypeError: if not geo_s.is_empty: # is it possible that simplification creates an Empty Geometry ????? @@ -834,7 +834,7 @@ class Gerber(Geometry): geo_dict['solid'] = geo_s if not geo_s.is_empty: - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) path = [path[-1]] @@ -847,11 +847,11 @@ class Gerber(Geometry): if self.regionoff_re.search(gline): making_region = False - if '0' not in self.apertures: - self.apertures['0'] = {} - self.apertures['0']['type'] = 'REG' - self.apertures['0']['size'] = 0.0 - self.apertures['0']['geometry'] = [] + if '0' not in self.tools: + self.tools['0'] = {} + self.tools['0']['type'] = 'REG' + self.tools['0']['size'] = 0.0 + self.tools['0']['geometry'] = [] # if D02 happened before G37 we now have a path with 1 element only; we have to add the current # geo to the poly_buffer otherwise we loose it @@ -882,7 +882,7 @@ class Gerber(Geometry): geo_dict['solid'] = geo_s if geo_s or geo_f: - self.apertures['0']['geometry'].append(deepcopy(geo_dict)) + self.tools['0']['geometry'].append(deepcopy(geo_dict)) path = [[current_x, current_y]] # Start new path @@ -903,9 +903,9 @@ class Gerber(Geometry): # --- Buffered --- geo_dict = {} - if current_aperture in self.apertures: + if current_aperture in self.tools: # the following line breaks loading of Circuit Studio Gerber files - # buff_value = float(self.apertures[current_aperture]['size']) / 2.0 + # buff_value = float(self.tools[current_aperture]['size']) / 2.0 # region_geo = Polygon(path).buffer(buff_value, int(self.steps_per_circle)) region_geo = Polygon(path) # Sprint Layout Gerbers with ground fill are crashed with above else: @@ -942,7 +942,7 @@ class Gerber(Geometry): geo_dict['solid'] = pol if not pol.is_empty: - self.apertures['0']['geometry'].append(deepcopy(geo_dict)) + self.tools['0']['geometry'].append(deepcopy(geo_dict)) except TypeError: # is it possible that simplification creates an Empty Geometry ????? if self.app.defaults['gerber_simplification']: @@ -961,7 +961,7 @@ class Gerber(Geometry): geo_dict['solid'] = region_s if not region_s.is_empty: - self.apertures['0']['geometry'].append(deepcopy(geo_dict)) + self.tools['0']['geometry'].append(deepcopy(geo_dict)) else: # is it possible that simplification creates an Empty Geometry ????? if self.app.defaults['gerber_simplification']: @@ -980,7 +980,7 @@ class Gerber(Geometry): geo_dict['solid'] = region_s if not region_s.is_empty: - self.apertures['0']['geometry'].append(deepcopy(geo_dict)) + self.tools['0']['geometry'].append(deepcopy(geo_dict)) path = [[current_x, current_y]] # Start new path continue @@ -1059,7 +1059,7 @@ class Gerber(Geometry): # this treats the case when we are storing geometry as solids flash = self.create_flash_geometry( Point([current_x, current_y]), - self.apertures[current_aperture], + self.tools[current_aperture], self.steps_per_circle ) if not flash.is_empty: @@ -1073,20 +1073,20 @@ class Gerber(Geometry): else: geo_dict['solid'] = flash - if current_aperture not in self.apertures: - self.apertures[current_aperture] = {} - if 'geometry' not in self.apertures[current_aperture]: - self.apertures[current_aperture]['geometry'] = [] - self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) + if current_aperture not in self.tools: + self.tools[current_aperture] = {} + if 'geometry' not in self.tools[current_aperture]: + self.tools[current_aperture]['geometry'] = [] + self.tools[current_aperture]['geometry'].append(deepcopy(geo_dict)) if making_region is False: # if the aperture is rectangle then add a rectangular shape having as parameters the # coordinates of the start and end point and also the width and height # of the 'R' aperture try: - if self.apertures[current_aperture]["type"] == 'R': - width = self.apertures[current_aperture]['width'] - height = self.apertures[current_aperture]['height'] + if self.tools[current_aperture]["type"] == 'R': + width = self.tools[current_aperture]['width'] + height = self.tools[current_aperture]['height'] minx = min(path[0][0], path[1][0]) - width / 2 maxx = max(path[0][0], path[1][0]) + width / 2 miny = min(path[0][1], path[1][1]) - height / 2 @@ -1109,21 +1109,21 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if current_aperture not in self.apertures: - self.apertures[current_aperture] = {} - if 'geometry' not in self.apertures[current_aperture]: - self.apertures[current_aperture]['geometry'] = [] - self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) + if current_aperture not in self.tools: + self.tools[current_aperture] = {} + if 'geometry' not in self.tools[current_aperture]: + self.tools[current_aperture]['geometry'] = [] + self.tools[current_aperture]['geometry'].append(deepcopy(geo_dict)) except Exception: pass last_path_aperture = current_aperture # we do this for the case that a region is done without having defined any aperture if last_path_aperture is None: - if '0' not in self.apertures: - self.apertures['0'] = {} - self.apertures['0']['type'] = 'REG' - self.apertures['0']['size'] = 0.0 - self.apertures['0']['geometry'] = [] + if '0' not in self.tools: + self.tools['0'] = {} + self.tools['0']['type'] = 'REG' + self.tools['0']['size'] = 0.0 + self.tools['0']['geometry'] = [] last_path_aperture = '0' else: self.app.inform.emit('[WARNING] %s: %s' % @@ -1146,18 +1146,18 @@ class Gerber(Geometry): if making_region: # we do this for the case that a region is done without having defined any aperture if last_path_aperture is None: - if '0' not in self.apertures: - self.apertures['0'] = {} - self.apertures['0']['type'] = 'REG' - self.apertures['0']['size'] = 0.0 - self.apertures['0']['geometry'] = [] + if '0' not in self.tools: + self.tools['0'] = {} + self.tools['0']['type'] = 'REG' + self.tools['0']['size'] = 0.0 + self.tools['0']['geometry'] = [] last_path_aperture = '0' geo_f = Polygon() else: geo_f = LineString(path) try: - if self.apertures[last_path_aperture]["type"] != 'R': + if self.tools[last_path_aperture]["type"] != 'R': if not geo_f.is_empty: follow_buffer.append(geo_f) geo_dict['follow'] = geo_f @@ -1171,11 +1171,11 @@ class Gerber(Geometry): if making_region: # we do this for the case that a region is done without having defined any aperture if last_path_aperture is None: - if '0' not in self.apertures: - self.apertures['0'] = {} - self.apertures['0']['type'] = 'REG' - self.apertures['0']['size'] = 0.0 - self.apertures['0']['geometry'] = [] + if '0' not in self.tools: + self.tools['0'] = {} + self.tools['0']['type'] = 'REG' + self.tools['0']['size'] = 0.0 + self.tools['0']['geometry'] = [] last_path_aperture = '0' try: @@ -1189,11 +1189,12 @@ class Gerber(Geometry): else: if last_path_aperture is None: self.app.log.warning("No aperture defined for curent path. (%d)" % line_num) - width = self.apertures[last_path_aperture]["size"] # TODO: WARNING this should fail! + # TODO: this may (should) fail + width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) try: - if self.apertures[last_path_aperture]["type"] != 'R': + if self.tools[last_path_aperture]["type"] != 'R': if not geo_s.is_empty: if self.app.defaults['gerber_simplification']: geo_s = geo_s.simplify(s_tol) @@ -1216,11 +1217,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) # if linear_x or linear_y are None, ignore those if linear_x is not None and linear_y is not None: @@ -1249,7 +1250,7 @@ class Gerber(Geometry): geo_f = LineString(path) if not geo_f.is_empty: try: - if self.apertures[last_path_aperture]["type"] != 'R': + if self.tools[last_path_aperture]["type"] != 'R': follow_buffer.append(geo_f) geo_dict['follow'] = geo_f except Exception as e: @@ -1258,11 +1259,11 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f # this treats the case when we are storing geometry as solids - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) if not geo_s.is_empty: try: - if self.apertures[last_path_aperture]["type"] != 'R': + if self.tools[last_path_aperture]["type"] != 'R': if self.app.defaults['gerber_simplification']: geo_s = geo_s.simplify(s_tol) @@ -1283,11 +1284,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) # Reset path starting point path = [[linear_x, linear_y]] @@ -1303,7 +1304,7 @@ class Gerber(Geometry): # this treats the case when we are storing geometry as solids flash = self.create_flash_geometry( Point([linear_x, linear_y]), - self.apertures[current_aperture], + self.tools[current_aperture], self.steps_per_circle ) @@ -1318,11 +1319,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = flash - if current_aperture not in self.apertures: - self.apertures[current_aperture] = {} - if 'geometry' not in self.apertures[current_aperture]: - self.apertures[current_aperture]['geometry'] = [] - self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) + if current_aperture not in self.tools: + self.tools[current_aperture] = {} + if 'geometry' not in self.tools[current_aperture]: + self.tools[current_aperture]['geometry'] = [] + self.tools[current_aperture]['geometry'].append(deepcopy(geo_dict)) # maybe those lines are not exactly needed but it is easier to read the program as those coordinates # are used in case that circular interpolation is encountered within the Gerber file @@ -1410,7 +1411,7 @@ class Gerber(Geometry): self.app.log.warning("No aperture defined for curent path. (%d)" % line_num) # --- BUFFERED --- - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] # this treats the case when we are storing geometry as paths geo_f = LineString(path) @@ -1431,11 +1432,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = buffered - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) current_x = circular_x current_y = circular_y @@ -1557,7 +1558,7 @@ class Gerber(Geometry): # In case that G01 (moving) aperture is rectangular, there is no need to still create # another geo since we already created a shapely box using the start and end coordinates found in # path variable. We do it only for other apertures than 'R' type - if self.apertures[last_path_aperture]["type"] == 'R': + if self.tools[last_path_aperture]["type"] == 'R': pass else: # EOF, create shapely LineString if something still in path @@ -1571,7 +1572,7 @@ class Gerber(Geometry): geo_dict['follow'] = geo_f # this treats the case when we are storing geometry as solids - width = self.apertures[last_path_aperture]["size"] + width = self.tools[last_path_aperture]["size"] geo_s = LineString(path).buffer(width / 1.999, int(self.steps_per_circle / 4)) if not geo_s.is_empty: if self.app.defaults['gerber_simplification']: @@ -1584,11 +1585,11 @@ class Gerber(Geometry): else: geo_dict['solid'] = geo_s - if last_path_aperture not in self.apertures: - self.apertures[last_path_aperture] = {} - if 'geometry' not in self.apertures[last_path_aperture]: - self.apertures[last_path_aperture]['geometry'] = [] - self.apertures[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) + if last_path_aperture not in self.tools: + self.tools[last_path_aperture] = {} + if 'geometry' not in self.tools[last_path_aperture]: + self.tools[last_path_aperture]['geometry'] = [] + self.tools[last_path_aperture]['geometry'].append(deepcopy(geo_dict)) # --- Apply buffer --- # this treats the case when we are storing geometry as paths @@ -1679,9 +1680,9 @@ class Gerber(Geometry): if self.app.defaults['gerber_clean_apertures']: # clean the Gerber file of apertures with no geometry - for apid, apvalue in list(self.apertures.items()): + for apid, apvalue in list(self.tools.items()): if 'geometry' not in apvalue: - self.apertures.pop(apid) + self.tools.pop(apid) # init this for the following operations self.conversion_done = False @@ -1959,8 +1960,8 @@ class Gerber(Geometry): except TypeError: self.solid_geometry = [self.solid_geometry] - if '0' not in self.apertures: - self.apertures['0'] = { + if '0' not in self.tools: + self.tools['0'] = { 'type': 'REG', 'size': 0.0, 'geometry': [] @@ -1968,7 +1969,7 @@ class Gerber(Geometry): for pol in self.solid_geometry: new_el = {'solid': pol, 'follow': pol.exterior} - self.apertures['0']['geometry'].append(new_el) + self.tools['0']['geometry'].append(new_el) def import_dxf_as_gerber(self, filename, units='MM'): """ @@ -2007,9 +2008,9 @@ class Gerber(Geometry): else: return "fail" - # create the self.apertures data structure - if '0' not in self.apertures: - self.apertures['0'] = { + # create the self.tools data structure + if '0' not in self.tools: + self.tools['0'] = { 'type': 'REG', 'size': 0.0, 'geometry': [] @@ -2017,7 +2018,7 @@ class Gerber(Geometry): for pol in flat_geo: new_el = {'solid': pol, 'follow': pol} - self.apertures['0']['geometry'].append(deepcopy(new_el)) + self.tools['0']['geometry'].append(deepcopy(new_el)) def scale(self, xfactor, yfactor=None, point=None): """ @@ -2102,10 +2103,10 @@ class Gerber(Geometry): # we need to scale the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: + for apid in self.tools: new_geometry = [] - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: new_geo_el = {} if 'solid' in geo_el: new_geo_el['solid'] = scale_geom(geo_el['solid']) @@ -2115,21 +2116,21 @@ class Gerber(Geometry): new_geo_el['clear'] = scale_geom(geo_el['clear']) new_geometry.append(new_geo_el) - self.apertures[apid]['geometry'] = deepcopy(new_geometry) + self.tools[apid]['geometry'] = deepcopy(new_geometry) try: - if str(self.apertures[apid]['type']) == 'R' or str(self.apertures[apid]['type']) == 'O': - self.apertures[apid]['width'] *= xfactor - self.apertures[apid]['height'] *= xfactor - elif str(self.apertures[apid]['type']) == 'P': - self.apertures[apid]['diam'] *= xfactor - self.apertures[apid]['nVertices'] *= xfactor + if str(self.tools[apid]['type']) == 'R' or str(self.tools[apid]['type']) == 'O': + self.tools[apid]['width'] *= xfactor + self.tools[apid]['height'] *= xfactor + elif str(self.tools[apid]['type']) == 'P': + self.tools[apid]['diam'] *= xfactor + self.tools[apid]['nVertices'] *= xfactor except KeyError: pass try: - if self.apertures[apid]['size'] is not None: - self.apertures[apid]['size'] = float(self.apertures[apid]['size'] * xfactor) + if self.tools[apid]['size'] is not None: + self.tools[apid]['size'] = float(self.tools[apid]['size'] * xfactor) except KeyError: pass @@ -2214,9 +2215,9 @@ class Gerber(Geometry): # we need to offset the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + for apid in self.tools: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: if 'solid' in geo_el: geo_el['solid'] = offset_geom(geo_el['solid']) if 'follow' in geo_el: @@ -2290,9 +2291,9 @@ class Gerber(Geometry): # we need to mirror the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + for apid in self.tools: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: if 'solid' in geo_el: geo_el['solid'] = mirror_geom(geo_el['solid']) if 'follow' in geo_el: @@ -2364,9 +2365,9 @@ class Gerber(Geometry): # we need to skew the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + for apid in self.tools: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: if 'solid' in geo_el: geo_el['solid'] = skew_geom(geo_el['solid']) if 'follow' in geo_el: @@ -2427,9 +2428,9 @@ class Gerber(Geometry): # we need to rotate the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + for apid in self.tools: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: if 'solid' in geo_el: geo_el['solid'] = rotate_geom(geo_el['solid']) if 'follow' in geo_el: @@ -2494,10 +2495,10 @@ class Gerber(Geometry): # we need to buffer the geometry stored in the Gerber apertures, too try: - for apid in self.apertures: + for apid in self.tools: new_geometry = [] - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: new_geo_el = {} if 'solid' in geo_el: new_geo_el['solid'] = buffer_geom(geo_el['solid']) @@ -2507,21 +2508,21 @@ class Gerber(Geometry): new_geo_el['clear'] = buffer_geom(geo_el['clear']) new_geometry.append(new_geo_el) - self.apertures[apid]['geometry'] = deepcopy(new_geometry) + self.tools[apid]['geometry'] = deepcopy(new_geometry) try: - if str(self.apertures[apid]['type']) == 'R' or str(self.apertures[apid]['type']) == 'O': - self.apertures[apid]['width'] += (distance * 2) - self.apertures[apid]['height'] += (distance * 2) - elif str(self.apertures[apid]['type']) == 'P': - self.apertures[apid]['diam'] += (distance * 2) - self.apertures[apid]['nVertices'] += (distance * 2) + if str(self.tools[apid]['type']) == 'R' or str(self.tools[apid]['type']) == 'O': + self.tools[apid]['width'] += (distance * 2) + self.tools[apid]['height'] += (distance * 2) + elif str(self.tools[apid]['type']) == 'P': + self.tools[apid]['diam'] += (distance * 2) + self.tools[apid]['nVertices'] += (distance * 2) except KeyError: pass try: - if self.apertures[apid]['size'] is not None: - self.apertures[apid]['size'] = float(self.apertures[apid]['size'] + (distance * 2)) + if self.tools[apid]['size'] is not None: + self.tools[apid]['size'] = float(self.tools[apid]['size'] + (distance * 2)) except KeyError: pass except Exception as e: @@ -2529,39 +2530,39 @@ class Gerber(Geometry): return 'fail' else: try: - for apid in self.apertures: + for apid in self.tools: try: - if str(self.apertures[apid]['type']) == 'R' or str(self.apertures[apid]['type']) == 'O': - self.apertures[apid]['width'] *= distance - self.apertures[apid]['height'] *= distance - elif str(self.apertures[apid]['type']) == 'P': - self.apertures[apid]['diam'] *= distance - self.apertures[apid]['nVertices'] *= distance + if str(self.tools[apid]['type']) == 'R' or str(self.tools[apid]['type']) == 'O': + self.tools[apid]['width'] *= distance + self.tools[apid]['height'] *= distance + elif str(self.tools[apid]['type']) == 'P': + self.tools[apid]['diam'] *= distance + self.tools[apid]['nVertices'] *= distance except KeyError: pass try: - if self.apertures[apid]['size'] is not None: - self.apertures[apid]['size'] = float(self.apertures[apid]['size']) * distance + if self.tools[apid]['size'] is not None: + self.tools[apid]['size'] = float(self.tools[apid]['size']) * distance except KeyError: pass new_geometry = [] - if 'geometry' in self.apertures[apid]: - for geo_el in self.apertures[apid]['geometry']: + if 'geometry' in self.tools[apid]: + for geo_el in self.tools[apid]['geometry']: new_geo_el = {} if 'follow' in geo_el: new_geo_el['follow'] = geo_el['follow'] - size = float(self.apertures[apid]['size']) + size = float(self.tools[apid]['size']) if isinstance(new_geo_el['follow'], Point): - if str(self.apertures[apid]['type']) == 'C': + if str(self.tools[apid]['type']) == 'C': new_geo_el['solid'] = geo_el['follow'].buffer( size / 1.9999, resolution=int(self.steps_per_circle) ) - elif str(self.apertures[apid]['type']) == 'R': - width = self.apertures[apid]['width'] - height = self.apertures[apid]['height'] + elif str(self.tools[apid]['type']) == 'R': + width = self.tools[apid]['width'] + height = self.tools[apid]['height'] minx = new_geo_el['follow'].x - width / 2 maxx = new_geo_el['follow'].x + width / 2 miny = new_geo_el['follow'].y - height / 2 @@ -2581,16 +2582,16 @@ class Gerber(Geometry): new_geo_el['clear'] = geo_el['clear'] new_geometry.append(new_geo_el) - self.apertures[apid]['geometry'] = deepcopy(new_geometry) + self.tools[apid]['geometry'] = deepcopy(new_geometry) except Exception as e: self.app.log.error('ParseGerber.Gerber.buffer() Exception --> %s' % str(e)) return 'fail' # make the new solid_geometry new_solid_geo = [] - for apid in self.apertures: - if 'geometry' in self.apertures[apid]: - new_solid_geo += [geo_el['solid'] for geo_el in self.apertures[apid]['geometry']] + for apid in self.tools: + if 'geometry' in self.tools[apid]: + new_solid_geo += [geo_el['solid'] for geo_el in self.tools[apid]['geometry']] self.solid_geometry = MultiPolygon(new_solid_geo) self.solid_geometry = self.solid_geometry.buffer(0.000001) diff --git a/appPlugins/ToolAlignObjects.py b/appPlugins/ToolAlignObjects.py index 1c67b2f3..d974c08a 100644 --- a/appPlugins/ToolAlignObjects.py +++ b/appPlugins/ToolAlignObjects.py @@ -237,7 +237,7 @@ class AlignObjects(AppTool): ) self.check_points() elif self.target_obj.kind.lower() == 'gerber': - for apid, apid_val in self.target_obj.apertures.items(): + for apid, apid_val in self.target_obj.tools.items(): for geo_el in apid_val['geometry']: if 'solid' in geo_el: if click_pt.within(geo_el['solid']): diff --git a/appPlugins/ToolCalibration.py b/appPlugins/ToolCalibration.py index cde836d2..05bca8b8 100644 --- a/appPlugins/ToolCalibration.py +++ b/appPlugins/ToolCalibration.py @@ -266,7 +266,7 @@ class ToolCalibration(AppTool): ) self.check_points() else: - for apid, apid_val in self.target_obj.apertures.items(): + for apid, apid_val in self.target_obj.tools.items(): for geo_el in apid_val['geometry']: if 'solid' in geo_el: if click_pt.within(geo_el['solid']): @@ -649,7 +649,7 @@ class ToolCalibration(AppTool): pass try: - obj_init.apertures = deepcopy(obj.apertures) + obj_init.tools = deepcopy(obj.tools) except AttributeError: pass @@ -675,7 +675,7 @@ class ToolCalibration(AppTool): pass try: - obj_init.apertures = deepcopy(obj.apertures) + obj_init.tools = deepcopy(obj.tools) except AttributeError: pass diff --git a/appPlugins/ToolCopperThieving.py b/appPlugins/ToolCopperThieving.py index 7bcb6b8c..670cb0af 100644 --- a/appPlugins/ToolCopperThieving.py +++ b/appPlugins/ToolCopperThieving.py @@ -260,9 +260,9 @@ class ToolCopperThieving(AppTool): self.app.proc_container.update_view_text(' %s' % _("Append geometry")) - new_apertures = deepcopy(self.grb_object.apertures) + new_apertures = deepcopy(self.grb_object.tools) aperture_found = None - for ap_id, ap_val in self.grb_object.apertures.items(): + for ap_id, ap_val in self.grb_object.tools.items(): if ap_val['type'] == 'C' and ap_val['size'] == self.rb_thickness: aperture_found = ap_id break @@ -309,7 +309,7 @@ class ToolCopperThieving(AppTool): grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(self.grb_object.follow) - grb_obj.apertures = new_apertures + grb_obj.tools = new_apertures grb_obj.solid_geometry = unary_union(geo_obj) grb_obj.follow_geometry = deepcopy(self.grb_object.follow_geometry) + [deepcopy(self.robber_line)] @@ -871,7 +871,7 @@ class ToolCopperThieving(AppTool): # create a new dictionary to hold the source object apertures allowing us to tamper with without altering # the original source object's apertures - new_apertures = deepcopy(tool_obj.grb_object.apertures) + new_apertures = deepcopy(tool_obj.grb_object.tools) if '0' not in new_apertures: new_apertures['0'] = { 'type': 'REG', @@ -910,7 +910,7 @@ class ToolCopperThieving(AppTool): grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(self.grb_object.follow) - grb_obj.apertures = new_apertures + grb_obj.tools = new_apertures grb_obj.solid_geometry = deepcopy(new_solid_geo) grb_obj.follow_geometry = deepcopy(self.grb_object.follow_geometry) @@ -974,16 +974,16 @@ class ToolCopperThieving(AppTool): if isinstance(geo_list, MultiPolygon): geo_list = list(geo_list.geoms) else: - for apid in self.sm_object.apertures: - for k in self.sm_object.apertures[apid]: + for apid in self.sm_object.tools: + for k in self.sm_object.tools[apid]: if k == 'geometry': - for elem in self.sm_object.apertures[apid]['geometry']: + for elem in self.sm_object.tools[apid]['geometry']: if 'follow' in elem and isinstance(elem['follow'], Point): if 'solid' in elem: geo_list.append(elem['solid']) # create a copy of the source apertures so we can manipulate them without altering the source object - new_apertures = deepcopy(self.sm_object.apertures) + new_apertures = deepcopy(self.sm_object.tools) # if the clearance is not zero apply it to the original soldermask geometry too if ppm_clearance != 0: @@ -1000,9 +1000,9 @@ class ToolCopperThieving(AppTool): # then add a buffered geometry for ap_id in new_apertures: - if 'geometry' in self.sm_object.apertures[ap_id]: + if 'geometry' in self.sm_object.tools[ap_id]: new_geo_list = [] - for geo_el in self.sm_object.apertures[ap_id]['geometry']: + for geo_el in self.sm_object.tools[ap_id]['geometry']: new_el = { 'solid': geo_el['solid'].buffer(ppm_clearance) if 'solid' in geo_el else [], 'follow': geo_el['follow'] if 'follow' in geo_el else [], @@ -1120,7 +1120,7 @@ class ToolCopperThieving(AppTool): grb_obj.multigeo = False grb_obj.follow = False grb_obj.follow_geometry = deepcopy(new_follow_geo) - grb_obj.apertures = deepcopy(new_apertures) + grb_obj.tools = deepcopy(new_apertures) grb_obj.solid_geometry = deepcopy(new_solid_geometry) app_obj.proc_container.update_view_text(' %s' % _("Append source file")) diff --git a/appPlugins/ToolCorners.py b/appPlugins/ToolCorners.py index 0b01a564..e680fd12 100644 --- a/appPlugins/ToolCorners.py +++ b/appPlugins/ToolCorners.py @@ -328,7 +328,7 @@ class ToolCorners(AppTool): geo_list.append(line_geo_hor) geo_list.append(line_geo_vert) - new_apertures = deepcopy(g_obj.apertures) + new_apertures = deepcopy(g_obj.tools) aperture_found = None for ap_id, ap_val in new_apertures.items(): @@ -390,7 +390,7 @@ class ToolCorners(AppTool): grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(g_obj.follow) - grb_obj.apertures = new_apertures + grb_obj.tools = new_apertures grb_obj.solid_geometry = unary_union(s_list) grb_obj.follow_geometry = deepcopy(g_obj.follow_geometry) + geo_list diff --git a/appPlugins/ToolEtchCompensation.py b/appPlugins/ToolEtchCompensation.py index ad0ec108..32f5e909 100644 --- a/appPlugins/ToolEtchCompensation.py +++ b/appPlugins/ToolEtchCompensation.py @@ -204,7 +204,7 @@ class ToolEtchCompensation(AppTool): for opt in grb_obj.options: new_options[opt] = deepcopy(grb_obj.options[opt]) - new_apertures = deepcopy(grb_obj.apertures) + new_apertures = deepcopy(grb_obj.tools) # update the apertures attributes (keys in the apertures dict) for ap in new_apertures: @@ -248,7 +248,7 @@ class ToolEtchCompensation(AppTool): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(new_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, local_use=new_obj, diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index 0e21c539..3135e0b9 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -107,7 +107,7 @@ class ToolExtract(AppTool): grb_obj.mark_shapes.enabled = True # create storage for shapes - for ap_code in grb_obj.apertures: + for ap_code in grb_obj.tools: grb_obj.mark_shapes_storage[ap_code] = [] self.old_name = grb_obj.options['name'] @@ -205,7 +205,7 @@ class ToolExtract(AppTool): try: obj = model_index.internalPointer().obj - sort = [int(k) for k in obj.apertures.keys()] + sort = [int(k) for k in obj.tools.keys()] sorted_apertures = sorted(sort) except Exception: # no object loaded @@ -216,7 +216,7 @@ class ToolExtract(AppTool): n = 0 for ap_code in sorted_apertures: ap_code = str(ap_code) - ap_type = obj.apertures[ap_code]['type'] + ap_type = obj.tools[ap_code]['type'] if ap_type == 'C' and self.ui.circular_cb.get_value() is True: n += 1 @@ -236,7 +236,7 @@ class ToolExtract(AppTool): for ap_code in sorted_apertures: ap_code = str(ap_code) - ap_type = obj.apertures[ap_code]['type'] + ap_type = obj.tools[ap_code]['type'] if ap_type == 'C': if self.ui.circular_cb.get_value() is False: continue @@ -265,8 +265,8 @@ class ToolExtract(AppTool): # Aperture SIZE try: - if obj.apertures[ap_code]['size'] is not None: - size_val = self.app.dec_format(float(obj.apertures[ap_code]['size']), self.decimals) + if obj.tools[ap_code]['size'] is not None: + size_val = self.app.dec_format(float(obj.tools[ap_code]['size']), self.decimals) ap_size_item = QtWidgets.QTableWidgetItem(str(size_val)) else: ap_size_item = QtWidgets.QTableWidgetItem('') @@ -393,7 +393,7 @@ class ToolExtract(AppTool): } } - for apid, apid_value in fcobj.apertures.items(): + for apid, apid_value in fcobj.tools.items(): if apid in sel_apid: ap_type = apid_value['type'] @@ -426,7 +426,7 @@ class ToolExtract(AppTool): return elif mode == 'ring': drills_found = set() - for apid, apid_value in fcobj.apertures.items(): + for apid, apid_value in fcobj.tools.items(): if apid in sel_apid: ap_type = apid_value['type'] @@ -513,7 +513,7 @@ class ToolExtract(AppTool): return else: drills_found = set() - for apid, apid_value in fcobj.apertures.items(): + for apid, apid_value in fcobj.tools.items(): if apid in sel_apid: ap_type = apid_value['type'] @@ -644,7 +644,7 @@ class ToolExtract(AppTool): outname = '%s_esm' % obj.options['name'].rpartition('.')[0] - new_apertures = deepcopy(obj.apertures) + new_apertures = deepcopy(obj.tools) new_solid_geometry = [] new_follow_geometry = [] @@ -653,7 +653,7 @@ class ToolExtract(AppTool): for it in self.ui.apertures_table.selectedItems(): sel_apid.append(it.text()) - for apid, apid_value in obj.apertures.items(): + for apid, apid_value in obj.tools.items(): if apid in sel_apid: ap_type = apid_value['type'] @@ -707,7 +707,7 @@ class ToolExtract(AppTool): new_obj.multitool = False new_obj.multigeo = False new_obj.follow = False - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(new_solid_geometry) new_obj.follow_geometry = deepcopy(new_follow_geometry) @@ -782,7 +782,7 @@ class ToolExtract(AppTool): new_obj.multitool = False new_obj.multigeo = False new_obj.follow = False - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = [deepcopy(new_geo_solid)] new_obj.follow_geometry = [deepcopy(new_geo_follow)] diff --git a/appPlugins/ToolFiducials.py b/appPlugins/ToolFiducials.py index 3e953af5..dd3be75c 100644 --- a/appPlugins/ToolFiducials.py +++ b/appPlugins/ToolFiducials.py @@ -337,13 +337,13 @@ class ToolFiducials(AppTool): radius = fid_size / 2.0 - new_apertures = deepcopy(g_obj.apertures) + new_apertures = deepcopy(g_obj.tools) if fid_type == 'circular': geo_list = [Point(pt).buffer(radius, self.grb_steps_per_circle) for pt in points_list] aperture_found = None - for ap_id, ap_val in g_obj.apertures.items(): + for ap_id, ap_val in g_obj.tools.items(): if ap_val['type'] == 'C' and ap_val['size'] == fid_size: aperture_found = ap_id break @@ -353,7 +353,7 @@ class ToolFiducials(AppTool): dict_el = {'follow': geo.centroid, 'solid': geo} new_apertures[aperture_found]['geometry'].append(deepcopy(dict_el)) else: - ap_keys = list(g_obj.apertures.keys()) + ap_keys = list(g_obj.tools.keys()) if ap_keys: new_apid = str(int(max(ap_keys)) + 1) else: @@ -393,7 +393,7 @@ class ToolFiducials(AppTool): geo_list.append([line_geo_hor, line_geo_vert]) aperture_found = None - for ap_id, ap_val in g_obj.apertures.items(): + for ap_id, ap_val in g_obj.tools.items(): if ap_val['type'] == 'C' and ap_val['size'] == line_thickness: aperture_found = ap_id break @@ -411,7 +411,7 @@ class ToolFiducials(AppTool): dict_el = {'follow': geo_buff_v.centroid, 'solid': geo_buff_v} new_apertures[aperture_found]['geometry'].append(deepcopy(dict_el)) else: - ap_keys = list(g_obj.apertures.keys()) + ap_keys = list(g_obj.tools.keys()) if ap_keys: new_apid = str(int(max(ap_keys)) + 1) else: @@ -471,7 +471,7 @@ class ToolFiducials(AppTool): aperture_found = None new_ap_size = math.sqrt(fid_size**2 + fid_size**2) - for ap_id, ap_val in g_obj.apertures.items(): + for ap_id, ap_val in g_obj.tools.items(): if ap_val['type'] == 'R' and \ round(ap_val['size'], ndigits=self.decimals) == round(new_ap_size, ndigits=self.decimals): aperture_found = ap_id @@ -485,7 +485,7 @@ class ToolFiducials(AppTool): dict_el = {'follow': geo.centroid, 'solid': geo} new_apertures[aperture_found]['geometry'].append(deepcopy(dict_el)) else: - ap_keys = list(g_obj.apertures.keys()) + ap_keys = list(g_obj.tools.keys()) if ap_keys: new_apid = str(int(max(ap_keys)) + 1) else: @@ -527,7 +527,7 @@ class ToolFiducials(AppTool): grb_obj.multitool = False grb_obj.multigeo = False grb_obj.follow = deepcopy(g_obj.follow) - grb_obj.apertures = new_apertures + grb_obj.tools = new_apertures grb_obj.solid_geometry = unary_union(s_list) grb_obj.follow_geometry = deepcopy(g_obj.follow_geometry) + geo_list diff --git a/appPlugins/ToolFilm.py b/appPlugins/ToolFilm.py index f4eb5bef..b1a018c0 100644 --- a/appPlugins/ToolFilm.py +++ b/appPlugins/ToolFilm.py @@ -410,27 +410,27 @@ class Film(AppTool): punch_size = float(self.ui.punch_size_spinner.get_value()) punching_geo = [] - for apid in film_obj.apertures: - if film_obj.apertures[apid]['type'] == 'C': - if punch_size >= float(film_obj.apertures[apid]['size']): + for apid in film_obj.tools: + if film_obj.tools[apid]['type'] == 'C': + if punch_size >= float(film_obj.tools[apid]['size']): self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Punch hole size " "is bigger than some of the apertures in the Gerber object.")) return 'fail' else: - for elem in film_obj.apertures[apid]['geometry']: + for elem in film_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(punch_size / 2)) else: - if punch_size >= float(film_obj.apertures[apid]['width']) or \ - punch_size >= float(film_obj.apertures[apid]['height']): + if punch_size >= float(film_obj.tools[apid]['width']) or \ + punch_size >= float(film_obj.tools[apid]['height']): self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed. Punch hole size " "is bigger than some of the apertures in the Gerber object.")) return 'fail' else: - for elem in film_obj.apertures[apid]['geometry']: + for elem in film_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(punch_size / 2)) diff --git a/appPlugins/ToolInvertGerber.py b/appPlugins/ToolInvertGerber.py index d54bc9f1..e26fc650 100644 --- a/appPlugins/ToolInvertGerber.py +++ b/appPlugins/ToolInvertGerber.py @@ -169,7 +169,7 @@ class ToolInvertGerber(AppTool): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(new_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index 9e7504a6..f1edcd31 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -1087,7 +1087,7 @@ class ToolIsolation(AppTool, Gerber): def job_thread(app_obj): with self.app.proc_container.new(_("Checking ...")): - ap_storage = fcobj.apertures + ap_storage = fcobj.tools p = app_obj.pool.apply_async(self.find_optim_mp, args=(ap_storage, self.decimals)) res = p.get() @@ -1157,9 +1157,9 @@ class ToolIsolation(AppTool, Gerber): app_obj.proc_container.update_view_text(' %d%%' % 0) total_geo = [] - for ap in list(fcobj.apertures.keys()): - if 'geometry' in fcobj.apertures[ap]: - for geo_el in fcobj.apertures[ap]['geometry']: + for ap in list(fcobj.tools.keys()): + if 'geometry' in fcobj.tools[ap]: + for geo_el in fcobj.tools[ap]['geometry']: if self.app.abort_flag: # graceful abort requested by the user raise grace diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index 8d1c3db2..6e6a3266 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -1044,7 +1044,7 @@ class NonCopperClear(AppTool, Gerber): def job_thread(app_obj): with self.app.proc_container.new(_("Checking ...")): - ap_storage = fcobj.apertures + ap_storage = fcobj.tools p = app_obj.pool.apply_async(self.find_optim_mp, args=(ap_storage, self.decimals)) res = p.get() @@ -1118,9 +1118,9 @@ class NonCopperClear(AppTool, Gerber): app_obj.proc_container.update_view_text(' %d%%' % 0) total_geo = [] - for ap in list(fcobj.apertures.keys()): - if 'geometry' in fcobj.apertures[ap]: - for geo_el in fcobj.apertures[ap]['geometry']: + for ap in list(fcobj.tools.keys()): + if 'geometry' in fcobj.tools[ap]: + for geo_el in fcobj.tools[ap]['geometry']: if self.app.abort_flag: # graceful abort requested by the user raise grace diff --git a/appPlugins/ToolOptimal.py b/appPlugins/ToolOptimal.py index 7ed7a511..73af6669 100644 --- a/appPlugins/ToolOptimal.py +++ b/appPlugins/ToolOptimal.py @@ -170,12 +170,12 @@ class ToolOptimal(AppTool): app_obj.proc_container.update_view_text(' %d%%' % 0) total_geo = [] - for ap in list(fcobj.apertures.keys()): - if 'geometry' in fcobj.apertures[ap]: + for ap in list(fcobj.tools.keys()): + if 'geometry' in fcobj.tools[ap]: app_obj.inform.emit( '%s: %s' % (_("Optimal Tool. Parsing geometry for aperture"), str(ap))) - for geo_el in fcobj.apertures[ap]['geometry']: + for geo_el in fcobj.tools[ap]['geometry']: if self.app.abort_flag: # graceful abort requested by the user raise grace diff --git a/appPlugins/ToolPDF.py b/appPlugins/ToolPDF.py index 8634b2f8..9dbae0c9 100644 --- a/appPlugins/ToolPDF.py +++ b/appPlugins/ToolPDF.py @@ -304,12 +304,12 @@ class ToolPDF(AppTool): def obj_init(grb_obj, app_obj): - grb_obj.apertures = ap_dict + grb_obj.tools = ap_dict poly_buff = [] follow_buf = [] - for ap in grb_obj.apertures: - for k in grb_obj.apertures[ap]: + for ap in grb_obj.tools: + for k in grb_obj.tools[ap]: if k == 'geometry': for geo_el in ap_dict[ap][k]: if 'solid' in geo_el: @@ -318,18 +318,18 @@ class ToolPDF(AppTool): follow_buf.append(geo_el['follow']) poly_buff = unary_union(poly_buff) - if '0' in grb_obj.apertures: + if '0' in grb_obj.tools: global_clear_geo = [] - if 'geometry' in grb_obj.apertures['0']: + if 'geometry' in grb_obj.tools['0']: for geo_el in ap_dict['0']['geometry']: if 'clear' in geo_el: global_clear_geo.append(geo_el['clear']) if global_clear_geo: solid = [] - for apid in grb_obj.apertures: - if 'geometry' in grb_obj.apertures[apid]: - for elem in grb_obj.apertures[apid]['geometry']: + for apid in grb_obj.tools: + if 'geometry' in grb_obj.tools[apid]: + for elem in grb_obj.tools[apid]['geometry']: if 'solid' in elem: solid_geo = deepcopy(elem['solid']) for clear_geo in global_clear_geo: diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index a6b1d67b..e5d008a4 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -1645,7 +1645,7 @@ class ToolPaint(AppTool, Gerber): traces_el_dict = {} # find the flashes and the lines that are in the selected polygon and store them separately - for apid, apval in obj.apertures.items(): + for apid, apval in obj.tools.items(): for geo_el in apval['geometry']: if apval["size"] == 0.0: if apval["size"] in traces_el_dict: @@ -1758,7 +1758,7 @@ class ToolPaint(AppTool, Gerber): except TypeError: cpoly.insert(lines_union) # # determine the Gerber follow line - # for apid, apval in obj.apertures.items(): + # for apid, apval in obj.tools.items(): # for geo_el in apval['geometry']: # if 'solid' in geo_el: # if Point(inside_pt).within(geo_el['solid']): diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index d27b9418..606cbd58 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -374,7 +374,7 @@ class Panelize(AppTool): # ############################################################################################################ if panel_source_obj.kind == 'gerber': copied_apertures = {} - for tt, tt_val in list(panel_source_obj.apertures.items()): + for tt, tt_val in list(panel_source_obj.tools.items()): copied_apertures[tt] = deepcopy(tt_val) to_optimize = self.ui.optimization_cb.get_value() @@ -510,9 +510,9 @@ class Panelize(AppTool): else: new_obj.solid_geometry = panel_source_obj.solid_geometry elif panel_source_obj.kind == 'gerber': - new_obj.apertures = copied_apertures - for ap in new_obj.apertures: - new_obj.apertures[ap]['geometry'] = [] + new_obj.tools = copied_apertures + for ap in new_obj.tools: + new_obj.tools[ap]['geometry'] = [] # find the number of polygons in the source solid_geometry geo_len = 0 @@ -529,10 +529,10 @@ class Panelize(AppTool): except TypeError: geo_len = 1 elif panel_source_obj.kind == 'gerber': - for ap in panel_source_obj.apertures: - if 'geometry' in panel_source_obj.apertures[ap]: + for ap in panel_source_obj.tools: + if 'geometry' in panel_source_obj.tools[ap]: try: - geo_len += len(panel_source_obj.apertures[ap]['geometry']) + geo_len += len(panel_source_obj.tools[ap]['geometry']) except TypeError: geo_len += 1 @@ -628,21 +628,21 @@ class Panelize(AppTool): if self.app.abort_flag: raise grace - for apid in panel_source_obj.apertures: + for apid in panel_source_obj.tools: # graceful abort requested by the user if app_obj.abort_flag: raise grace - if 'geometry' in panel_source_obj.apertures[apid]: + if 'geometry' in panel_source_obj.tools[apid]: # calculate the number of polygons try: - geo_len = len(panel_source_obj.apertures[apid]['geometry']) + geo_len = len(panel_source_obj.tools[apid]['geometry']) except TypeError: geo_len = 1 # panelization -> tools pol_nr = 0 - for el in panel_source_obj.apertures[apid]['geometry']: + for el in panel_source_obj.tools[apid]['geometry']: if app_obj.abort_flag: # graceful abort requested by the user raise grace @@ -657,7 +657,7 @@ class Panelize(AppTool): if 'follow' in el: geo_aper = translate_recursion(el['follow']) new_el['follow'] = geo_aper - new_obj.apertures[apid]['geometry'].append(deepcopy(new_el)) + new_obj.tools[apid]['geometry'].append(deepcopy(new_el)) # update progress pol_nr += 1 @@ -741,9 +741,9 @@ class Panelize(AppTool): new_obj.tools = {} new_tid = 0 - for apid in new_obj.apertures: + for apid in new_obj.tools: new_tid += 1 - new_sgeo = [g['solid'] for g in new_obj.apertures[apid]['geometry'] if 'solid' in g] + new_sgeo = [g['solid'] for g in new_obj.tools[apid]['geometry'] if 'solid' in g] new_sgeo = unary_union(new_sgeo) new_obj.tools[new_tid] = { 'tooldia': self.app.defaults["tools_mill_tooldia"], @@ -764,7 +764,7 @@ class Panelize(AppTool): 'data': deepcopy(default_data), 'solid_geometry': deepcopy(new_obj.solid_geometry) } - del new_obj.apertures + del new_obj.tools app_obj.inform.emit('%s' % _("Generating panel ... Adding the source code.")) new_obj.source_file = self.app.f_handlers.export_dxf(obj_name=self.outname, filename=None, @@ -803,9 +803,9 @@ class Panelize(AppTool): else: new_obj.solid_geometry = panel_source_obj.solid_geometry elif panel_source_obj.kind == 'gerber': - new_obj.apertures = copied_apertures - for ap in new_obj.apertures: - new_obj.apertures[ap]['geometry'] = [] + new_obj.tools = copied_apertures + for ap in new_obj.tools: + new_obj.tools[ap]['geometry'] = [] # find the number of polygons in the source solid_geometry geo_len = 0 @@ -822,10 +822,10 @@ class Panelize(AppTool): except TypeError: geo_len = 1 elif panel_source_obj.kind == 'gerber': - for ap in panel_source_obj.apertures: - if 'geometry' in panel_source_obj.apertures[ap]: + for ap in panel_source_obj.tools: + if 'geometry' in panel_source_obj.tools[ap]: try: - geo_len += len(panel_source_obj.apertures[ap]['geometry']) + geo_len += len(panel_source_obj.tools[ap]['geometry']) except TypeError: geo_len += 1 @@ -907,21 +907,21 @@ class Panelize(AppTool): if self.app.abort_flag: raise grace - for apid in panel_source_obj.apertures: + for apid in panel_source_obj.tools: # graceful abort requested by the user if app_obj.abort_flag: raise grace - if 'geometry' in panel_source_obj.apertures[apid]: + if 'geometry' in panel_source_obj.tools[apid]: # calculate the number of polygons try: - geo_len = len(panel_source_obj.apertures[apid]['geometry']) + geo_len = len(panel_source_obj.tools[apid]['geometry']) except TypeError: geo_len = 1 # panelization -> apertures pol_nr = 0 - for el in panel_source_obj.apertures[apid]['geometry']: + for el in panel_source_obj.tools[apid]['geometry']: if app_obj.abort_flag: # graceful abort requested by the user raise grace @@ -936,7 +936,7 @@ class Panelize(AppTool): if 'follow' in el: geo_aper = translate_recursion(el['follow']) new_el['follow'] = geo_aper - new_obj.apertures[apid]['geometry'].append(deepcopy(new_el)) + new_obj.tools[apid]['geometry'].append(deepcopy(new_el)) # update progress pol_nr += 1 @@ -994,7 +994,7 @@ class Panelize(AppTool): } new_solid_list.append(deepcopy(new_el)) - new_obj.apertures = { + new_obj.tools = { '0': { 'type': 'REG', 'size': 0.0, @@ -1006,7 +1006,7 @@ class Panelize(AppTool): new_obj.solid_geometry = deepcopy(all_geo) del new_obj.tools else: - new_obj.apertures = { + new_obj.tools = { '0': { 'type': 'REG', 'size': 0.0, diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index ce63045c..58e2bcce 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -141,7 +141,7 @@ class ToolPunchGerber(AppTool, Gerber): grb_obj.mark_shapes.enabled = True # create storage for shapes - for ap_code in grb_obj.apertures: + for ap_code in grb_obj.tools: grb_obj.mark_shapes_storage[ap_code] = [] self.old_name = grb_obj.options['name'] @@ -244,7 +244,7 @@ class ToolPunchGerber(AppTool, Gerber): try: obj = model_index.internalPointer().obj - sort = [int(k) for k in obj.apertures.keys()] + sort = [int(k) for k in obj.tools.keys()] sorted_apertures = sorted(sort) except Exception: # no object loaded @@ -255,7 +255,7 @@ class ToolPunchGerber(AppTool, Gerber): n = 0 for ap_code in sorted_apertures: ap_code = str(ap_code) - ap_type = obj.apertures[ap_code]['type'] + ap_type = obj.tools[ap_code]['type'] if ap_type == 'C' and self.ui.circular_cb.get_value() is True: n += 1 @@ -275,7 +275,7 @@ class ToolPunchGerber(AppTool, Gerber): for ap_code in sorted_apertures: ap_code = str(ap_code) - ap_type = obj.apertures[ap_code]['type'] + ap_type = obj.tools[ap_code]['type'] if ap_type == 'C': if self.ui.circular_cb.get_value() is False: continue @@ -304,8 +304,8 @@ class ToolPunchGerber(AppTool, Gerber): # Aperture SIZE try: - if obj.apertures[ap_code]['size'] is not None: - size_val = self.app.dec_format(float(obj.apertures[ap_code]['size']), self.decimals) + if obj.tools[ap_code]['size'] is not None: + size_val = self.app.dec_format(float(obj.tools[ap_code]['size']), self.decimals) ap_size_item = QtWidgets.QTableWidgetItem(str(size_val)) else: ap_size_item = QtWidgets.QTableWidgetItem('') @@ -579,9 +579,9 @@ class ToolPunchGerber(AppTool, Gerber): # this is the target geometry grb_solid_geometry = [] target_geometry = [] - for apid in grb_obj.apertures: - if 'geometry' in grb_obj.apertures[apid]: - for el_geo in grb_obj.apertures[apid]['geometry']: + for apid in grb_obj.tools: + if 'geometry' in grb_obj.tools[apid]: + for el_geo in grb_obj.tools[apid]['geometry']: if 'solid' in el_geo: if apid in sel_apid: target_geometry.append(el_geo['solid']) @@ -605,7 +605,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = unary_union(punched_solid_geometry) # update the gerber apertures to include the clear geometry so it can be exported successfully - new_apertures = deepcopy(grb_obj.apertures) + new_apertures = deepcopy(grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -650,7 +650,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -685,17 +685,17 @@ class ToolPunchGerber(AppTool, Gerber): apid = sel_geo['apid'] idx = sel_geo['idx'] for exc_geo in exc_solid_geometry.geoms: - if exc_geo.within(self.grb_obj.apertures[apid]['geometry'][idx]['solid']) and \ - isinstance(self.grb_obj.apertures[apid]['geometry'][idx]['follow'], Point): + if exc_geo.within(self.grb_obj.tools[apid]['geometry'][idx]['solid']) and \ + isinstance(self.grb_obj.tools[apid]['geometry'][idx]['follow'], Point): fin_exc_geo.append(exc_geo) exc_solid_geometry = MultiPolygon(fin_exc_geo) # this is the target geometry grb_solid_geometry = [] target_geometry = [] - for apid in self.grb_obj.apertures: - if 'geometry' in self.grb_obj.apertures[apid]: - for el_geo in self.grb_obj.apertures[apid]['geometry']: + for apid in self.grb_obj.tools: + if 'geometry' in self.grb_obj.tools[apid]: + for el_geo in self.grb_obj.tools[apid]['geometry']: if 'solid' in el_geo: if apid in sel_apid: target_geometry.append(el_geo['solid']) @@ -719,7 +719,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = unary_union(punched_solid_geometry) # update the gerber apertures to include the clear geometry so it can be exported successfully - new_apertures = deepcopy(self.grb_obj.apertures) + new_apertures = deepcopy(self.grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -729,7 +729,7 @@ class ToolPunchGerber(AppTool, Gerber): for pad_elem in self.manual_pads: apid = pad_elem['apid'] idx = pad_elem['idx'] - sel_geo = self.grb_obj.apertures[apid]['geometry'][idx]['solid'] + sel_geo = self.grb_obj.tools[apid]['geometry'][idx]['solid'] sel_pad_geo_list.append(sel_geo) # store here the clear geometry, the key is the drill size @@ -771,7 +771,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -798,53 +798,53 @@ class ToolPunchGerber(AppTool, Gerber): sel_apid.append(it.text()) punching_geo = [] - for apid in grb_obj.apertures: + for apid in grb_obj.tools: if apid in sel_apid: - if grb_obj.apertures[apid]['type'] == 'C' and self.ui.circular_cb.get_value(): - for elem in grb_obj.apertures[apid]['geometry']: + if grb_obj.tools[apid]['type'] == 'C' and self.ui.circular_cb.get_value(): + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): - if punch_size >= float(grb_obj.apertures[apid]['size']): + if punch_size >= float(grb_obj.tools[apid]['size']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' punching_geo.append(elem['follow'].buffer(punch_size / 2)) - elif grb_obj.apertures[apid]['type'] == 'R': + elif grb_obj.tools[apid]['type'] == 'R': - if round(float(grb_obj.apertures[apid]['width']), self.decimals) == \ - round(float(grb_obj.apertures[apid]['height']), self.decimals) and \ + if round(float(grb_obj.tools[apid]['width']), self.decimals) == \ + round(float(grb_obj.tools[apid]['height']), self.decimals) and \ self.ui.square_cb.get_value(): - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): - if punch_size >= float(grb_obj.apertures[apid]['width']) or \ - punch_size >= float(grb_obj.apertures[apid]['height']): + if punch_size >= float(grb_obj.tools[apid]['width']) or \ + punch_size >= float(grb_obj.tools[apid]['height']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' punching_geo.append(elem['follow'].buffer(punch_size / 2)) - elif round(float(grb_obj.apertures[apid]['width']), self.decimals) != \ - round(float(grb_obj.apertures[apid]['height']), self.decimals) and \ + elif round(float(grb_obj.tools[apid]['width']), self.decimals) != \ + round(float(grb_obj.tools[apid]['height']), self.decimals) and \ self.ui.rectangular_cb.get_value(): - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): - if punch_size >= float(grb_obj.apertures[apid]['width']) or \ - punch_size >= float(grb_obj.apertures[apid]['height']): + if punch_size >= float(grb_obj.tools[apid]['width']) or \ + punch_size >= float(grb_obj.tools[apid]['height']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' punching_geo.append(elem['follow'].buffer(punch_size / 2)) - elif grb_obj.apertures[apid]['type'] == 'O' and self.ui.oblong_cb.get_value(): - for elem in grb_obj.apertures[apid]['geometry']: + elif grb_obj.tools[apid]['type'] == 'O' and self.ui.oblong_cb.get_value(): + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): - if punch_size >= float(grb_obj.apertures[apid]['size']): + if punch_size >= float(grb_obj.tools[apid]['size']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' punching_geo.append(elem['follow'].buffer(punch_size / 2)) - elif grb_obj.apertures[apid]['type'] not in ['C', 'R', 'O'] and self.ui.other_cb.get_value(): - for elem in grb_obj.apertures[apid]['geometry']: + elif grb_obj.tools[apid]['type'] not in ['C', 'R', 'O'] and self.ui.other_cb.get_value(): + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): - if punch_size >= float(grb_obj.apertures[apid]['size']): + if punch_size >= float(grb_obj.tools[apid]['size']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' punching_geo.append(elem['follow'].buffer(punch_size / 2)) @@ -863,7 +863,7 @@ class ToolPunchGerber(AppTool, Gerber): return 'fail' # update the gerber apertures to include the clear geometry so it can be exported successfully - new_apertures = deepcopy(grb_obj.apertures) + new_apertures = deepcopy(grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -904,7 +904,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -932,16 +932,16 @@ class ToolPunchGerber(AppTool, Gerber): # this is the punching geometry punching_geo = [] - for apid in self.grb_obj.apertures: + for apid in self.grb_obj.tools: for pad_elem in self.manual_pads: pad_apid = pad_elem['apid'] pad_idx = pad_elem['idx'] if pad_apid == apid: - if 'size' in self.grb_obj.apertures[apid]: - if punch_size >= float(self.grb_obj.apertures[apid]['size']): + if 'size' in self.grb_obj.tools[apid]: + if punch_size >= float(self.grb_obj.tools[apid]['size']): self.app.inform.emit('[ERROR_NOTCL] %s' % fail_msg) return 'fail' - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(punch_size / 2)) punching_geo = MultiPolygon(punching_geo) @@ -958,7 +958,7 @@ class ToolPunchGerber(AppTool, Gerber): return 'fail' # update the gerber apertures to include the clear geometry so it can be exported successfully - new_apertures = deepcopy(self.grb_obj.apertures) + new_apertures = deepcopy(self.grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -999,7 +999,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -1026,7 +1026,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = temp_solid_geometry - new_apertures = deepcopy(grb_obj.apertures) + new_apertures = deepcopy(grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -1040,7 +1040,7 @@ class ToolPunchGerber(AppTool, Gerber): # store here the clear geometry, the key is the new aperture size holes_apertures = {} - for apid, apid_value in grb_obj.apertures.items(): + for apid, apid_value in grb_obj.tools.items(): ap_type = apid_value['type'] punching_geo = [] @@ -1059,7 +1059,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = float(apid_value['width']) - (2 * oblong_r_val) - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1072,7 +1072,7 @@ class ToolPunchGerber(AppTool, Gerber): if self.ui.square_cb.get_value(): dia = float(apid_value['height']) - (2 * square_r_val) - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1082,7 +1082,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = float(apid_value['width']) - (2 * rect_r_val) - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1100,7 +1100,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = dy - (2 * other_r_val) - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1148,7 +1148,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -1175,7 +1175,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = temp_solid_geometry - new_apertures = deepcopy(self.grb_obj.apertures) + new_apertures = deepcopy(self.grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -1189,7 +1189,7 @@ class ToolPunchGerber(AppTool, Gerber): # store here the clear geometry, the key is the new aperture size holes_apertures = {} - for apid, apid_value in self.grb_obj.apertures.items(): + for apid, apid_value in self.grb_obj.tools.items(): ap_type = apid_value['type'] punching_geo = [] @@ -1200,7 +1200,7 @@ class ToolPunchGerber(AppTool, Gerber): if pad_apid == apid: if ap_type == 'C': dia = float(apid_value['size']) - (2 * circ_r_val) - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif ap_type == 'O' and self.ui.oblong_cb.get_value(): width = float(apid_value['width']) @@ -1210,7 +1210,7 @@ class ToolPunchGerber(AppTool, Gerber): dia = float(apid_value['height']) - (2 * oblong_r_val) else: dia = float(apid_value['width']) - (2 * oblong_r_val) - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif ap_type == 'R': width = float(apid_value['width']) @@ -1220,14 +1220,14 @@ class ToolPunchGerber(AppTool, Gerber): if round(width, self.decimals) == round(height, self.decimals): if self.ui.square_cb.get_value(): dia = float(apid_value['height']) - (2 * square_r_val) - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif self.ui.rectangular_cb.get_value(): if width > height: dia = float(apid_value['height']) - (2 * rect_r_val) else: dia = float(apid_value['width']) - (2 * rect_r_val) - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif self.ui.other_cb.get_value(): try: @@ -1242,7 +1242,7 @@ class ToolPunchGerber(AppTool, Gerber): dia = dx - (2 * other_r_val) else: dia = dy - (2 * other_r_val) - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) # if dia is None then none of the above applied so we skip the following @@ -1288,7 +1288,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -1310,7 +1310,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = temp_solid_geometry - new_apertures = deepcopy(grb_obj.apertures) + new_apertures = deepcopy(grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -1324,7 +1324,7 @@ class ToolPunchGerber(AppTool, Gerber): # store here the clear geometry, the key is the new aperture size holes_apertures = {} - for apid, apid_value in grb_obj.apertures.items(): + for apid, apid_value in grb_obj.tools.items(): ap_type = apid_value['type'] punching_geo = [] @@ -1343,7 +1343,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = float(apid_value['width']) * prop_factor - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1356,7 +1356,7 @@ class ToolPunchGerber(AppTool, Gerber): if self.ui.square_cb.get_value(): dia = float(apid_value['height']) * prop_factor - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1366,7 +1366,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = float(apid_value['width']) * prop_factor - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1384,7 +1384,7 @@ class ToolPunchGerber(AppTool, Gerber): else: dia = dy * prop_factor - for elem in grb_obj.apertures[apid]['geometry']: + for elem in grb_obj.tools[apid]['geometry']: if 'follow' in elem: if isinstance(elem['follow'], Point): punching_geo.append(elem['follow'].buffer(dia / 2)) @@ -1432,7 +1432,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(grb_obj.fill_color) new_obj.outline_color = deepcopy(grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -1454,7 +1454,7 @@ class ToolPunchGerber(AppTool, Gerber): punched_solid_geometry = temp_solid_geometry - new_apertures = deepcopy(self.grb_obj.apertures) + new_apertures = deepcopy(self.grb_obj.tools) new_apertures_items = new_apertures.items() # find maximum aperture id @@ -1468,7 +1468,7 @@ class ToolPunchGerber(AppTool, Gerber): # store here the clear geometry, the key is the new aperture size holes_apertures = {} - for apid, apid_value in self.grb_obj.apertures.items(): + for apid, apid_value in self.grb_obj.tools.items(): ap_type = apid_value['type'] punching_geo = [] @@ -1480,7 +1480,7 @@ class ToolPunchGerber(AppTool, Gerber): if ap_type == 'C' and self.ui.circular_cb.get_value(): dia = float(apid_value['size']) * prop_factor - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif ap_type == 'O' and self.ui.oblong_cb.get_value(): width = float(apid_value['width']) @@ -1490,7 +1490,7 @@ class ToolPunchGerber(AppTool, Gerber): dia = float(apid_value['height']) * prop_factor else: dia = float(apid_value['width']) * prop_factor - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif ap_type == 'R': width = float(apid_value['width']) @@ -1500,14 +1500,14 @@ class ToolPunchGerber(AppTool, Gerber): if round(width, self.decimals) == round(height, self.decimals): if self.ui.square_cb.get_value(): dia = float(apid_value['height']) * prop_factor - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif self.ui.rectangular_cb.get_value(): if width > height: dia = float(apid_value['height']) * prop_factor else: dia = float(apid_value['width']) * prop_factor - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) elif self.ui.other_cb.get_value(): try: @@ -1522,7 +1522,7 @@ class ToolPunchGerber(AppTool, Gerber): dia = dx * prop_factor else: dia = dy * prop_factor - pad_point = self.grb_obj.apertures[apid]['geometry'][pad_idx]['follow'] + pad_point = self.grb_obj.tools[apid]['geometry'][pad_idx]['follow'] punching_geo.append(pad_point.buffer(dia / 2)) # if dia is None then none of the above applied so we skip the following @@ -1568,7 +1568,7 @@ class ToolPunchGerber(AppTool, Gerber): new_obj.fill_color = deepcopy(self.grb_obj.fill_color) new_obj.outline_color = deepcopy(self.grb_obj.outline_color) - new_obj.apertures = deepcopy(new_apertures) + new_obj.tools = deepcopy(new_apertures) new_obj.solid_geometry = deepcopy(punched_solid_geometry) new_obj.source_file = app_obj.f_handlers.export_gerber(obj_name=outname, filename=None, @@ -1585,7 +1585,7 @@ class ToolPunchGerber(AppTool, Gerber): for it in self.ui.apertures_table.selectedItems(): sel_apid.append(it.text()) - for apid, apid_value in self.grb_obj.apertures.items(): + for apid, apid_value in self.grb_obj.tools.items(): if apid in sel_apid: for idx, elem in enumerate(apid_value['geometry']): if 'follow' in elem and isinstance(elem['follow'], Point): @@ -1614,11 +1614,11 @@ class ToolPunchGerber(AppTool, Gerber): Each dictionary is in the format: { 'apid': aperture in the target Gerber object apertures dict, - 'idx': index of the selected geo dict in the self.grb_obj.apertures[apid]['geometry] list of geo_dicts + 'idx': index of the selected geo dict in the self.grb_obj.tools[apid]['geometry] list of geo_dicts } - Each geo_dict in the obj.apertures[apid]['geometry'] list has possible keys: + Each geo_dict in the obj.tools[apid]['geometry'] list has possible keys: { 'solid': Shapely Polygon, 'follow': Shapely Point or LineString, @@ -1683,7 +1683,7 @@ class ToolPunchGerber(AppTool, Gerber): for el in pads: apid = el['apid'] idx = el['idx'] - clicked_poly = self.grb_obj.apertures[apid]['geometry'][idx]['solid'] + clicked_poly = self.grb_obj.tools[apid]['geometry'][idx]['solid'] if clicked_poly not in self.poly_dict.values(): shape_id = self.app.tool_shapes.add( tolerance=self.grb_obj.drawing_tolerance, layer=0, shape=clicked_poly, @@ -1890,7 +1890,7 @@ class ToolPunchGerber(AppTool, Gerber): sel_apid.append(it.text()) self.manual_pads = [] - for apid, apid_value in self.grb_obj.apertures.items(): + for apid, apid_value in self.grb_obj.tools.items(): if apid in sel_apid: for idx, elem in enumerate(apid_value['geometry']): if 'follow' in elem and isinstance(elem['follow'], Point): diff --git a/appPlugins/ToolQRCode.py b/appPlugins/ToolQRCode.py index 56f73d8f..f7e8d773 100644 --- a/appPlugins/ToolQRCode.py +++ b/appPlugins/ToolQRCode.py @@ -322,8 +322,8 @@ class QRCode(AppTool): sort_apid = [] new_apid = '10' - if self.grb_object.apertures: - for k, v in list(self.grb_object.apertures.items()): + if self.grb_object.tools: + for k, v in list(self.grb_object.tools.items()): sort_apid.append(int(k)) sorted_apertures = sorted(sort_apid) max_apid = max(sorted_apertures) @@ -333,8 +333,8 @@ class QRCode(AppTool): new_apid = '10' # don't know if the condition is required since I already made sure above that the new_apid is a new one - if new_apid not in self.grb_object.apertures: - self.grb_object.apertures[new_apid] = { + if new_apid not in self.grb_object.tools: + self.grb_object.tools[new_apid] = { 'type': 'R', 'geometry': [] } @@ -343,12 +343,12 @@ class QRCode(AppTool): # I've artificially added 1% to the height and width because otherwise after loading the # exported file, it will not be correctly reconstructed (it will be made from multiple shapes instead of # one shape which show that the buffering didn't worked well). It may be the MM to INCH conversion. - self.grb_object.apertures[new_apid]['height'] = deepcopy(box_size * 1.01) - self.grb_object.apertures[new_apid]['width'] = deepcopy(box_size * 1.01) - self.grb_object.apertures[new_apid]['size'] = deepcopy(math.sqrt(box_size ** 2 + box_size ** 2)) + self.grb_object.tools[new_apid]['height'] = deepcopy(box_size * 1.01) + self.grb_object.tools[new_apid]['width'] = deepcopy(box_size * 1.01) + self.grb_object.tools[new_apid]['size'] = deepcopy(math.sqrt(box_size ** 2 + box_size ** 2)) - if '0' not in self.grb_object.apertures: - self.grb_object.apertures['0'] = { + if '0' not in self.grb_object.tools: + self.grb_object.tools['0'] = { 'type': 'REG', 'size': 0.0, 'geometry': [] @@ -357,7 +357,7 @@ class QRCode(AppTool): # in case that the QRCode geometry is dropped onto a copper region (found in the '0' aperture) # make sure that I place a cutout there zero_elem = {'clear': offset_mask_geo} - self.grb_object.apertures['0']['geometry'].append(deepcopy(zero_elem)) + self.grb_object.tools['0']['geometry'].append(deepcopy(zero_elem)) try: a, b, c, d = self.grb_object.bounds() @@ -374,10 +374,10 @@ class QRCode(AppTool): 'solid': translate(geo, xoff=pos[0], yoff=pos[1]), 'follow': translate(geo.centroid, xoff=pos[0], yoff=pos[1]) } - self.grb_object.apertures[new_apid]['geometry'].append(deepcopy(geo_elem)) + self.grb_object.tools[new_apid]['geometry'].append(deepcopy(geo_elem)) except TypeError: geo_elem = {'solid': self.qrcode_geometry} - self.grb_object.apertures[new_apid]['geometry'].append(deepcopy(geo_elem)) + 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'], diff --git a/appPlugins/ToolReport.py b/appPlugins/ToolReport.py index 1c4f1b3f..0465c22e 100644 --- a/appPlugins/ToolReport.py +++ b/appPlugins/ToolReport.py @@ -374,19 +374,19 @@ class ObjectReport(AppTool): # Items that depend on the object type if obj.kind.lower() == 'gerber': temp_ap = {} - for ap in obj.apertures: + for ap in obj.tools: temp_ap.clear() - temp_ap = deepcopy(obj.apertures[ap]) + temp_ap = deepcopy(obj.tools[ap]) temp_ap.pop('geometry', None) solid_nr = 0 follow_nr = 0 clear_nr = 0 - if 'geometry' in obj.apertures[ap]: - if obj.apertures[ap]['geometry']: + if 'geometry' in obj.tools[ap]: + if obj.tools[ap]['geometry']: font.setBold(True) - for el in obj.apertures[ap]['geometry']: + for el in obj.tools[ap]['geometry']: if 'solid' in el: solid_nr += 1 if 'follow' in el: diff --git a/appPlugins/ToolRulesCheck.py b/appPlugins/ToolRulesCheck.py index 32409639..641c6545 100644 --- a/appPlugins/ToolRulesCheck.py +++ b/appPlugins/ToolRulesCheck.py @@ -651,7 +651,7 @@ class RulesCheck(AppTool): if copper_name_1 != '' and self.ui.copper_t_cb.get_value(): elem_dict = { 'name': deepcopy(copper_name_1), - 'apertures': deepcopy(app_obj.collection.get_by_name(copper_name_1).apertures) + 'apertures': deepcopy(app_obj.collection.get_by_name(copper_name_1).tools) } copper_list.append(elem_dict) @@ -659,7 +659,7 @@ class RulesCheck(AppTool): if copper_name_2 != '' and self.ui.copper_b_cb.get_value(): elem_dict = { 'name': deepcopy(copper_name_2), - 'apertures': deepcopy(app_obj.collection.get_by_name(copper_name_2).apertures) + 'apertures': deepcopy(app_obj.collection.get_by_name(copper_name_2).tools) } copper_list.append(elem_dict) @@ -684,7 +684,7 @@ class RulesCheck(AppTool): if copper_t_obj != '': copper_t_dict['name'] = deepcopy(copper_t_obj) - copper_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_t_obj).apertures) + copper_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_t_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(copper_t_dict, @@ -695,7 +695,7 @@ class RulesCheck(AppTool): copper_b_dict = {} if copper_b_obj != '': copper_b_dict['name'] = deepcopy(copper_b_obj) - copper_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_b_obj).apertures) + copper_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_b_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(copper_b_dict, @@ -717,17 +717,17 @@ class RulesCheck(AppTool): copper_top = self.ui.copper_t_object.currentText() if copper_top != '' and self.ui.copper_t_cb.get_value(): top_dict['name'] = deepcopy(copper_top) - top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_top).apertures) + top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_top).tools) copper_bottom = self.ui.copper_b_object.currentText() if copper_bottom != '' and self.ui.copper_b_cb.get_value(): bottom_dict['name'] = deepcopy(copper_bottom) - bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_bottom).apertures) + bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_bottom).tools) copper_outline = self.ui.outline_object.currentText() if copper_outline != '' and self.ui.out_cb.get_value(): outline_dict['name'] = deepcopy(copper_outline) - outline_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_outline).apertures) + outline_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_outline).tools) try: copper_outline_clearance = float(self.ui.clearance_copper2ol_entry.get_value()) @@ -779,7 +779,7 @@ class RulesCheck(AppTool): silk_obj = self.ui.ss_t_object.currentText() if silk_obj != '': silk_dict['name'] = deepcopy(silk_obj) - silk_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_obj).apertures) + silk_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(silk_dict, @@ -789,7 +789,7 @@ class RulesCheck(AppTool): silk_obj = self.ui.ss_b_object.currentText() if silk_obj != '': silk_dict['name'] = deepcopy(silk_obj) - silk_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_obj).apertures) + silk_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(silk_dict, @@ -817,25 +817,25 @@ class RulesCheck(AppTool): silk_top = self.ui.ss_t_object.currentText() if silk_top != '' and self.ui.ss_t_cb.get_value(): silk_t_dict['name'] = deepcopy(silk_top) - silk_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_top).apertures) + silk_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_top).tools) top_ss = True silk_bottom = self.ui.ss_b_object.currentText() if silk_bottom != '' and self.ui.ss_b_cb.get_value(): silk_b_dict['name'] = deepcopy(silk_bottom) - silk_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_bottom).apertures) + silk_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_bottom).tools) bottom_ss = True sm_top = self.ui.sm_t_object.currentText() if sm_top != '' and self.ui.sm_t_cb.get_value(): sm_t_dict['name'] = deepcopy(sm_top) - sm_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(sm_top).apertures) + sm_t_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(sm_top).tools) top_sm = True sm_bottom = self.ui.sm_b_object.currentText() if sm_bottom != '' and self.ui.sm_b_cb.get_value(): sm_b_dict['name'] = deepcopy(sm_bottom) - sm_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(sm_bottom).apertures) + sm_b_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(sm_bottom).tools) bottom_sm = True try: @@ -880,17 +880,17 @@ class RulesCheck(AppTool): silk_top = self.ui.ss_t_object.currentText() if silk_top != '' and self.ui.ss_t_cb.get_value(): top_dict['name'] = deepcopy(silk_top) - top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_top).apertures) + top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_top).tools) silk_bottom = self.ui.ss_b_object.currentText() if silk_bottom != '' and self.ui.ss_b_cb.get_value(): bottom_dict['name'] = deepcopy(silk_bottom) - bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_bottom).apertures) + bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(silk_bottom).tools) copper_outline = self.ui.outline_object.currentText() if copper_outline != '' and self.ui.out_cb.get_value(): outline_dict['name'] = deepcopy(copper_outline) - outline_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_outline).apertures) + outline_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_outline).tools) try: copper_outline_clearance = float(self.ui.clearance_copper2ol_entry.get_value()) @@ -943,7 +943,7 @@ class RulesCheck(AppTool): solder_obj = self.ui.sm_t_object.currentText() if solder_obj != '': sm_dict['name'] = deepcopy(solder_obj) - sm_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(solder_obj).apertures) + sm_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(solder_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(sm_dict, @@ -953,7 +953,7 @@ class RulesCheck(AppTool): solder_obj = self.ui.sm_b_object.currentText() if solder_obj != '': sm_dict['name'] = deepcopy(solder_obj) - sm_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(solder_obj).apertures) + sm_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(solder_obj).tools) self.results.append(self.pool.apply_async(self.check_inside_gerber_clearance, args=(sm_dict, @@ -976,12 +976,12 @@ class RulesCheck(AppTool): copper_top = self.ui.copper_t_object.currentText() if copper_top != '' and self.ui.copper_t_cb.get_value(): top_dict['name'] = deepcopy(copper_top) - top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_top).apertures) + top_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_top).tools) copper_bottom = self.ui.copper_b_object.currentText() if copper_bottom != '' and self.ui.copper_b_cb.get_value(): bottom_dict['name'] = deepcopy(copper_bottom) - bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_bottom).apertures) + bottom_dict['apertures'] = deepcopy(app_obj.collection.get_by_name(copper_bottom).tools) excellon_1 = self.ui.e1_object.currentText() if excellon_1 != '' and self.ui.e1_cb.get_value(): diff --git a/appPlugins/ToolSolderPaste.py b/appPlugins/ToolSolderPaste.py index e92fbcee..d3a3c5da 100644 --- a/appPlugins/ToolSolderPaste.py +++ b/appPlugins/ToolSolderPaste.py @@ -736,7 +736,8 @@ class SolderPaste(AppTool): self.flat_geometry.append(geometry) return self.flat_geometry - # TODO when/if the Gerber files will have solid_geometry in the self.apertures I will have to take care here + # TODO when/if the Gerber files will have solid_geometry in the self.tools I will have to take care here + flatten(geometry=obj.solid_geometry, pathonly=True) def geo_init(geo_obj, app_obj): diff --git a/appPlugins/ToolSub.py b/appPlugins/ToolSub.py index b520a33e..099909b3 100644 --- a/appPlugins/ToolSub.py +++ b/appPlugins/ToolSub.py @@ -283,29 +283,29 @@ class ToolSub(AppTool): # crate the new_apertures # dict structure from TARGET apertures # -------------------------------- - for apid in self.target_grb_obj.apertures: + for apid in self.target_grb_obj.tools: self.new_apertures[apid] = {} - for key in self.target_grb_obj.apertures[apid]: + for key in self.target_grb_obj.tools[apid]: if key == 'geometry': self.new_apertures[apid]['geometry'] = [] else: - self.new_apertures[apid][key] = self.target_grb_obj.apertures[apid][key] + self.new_apertures[apid][key] = self.target_grb_obj.tools[apid][key] def worker_job(app_obj): with app_obj.app.proc_container.new('%s...' % _("Working")): # SUBTRACTOR geometry (always the same) sub_geometry = {'solid': [], 'clear': []} # iterate over SUBTRACTOR geometry and load it in the sub_geometry dict - for s_apid in app_obj.sub_grb_obj.apertures: - for s_el in app_obj.sub_grb_obj.apertures[s_apid]['geometry']: + for s_apid in app_obj.sub_grb_obj.tools: + for s_el in app_obj.sub_grb_obj.tools[s_apid]['geometry']: if "solid" in s_el: sub_geometry['solid'].append(s_el["solid"]) if "clear" in s_el: sub_geometry['clear'].append(s_el["clear"]) - for ap_id in app_obj.target_grb_obj.apertures: + for ap_id in app_obj.target_grb_obj.tools: # TARGET geometry - target_geo = [geo for geo in app_obj.target_grb_obj.apertures[ap_id]['geometry']] + target_geo = [geo for geo in app_obj.target_grb_obj.tools[ap_id]['geometry']] # send the job to the multiprocessing JOB app_obj.results.append( @@ -391,17 +391,17 @@ class ToolSub(AppTool): def obj_init(grb_obj, app_obj): - grb_obj.apertures = deepcopy(self.new_apertures) + grb_obj.tools = deepcopy(self.new_apertures) - if '0' not in grb_obj.apertures: - grb_obj.apertures['0'] = {} - grb_obj.apertures['0']['type'] = 'REG' - grb_obj.apertures['0']['size'] = 0.0 - grb_obj.apertures['0']['geometry'] = [] + if '0' not in grb_obj.tools: + grb_obj.tools['0'] = {} + grb_obj.tools['0']['type'] = 'REG' + grb_obj.tools['0']['size'] = 0.0 + grb_obj.tools['0']['geometry'] = [] - for apid in list(grb_obj.apertures.keys()): + for apid in list(grb_obj.tools.keys()): # output is a tuple in the format (apid, surviving_geo, modified_geo) - # apid is the aperture id (key in the obj.apertures and string) + # apid is the aperture id (key in the obj.tools and string) # unaffected_geo and affected_geo are lists for t in output: new_apid = t[0] @@ -409,23 +409,23 @@ class ToolSub(AppTool): surving_geo = t[1] modified_geo = t[2] if surving_geo: - grb_obj.apertures[apid]['geometry'] += deepcopy(surving_geo) + grb_obj.tools[apid]['geometry'] += deepcopy(surving_geo) if modified_geo: - grb_obj.apertures['0']['geometry'] += modified_geo + grb_obj.tools['0']['geometry'] += modified_geo # if the current aperture does not have geometry then get rid of it - if not grb_obj.apertures[apid]['geometry']: - grb_obj.apertures.pop(apid, None) + if not grb_obj.tools[apid]['geometry']: + grb_obj.tools.pop(apid, None) # delete the '0' aperture if it has no geometry - if not grb_obj.apertures['0']['geometry']: - grb_obj.apertures.pop('0', None) + if not grb_obj.tools['0']['geometry']: + grb_obj.tools.pop('0', None) poly_buff = [] follow_buff = [] - for ap in grb_obj.apertures: - for elem in grb_obj.apertures[ap]['geometry']: + for ap in grb_obj.tools: + for elem in grb_obj.tools[ap]['geometry']: if 'solid' in elem: solid_geo = elem['solid'] poly_buff.append(solid_geo) diff --git a/app_Main.py b/app_Main.py index afdffc63..3694c3d7 100644 --- a/app_Main.py +++ b/app_Main.py @@ -5618,7 +5618,7 @@ class App(QtCore.QObject): pass try: - obj_init.apertures = deepcopy(obj.apertures) + obj_init.tools = deepcopy(obj.tools) except AttributeError: pass @@ -5677,7 +5677,7 @@ class App(QtCore.QObject): pass try: - obj_init.apertures = deepcopy(obj.apertures) + obj_init.tools = deepcopy(obj.tools) except AttributeError: pass @@ -5689,9 +5689,9 @@ class App(QtCore.QObject): def initialize_gerber(obj_init, app_obj): obj_init.solid_geometry = deepcopy(obj.solid_geometry) - obj_init.apertures = deepcopy(obj.apertures) + obj_init.tools = deepcopy(obj.tools) obj_init.aperture_macros = deepcopy(obj.aperture_macros) - if not obj_init.apertures: + if not obj_init.tools: app_obj.debug("on_copy_object2() --> no gerber apertures") return 'fail' @@ -5863,9 +5863,9 @@ class App(QtCore.QObject): apertures['0']['geometry'].append(deepcopy(new_elem)) obj_init.solid_geometry = deepcopy(obj.solid_geometry) - obj_init.apertures = deepcopy(apertures) + obj_init.tools = deepcopy(apertures) - if not obj_init.apertures: + if not obj_init.tools: app_obj.log("convert_any2gerber() failed") return 'fail' @@ -5899,9 +5899,9 @@ class App(QtCore.QObject): solid_geometry = solid_geometry.buffer(0.0000001) obj_init.solid_geometry = deepcopy(solid_geometry) - obj_init.apertures = deepcopy(apertures) + obj_init.tools = deepcopy(apertures) - if not obj_init.apertures: + if not obj_init.tools: app_obj.log("convert_any2gerber() failed") return 'fail' @@ -5986,9 +5986,9 @@ class App(QtCore.QObject): obj_init.solid_geometry = [] - for apid in obj.apertures: - if 'geometry' in obj.apertures[apid]: - for geo_dict in obj.apertures[apid]['geometry']: + for apid in obj.tools: + if 'geometry' in obj.tools[apid]: + for geo_dict in obj.tools[apid]['geometry']: if 'follow' in geo_dict: if isinstance(geo_dict['follow'], Point): geo = geo_dict['solid'] @@ -6034,7 +6034,7 @@ class App(QtCore.QObject): geo = geo_dict['solid'] try: - new_dia = obj.apertures[apid]['size'] + new_dia = obj.tools[apid]['size'] except Exception: continue @@ -10360,26 +10360,26 @@ class MenuFileHandlers(QtCore.QObject): header += '%%FS%sAX%s%sY%s%s*%%\n' % (gzeros, gwhole, gfract, gwhole, gfract) header += "%MO{units}*%\n".format(units=gunits) - for apid in obj.apertures: - if obj.apertures[apid]['type'] == 'C': + for apid in obj.tools: + if obj.tools[apid]['type'] == 'C': header += "%ADD{apid}{type},{size}*%\n".format( apid=str(apid), type='C', - size=(factor * obj.apertures[apid]['size']) + size=(factor * obj.tools[apid]['size']) ) - elif obj.apertures[apid]['type'] == 'R': + elif obj.tools[apid]['type'] == 'R': header += "%ADD{apid}{type},{width}X{height}*%\n".format( apid=str(apid), type='R', - width=(factor * obj.apertures[apid]['width']), - height=(factor * obj.apertures[apid]['height']) + width=(factor * obj.tools[apid]['width']), + height=(factor * obj.tools[apid]['height']) ) - elif obj.apertures[apid]['type'] == 'O': + elif obj.tools[apid]['type'] == 'O': header += "%ADD{apid}{type},{width}X{height}*%\n".format( apid=str(apid), type='O', - width=(factor * obj.apertures[apid]['width']), - height=(factor * obj.apertures[apid]['height']) + width=(factor * obj.tools[apid]['width']), + height=(factor * obj.tools[apid]['height']) ) header += '\n' diff --git a/tclCommands/TclCommandAddAperture.py b/tclCommands/TclCommandAddAperture.py index d157eeba..2714966a 100644 --- a/tclCommands/TclCommandAddAperture.py +++ b/tclCommands/TclCommandAddAperture.py @@ -71,7 +71,7 @@ class TclCommandAddAperture(TclCommandSignaled): if obj.kind != 'gerber': return 'Expected Gerber, got %s %s.' % (name, type(obj)) - obj_apertures_keys = list(obj.apertures.keys()) + obj_apertures_keys = list(obj.tools.keys()) if 'apid' in args: new_apid = args['apid'] else: @@ -94,7 +94,7 @@ class TclCommandAddAperture(TclCommandSignaled): new_type = 'C' if new_type == 'C': new_size = args['size'] if 'size' in args else 0.6 - obj.apertures[str(new_apid)] = { + obj.tools[str(new_apid)] = { 'type': new_type, 'size': new_size, 'geometry': [] @@ -104,7 +104,7 @@ class TclCommandAddAperture(TclCommandSignaled): new_height = args['height'] if 'height' in args else 0.0 new_size = math.sqrt(new_width ** 2 + new_height ** 2) if new_width > 0 and new_height > 0 else 0 - obj.apertures[str(new_apid)] = { + obj.tools[str(new_apid)] = { 'type': new_type, 'size': new_size, 'width': new_width, @@ -114,4 +114,4 @@ class TclCommandAddAperture(TclCommandSignaled): else: return 'The supported aperture types are: C=circular, R=rectangular, O=oblong' - print(obj.apertures) \ No newline at end of file + print(obj.tools) \ No newline at end of file