- solved bug in Gerber apertures size and dimensions values conversion when file units are different than app units
This commit is contained in:
parent
fc1dfb8550
commit
2e7d9f953f
|
@ -19,6 +19,7 @@ CAD program, and create G-Code for Isolation routing.
|
|||
- moved the key handler out of the Measurement tool to flatcamGUI.FlatCAMGui.keyPressEvent()
|
||||
- Gerber Editor: started to add new function of poligonize which should make a filled polygon out of a shape
|
||||
- cleaned up Measuring Tool
|
||||
- solved bug in Gerber apertures size and dimensions values conversion when file units are different than app units
|
||||
|
||||
13.04.2019
|
||||
|
||||
|
|
14
camlib.py
14
camlib.py
|
@ -2162,6 +2162,9 @@ class Gerber (Geometry):
|
|||
# Coordinates of the current path, each is [x, y]
|
||||
path = []
|
||||
|
||||
# store the file units here:
|
||||
gerber_units = 'IN'
|
||||
|
||||
# this is for temporary storage of geometry until it is added to poly_buffer
|
||||
geo = None
|
||||
|
||||
|
@ -3180,6 +3183,13 @@ class Gerber (Geometry):
|
|||
self.apertures[last_path_aperture]['solid_geometry'] = []
|
||||
self.apertures[last_path_aperture]['solid_geometry'].append(geo)
|
||||
|
||||
# TODO: make sure to keep track of units changes because right now it seems to happen in a weird way
|
||||
# find out the conversion factor used to convert inside the self.apertures keys: size, width, height
|
||||
file_units = gerber_units if gerber_units else 'IN'
|
||||
app_units = self.app.defaults['units']
|
||||
|
||||
conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1
|
||||
|
||||
# first check if we have any clear_geometry (LPC) and if yes then we need to substract it
|
||||
# from the apertures solid_geometry
|
||||
temp_geo = []
|
||||
|
@ -3195,7 +3205,9 @@ class Gerber (Geometry):
|
|||
self.apertures[apid]['solid_geometry'] = deepcopy(temp_geo)
|
||||
self.apertures[apid].pop('clear_geometry', None)
|
||||
|
||||
|
||||
for k, v in self.apertures[apid].items():
|
||||
if k == 'size' or k == 'width' or k == 'height':
|
||||
self.apertures[apid][k] = v * conversion_factor
|
||||
|
||||
# --- Apply buffer ---
|
||||
# this treats the case when we are storing geometry as paths
|
||||
|
|
|
@ -1570,15 +1570,15 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
|
||||
if str(self.storage_dict[ap_code]['type']) == 'R' or str(self.storage_dict[ap_code]['type']) == 'O':
|
||||
ap_dim_item = QtWidgets.QTableWidgetItem(
|
||||
'%.4f, %.4f' % (self.storage_dict[ap_code]['width'] * self.gerber_obj.file_units_factor,
|
||||
self.storage_dict[ap_code]['height'] * self.gerber_obj.file_units_factor
|
||||
'%.4f, %.4f' % (self.storage_dict[ap_code]['width'],
|
||||
self.storage_dict[ap_code]['height']
|
||||
)
|
||||
)
|
||||
ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
elif str(self.storage_dict[ap_code]['type']) == 'P':
|
||||
ap_dim_item = QtWidgets.QTableWidgetItem(
|
||||
'%.4f, %.4f' % (self.storage_dict[ap_code]['diam'] * self.gerber_obj.file_units_factor,
|
||||
self.storage_dict[ap_code]['nVertices'] * self.gerber_obj.file_units_factor)
|
||||
'%.4f, %.4f' % (self.storage_dict[ap_code]['diam'],
|
||||
self.storage_dict[ap_code]['nVertices'])
|
||||
)
|
||||
ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
else:
|
||||
|
@ -1588,8 +1588,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
|
|||
try:
|
||||
if self.storage_dict[ap_code]['size'] is not None:
|
||||
ap_size_item = QtWidgets.QTableWidgetItem('%.4f' %
|
||||
float(self.storage_dict[ap_code]['size'] *
|
||||
self.gerber_obj.file_units_factor))
|
||||
float(self.storage_dict[ap_code]['size']))
|
||||
else:
|
||||
ap_size_item = QtWidgets.QTableWidgetItem('')
|
||||
except KeyError:
|
||||
|
|
Loading…
Reference in New Issue