- added display of the results for the Rules Check Tool in a formatted way

This commit is contained in:
Marius Stanciu 2019-10-06 04:13:19 +03:00 committed by Marius
parent d103c2d234
commit fa7511e129
4 changed files with 82 additions and 16 deletions

View File

@ -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()

View File

@ -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

View File

@ -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('<b>%s:</b>' % _("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(

View File

@ -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 += '<b>RULE NAME:</b>\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}: <span style="color:{color};">{status}</span>.\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}: <span style="color:{color};">{status}</span>.\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()))