|
|
@@ -125,15 +125,25 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
grid1.setColumnStretch(0, 0)
|
|
|
grid1.setColumnStretch(1, 1)
|
|
|
|
|
|
+ self.method_label = QtWidgets.QLabel('<b>%s</b>' % _("Method"))
|
|
|
+ grid1.addWidget(self.method_label, 2, 0, 1, 2)
|
|
|
+
|
|
|
# ## Axis
|
|
|
- self.hole_size_radio = RadioSet([{'label': _("Fixed"), 'value': 'fixed'},
|
|
|
- {'label': _("Proportional"), 'value': 'prop'}])
|
|
|
+ self.hole_size_radio = RadioSet(
|
|
|
+ [
|
|
|
+ {'label': _("Fixed Diameter"), 'value': 'fixed'},
|
|
|
+ {'label': _("Fixed Annular Ring"), 'value': 'ring'},
|
|
|
+ {'label': _("Proportional"), 'value': 'prop'}
|
|
|
+ ],
|
|
|
+ orientation='vertical',
|
|
|
+ stretch=False)
|
|
|
+
|
|
|
self.hole_size_label = QtWidgets.QLabel('%s:' % _("Hole Size"))
|
|
|
self.hole_size_label.setToolTip(
|
|
|
- _("The type of hole size. Can be:\n"
|
|
|
- "- Fixed -> all holes will have a set size\n"
|
|
|
- "- Proprotional -> each hole will havea a variable size\n"
|
|
|
- "such as to preserve a set annular ring"))
|
|
|
+ _("The selected method of extracting the drills. Can be:\n"
|
|
|
+ "- Fixed Diameter -> all holes will have a set size\n"
|
|
|
+ "- Fixed Annular Ring -> all holes will have a set annular ring\n"
|
|
|
+ "- Proportional -> each hole size will be a fraction of the pad size"))
|
|
|
|
|
|
grid1.addWidget(self.hole_size_label, 3, 0)
|
|
|
grid1.addWidget(self.hole_size_radio, 3, 1)
|
|
|
@@ -145,18 +155,27 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
grid1.addWidget(separator_line, 5, 0, 1, 2)
|
|
|
|
|
|
+ # Annular Ring
|
|
|
+ self.fixed_label = QtWidgets.QLabel('<b>%s</b>' % _("Fixed Diameter"))
|
|
|
+ grid1.addWidget(self.fixed_label, 6, 0, 1, 2)
|
|
|
+
|
|
|
# Diameter value
|
|
|
self.dia_entry = FCDoubleSpinner()
|
|
|
self.dia_entry.set_precision(self.decimals)
|
|
|
self.dia_entry.set_range(0.0000, 9999.9999)
|
|
|
|
|
|
- self.dia_label = QtWidgets.QLabel('%s:' % _("Diameter"))
|
|
|
+ self.dia_label = QtWidgets.QLabel('%s:' % _("Value"))
|
|
|
self.dia_label.setToolTip(
|
|
|
_("Fixed hole diameter.")
|
|
|
)
|
|
|
|
|
|
- grid1.addWidget(self.dia_label, 7, 0)
|
|
|
- grid1.addWidget(self.dia_entry, 7, 1)
|
|
|
+ grid1.addWidget(self.dia_label, 8, 0)
|
|
|
+ grid1.addWidget(self.dia_entry, 8, 1)
|
|
|
+
|
|
|
+ separator_line = QtWidgets.QFrame()
|
|
|
+ separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
|
|
+ separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
+ grid1.addWidget(separator_line, 9, 0, 1, 2)
|
|
|
|
|
|
self.ring_frame = QtWidgets.QFrame()
|
|
|
self.ring_frame.setContentsMargins(0, 0, 0, 0)
|
|
|
@@ -173,7 +192,7 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
self.ring_box.addLayout(grid2)
|
|
|
|
|
|
# Annular Ring value
|
|
|
- self.ring_label = QtWidgets.QLabel('<b>%s</b>' % _("Annular Ring"))
|
|
|
+ self.ring_label = QtWidgets.QLabel('<b>%s</b>' % _("Fixed Annular Ring"))
|
|
|
self.ring_label.setToolTip(
|
|
|
_("The size of annular ring.\n"
|
|
|
"The copper sliver between the drill hole exterior\n"
|
|
|
@@ -246,6 +265,35 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
grid2.addWidget(self.other_ring_label, 5, 0)
|
|
|
grid2.addWidget(self.other_ring_entry, 5, 1)
|
|
|
|
|
|
+ grid3 = QtWidgets.QGridLayout()
|
|
|
+ self.layout.addLayout(grid3)
|
|
|
+ grid3.setColumnStretch(0, 0)
|
|
|
+ grid3.setColumnStretch(1, 1)
|
|
|
+
|
|
|
+ separator_line = QtWidgets.QFrame()
|
|
|
+ separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
|
|
+ separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
|
|
+ grid3.addWidget(separator_line, 1, 0, 1, 2)
|
|
|
+
|
|
|
+ # Annular Ring value
|
|
|
+ self.prop_label = QtWidgets.QLabel('<b>%s</b>' % _("Proportional Diameter"))
|
|
|
+ grid3.addWidget(self.prop_label, 2, 0, 1, 2)
|
|
|
+
|
|
|
+ # Diameter value
|
|
|
+ self.factor_entry = FCDoubleSpinner(suffix='%')
|
|
|
+ self.factor_entry.set_precision(self.decimals)
|
|
|
+ self.factor_entry.set_range(0.0000, 100.0000)
|
|
|
+ self.factor_entry.setSingleStep(0.1)
|
|
|
+
|
|
|
+ self.factor_label = QtWidgets.QLabel('%s:' % _("Value"))
|
|
|
+ self.factor_label.setToolTip(
|
|
|
+ _("Proportional Diameter.\n"
|
|
|
+ "The drill diameter will be a fraction of the pad size.")
|
|
|
+ )
|
|
|
+
|
|
|
+ grid3.addWidget(self.factor_label, 3, 0)
|
|
|
+ grid3.addWidget(self.factor_entry, 3, 1)
|
|
|
+
|
|
|
# Extract drills from Gerber apertures flashes (pads)
|
|
|
self.e_drills_button = QtWidgets.QPushButton(_("Extract Drills"))
|
|
|
self.e_drills_button.setToolTip(
|
|
|
@@ -280,6 +328,13 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
self.rectangular_ring_entry.setEnabled(False)
|
|
|
self.other_ring_entry.setEnabled(False)
|
|
|
|
|
|
+ self.dia_entry.setDisabled(True)
|
|
|
+ self.dia_label.setDisabled(True)
|
|
|
+ self.factor_label.setDisabled(True)
|
|
|
+ self.factor_entry.setDisabled(True)
|
|
|
+
|
|
|
+ self.ring_frame.setDisabled(True)
|
|
|
+
|
|
|
# ## Signals
|
|
|
self.hole_size_radio.activated_custom.connect(self.on_hole_size_toggle)
|
|
|
self.e_drills_button.clicked.connect(self.on_extract_drills_click)
|
|
|
@@ -359,6 +414,8 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
self.rectangular_cb.set_value(self.app.defaults["tools_edrills_rectangular"])
|
|
|
self.other_cb.set_value(self.app.defaults["tools_edrills_others"])
|
|
|
|
|
|
+ self.factor_entry.set_value(float(self.app.defaults["tools_edrills_hole_prop_factor"]))
|
|
|
+
|
|
|
def on_extract_drills_click(self):
|
|
|
|
|
|
drill_dia = self.dia_entry.get_value()
|
|
|
@@ -368,6 +425,8 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
rect_r_val = self.rectangular_ring_entry.get_value()
|
|
|
other_r_val = self.other_ring_entry.get_value()
|
|
|
|
|
|
+ prop_factor = self.factor_entry.get_value() / 100.0
|
|
|
+
|
|
|
drills = list()
|
|
|
tools = dict()
|
|
|
|
|
|
@@ -376,7 +435,7 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
|
|
|
try:
|
|
|
fcobj = model_index.internalPointer().obj
|
|
|
- except Exception as e:
|
|
|
+ except Exception:
|
|
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
|
|
|
return
|
|
|
|
|
|
@@ -421,7 +480,7 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
if 'solid_geometry' not in tools["1"] or not tools["1"]['solid_geometry']:
|
|
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No drills extracted. Try different parameters."))
|
|
|
return
|
|
|
- else:
|
|
|
+ elif mode == 'ring':
|
|
|
drills_found = set()
|
|
|
for apid, apid_value in fcobj.apertures.items():
|
|
|
ap_type = apid_value['type']
|
|
|
@@ -435,9 +494,9 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
height = float(apid_value['height'])
|
|
|
if self.oblong_cb.get_value():
|
|
|
if width > height:
|
|
|
- dia = float(apid_value['height']) - (2 * rect_r_val)
|
|
|
+ dia = float(apid_value['height']) - (2 * oblong_r_val)
|
|
|
else:
|
|
|
- dia = float(apid_value['width']) - (2 * rect_r_val)
|
|
|
+ dia = float(apid_value['width']) - (2 * oblong_r_val)
|
|
|
elif ap_type == 'R':
|
|
|
width = float(apid_value['width'])
|
|
|
height = float(apid_value['height'])
|
|
|
@@ -506,6 +565,91 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
if True not in drills_found:
|
|
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("No drills extracted. Try different parameters."))
|
|
|
return
|
|
|
+ else:
|
|
|
+ drills_found = set()
|
|
|
+ for apid, apid_value in fcobj.apertures.items():
|
|
|
+ ap_type = apid_value['type']
|
|
|
+
|
|
|
+ dia = None
|
|
|
+ if ap_type == 'C':
|
|
|
+ if self.circular_cb.get_value():
|
|
|
+ dia = float(apid_value['size']) * prop_factor
|
|
|
+ elif ap_type == 'O':
|
|
|
+ width = float(apid_value['width'])
|
|
|
+ height = float(apid_value['height'])
|
|
|
+ if self.oblong_cb.get_value():
|
|
|
+ if width > height:
|
|
|
+ dia = float(apid_value['height']) * prop_factor
|
|
|
+ else:
|
|
|
+ dia = float(apid_value['width']) * prop_factor
|
|
|
+ elif ap_type == 'R':
|
|
|
+ width = float(apid_value['width'])
|
|
|
+ height = float(apid_value['height'])
|
|
|
+
|
|
|
+ # if the height == width (float numbers so the reason for the following)
|
|
|
+ if abs(float('%.*f' % (self.decimals, width)) - float('%.*f' % (self.decimals, height))) < \
|
|
|
+ (10 ** -self.decimals):
|
|
|
+ if self.square_cb.get_value():
|
|
|
+ dia = float(apid_value['height']) * prop_factor
|
|
|
+ else:
|
|
|
+ if self.rectangular_cb.get_value():
|
|
|
+ if width > height:
|
|
|
+ dia = float(apid_value['height']) * prop_factor
|
|
|
+ else:
|
|
|
+ dia = float(apid_value['width']) * prop_factor
|
|
|
+ else:
|
|
|
+ if self.other_cb.get_value():
|
|
|
+ try:
|
|
|
+ dia = float(apid_value['size']) * prop_factor
|
|
|
+ except KeyError:
|
|
|
+ if ap_type == 'AM':
|
|
|
+ pol = apid_value['geometry'][0]['solid']
|
|
|
+ x0, y0, x1, y1 = pol.bounds
|
|
|
+ dx = x1 - x0
|
|
|
+ dy = y1 - y0
|
|
|
+ if dx <= dy:
|
|
|
+ dia = dx * prop_factor
|
|
|
+ else:
|
|
|
+ dia = dy * prop_factor
|
|
|
+
|
|
|
+ # if dia is None then none of the above applied so we skip the following
|
|
|
+ if dia is None:
|
|
|
+ continue
|
|
|
+
|
|
|
+ tool_in_drills = False
|
|
|
+ for tool, tool_val in tools.items():
|
|
|
+ if abs(float('%.*f' % (self.decimals, tool_val["C"])) - float('%.*f' % (self.decimals, dia))) < \
|
|
|
+ (10 ** -self.decimals):
|
|
|
+ tool_in_drills = tool
|
|
|
+
|
|
|
+ if tool_in_drills is False:
|
|
|
+ if tools:
|
|
|
+ new_tool = max([int(t) for t in tools]) + 1
|
|
|
+ tool_in_drills = str(new_tool)
|
|
|
+ else:
|
|
|
+ tool_in_drills = "1"
|
|
|
+
|
|
|
+ for geo_el in apid_value['geometry']:
|
|
|
+ if 'follow' in geo_el and isinstance(geo_el['follow'], Point):
|
|
|
+ if tool_in_drills not in tools:
|
|
|
+ tools[tool_in_drills] = {"C": dia}
|
|
|
+
|
|
|
+ drills.append({"point": geo_el['follow'], "tool": tool_in_drills})
|
|
|
+
|
|
|
+ if 'solid_geometry' not in tools[tool_in_drills]:
|
|
|
+ tools[tool_in_drills]['solid_geometry'] = list()
|
|
|
+ else:
|
|
|
+ tools[tool_in_drills]['solid_geometry'].append(geo_el['follow'])
|
|
|
+
|
|
|
+ if tool_in_drills in tools:
|
|
|
+ if 'solid_geometry' not in tools[tool_in_drills] or not tools[tool_in_drills]['solid_geometry']:
|
|
|
+ drills_found.add(False)
|
|
|
+ else:
|
|
|
+ drills_found.add(True)
|
|
|
+
|
|
|
+ if True not in drills_found:
|
|
|
+ self.app.inform.emit('[WARNING_NOTCL] %s' % _("No drills extracted. Try different parameters."))
|
|
|
+ return
|
|
|
|
|
|
def obj_init(obj_inst, app_inst):
|
|
|
obj_inst.tools = tools
|
|
|
@@ -518,16 +662,36 @@ class ToolExtractDrills(FlatCAMTool):
|
|
|
|
|
|
def on_hole_size_toggle(self, val):
|
|
|
if val == "fixed":
|
|
|
+ self.fixed_label.setDisabled(False)
|
|
|
self.dia_entry.setDisabled(False)
|
|
|
self.dia_label.setDisabled(False)
|
|
|
|
|
|
self.ring_frame.setDisabled(True)
|
|
|
- else:
|
|
|
+
|
|
|
+ self.prop_label.setDisabled(True)
|
|
|
+ self.factor_label.setDisabled(True)
|
|
|
+ self.factor_entry.setDisabled(True)
|
|
|
+ elif val == "ring":
|
|
|
+ self.fixed_label.setDisabled(True)
|
|
|
self.dia_entry.setDisabled(True)
|
|
|
self.dia_label.setDisabled(True)
|
|
|
|
|
|
self.ring_frame.setDisabled(False)
|
|
|
|
|
|
+ self.prop_label.setDisabled(True)
|
|
|
+ self.factor_label.setDisabled(True)
|
|
|
+ self.factor_entry.setDisabled(True)
|
|
|
+ elif val == "prop":
|
|
|
+ self.fixed_label.setDisabled(True)
|
|
|
+ self.dia_entry.setDisabled(True)
|
|
|
+ self.dia_label.setDisabled(True)
|
|
|
+
|
|
|
+ self.ring_frame.setDisabled(True)
|
|
|
+
|
|
|
+ self.prop_label.setDisabled(False)
|
|
|
+ self.factor_label.setDisabled(False)
|
|
|
+ self.factor_entry.setDisabled(False)
|
|
|
+
|
|
|
def reset_fields(self):
|
|
|
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
self.gerber_object_combo.setCurrentIndex(0)
|