- Excellon UI: made sure that when the Multicolor checkbox is unchecked, the color is updated in the Color column of the tools table

This commit is contained in:
Marius Stanciu
2020-07-21 07:20:14 +03:00
committed by Marius
parent 617b483267
commit 687efd1fc0
3 changed files with 31 additions and 13 deletions

View File

@@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta
- Excellon UI in Legacy Mode (2D): fixed the Solid checkbox functionality - Excellon UI in Legacy Mode (2D): fixed the Solid checkbox functionality
- Excellon UI: fixed plot checkbox performing an extra plot function which was not required - Excellon UI: fixed plot checkbox performing an extra plot function which was not required
- Excellon UI: added a column which will color each row/tool of that column in the color used when checking Multicolor checkbox - Excellon UI: added a column which will color each row/tool of that column in the color used when checking Multicolor checkbox
- Excellon UI: made sure that when the Multicolor checkbox is unchecked, the color is updated in the Color column of the tools table
20.07.2020 20.07.2020

View File

@@ -584,7 +584,7 @@ class ExcellonObjectUI(ObjectUI):
self.tools_table.setColumnCount(6) self.tools_table.setColumnCount(6)
self.tools_table.setHorizontalHeaderLabels(['#', _('Diameter'), _('Drills'), _('Slots'), self.tools_table.setHorizontalHeaderLabels(['#', _('Diameter'), _('Drills'), _('Slots'),
" ", 'P']) "C", 'P'])
self.tools_table.setSortingEnabled(False) self.tools_table.setSortingEnabled(False)
self.tools_table.horizontalHeaderItem(0).setToolTip( self.tools_table.horizontalHeaderItem(0).setToolTip(
@@ -601,6 +601,8 @@ class ExcellonObjectUI(ObjectUI):
self.tools_table.horizontalHeaderItem(3).setToolTip( self.tools_table.horizontalHeaderItem(3).setToolTip(
_("The number of Slot holes. Holes that are created by\n" _("The number of Slot holes. Holes that are created by\n"
"milling them with an endmill bit.")) "milling them with an endmill bit."))
self.tools_table.horizontalHeaderItem(4).setToolTip(
_("Show the color of the drill holes when using multi-color."))
self.tools_table.horizontalHeaderItem(5).setToolTip( self.tools_table.horizontalHeaderItem(5).setToolTip(
_("Toggle display of the drills for the current tool.\n" _("Toggle display of the drills for the current tool.\n"
"This does not select the tools for G-code generation.")) "This does not select the tools for G-code generation."))

View File

@@ -284,13 +284,18 @@ class ExcellonObject(FlatCAMObj, Excellon):
empty_plot_item.setFlags(QtCore.Qt.NoItemFlags) empty_plot_item.setFlags(QtCore.Qt.NoItemFlags)
self.ui.tools_table.setItem(self.tool_row, 4, empty_plot_item) self.ui.tools_table.setItem(self.tool_row, 4, empty_plot_item)
if 'multicolor' in self.tools[tool_no]: if 'multicolor' in self.tools[tool_no] and self.tools[tool_no]['multicolor'] is not None:
red = self.tools[tool_no]['multicolor'][0] * 255 red = self.tools[tool_no]['multicolor'][0] * 255
green = self.tools[tool_no]['multicolor'][1] * 255 green = self.tools[tool_no]['multicolor'][1] * 255
blue = self.tools[tool_no]['multicolor'][2] * 255 blue = self.tools[tool_no]['multicolor'][2] * 255
alpha = self.tools[tool_no]['multicolor'][3] * 255 alpha = self.tools[tool_no]['multicolor'][3] * 255
h_color = QtGui.QColor(red, green, blue, alpha) h_color = QtGui.QColor(red, green, blue, alpha)
self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color) self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color)
else:
h1 = self.app.defaults["excellon_plot_fill"][1:7]
h2 = self.app.defaults["excellon_plot_fill"][7:9]
h_color = QtGui.QColor('#' + h2 + h1)
self.ui.tools_table.item(self.tool_row, 4).setBackground(h_color)
# Plot Item # Plot Item
plot_item = FCCheckBox() plot_item = FCCheckBox()
@@ -303,13 +308,15 @@ class ExcellonObject(FlatCAMObj, Excellon):
# add a last row with the Total number of drills # add a last row with the Total number of drills
empty_1 = QtWidgets.QTableWidgetItem('') empty_1 = QtWidgets.QTableWidgetItem('')
empty_1.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_1.setFlags(QtCore.Qt.NoItemFlags)
empty_1_1 = QtWidgets.QTableWidgetItem('') empty_1_1 = QtWidgets.QTableWidgetItem('')
empty_1_1.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_1_1.setFlags(QtCore.Qt.NoItemFlags)
empty_1_2 = QtWidgets.QTableWidgetItem('') empty_1_2 = QtWidgets.QTableWidgetItem('')
empty_1_2.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_1_2.setFlags(QtCore.Qt.NoItemFlags)
empty_1_3 = QtWidgets.QTableWidgetItem('') empty_1_3 = QtWidgets.QTableWidgetItem('')
empty_1_3.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_1_3.setFlags(QtCore.Qt.NoItemFlags)
empty_1_4 = QtWidgets.QTableWidgetItem('')
empty_1_4.setFlags(QtCore.Qt.NoItemFlags)
label_tot_drill_count = QtWidgets.QTableWidgetItem(_('Total Drills')) label_tot_drill_count = QtWidgets.QTableWidgetItem(_('Total Drills'))
tot_drill_count = QtWidgets.QTableWidgetItem('%d' % self.tot_drill_cnt) tot_drill_count = QtWidgets.QTableWidgetItem('%d' % self.tot_drill_cnt)
@@ -320,6 +327,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.ui.tools_table.setItem(self.tool_row, 1, label_tot_drill_count) self.ui.tools_table.setItem(self.tool_row, 1, label_tot_drill_count)
self.ui.tools_table.setItem(self.tool_row, 2, tot_drill_count) # Total number of drills self.ui.tools_table.setItem(self.tool_row, 2, tot_drill_count) # Total number of drills
self.ui.tools_table.setItem(self.tool_row, 3, empty_1_1) self.ui.tools_table.setItem(self.tool_row, 3, empty_1_1)
self.ui.tools_table.setItem(self.tool_row, 4, empty_1_2)
self.ui.tools_table.setItem(self.tool_row, 5, empty_1_3) self.ui.tools_table.setItem(self.tool_row, 5, empty_1_3)
font = QtGui.QFont() font = QtGui.QFont()
@@ -334,13 +342,15 @@ class ExcellonObject(FlatCAMObj, Excellon):
# add a last row with the Total number of slots # add a last row with the Total number of slots
empty_2 = QtWidgets.QTableWidgetItem('') empty_2 = QtWidgets.QTableWidgetItem('')
empty_2.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_2.setFlags(QtCore.Qt.NoItemFlags)
empty_2_1 = QtWidgets.QTableWidgetItem('') empty_2_1 = QtWidgets.QTableWidgetItem('')
empty_2_1.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_2_1.setFlags(QtCore.Qt.NoItemFlags)
empty_2_2 = QtWidgets.QTableWidgetItem('') empty_2_2 = QtWidgets.QTableWidgetItem('')
empty_2_2.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_2_2.setFlags(QtCore.Qt.NoItemFlags)
empty_2_3 = QtWidgets.QTableWidgetItem('') empty_2_3 = QtWidgets.QTableWidgetItem('')
empty_2_3.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) empty_2_3.setFlags(QtCore.Qt.NoItemFlags)
empty_2_4 = QtWidgets.QTableWidgetItem('')
empty_2_4.setFlags(QtCore.Qt.NoItemFlags)
label_tot_slot_count = QtWidgets.QTableWidgetItem(_('Total Slots')) label_tot_slot_count = QtWidgets.QTableWidgetItem(_('Total Slots'))
tot_slot_count = QtWidgets.QTableWidgetItem('%d' % self.tot_slot_cnt) tot_slot_count = QtWidgets.QTableWidgetItem('%d' % self.tot_slot_cnt)
@@ -351,7 +361,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.ui.tools_table.setItem(self.tool_row, 1, label_tot_slot_count) self.ui.tools_table.setItem(self.tool_row, 1, label_tot_slot_count)
self.ui.tools_table.setItem(self.tool_row, 2, empty_2_1) self.ui.tools_table.setItem(self.tool_row, 2, empty_2_1)
self.ui.tools_table.setItem(self.tool_row, 3, tot_slot_count) # Total number of slots self.ui.tools_table.setItem(self.tool_row, 3, tot_slot_count) # Total number of slots
self.ui.tools_table.setItem(self.tool_row, 5, empty_2_3) self.ui.tools_table.setItem(self.tool_row, 4, empty_2_3)
self.ui.tools_table.setItem(self.tool_row, 5, empty_2_4)
for kl in [1, 2, 3]: for kl in [1, 2, 3]:
self.ui.tools_table.item(self.tool_row, kl).setFont(font) self.ui.tools_table.item(self.tool_row, kl).setFont(font)
@@ -382,7 +393,7 @@ class ExcellonObject(FlatCAMObj, Excellon):
horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents) horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents) horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents)
horizontal_header.setSectionResizeMode(4, QtWidgets.QHeaderView.Fixed) horizontal_header.setSectionResizeMode(4, QtWidgets.QHeaderView.Fixed)
horizontal_header.resizeSection(4, 3) horizontal_header.resizeSection(4, 17)
horizontal_header.setSectionResizeMode(5, QtWidgets.QHeaderView.Fixed) horizontal_header.setSectionResizeMode(5, QtWidgets.QHeaderView.Fixed)
horizontal_header.resizeSection(5, 17) horizontal_header.resizeSection(5, 17)
self.ui.tools_table.setColumnWidth(5, 17) self.ui.tools_table.setColumnWidth(5, 17)
@@ -1054,11 +1065,13 @@ class ExcellonObject(FlatCAMObj, Excellon):
self.read_form_item('solid') self.read_form_item('solid')
self.plot() self.plot()
def on_multicolored_cb_click(self, *args): def on_multicolored_cb_click(self, val):
if self.muted_ui: if self.muted_ui:
return return
self.read_form_item('multicolored') self.read_form_item('multicolored')
self.plot() self.plot()
if not val:
self.build_ui()
def on_autoload_db_toggled(self, state): def on_autoload_db_toggled(self, state):
self.app.defaults["excellon_autoload_db"] = True if state else False self.app.defaults["excellon_autoload_db"] = True if state else False
@@ -1142,6 +1155,8 @@ class ExcellonObject(FlatCAMObj, Excellon):
geo_color = random_color() geo_color = random_color()
if multicolored: if multicolored:
self.tools[tool]['multicolor'] = geo_color self.tools[tool]['multicolor'] = geo_color
else:
self.tools[tool]['multicolor'] = None
# tool is a dict also # tool is a dict also
for geo in self.tools[tool]["solid_geometry"]: for geo in self.tools[tool]["solid_geometry"]: