- aperture keys in the gerber 'tools' dictionary are now stored as integers instead of strings as before; need to check the application especially the Gerber Editor

- fixed issues in Gerber Editor (using the '0' insteadd of 'REG' type for apertures)
This commit is contained in:
Marius Stanciu
2021-03-04 17:45:47 +02:00
parent cda5f830be
commit 0986ef143c
19 changed files with 217 additions and 205 deletions

View File

@@ -275,7 +275,7 @@ class ToolCopperThieving(AppTool):
if ap_keys:
new_apid = str(int(max(ap_keys)) + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {
'type': 'C',
@@ -872,29 +872,29 @@ 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.tools)
if '0' not in new_apertures:
new_apertures['0'] = {
if 0 not in new_apertures:
new_apertures[0] = {
'type': 'REG',
'size': 0.0,
'geometry': []
}
# add the thieving geometry in the '0' aperture of the new_apertures dict
# add the thieving geometry in the 0 aperture of the new_apertures dict
try:
for poly in tool_obj.thief_solid_geometry:
# append to the new solid geometry
geo_list.append(poly)
# append into the '0' aperture
# append into the 0 aperture
geo_elem = {'solid': poly, 'follow': poly.exterior}
new_apertures['0']['geometry'].append(deepcopy(geo_elem))
new_apertures[0]['geometry'].append(deepcopy(geo_elem))
except TypeError:
# append to the new solid geometry
geo_list.append(tool_obj.thief_solid_geometry)
# append into the '0' aperture
# append into the 0 aperture
geo_elem = {'solid': tool_obj.new_solid_geometry, 'follow': tool_obj.new_solid_geometry.exterior}
new_apertures['0']['geometry'].append(deepcopy(geo_elem))
new_apertures[0]['geometry'].append(deepcopy(geo_elem))
# prepare also the solid_geometry for the new object having the thieving geometry
new_solid_geo = MultiPolygon(geo_list).buffer(0.0000001).buffer(-0.0000001)
@@ -1029,8 +1029,8 @@ class ToolCopperThieving(AppTool):
for geo in thieving_solid_geo:
plated_area += geo.area
if '0' not in new_apertures:
new_apertures['0'] = {
if 0 not in new_apertures:
new_apertures[0] = {
'type': 'REG',
'size': 0.0,
'geometry': []
@@ -1043,23 +1043,23 @@ class ToolCopperThieving(AppTool):
# append to the new solid geometry
geo_list.append(poly_b)
# append into the '0' aperture
# append into the 0 aperture
geo_elem = {
'solid': poly_b,
'follow': poly_b.exterior
}
new_apertures['0']['geometry'].append(deepcopy(geo_elem))
new_apertures[0]['geometry'].append(deepcopy(geo_elem))
except TypeError:
# append to the new solid geometry
assert isinstance(thieving_solid_geo, Polygon)
geo_list.append(thieving_solid_geo.buffer(ppm_clearance))
# append into the '0' aperture
# append into the 0 aperture
geo_elem = {
'solid': thieving_solid_geo.buffer(ppm_clearance),
'follow': thieving_solid_geo.buffer(ppm_clearance).exterior
}
new_apertures['0']['geometry'].append(deepcopy(geo_elem))
new_apertures[0]['geometry'].append(deepcopy(geo_elem))
# if we have robber bar geometry, add it
if robber_solid_geo and geo_choice in ['b', 'r']:
@@ -1084,7 +1084,7 @@ class ToolCopperThieving(AppTool):
if ap_keys and max_apid != 0:
new_apid = str(max_apid + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {
'type': 'C',

View File

@@ -349,7 +349,7 @@ class ToolCorners(AppTool):
if ap_keys:
new_apid = str(int(max(ap_keys)) + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {}
new_apertures[new_apid]['type'] = 'C'

View File

@@ -763,7 +763,7 @@ class ToolExtract(AppTool):
return
new_apertures = {
'10': {
10: {
'type': 'C',
'size': thickness,
'geometry': [

View File

@@ -357,7 +357,7 @@ class ToolFiducials(AppTool):
if ap_keys:
new_apid = str(int(max(ap_keys)) + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {
'type': 'C',
@@ -415,7 +415,7 @@ class ToolFiducials(AppTool):
if ap_keys:
new_apid = str(int(max(ap_keys)) + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {
'type': 'C',
@@ -489,7 +489,7 @@ class ToolFiducials(AppTool):
if ap_keys:
new_apid = str(int(max(ap_keys)) + 1)
else:
new_apid = '10'
new_apid = 10
new_apertures[new_apid] = {
'type': 'R',

View File

@@ -148,8 +148,8 @@ class ToolInvertGerber(AppTool):
new_apertures = {}
if '0' not in new_apertures:
new_apertures['0'] = {
if 0 not in new_apertures:
new_apertures[0] = {
'type': 'C',
'size': 0.0,
'geometry': []
@@ -158,10 +158,10 @@ class ToolInvertGerber(AppTool):
try:
for poly in new_solid_geometry:
new_el = {'solid': poly, 'follow': poly.exterior}
new_apertures['0']['geometry'].append(new_el)
new_apertures[0]['geometry'].append(new_el)
except TypeError:
new_el = {'solid': new_solid_geometry, 'follow': new_solid_geometry.exterior}
new_apertures['0']['geometry'].append(new_el)
new_apertures[0]['geometry'].append(new_el)
def init_func(new_obj, app_obj):
new_obj.options.update(new_options)

View File

@@ -122,7 +122,7 @@ class ToolOptimal(AppTool):
def set_tool_ui(self):
self.ui.result_entry.set_value(0.0)
self.ui.freq_entry.set_value('0')
self.ui.freq_entry.set_value(0)
self.ui.precision_spinner.set_value(int(self.app.defaults["tools_opt_precision"]))
self.ui.locations_textb.clear()
@@ -139,7 +139,7 @@ class ToolOptimal(AppTool):
self.ui.locate_button.setVisible(False)
self.ui.result_entry.set_value(0.0)
self.ui.freq_entry.set_value('0')
self.ui.freq_entry.set_value(0)
self.reset_fields()
def find_minimum_distance(self):

View File

@@ -237,7 +237,7 @@ class ToolPDF(AppTool):
points = {}
def obj_init(new_obj, app_obj):
clear_geo = [geo_el['clear'] for geo_el in ap_dict['0']['geometry']]
clear_geo = [geo_el['clear'] for geo_el in ap_dict[0]['geometry']]
new_obj.tools = {}
@@ -318,10 +318,10 @@ class ToolPDF(AppTool):
follow_buf.append(geo_el['follow'])
poly_buff = unary_union(poly_buff)
if '0' in grb_obj.tools:
if 0 in grb_obj.tools:
global_clear_geo = []
if 'geometry' in grb_obj.tools['0']:
for geo_el in ap_dict['0']['geometry']:
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'])

View File

@@ -995,7 +995,7 @@ class Panelize(AppTool):
new_solid_list.append(deepcopy(new_el))
new_obj.tools = {
'0': {
0: {
'type': 'REG',
'size': 0.0,
'geometry': deepcopy(new_solid_list)
@@ -1007,7 +1007,7 @@ class Panelize(AppTool):
del new_obj.tools
else:
new_obj.tools = {
'0': {
0: {
'type': 'REG',
'size': 0.0,
'geometry': deepcopy(new_obj.solid_geometry)

View File

@@ -321,7 +321,7 @@ class QRCode(AppTool):
box_size = float(self.ui.bsize_entry.get_value()) / 10.0
sort_apid = []
new_apid = '10'
new_apid = 10
if self.grb_object.tools:
for k, v in list(self.grb_object.tools.items()):
sort_apid.append(int(k))
@@ -330,7 +330,7 @@ class QRCode(AppTool):
if max_apid >= 10:
new_apid = str(max_apid + 1)
else:
new_apid = '10'
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.tools:
@@ -347,17 +347,17 @@ class QRCode(AppTool):
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.tools:
self.grb_object.tools['0'] = {
if 0 not in self.grb_object.tools:
self.grb_object.tools[0] = {
'type': 'REG',
'size': 0.0,
'geometry': []
}
# in case that the QRCode geometry is dropped onto a copper region (found in the '0' aperture)
# 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.tools['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()

View File

@@ -33,7 +33,7 @@ class ToolSub(AppTool):
job_finished = QtCore.pyqtSignal(bool)
# the string param is the outname and the list is a list of tuples each being formed from the new_aperture_geometry
# list and the second element is also a list with possible geometry that needs to be added to the '0' aperture
# list and the second element is also a list with possible geometry that needs to be added to the 0 aperture
# meaning geometry that was deformed
aperture_processing_finished = QtCore.pyqtSignal(str, list)
@@ -393,11 +393,11 @@ class ToolSub(AppTool):
grb_obj.tools = deepcopy(self.new_apertures)
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'] = []
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.tools.keys()):
# output is a tuple in the format (apid, surviving_geo, modified_geo)
@@ -412,15 +412,15 @@ class ToolSub(AppTool):
grb_obj.tools[apid]['geometry'] += deepcopy(surving_geo)
if modified_geo:
grb_obj.tools['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.tools[apid]['geometry']:
grb_obj.tools.pop(apid, None)
# delete the '0' aperture if it has no geometry
if not grb_obj.tools['0']['geometry']:
grb_obj.tools.pop('0', None)
# delete the 0 aperture if it has no geometry
if not grb_obj.tools[0]['geometry']:
grb_obj.tools.pop(0, None)
poly_buff = []
follow_buff = []