- finished the GUI in the Extract Drills Tool
This commit is contained in:
parent
fc31bb573d
commit
f2ccb48c98
|
@ -954,6 +954,11 @@ class App(QtCore.QObject):
|
||||||
"tools_cal_toolchange_xy": '',
|
"tools_cal_toolchange_xy": '',
|
||||||
"tools_cal_sec_point": 'tl',
|
"tools_cal_sec_point": 'tl',
|
||||||
|
|
||||||
|
# Drills Extraction Tool
|
||||||
|
"tools_edrills_hole_type": 'fixed',
|
||||||
|
"tools_edrills_hole_fixed_dia": 0.5,
|
||||||
|
"tools_edrills_hole_ring": 0.2,
|
||||||
|
|
||||||
# Utilities
|
# Utilities
|
||||||
# file associations
|
# file associations
|
||||||
"fa_excellon": 'drd, drl, exc, ncd, tap, xln',
|
"fa_excellon": 'drd, drl, exc, ncd, tap, xln',
|
||||||
|
@ -2464,12 +2469,13 @@ class App(QtCore.QObject):
|
||||||
self.qrcode_tool = None
|
self.qrcode_tool = None
|
||||||
self.copper_thieving_tool = None
|
self.copper_thieving_tool = None
|
||||||
self.fiducial_tool = None
|
self.fiducial_tool = None
|
||||||
|
self.edrills_tool = None
|
||||||
|
|
||||||
# always install tools only after the shell is initialized because the self.inform.emit() depends on shell
|
# always install tools only after the shell is initialized because the self.inform.emit() depends on shell
|
||||||
try:
|
try:
|
||||||
self.install_tools()
|
self.install_tools()
|
||||||
except AttributeError:
|
except AttributeError as e:
|
||||||
pass
|
log.debug("App.__init__() install tools() --> %s" % str(e))
|
||||||
|
|
||||||
# ##################################################################################
|
# ##################################################################################
|
||||||
# ########################### SETUP RECENT ITEMS ###################################
|
# ########################### SETUP RECENT ITEMS ###################################
|
||||||
|
@ -3017,13 +3023,6 @@ class App(QtCore.QObject):
|
||||||
|
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
self.dblsidedtool = DblSidedTool(self)
|
|
||||||
self.dblsidedtool.install(icon=QtGui.QIcon(self.resource_location + '/doubleside16.png'), separator=True)
|
|
||||||
|
|
||||||
self.cal_exc_tool = ToolCalibration(self)
|
|
||||||
self.cal_exc_tool.install(icon=QtGui.QIcon(self.resource_location + '/calibrate_16.png'), pos=self.ui.menutool,
|
|
||||||
before=self.dblsidedtool.menuAction,
|
|
||||||
separator=False)
|
|
||||||
self.distance_tool = Distance(self)
|
self.distance_tool = Distance(self)
|
||||||
self.distance_tool.install(icon=QtGui.QIcon(self.resource_location + '/distance16.png'), pos=self.ui.menuedit,
|
self.distance_tool.install(icon=QtGui.QIcon(self.resource_location + '/distance16.png'), pos=self.ui.menuedit,
|
||||||
before=self.ui.menueditorigin,
|
before=self.ui.menueditorigin,
|
||||||
|
@ -3035,6 +3034,17 @@ class App(QtCore.QObject):
|
||||||
before=self.ui.menueditorigin,
|
before=self.ui.menueditorigin,
|
||||||
separator=True)
|
separator=True)
|
||||||
|
|
||||||
|
self.dblsidedtool = DblSidedTool(self)
|
||||||
|
self.dblsidedtool.install(icon=QtGui.QIcon(self.resource_location + '/doubleside16.png'), separator=False)
|
||||||
|
|
||||||
|
self.cal_exc_tool = ToolCalibration(self)
|
||||||
|
self.cal_exc_tool.install(icon=QtGui.QIcon(self.resource_location + '/calibrate_16.png'), pos=self.ui.menutool,
|
||||||
|
before=self.dblsidedtool.menuAction,
|
||||||
|
separator=False)
|
||||||
|
|
||||||
|
self.edrills_tool = ToolExtractDrills(self)
|
||||||
|
self.edrills_tool.install(icon=QtGui.QIcon(self.resource_location + '/drill16.png'), separator=True)
|
||||||
|
|
||||||
self.panelize_tool = Panelize(self)
|
self.panelize_tool = Panelize(self)
|
||||||
self.panelize_tool.install(icon=QtGui.QIcon(self.resource_location + '/panelize16.png'))
|
self.panelize_tool.install(icon=QtGui.QIcon(self.resource_location + '/panelize16.png'))
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
10.02.2019
|
10.02.2019
|
||||||
|
|
||||||
- working on a new tool: Extract Drills Tool who will create a Excellon object out of the apertures of a Gerber object
|
- working on a new tool: Extract Drills Tool who will create a Excellon object out of the apertures of a Gerber object
|
||||||
|
- finished the GUI in the Extract Drills Tool
|
||||||
|
|
||||||
8.01.2019
|
8.01.2019
|
||||||
|
|
||||||
|
|
|
@ -59,21 +59,15 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
self.grb_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
|
self.grb_label = QtWidgets.QLabel("<b>%s:</b>" % _("GERBER"))
|
||||||
self.grb_label.setToolTip('%s.' % _("Gerber from which to extract drill holes"))
|
self.grb_label.setToolTip('%s.' % _("Gerber from which to extract drill holes"))
|
||||||
|
|
||||||
self.mirror_gerber_button.setStyleSheet("""
|
|
||||||
QPushButton
|
|
||||||
{
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
""")
|
|
||||||
self.mirror_gerber_button.setMinimumWidth(60)
|
|
||||||
|
|
||||||
# grid_lay.addRow("Bottom Layer:", self.object_combo)
|
# grid_lay.addRow("Bottom Layer:", self.object_combo)
|
||||||
grid_lay.addWidget(self.grb_label, 0, 0)
|
grid_lay.addWidget(self.grb_label, 0, 0)
|
||||||
grid_lay.addWidget(self.gerber_object_combo, 1, 0)
|
grid_lay.addWidget(self.gerber_object_combo, 1, 0)
|
||||||
|
|
||||||
# ## Grid Layout
|
# ## Grid Layout
|
||||||
grid_lay1 = QtWidgets.QGridLayout()
|
grid1 = QtWidgets.QGridLayout()
|
||||||
self.layout.addLayout(grid_lay1)
|
self.layout.addLayout(grid1)
|
||||||
|
grid1.setColumnStretch(0, 0)
|
||||||
|
grid1.setColumnStretch(1, 1)
|
||||||
|
|
||||||
# ## Axis
|
# ## Axis
|
||||||
self.hole_size_radio = RadioSet([{'label': _("Fixed"), 'value': 'fixed'},
|
self.hole_size_radio = RadioSet([{'label': _("Fixed"), 'value': 'fixed'},
|
||||||
|
@ -85,20 +79,15 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
"- Proprotional -> each hole will havea a variable size\n"
|
"- Proprotional -> each hole will havea a variable size\n"
|
||||||
"such as to preserve a set annular ring"))
|
"such as to preserve a set annular ring"))
|
||||||
|
|
||||||
grid_lay1.addWidget(self.hole_size_label, 3, 0)
|
grid1.addWidget(self.hole_size_label, 3, 0)
|
||||||
grid_lay1.addWidget(self.hole_size_radio, 3, 1)
|
grid1.addWidget(self.hole_size_radio, 3, 1)
|
||||||
|
|
||||||
self.layout.addWidget(QtWidgets.QLabel(''))
|
# grid_lay1.addWidget(QtWidgets.QLabel(''))
|
||||||
|
|
||||||
separator_line = QtWidgets.QFrame()
|
separator_line = QtWidgets.QFrame()
|
||||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||||
self.layout.addWidget(separator_line)
|
grid1.addWidget(separator_line, 5, 0, 1, 2)
|
||||||
|
|
||||||
grid1 = QtWidgets.QGridLayout()
|
|
||||||
self.layout.addLayout(grid1)
|
|
||||||
grid1.setColumnStretch(0, 0)
|
|
||||||
grid1.setColumnStretch(1, 1)
|
|
||||||
|
|
||||||
# Diameter value
|
# Diameter value
|
||||||
self.dia_entry = FCDoubleSpinner()
|
self.dia_entry = FCDoubleSpinner()
|
||||||
|
@ -110,8 +99,8 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
_("Fixed hole diameter.")
|
_("Fixed hole diameter.")
|
||||||
)
|
)
|
||||||
|
|
||||||
grid1.addWidget(self.dia_label, 1, 0)
|
grid1.addWidget(self.dia_label, 7, 0)
|
||||||
grid1.addWidget(self.dia_entry, 1, 1)
|
grid1.addWidget(self.dia_entry, 7, 1)
|
||||||
|
|
||||||
# Annular Ring value
|
# Annular Ring value
|
||||||
self.ring_entry = FCDoubleSpinner()
|
self.ring_entry = FCDoubleSpinner()
|
||||||
|
@ -125,8 +114,8 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
"and the margin of the copper pad.")
|
"and the margin of the copper pad.")
|
||||||
)
|
)
|
||||||
|
|
||||||
grid1.addWidget(self.ring_label, 2, 0)
|
grid1.addWidget(self.ring_label, 8, 0)
|
||||||
grid1.addWidget(self.ring_entry, 2, 1)
|
grid1.addWidget(self.ring_entry, 8, 1)
|
||||||
|
|
||||||
# Calculate Bounding box
|
# Calculate Bounding box
|
||||||
self.e_drills_button = QtWidgets.QPushButton(_("Extract Drills"))
|
self.e_drills_button = QtWidgets.QPushButton(_("Extract Drills"))
|
||||||
|
@ -157,7 +146,7 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
self.layout.addWidget(self.reset_button)
|
self.layout.addWidget(self.reset_button)
|
||||||
|
|
||||||
# ## Signals
|
# ## Signals
|
||||||
self.hole_size_radio.activated_custom(self.on_hole_size_toggle)
|
self.hole_size_radio.activated_custom.connect(self.on_hole_size_toggle)
|
||||||
self.e_drills_button.clicked.connect(self.on_extract_drills_click)
|
self.e_drills_button.clicked.connect(self.on_extract_drills_click)
|
||||||
self.reset_button.clicked.connect(self.set_tool_ui)
|
self.reset_button.clicked.connect(self.set_tool_ui)
|
||||||
|
|
||||||
|
@ -165,7 +154,7 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
self.drills = dict()
|
self.drills = dict()
|
||||||
|
|
||||||
def install(self, icon=None, separator=None, **kwargs):
|
def install(self, icon=None, separator=None, **kwargs):
|
||||||
FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
|
FlatCAMTool.install(self, icon, separator, shortcut='ALT+E', **kwargs)
|
||||||
|
|
||||||
def run(self, toggle=True):
|
def run(self, toggle=True):
|
||||||
self.app.report_usage("Extract Drills()")
|
self.app.report_usage("Extract Drills()")
|
||||||
|
@ -204,60 +193,56 @@ class ToolExtractDrills(FlatCAMTool):
|
||||||
|
|
||||||
def on_extract_drills_click(self):
|
def on_extract_drills_click(self):
|
||||||
selection_index = self.gerber_object_combo.currentIndex()
|
selection_index = self.gerber_object_combo.currentIndex()
|
||||||
# fcobj = self.app.collection.object_list[selection_index]
|
|
||||||
model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
|
model_index = self.app.collection.index(selection_index, 0, self.gerber_object_combo.rootModelIndex())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fcobj = model_index.internalPointer().obj
|
fcobj = model_index.internalPointer().obj
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
|
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ..."))
|
||||||
return
|
return
|
||||||
|
|
||||||
if not isinstance(fcobj, FlatCAMGerber):
|
# axis = self.mirror_axis.get_value()
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Only Gerber, Excellon and Geometry objects can be mirrored."))
|
# mode = self.axis_location.get_value()
|
||||||
return
|
#
|
||||||
|
# if mode == "point":
|
||||||
axis = self.mirror_axis.get_value()
|
# try:
|
||||||
mode = self.axis_location.get_value()
|
# px, py = self.point_entry.get_value()
|
||||||
|
# except TypeError:
|
||||||
if mode == "point":
|
# self.app.inform.emit('[WARNING_NOTCL] %s' % _("'Point' coordinates missing. "
|
||||||
try:
|
# "Using Origin (0, 0) as mirroring reference."))
|
||||||
px, py = self.point_entry.get_value()
|
# px, py = (0, 0)
|
||||||
except TypeError:
|
#
|
||||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("'Point' coordinates missing. "
|
# else:
|
||||||
"Using Origin (0, 0) as mirroring reference."))
|
# selection_index_box = self.box_combo.currentIndex()
|
||||||
px, py = (0, 0)
|
# model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
|
||||||
|
# try:
|
||||||
else:
|
# bb_obj = model_index_box.internalPointer().obj
|
||||||
selection_index_box = self.box_combo.currentIndex()
|
# except Exception as e:
|
||||||
model_index_box = self.app.collection.index(selection_index_box, 0, self.box_combo.rootModelIndex())
|
# self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Box object loaded ..."))
|
||||||
try:
|
# return
|
||||||
bb_obj = model_index_box.internalPointer().obj
|
#
|
||||||
except Exception as e:
|
# xmin, ymin, xmax, ymax = bb_obj.bounds()
|
||||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Box object loaded ..."))
|
# px = 0.5 * (xmin + xmax)
|
||||||
return
|
# py = 0.5 * (ymin + ymax)
|
||||||
|
#
|
||||||
xmin, ymin, xmax, ymax = bb_obj.bounds()
|
# fcobj.mirror(axis, [px, py])
|
||||||
px = 0.5 * (xmin + xmax)
|
# self.app.object_changed.emit(fcobj)
|
||||||
py = 0.5 * (ymin + ymax)
|
# fcobj.plot()
|
||||||
|
|
||||||
fcobj.mirror(axis, [px, py])
|
|
||||||
self.app.object_changed.emit(fcobj)
|
|
||||||
fcobj.plot()
|
|
||||||
self.app.inform.emit('[success] Gerber %s %s...' % (str(fcobj.options['name']), _("was mirrored")))
|
self.app.inform.emit('[success] Gerber %s %s...' % (str(fcobj.options['name']), _("was mirrored")))
|
||||||
|
|
||||||
def on_hole_size_toggle(self, val):
|
def on_hole_size_toggle(self, val):
|
||||||
if val == "fixed":
|
if val == "fixed":
|
||||||
self.dia_entry.show()
|
self.dia_entry.setDisabled(False)
|
||||||
self.dia_label.show()
|
self.dia_label.setDisabled(False)
|
||||||
|
|
||||||
self.ring_label.hide()
|
self.ring_label.setDisabled(True)
|
||||||
self.ring_entry.hide()
|
self.ring_entry.setDisabled(True)
|
||||||
else:
|
else:
|
||||||
self.dia_entry.hide()
|
self.dia_entry.setDisabled(True)
|
||||||
self.dia_label.hide()
|
self.dia_label.setDisabled(True)
|
||||||
|
|
||||||
self.ring_label.show()
|
self.ring_label.setDisabled(False)
|
||||||
self.ring_entry.show()
|
self.ring_entry.setDisabled(False)
|
||||||
|
|
||||||
def reset_fields(self):
|
def reset_fields(self):
|
||||||
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
self.gerber_object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
||||||
|
|
Loading…
Reference in New Issue