From 93f9a2f0526daa1af5c9d50b50669871a73c5d29 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 3 Aug 2019 22:53:44 +0300 Subject: [PATCH] - solved bug such that the app is not crashing when some apertures in the Gerber file have no geometry. More than that, now the apertures that have geometry elements are bolded as opposed to the ones without geometry for which the text is unbolded --- README.md | 1 + flatcamTools/ToolProperties.py | 44 ++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index c37d1c93..8bfe1732 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - added project name to the window title - fulfilled request: When saving a CNC file, if the file name is changed in the OS window, the new name does appear in the “Selected” (in name) and “Project” tabs (in cnc_job) +- solved bug such that the app is not crashing when some apertures in the Gerber file have no geometry. More than that, now the apertures that have geometry elements are bolded as opposed to the ones without geometry for which the text is unbolded 31.07.2019 diff --git a/flatcamTools/ToolProperties.py b/flatcamTools/ToolProperties.py index cf6c6db2..971b1216 100644 --- a/flatcamTools/ToolProperties.py +++ b/flatcamTools/ToolProperties.py @@ -112,6 +112,8 @@ class Properties(FlatCAMTool): def addItems(self, obj): parent = self.treeWidget.invisibleRootItem() + apertures = '' + tools = '' font = QtGui.QFont() font.setBold(True) @@ -131,11 +133,8 @@ class Properties(FlatCAMTool): self.addChild(obj_type, ['Object Type:', ('%s' % (obj.kind.capitalize()))], True) try: self.addChild(obj_type, - ['Geo Type:', - ('%s' % ({False: "Single-Geo", True: "Multi-Geo"}[obj.multigeo])) - ], - True - ) + ['Geo Type:', ('%s' % ({False: "Single-Geo", True: "Multi-Geo"}[obj.multigeo]))], + True) except Exception as e: log.debug("Properties.addItems() --> %s" % str(e)) @@ -179,26 +178,31 @@ class Properties(FlatCAMTool): self.addChild(options, [str(option), str(obj.options[option])], True) if obj.kind.lower() == 'gerber': - temp_ap = {} + temp_ap = dict() for ap in obj.apertures: temp_ap.clear() temp_ap = deepcopy(obj.apertures[ap]) temp_ap.pop('geometry', None) - if obj.apertures[ap]['geometry']: - solid_nr = 0 - follow_nr = 0 - clear_nr = 0 - for el in obj.apertures[ap]['geometry']: - if 'solid' in el: - solid_nr += 1 - if 'follow' in el: - follow_nr += 1 - if 'clear' in el: - clear_nr += 1 - temp_ap['Solid_Geo'] = '%s Polygons' % str(solid_nr) - temp_ap['Follow_Geo'] = '%s LineStrings' % str(follow_nr) - temp_ap['Clear_Geo'] = '%s Polygons' % str(clear_nr) + solid_nr = 0 + follow_nr = 0 + clear_nr = 0 + + if 'geometry' in obj.apertures[ap]: + if obj.apertures[ap]['geometry']: + font.setBold(True) + for el in obj.apertures[ap]['geometry']: + if 'solid' in el: + solid_nr += 1 + if 'follow' in el: + follow_nr += 1 + if 'clear' in el: + clear_nr += 1 + else: + font.setBold(False) + temp_ap['Solid_Geo'] = '%s Polygons' % str(solid_nr) + temp_ap['Follow_Geo'] = '%s LineStrings' % str(follow_nr) + temp_ap['Clear_Geo'] = '%s Polygons' % str(clear_nr) apid = self.addParent(apertures, str(ap), expanded=False, color=QtGui.QColor("#000000"), font=font) for key in temp_ap: