- Milling Tool - fixed a crash when clicking the Generate CNCJob object button with no object selected

- Milling, Isolation, NCC, Paint Tools UI update
This commit is contained in:
Marius Stanciu
2020-12-05 00:32:12 +02:00
committed by Marius
parent d200e3fd1e
commit a742ad8827
5 changed files with 88 additions and 60 deletions

View File

@@ -3243,7 +3243,13 @@ class IsoUI:
self.grid3.addLayout(new_tool_lay, 2, 1)
bhlay = QtWidgets.QHBoxLayout()
# #############################################################################################################
# ################################ Button Grid ###########################################################
# #############################################################################################################
button_grid = QtWidgets.QGridLayout()
button_grid.setColumnStretch(0, 1)
button_grid.setColumnStretch(1, 0)
self.grid3.addLayout(button_grid, 7, 0, 1, 2)
self.search_and_add_btn = FCButton(_('Search and Add'))
self.search_and_add_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
@@ -3254,7 +3260,8 @@ class IsoUI:
"in the Tools Database. If nothing is found\n"
"in the Tools DB then a default tool is added.")
)
bhlay.addWidget(self.search_and_add_btn)
button_grid.addWidget(self.search_and_add_btn, 0, 0)
self.addtool_from_db_btn = FCButton(_('Pick from DB'))
self.addtool_from_db_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/search_db32.png'))
@@ -3264,24 +3271,19 @@ class IsoUI:
"Tools database administration in in:\n"
"Menu: Options -> Tools Database")
)
bhlay.addWidget(self.addtool_from_db_btn)
self.grid3.addLayout(bhlay, 7, 0, 1, 2)
button_grid.addWidget(self.addtool_from_db_btn, 1, 0)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.grid3.addWidget(separator_line, 8, 0, 1, 2)
self.deltool_btn = FCButton(_('Delete'))
self.deltool_btn = FCButton()
self.deltool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/trash16.png'))
self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n"
"by first selecting a row in the Tool Table.")
)
self.grid3.addWidget(self.deltool_btn, 9, 0, 1, 2)
self.deltool_btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
# self.grid3.addWidget(FCLabel(''), 10, 0, 1, 2)
button_grid.addWidget(self.deltool_btn, 0, 1, 2, 1)
# #############################################################################################################
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)

View File

@@ -2398,10 +2398,22 @@ class ToolMilling(AppTool, Excellon):
def on_generate_cncjob_click(self):
self.app.delete_selection_shape()
self.obj_name = self.ui.object_combo.currentText()
# Get source object.
try:
self.target_obj = self.app.collection.get_by_name(self.obj_name)
except Exception as e:
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), str(self.obj_name)))
return "Could not retrieve object: %s with error: %s" % (self.obj_name, str(e))
if self.target_obj is None:
self.app.inform.emit('[ERROR_NOTCL] %s.' % _("Object not found"))
return
if self.target_obj.kind == 'geometry':
self.on_generatecnc_from_geo()
if self.target_obj.kind == 'excellon':
elif self.target_obj.kind == 'excellon':
pass
def on_generatecnc_from_geo(self):
@@ -3519,15 +3531,26 @@ class MillingUI:
grid_tool.addWidget(self.addtool_entry_lbl, 3, 0)
grid_tool.addWidget(self.addtool_entry, 3, 1)
bhlay = QtWidgets.QHBoxLayout()
# #############################################################################################################
# ################################ Button Grid ###########################################################
# #############################################################################################################
button_grid = QtWidgets.QGridLayout()
button_grid.setColumnStretch(0, 1)
button_grid.setColumnStretch(1, 0)
grid_tool.addLayout(button_grid, 5, 0, 1, 2)
self.search_and_add_btn = FCButton(_('Search and Add'))
self.search_and_add_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.search_and_add_btn.setToolTip(
_("Add a new tool to the Tool Table\n"
"with the diameter specified above.")
"with the diameter specified above.\n"
"This is done by a background search\n"
"in the Tools Database. If nothing is found\n"
"in the Tools DB then a default tool is added.")
)
button_grid.addWidget(self.search_and_add_btn, 0, 0)
self.addtool_from_db_btn = FCButton(_('Pick from DB'))
self.addtool_from_db_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/search_db32.png'))
self.addtool_from_db_btn.setToolTip(
@@ -3537,24 +3560,18 @@ class MillingUI:
"Menu: Options -> Tools Database")
)
bhlay.addWidget(self.search_and_add_btn)
bhlay.addWidget(self.addtool_from_db_btn)
button_grid.addWidget(self.addtool_from_db_btn, 1, 0)
grid_tool.addLayout(bhlay, 5, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid_tool.addWidget(separator_line, 9, 0, 1, 2)
self.deltool_btn = FCButton(_('Delete'))
self.deltool_btn = FCButton()
self.deltool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/trash16.png'))
self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n"
"by first selecting a row in the Tool Table.")
)
self.deltool_btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
grid_tool.addWidget(self.deltool_btn, 12, 0, 1, 2)
button_grid.addWidget(self.deltool_btn, 0, 1, 2, 1)
# #############################################################################################################
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)

View File

@@ -242,7 +242,7 @@ class NonCopperClear(AppTool, Gerber):
self.ui.apply_param_to_all.clicked.connect(self.on_apply_param_to_all_clicked)
# add a new tool Signals
self.ui.add_newtool_button.clicked.connect(lambda: self.on_tool_add())
self.ui.search_and_add_btn.clicked.connect(lambda: self.on_tool_add())
self.ui.addtool_from_db_btn.clicked.connect(self.on_ncc_tool_add_from_db_clicked)
self.app.proj_selection_changed.connect(self.on_object_selection_changed)
@@ -4140,18 +4140,25 @@ class NccUI:
self.grid3.addLayout(new_tool_lay, 2, 1)
hlay = QtWidgets.QHBoxLayout()
# #############################################################################################################
# ################################ Button Grid ###########################################################
# #############################################################################################################
button_grid = QtWidgets.QGridLayout()
button_grid.setColumnStretch(0, 1)
button_grid.setColumnStretch(1, 0)
self.grid3.addLayout(button_grid, 7, 0, 1, 2)
self.add_newtool_button = FCButton(_('Search and Add'))
self.add_newtool_button.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.add_newtool_button.setToolTip(
self.search_and_add_btn = FCButton(_('Search and Add'))
self.search_and_add_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.search_and_add_btn.setToolTip(
_("Add a new tool to the Tool Table\n"
"with the diameter specified above.\n"
"This is done by a background search\n"
"in the Tools Database. If nothing is found\n"
"in the Tools DB then a default tool is added.")
)
hlay.addWidget(self.add_newtool_button)
button_grid.addWidget(self.search_and_add_btn, 0, 0)
self.addtool_from_db_btn = FCButton(_('Pick from DB'))
self.addtool_from_db_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/search_db32.png'))
@@ -4161,24 +4168,19 @@ class NccUI:
"Tools database administration in in:\n"
"Menu: Options -> Tools Database")
)
hlay.addWidget(self.addtool_from_db_btn)
self.grid3.addLayout(hlay, 7, 0, 1, 2)
button_grid.addWidget(self.addtool_from_db_btn, 1, 0)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.grid3.addWidget(separator_line, 8, 0, 1, 2)
self.deltool_btn = FCButton(_('Delete'))
self.deltool_btn = FCButton()
self.deltool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/trash16.png'))
self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n"
"by first selecting a row in the Tool Table.")
)
self.grid3.addWidget(self.deltool_btn, 9, 0, 1, 2)
self.deltool_btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
# self.grid3.addWidget(FCLabel(''), 10, 0, 1, 2)
button_grid.addWidget(self.deltool_btn, 0, 1, 2, 1)
# #############################################################################################################
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)

View File

@@ -180,7 +180,7 @@ class ToolPaint(AppTool, Gerber):
self.ui.apply_param_to_all.clicked.connect(self.on_apply_param_to_all_clicked)
# adding tools
self.ui.add_newtool_button.clicked.connect(lambda: self.on_tool_add())
self.ui.search_and_add_btn.clicked.connect(lambda: self.on_tool_add())
self.ui.addtool_from_db_btn.clicked.connect(self.on_paint_tool_add_from_db_clicked)
self.app.proj_selection_changed.connect(self.on_object_selection_changed)
@@ -2798,6 +2798,7 @@ class PaintUI:
self.tools_frame = QtWidgets.QFrame()
self.tools_frame.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.tools_frame)
self.tools_box = QtWidgets.QVBoxLayout()
self.tools_box.setContentsMargins(0, 0, 0, 0)
self.tools_frame.setLayout(self.tools_box)
@@ -2943,18 +2944,25 @@ class PaintUI:
self.grid3.addWidget(self.new_tooldia_lbl, 2, 0)
self.grid3.addWidget(self.new_tooldia_entry, 2, 1)
hlay = QtWidgets.QHBoxLayout()
# #############################################################################################################
# ################################ Button Grid ###########################################################
# #############################################################################################################
button_grid = QtWidgets.QGridLayout()
button_grid.setColumnStretch(0, 1)
button_grid.setColumnStretch(1, 0)
self.grid3.addLayout(button_grid, 7, 0, 1, 2)
self.add_newtool_button = FCButton(_('Search and Add'))
self.add_newtool_button.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.add_newtool_button.setToolTip(
self.search_and_add_btn = FCButton(_('Search and Add'))
self.search_and_add_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/plus16.png'))
self.search_and_add_btn.setToolTip(
_("Add a new tool to the Tool Table\n"
"with the diameter specified above.\n"
"This is done by a background search\n"
"in the Tools Database. If nothing is found\n"
"in the Tools DB then a default tool is added.")
)
hlay.addWidget(self.add_newtool_button)
button_grid.addWidget(self.search_and_add_btn, 0, 0)
self.addtool_from_db_btn = FCButton(_('Pick from DB'))
self.addtool_from_db_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/search_db32.png'))
@@ -2964,22 +2972,19 @@ class PaintUI:
"Tools database administration in in:\n"
"Menu: Options -> Tools Database")
)
hlay.addWidget(self.addtool_from_db_btn)
self.grid3.addLayout(hlay, 7, 0, 1, 2)
button_grid.addWidget(self.addtool_from_db_btn, 1, 0)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.grid3.addWidget(separator_line, 8, 0, 1, 2)
self.deltool_btn = FCButton(_('Delete'))
self.deltool_btn = FCButton()
self.deltool_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/trash16.png'))
self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n"
"by first selecting a row in the Tool Table.")
)
self.grid3.addWidget(self.deltool_btn, 9, 0, 1, 2)
self.deltool_btn.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
button_grid.addWidget(self.deltool_btn, 0, 1, 2, 1)
# #############################################################################################################
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
@@ -3205,7 +3210,7 @@ class PaintUI:
""")
self.tools_box.addWidget(self.generate_paint_button)
self.tools_box.addStretch()
self.tools_box.addStretch(1)
# ## Reset Tool
self.reset_button = FCButton(_("Reset Tool"))
@@ -3270,7 +3275,7 @@ class PaintUI:
self.area_shape_radio.show()
else: # All = index 0 in combobox
self.new_tooldia_entry.setDisabled(False)
self.add_newtool_button.setDisabled(False)
self.search_and_add_btn.setDisabled(False)
self.deltool_btn.setDisabled(False)
self.tools_table.setContextMenuPolicy(Qt.ActionsContextMenu)