From fa7511e129da0947f9c82776b6012f08550ef77b Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 6 Oct 2019 04:13:19 +0300 Subject: [PATCH] - added display of the results for the Rules Check Tool in a formatted way --- FlatCAMObj.py | 2 +- README.md | 1 + flatcamTools/ToolOptimal.py | 57 ++++++++++++++++++++++++++++------ flatcamTools/ToolRulesCheck.py | 38 ++++++++++++++++++++--- 4 files changed, 82 insertions(+), 16 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index fae047ad..7c4fd10b 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -6831,7 +6831,7 @@ class FlatCAMDocument(FlatCAMObj): def on_text_changed(self): self.source_file = self.document_editor_tab.code_editor.toHtml() - print(self.source_file) + # print(self.source_file) def font_family(self, font): # self.document_editor_tab.code_editor.selectAll() diff --git a/README.md b/README.md index 065a7306..d174719c 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - remade the Mark area Tool in Gerber Editor to be able to clear the markings and also to delete the marked polygons (Gerber apertures) - working in adding to the Optimal Tool the rest of the distances found in the Gerber and the locations associated; added GUI +- added display of the results for the Rules Check Tool in a formatted way 5.10.2019 diff --git a/flatcamTools/ToolOptimal.py b/flatcamTools/ToolOptimal.py index a683fca5..2c221477 100644 --- a/flatcamTools/ToolOptimal.py +++ b/flatcamTools/ToolOptimal.py @@ -117,6 +117,17 @@ class ToolOptimal(FlatCAMTool): self.locations_textb.setStyleSheet(stylesheet) form_lay.addRow(self.locations_textb) + # Jump button + self.locate_button = QtWidgets.QPushButton(_("Jump to selected position")) + self.locate_button.setToolTip( + _("Select a position in the Locations text box and then\n" + "click this button.") + ) + self.locate_button.setMinimumWidth(60) + self.locate_button.setDisabled(True) + form_lay.addRow(self.locate_button) + + # Other distances in Gerber self.title_second_res_label = QtWidgets.QLabel('%s:' % _("Other distances")) self.title_second_res_label.setToolTip(_("Will display other distances in the Gerber file ordered from\n" "the minimum to the maximum, not including the absolute minimum.")) @@ -128,16 +139,6 @@ class ToolOptimal(FlatCAMTool): "where the distance was found.")) form_lay.addRow(self.sec_locations_cb) - # Jump button - self.locate_button = QtWidgets.QPushButton(_("Jump to selected position")) - self.locate_button.setToolTip( - _("Select a position in the Locations text box and then\n" - "click this button.") - ) - self.locate_button.setMinimumWidth(60) - self.locate_button.setDisabled(True) - form_lay.addRow(self.locate_button) - # this way I can hide/show the frame self.sec_locations_frame = QtWidgets.QFrame() self.sec_locations_frame.setContentsMargins(0, 0, 0, 0) @@ -146,6 +147,42 @@ class ToolOptimal(FlatCAMTool): self.distances_box.setContentsMargins(0, 0, 0, 0) self.sec_locations_frame.setLayout(self.distances_box) + # Other distances + self.distances_textb = FCTextArea(parent=self) + self.distances_textb.setReadOnly(True) + self.distances_textb.setToolTip(_("Gerber distances.")) + stylesheet = """ + QTextEdit { selection-background-color:yellow; + selection-color:black; + } + """ + + self.distances_textb.setStyleSheet(stylesheet) + self.distances_box.addWidget(self.distances_textb) + + # Locations where minimum was found + self.locations_sec_textb = FCTextArea(parent=self) + self.locations_sec_textb.setReadOnly(True) + self.locations_sec_textb.setToolTip(_("Coordinates for points where the selected distance was found.")) + stylesheet = """ + QTextEdit { selection-background-color:yellow; + selection-color:black; + } + """ + + self.locations_sec_textb.setStyleSheet(stylesheet) + self.distances_box.addWidget(self.locations_sec_textb) + + # Jump button + self.locate_sec_button = QtWidgets.QPushButton(_("Jump to selected position")) + self.locate_sec_button.setToolTip( + _("Select a position in the Locations text box and then\n" + "click this button.") + ) + self.locate_sec_button.setMinimumWidth(60) + self.locate_sec_button.setDisabled(True) + self.distances_box.addWidget(self.locate_sec_button) + # GO button self.calculate_button = QtWidgets.QPushButton(_("Find Minimum")) self.calculate_button.setToolTip( diff --git a/flatcamTools/ToolRulesCheck.py b/flatcamTools/ToolRulesCheck.py index 9096ec6b..0b69753b 100644 --- a/flatcamTools/ToolRulesCheck.py +++ b/flatcamTools/ToolRulesCheck.py @@ -811,7 +811,7 @@ class RulesCheck(FlatCAMTool): name = elem['name'] for apid in elem['apertures']: tool_dia = float(elem['apertures'][apid]['size']) - if tool_dia < float(size): + if tool_dia < float(size) and tool_dia != 0.0: dia_list.append(tool_dia) for geo_el in elem['apertures'][apid]['geometry']: if 'solid' in geo_el.keys(): @@ -934,11 +934,11 @@ class RulesCheck(FlatCAMTool): if gerber_obj: name_list.append(gerber_obj['name']) if gerber_extra_obj: - name_list.append(gerber_obj['name']) + name_list.append(gerber_extra_obj['name']) if exc_obj: - name_list.append(gerber_obj['name']) + name_list.append(exc_obj['name']) if exc_extra_obj: - name_list.append(gerber_obj['name']) + name_list.append(exc_extra_obj['name']) obj_violations['name'] = name_list obj_violations['points'] = points_list @@ -1388,7 +1388,35 @@ class RulesCheck(FlatCAMTool): self.app.worker_task.emit({'fcn': worker_job, 'params': [self.app]}) def on_tool_finished(self, res): - print(res) + def init(new_obj, app_obj): + txt = '' + for el in res: + txt += 'RULE NAME:\t%s\n' % str(el[0]).upper() + if isinstance(el[1][0]['name'], list): + for name in el[1][0]['name']: + txt += 'File name: %s\n' % str(name) + else: + txt += 'File name: %s\n' % str(el[1][0]['name']) + + point_txt = '' + if el[1][0]['points']: + txt += '{title}: {status}.\n'.format(title=_("STATUS"), + color='red', + status=_("FAILED")) + + for pt in el[1][0]['points']: + point_txt += str(pt) + point_txt += ', ' + txt += 'Violations: %s\n' % str(point_txt) + else: + txt += '{title}: {status}.\n'.format(title=_("STATUS"), + color='green', + status=_("PASSED")) + txt += '%s\n' % _("Violations: There are no violations for the current rule.") + txt += '\n\n' + new_obj.source_file = txt + + self.app.new_object('document', name='Rules Check results', initialize=init, plot=False ) def reset_fields(self): # self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))