- more fixes in Rules Check Tool
This commit is contained in:
parent
53338a2186
commit
0ca078abf2
|
@ -12,7 +12,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
12.10.2019
|
12.10.2019
|
||||||
|
|
||||||
- fixed the Gerber Parser convert units unnecessary usage. The only units conversion should be done when creating the new object, after the parsing
|
- fixed the Gerber Parser convert units unnecessary usage. The only units conversion should be done when creating the new object, after the parsing
|
||||||
|
- more fixes in Rules Check Tool
|
||||||
|
|
||||||
11.10.2019
|
11.10.2019
|
||||||
|
|
||||||
|
|
|
@ -564,6 +564,8 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_inside_gerber_clearance(gerber_obj, size, rule):
|
def check_inside_gerber_clearance(gerber_obj, size, rule):
|
||||||
|
log.debug("RulesCheck.check_inside_gerber_clearance()")
|
||||||
|
|
||||||
rule_title = rule
|
rule_title = rule
|
||||||
|
|
||||||
violations = list()
|
violations = list()
|
||||||
|
@ -639,6 +641,7 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_gerber_clearance(gerber_list, size, rule):
|
def check_gerber_clearance(gerber_list, size, rule):
|
||||||
|
log.debug("RulesCheck.check_gerber_clearance()")
|
||||||
rule_title = rule
|
rule_title = rule
|
||||||
|
|
||||||
violations = list()
|
violations = list()
|
||||||
|
@ -694,11 +697,13 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
if isinstance(total_geo_grb_1, Polygon):
|
if isinstance(total_geo_grb_1, Polygon):
|
||||||
len_1 = 1
|
len_1 = 1
|
||||||
|
total_geo_grb_1 = [total_geo_grb_1]
|
||||||
else:
|
else:
|
||||||
len_1 = len(total_geo_grb_1)
|
len_1 = len(total_geo_grb_1)
|
||||||
|
|
||||||
if isinstance(total_geo_grb_3, Polygon):
|
if isinstance(total_geo_grb_3, Polygon):
|
||||||
len_3 = 1
|
len_3 = 1
|
||||||
|
total_geo_grb_3 = [total_geo_grb_3]
|
||||||
else:
|
else:
|
||||||
len_3 = len(total_geo_grb_3)
|
len_3 = len(total_geo_grb_3)
|
||||||
|
|
||||||
|
@ -743,6 +748,8 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_holes_size(elements, size):
|
def check_holes_size(elements, size):
|
||||||
|
log.debug("RulesCheck.check_holes_size()")
|
||||||
|
|
||||||
rule = _("Hole Size")
|
rule = _("Hole Size")
|
||||||
|
|
||||||
violations = list()
|
violations = list()
|
||||||
|
@ -757,7 +764,7 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
name = elem['name']
|
name = elem['name']
|
||||||
for tool in elem['tools']:
|
for tool in elem['tools']:
|
||||||
tool_dia = float(elem['tools'][tool]['C'])
|
tool_dia = float('%.*f' % (4, float(elem['tools'][tool]['C'])))
|
||||||
if tool_dia < float(size):
|
if tool_dia < float(size):
|
||||||
dia_list.append(tool_dia)
|
dia_list.append(tool_dia)
|
||||||
obj_violations['name'] = name
|
obj_violations['name'] = name
|
||||||
|
@ -768,6 +775,7 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_holes_clearance(elements, size):
|
def check_holes_clearance(elements, size):
|
||||||
|
log.debug("RulesCheck.check_holes_clearance()")
|
||||||
rule = _("Hole to Hole Clearance")
|
rule = _("Hole to Hole Clearance")
|
||||||
|
|
||||||
violations = list()
|
violations = list()
|
||||||
|
@ -822,6 +830,8 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_traces_size(elements, size):
|
def check_traces_size(elements, size):
|
||||||
|
log.debug("RulesCheck.check_traces_size()")
|
||||||
|
|
||||||
rule = _("Trace Size")
|
rule = _("Trace Size")
|
||||||
|
|
||||||
violations = list()
|
violations = list()
|
||||||
|
@ -934,11 +944,13 @@ class RulesCheck(FlatCAMTool):
|
||||||
|
|
||||||
if isinstance(total_geo_grb, Polygon):
|
if isinstance(total_geo_grb, Polygon):
|
||||||
len_1 = 1
|
len_1 = 1
|
||||||
|
total_geo_grb = [total_geo_grb]
|
||||||
else:
|
else:
|
||||||
len_1 = len(total_geo_grb)
|
len_1 = len(total_geo_grb)
|
||||||
|
|
||||||
if isinstance(total_geo_exc, Polygon):
|
if isinstance(total_geo_exc, Polygon):
|
||||||
len_2 = 1
|
len_2 = 1
|
||||||
|
total_geo_exc = [total_geo_exc]
|
||||||
else:
|
else:
|
||||||
len_2 = len(total_geo_exc)
|
len_2 = len(total_geo_exc)
|
||||||
|
|
||||||
|
@ -946,21 +958,32 @@ class RulesCheck(FlatCAMTool):
|
||||||
log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations))
|
log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations))
|
||||||
|
|
||||||
min_dict = dict()
|
min_dict = dict()
|
||||||
|
dist = None
|
||||||
for geo in total_geo_grb:
|
for geo in total_geo_grb:
|
||||||
for s_geo in total_geo_exc:
|
for s_geo in total_geo_exc:
|
||||||
# minimize the number of distances by not taking into considerations those that are too small
|
try:
|
||||||
dist = geo.exterior.distance(s_geo)
|
# minimize the number of distances by not taking into considerations those that are too small
|
||||||
if float(dist) < float(size):
|
dist = abs(geo.exterior.distance(s_geo))
|
||||||
loc_1, loc_2 = nearest_points(geo.exterior, s_geo)
|
except Exception as e:
|
||||||
|
log.debug("RulesCheck.check_gerber_annular_ring() --> %s" % str(e))
|
||||||
|
|
||||||
dx = loc_1.x - loc_2.x
|
if dist > 0:
|
||||||
dy = loc_1.y - loc_2.y
|
if float(dist) < float(size):
|
||||||
loc = min(loc_1.x, loc_2.x) + (abs(dx) / 2), min(loc_1.y, loc_2.y) + (abs(dy) / 2)
|
loc_1, loc_2 = nearest_points(geo.exterior, s_geo)
|
||||||
|
|
||||||
|
dx = loc_1.x - loc_2.x
|
||||||
|
dy = loc_1.y - loc_2.y
|
||||||
|
loc = min(loc_1.x, loc_2.x) + (abs(dx) / 2), min(loc_1.y, loc_2.y) + (abs(dy) / 2)
|
||||||
|
|
||||||
|
if dist in min_dict:
|
||||||
|
min_dict[dist].append(loc)
|
||||||
|
else:
|
||||||
|
min_dict[dist] = [loc]
|
||||||
|
else:
|
||||||
if dist in min_dict:
|
if dist in min_dict:
|
||||||
min_dict[dist].append(loc)
|
min_dict[dist].append(s_geo.representative_point())
|
||||||
else:
|
else:
|
||||||
min_dict[dist] = [loc]
|
min_dict[dist] = [s_geo.representative_point()]
|
||||||
|
|
||||||
points_list = list()
|
points_list = list()
|
||||||
for dist in min_dict.keys():
|
for dist in min_dict.keys():
|
||||||
|
@ -968,19 +991,32 @@ class RulesCheck(FlatCAMTool):
|
||||||
points_list.append(location)
|
points_list.append(location)
|
||||||
|
|
||||||
name_list = list()
|
name_list = list()
|
||||||
if gerber_obj:
|
try:
|
||||||
name_list.append(gerber_obj['name'])
|
if gerber_obj:
|
||||||
if gerber_extra_obj:
|
name_list.append(gerber_obj['name'])
|
||||||
name_list.append(gerber_extra_obj['name'])
|
except KeyError:
|
||||||
if exc_obj:
|
pass
|
||||||
name_list.append(exc_obj['name'])
|
try:
|
||||||
if exc_extra_obj:
|
if gerber_extra_obj:
|
||||||
name_list.append(exc_extra_obj['name'])
|
name_list.append(gerber_extra_obj['name'])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if exc_obj:
|
||||||
|
name_list.append(exc_obj['name'])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
if exc_extra_obj:
|
||||||
|
name_list.append(exc_extra_obj['name'])
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
obj_violations['name'] = name_list
|
obj_violations['name'] = name_list
|
||||||
obj_violations['points'] = points_list
|
obj_violations['points'] = points_list
|
||||||
violations.append(deepcopy(obj_violations))
|
violations.append(deepcopy(obj_violations))
|
||||||
|
|
||||||
return rule_title, violations
|
return rule_title, violations
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
@ -1438,22 +1474,46 @@ class RulesCheck(FlatCAMTool):
|
||||||
txt += 'File name: %s<BR>' % str(el[1][0]['name'])
|
txt += 'File name: %s<BR>' % str(el[1][0]['name'])
|
||||||
|
|
||||||
point_txt = ''
|
point_txt = ''
|
||||||
if el[1][0]['points']:
|
try:
|
||||||
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
if el[1][0]['points']:
|
||||||
color='red',
|
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
||||||
status=_("FAILED"))
|
color='red',
|
||||||
if 'Failed' in el[1][0]['points'][0]:
|
status=_("FAILED"))
|
||||||
point_txt = el[1][0]['points'][0]
|
if 'Failed' in el[1][0]['points'][0]:
|
||||||
|
point_txt = el[1][0]['points'][0]
|
||||||
|
else:
|
||||||
|
for pt in el[1][0]['points']:
|
||||||
|
point_txt += '(%.*f, %.*f)' % (self.decimals, float(pt[0]), self.decimals, float(pt[1]))
|
||||||
|
point_txt += ', '
|
||||||
|
txt += 'Violations: %s<BR>' % str(point_txt)
|
||||||
else:
|
else:
|
||||||
for pt in el[1][0]['points']:
|
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
||||||
point_txt += '(%.*f, %.*f)' % (self.decimals, float(pt[0]), self.decimals, float(pt[1]))
|
color='green',
|
||||||
point_txt += ', '
|
status=_("PASSED"))
|
||||||
txt += 'Violations: %s<BR>' % str(point_txt)
|
txt += '%s<BR>' % _("Violations: There are no violations for the current rule.")
|
||||||
else:
|
except KeyError:
|
||||||
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
pass
|
||||||
color='green',
|
|
||||||
status=_("PASSED"))
|
try:
|
||||||
txt += '%s<BR>' % _("Violations: There are no violations for the current rule.")
|
if el[1][0]['dia']:
|
||||||
|
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
||||||
|
color='red',
|
||||||
|
status=_("FAILED"))
|
||||||
|
if 'Failed' in el[1][0]['dia']:
|
||||||
|
point_txt = el[1][0]['dia']
|
||||||
|
else:
|
||||||
|
for pt in el[1][0]['dia']:
|
||||||
|
point_txt += '%.*f' % (self.decimals, float(pt))
|
||||||
|
point_txt += ', '
|
||||||
|
txt += 'Violations: %s<BR>' % str(point_txt)
|
||||||
|
else:
|
||||||
|
txt += '{title}: <span style="color:{color};">{status}</span>.<BR>'.format(title=_("STATUS"),
|
||||||
|
color='green',
|
||||||
|
status=_("PASSED"))
|
||||||
|
txt += '%s<BR>' % _("Violations: There are no violations for the current rule.")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
txt += '<BR><BR>'
|
txt += '<BR><BR>'
|
||||||
new_obj.source_file = txt
|
new_obj.source_file = txt
|
||||||
new_obj.read_only = True
|
new_obj.read_only = True
|
||||||
|
|
Loading…
Reference in New Issue