- in Geometry UI and in Drilling Tool added ability to edit existing Exclusion Areas and change the Strategy and OverZ parameters for each of them
- in Geometry UI and in Drilling Tool added a Delete menu entry in the Exclusion Area Table context menu
This commit is contained in:
@@ -10,7 +10,7 @@ from PyQt5 import QtWidgets, QtCore, QtGui
|
||||
from appTool import AppTool
|
||||
from appGUI.GUIElements import FCCheckBox, FCDoubleSpinner, RadioSet, FCTable, FCButton, \
|
||||
FCComboBox, OptionalInputSection, FCSpinner, NumericalEvalEntry, OptionalHideInputSection, FCLabel, \
|
||||
NumericalEvalTupleEntry
|
||||
NumericalEvalTupleEntry, FCComboBox2
|
||||
from appParsers.ParseExcellon import Excellon
|
||||
|
||||
from copy import deepcopy
|
||||
@@ -45,6 +45,7 @@ else:
|
||||
|
||||
|
||||
class ToolDrilling(AppTool, Excellon):
|
||||
builduiSig = QtCore.pyqtSignal()
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
@@ -204,6 +205,14 @@ class ToolDrilling(AppTool, Excellon):
|
||||
"e_area_shape": "tools_drill_area_shape",
|
||||
}
|
||||
|
||||
# #############################################################################################################
|
||||
# ############################## EXCLUSION TABLE context menu #################################################
|
||||
# #############################################################################################################
|
||||
self.ui.exclusion_table.setupContextMenu()
|
||||
self.ui.exclusion_table.addContextMenu(
|
||||
_("Delete"), self.on_delete_sel_areas, icon=QtGui.QIcon(self.app.resource_location + "/trash16.png")
|
||||
)
|
||||
|
||||
self.poly_drawn = False
|
||||
self.connect_signals_at_init()
|
||||
|
||||
@@ -248,6 +257,7 @@ class ToolDrilling(AppTool, Excellon):
|
||||
# #############################################################################
|
||||
# ############################ SIGNALS ########################################
|
||||
# #############################################################################
|
||||
self.builduiSig.connect(self.build_tool_ui)
|
||||
|
||||
self.ui.search_load_db_btn.clicked.connect(self.on_tool_db_load)
|
||||
|
||||
@@ -650,7 +660,11 @@ class ToolDrilling(AppTool, Excellon):
|
||||
# all the tools are selected by default
|
||||
self.ui.tools_table.selectAll()
|
||||
|
||||
# Build Exclusion Areas section
|
||||
# #############################################################################################################
|
||||
# ################################### Build Exclusion Areas section ###########################################
|
||||
# #############################################################################################################
|
||||
self.ui_disconnect()
|
||||
|
||||
e_len = len(self.app.exc_areas.exclusion_areas_storage)
|
||||
self.ui.exclusion_table.setRowCount(e_len)
|
||||
|
||||
@@ -669,14 +683,28 @@ class ToolDrilling(AppTool, Excellon):
|
||||
object_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.ui.exclusion_table.setItem(area, 1, object_item) # Origin Object
|
||||
|
||||
strategy_item = QtWidgets.QTableWidgetItem('%s' % area_dict["strategy"])
|
||||
strategy_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.ui.exclusion_table.setItem(area, 2, strategy_item) # Strategy
|
||||
# strategy_item = QtWidgets.QTableWidgetItem('%s' % area_dict["strategy"])
|
||||
# strategy_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
strategy_item = FCComboBox2(policy=False)
|
||||
strategy_item.addItems([_("Around"), _("Over")])
|
||||
idx = 0 if area_dict["strategy"] == 'around' else 1
|
||||
# protection against having this translated or loading a project with translated values
|
||||
if idx == -1:
|
||||
strategy_item.setCurrentIndex(0)
|
||||
else:
|
||||
strategy_item.setCurrentIndex(idx)
|
||||
self.ui.exclusion_table.setCellWidget(area, 2, strategy_item) # Strategy
|
||||
|
||||
overz_item = QtWidgets.QTableWidgetItem('%s' % area_dict["overz"])
|
||||
overz_item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
self.ui.exclusion_table.setItem(area, 3, overz_item) # Over Z
|
||||
|
||||
# make the Overz column editable
|
||||
for row in range(e_len):
|
||||
self.ui.exclusion_table.item(row, 3).setFlags(QtCore.Qt.ItemIsSelectable |
|
||||
QtCore.Qt.ItemIsEditable |
|
||||
QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
self.ui.exclusion_table.resizeColumnsToContents()
|
||||
self.ui.exclusion_table.resizeRowsToContents()
|
||||
|
||||
@@ -810,6 +838,12 @@ class ToolDrilling(AppTool, Excellon):
|
||||
|
||||
self.ui.order_radio.activated_custom[str].connect(self.on_order_changed)
|
||||
|
||||
# Exclusion Table widgets connect
|
||||
for row in range(self.ui.exclusion_table.rowCount()):
|
||||
self.ui.exclusion_table.cellWidget(row, 2).currentIndexChanged.connect(self.on_exclusion_table_strategy)
|
||||
|
||||
self.ui.exclusion_table.itemChanged.connect(self.on_exclusion_table_overz)
|
||||
|
||||
def ui_disconnect(self):
|
||||
# rows selected
|
||||
try:
|
||||
@@ -891,6 +925,18 @@ class ToolDrilling(AppTool, Excellon):
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
|
||||
# Exclusion Table widgets disconnect
|
||||
for row in range(self.ui.exclusion_table.rowCount()):
|
||||
try:
|
||||
self.ui.exclusion_table.cellWidget(row, 2).currentIndexChanged.disconnect()
|
||||
except (TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
try:
|
||||
self.ui.exclusion_table.itemChanged.disconnect()
|
||||
except (TypeError, AttributeError):
|
||||
pass
|
||||
|
||||
def on_tool_db_load(self):
|
||||
|
||||
filename = self.app.tools_database_path()
|
||||
@@ -1472,6 +1518,49 @@ class ToolDrilling(AppTool, Excellon):
|
||||
self.ui.exclusion_table.selectAll()
|
||||
self.draw_sel_shape()
|
||||
|
||||
def on_exclusion_table_overz(self, current_item):
|
||||
self.ui_disconnect()
|
||||
|
||||
current_row = current_item.row()
|
||||
try:
|
||||
d = float(self.ui.exclusion_table.item(current_row, 3).text())
|
||||
except ValueError:
|
||||
# try to convert comma to decimal point. if it's still not working error message and return
|
||||
try:
|
||||
d = float(self.ui.exclusion_table.item(current_row, 3).text().replace(',', '.'))
|
||||
except ValueError:
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
|
||||
return
|
||||
except AttributeError:
|
||||
self.ui_connect()
|
||||
return
|
||||
|
||||
overz = self.app.dec_format(d, self.decimals)
|
||||
idx = int(self.ui.exclusion_table.item(current_row, 0).text())
|
||||
|
||||
for area_dict in self.app.exc_areas.exclusion_areas_storage:
|
||||
if area_dict['idx'] == idx:
|
||||
area_dict['overz'] = overz
|
||||
|
||||
self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table."))
|
||||
self.ui_connect()
|
||||
self.builduiSig.emit()
|
||||
|
||||
def on_exclusion_table_strategy(self):
|
||||
cw = self.sender()
|
||||
cw_index = self.ui.exclusion_table.indexAt(cw.pos())
|
||||
cw_row = cw_index.row()
|
||||
idx = int(self.ui.exclusion_table.item(cw_row, 0).text())
|
||||
|
||||
for area_dict in self.app.exc_areas.exclusion_areas_storage:
|
||||
if area_dict['idx'] == idx:
|
||||
strategy = self.ui.exclusion_table.cellWidget(cw_row, 2).currentIndex()
|
||||
area_dict['strategy'] = "around" if strategy == 0 else 'overz'
|
||||
|
||||
self.app.inform.emit('[success] %s' % _("Value edited in Exclusion Table."))
|
||||
self.ui_connect()
|
||||
self.builduiSig.emit()
|
||||
|
||||
@staticmethod
|
||||
def process_slot_as_drills(slot, overlap, add_last_pt=False):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user