- in NCC Plugin updated the GUI

This commit is contained in:
Marius Stanciu
2021-09-05 22:50:33 +03:00
committed by Marius Stanciu
parent b45eeff5ed
commit d42c33a02d
3 changed files with 131 additions and 114 deletions

View File

@@ -10,7 +10,7 @@ from PyQt6 import QtWidgets, QtCore, QtGui
from appTool import AppTool
from appGUI.GUIElements import FCCheckBox, FCDoubleSpinner, RadioSet, FCTable, FCButton,\
FCComboBox, OptionalInputSection, FCLabel, FCInputDialogSpinnerButton, FCComboBox2, \
VerticalScrollArea, FCGridLayout
VerticalScrollArea, FCGridLayout, FCFrame
from appParsers.ParseGerber import Gerber
from camlib import grace
@@ -473,14 +473,7 @@ class NonCopperClear(AppTool, Gerber):
""")
# Add Tool section
self.ui.tool_sel_label.hide()
self.ui.new_tooldia_lbl.hide()
self.ui.new_tooldia_entry.hide()
self.ui.search_and_add_btn.hide()
self.ui.addtool_from_db_btn.hide()
self.ui.find_optimal_button.hide()
self.ui.deltool_btn.hide()
self.ui.add_tool_separator_line.hide()
self.ui.add_tool_frame.hide()
# Tool parameters section
if self.ncc_tools:
@@ -504,7 +497,6 @@ class NonCopperClear(AppTool, Gerber):
self.ui.ncc_rest_cb.hide()
# All param section
self.ui.all_param_separator_line2.hide()
self.ui.apply_param_to_all.hide()
# Context Menu section
@@ -519,14 +511,7 @@ class NonCopperClear(AppTool, Gerber):
""")
# Add Tool section
self.ui.tool_sel_label.show()
self.ui.new_tooldia_lbl.show()
self.ui.new_tooldia_entry.show()
self.ui.search_and_add_btn.show()
self.ui.addtool_from_db_btn.show()
self.ui.find_optimal_button.show()
self.ui.deltool_btn.show()
self.ui.add_tool_separator_line.show()
self.ui.add_tool_frame.show()
# Tool parameters section
if self.ncc_tools:
@@ -551,7 +536,6 @@ class NonCopperClear(AppTool, Gerber):
self.ui.ncc_rest_cb.show()
# All param section
self.ui.all_param_separator_line2.show()
self.ui.apply_param_to_all.show()
# Context Menu section
@@ -4144,12 +4128,27 @@ class NccUI:
self.level.setCheckable(True)
self.title_box.addWidget(self.level)
# ## Grid Layout
# #############################################################################################################
# Source Object for Paint Frame
# #############################################################################################################
self.obj_combo_label = FCLabel('<span style="color:darkorange;"><b>%s</b></span>' % _("Source Object"))
self.obj_combo_label.setToolTip(
_("Source object for milling operation.")
)
self.tools_box.addWidget(self.obj_combo_label)
obj_frame = FCFrame()
self.tools_box.addWidget(obj_frame)
# Grid Layout
grid0 = FCGridLayout(v_spacing=5, h_spacing=3)
grid0.setColumnStretch(0, 0)
grid0.setColumnStretch(1, 1)
self.tools_box.addLayout(grid0)
obj_frame.setLayout(grid0)
# #############################################################################################################
# Type of object to be painted
# #############################################################################################################
self.type_obj_combo_label = FCLabel('%s:' % _("Type"))
self.type_obj_combo_label.setToolTip(
_("Specify the type of object to be cleared of excess copper.\n"
@@ -4165,35 +4164,44 @@ class NccUI:
grid0.addWidget(self.type_obj_combo_label, 0, 0)
grid0.addWidget(self.type_obj_radio, 0, 1)
# ################################################
# ##### The object to be copper cleaned ##########
# ################################################
# #############################################################################################################
# The object to be copper cleared
# #############################################################################################################
self.object_combo = FCComboBox()
self.object_combo.setModel(self.app.collection)
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
# self.object_combo.setCurrentIndex(1)
self.object_combo.is_last = True
# self.object_label = FCLabel('%s:' % _("Object"))
# self.object_label.setToolTip(_("Object to be cleared of excess copper."))
grid0.addWidget(self.object_combo, 2, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid0.addWidget(separator_line, 4, 0, 1, 2)
# separator_line = QtWidgets.QFrame()
# separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
# separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
# grid0.addWidget(separator_line, 4, 0, 1, 2)
# #############################################################################################################
# Tool Table Frame
# #############################################################################################################
# ### Tools ## ##
self.tools_table_label = FCLabel('<b>%s</b>' % _('Tools Table'))
self.tools_table_label = FCLabel('<span style="color:green;"><b>%s</b></span>' % _('Tools Table'))
self.tools_table_label.setToolTip(
_("Tools pool from which the algorithm\n"
"will pick the ones used for copper clearing.")
)
grid0.addWidget(self.tools_table_label, 6, 0, 1, 2)
self.tools_box.addWidget(self.tools_table_label)
tt_frame = FCFrame()
self.tools_box.addWidget(tt_frame)
# Grid Layout
grid1 = FCGridLayout(v_spacing=5, h_spacing=3)
grid1.setColumnStretch(0, 0)
grid1.setColumnStretch(1, 1)
tt_frame.setLayout(grid1)
self.tools_table = FCTable(drag_drop=True)
grid0.addWidget(self.tools_table, 8, 0, 1, 2)
# self.tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
grid1.addWidget(self.tools_table, 2, 0, 1, 2)
self.tools_table.setColumnCount(4)
# 3rd column is reserved (and hidden) for the tool ID
@@ -4221,17 +4229,6 @@ class NccUI:
"B = ball tip milling tool\n"
"V = v-shape milling tool"))
# self.tools_table.horizontalHeaderItem(4).setToolTip(
# _("The 'Operation' can be:\n"
# "- Isolation -> will ensure that the non-copper clearing is always complete.\n"
# "If it's not successful then the non-copper clearing will fail, too.\n"
# "- Clear -> the regular non-copper clearing."))
grid1 = FCGridLayout(v_spacing=5, h_spacing=3)
grid1.setColumnStretch(0, 0)
grid1.setColumnStretch(1, 1)
self.tools_box.addLayout(grid1)
# Tool order
self.ncc_order_label = FCLabel('%s:' % _('Tool order'))
self.ncc_order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n"
@@ -4251,32 +4248,39 @@ class NccUI:
"WARNING: using rest machining will automatically set the order\n"
"in reverse and disable this control."))
grid1.addWidget(self.ncc_order_label, 1, 0)
grid1.addWidget(self.ncc_order_radio, 1, 1)
grid1.addWidget(self.ncc_order_label, 4, 0)
grid1.addWidget(self.ncc_order_radio, 4, 1)
# ##############################################################################
# ###################### ADD A NEW TOOL ########################################
# ##############################################################################
self.add_tool_frame = QtWidgets.QFrame()
self.add_tool_frame.setContentsMargins(0, 0, 0, 0)
grid1.addWidget(self.add_tool_frame, 6, 0, 1, 2)
new_tool_grid = FCGridLayout(v_spacing=5, h_spacing=3)
new_tool_grid.setColumnStretch(0, 0)
new_tool_grid.setColumnStretch(1, 1)
new_tool_grid.setContentsMargins(0, 0, 0, 0)
self.add_tool_frame.setLayout(new_tool_grid)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
grid1.addWidget(separator_line, 2, 0, 1, 2)
new_tool_grid.addWidget(separator_line, 0, 0, 1, 2)
# #############################################################
# ############### Tool selection ##############################
# #############################################################
self.grid3 = FCGridLayout(v_spacing=5, h_spacing=3)
self.tools_box.addLayout(self.grid3)
self.grid3.setColumnStretch(0, 0)
self.grid3.setColumnStretch(1, 1)
self.tool_sel_label = FCLabel('<b>%s</b>' % _('Add from DB'))
self.grid3.addWidget(self.tool_sel_label, 0, 0, 1, 2)
new_tool_grid.addWidget(self.tool_sel_label, 2, 0, 1, 2)
# ### Tool Diameter ####
self.new_tooldia_lbl = FCLabel('%s:' % _('Tool Dia'))
self.new_tooldia_lbl.setToolTip(
_("Diameter for the new tool")
)
self.grid3.addWidget(self.new_tooldia_lbl, 2, 0)
new_tool_grid.addWidget(self.new_tooldia_lbl, 4, 0)
new_tool_lay = QtWidgets.QHBoxLayout()
@@ -4298,7 +4302,7 @@ class NccUI:
)
new_tool_lay.addWidget(self.find_optimal_button)
self.grid3.addLayout(new_tool_lay, 2, 1)
new_tool_grid.addLayout(new_tool_lay, 4, 1)
# #############################################################################################################
# ################################ Button Grid ###########################################################
@@ -4306,7 +4310,7 @@ class NccUI:
button_grid = FCGridLayout(v_spacing=5, h_spacing=3)
button_grid.setColumnStretch(0, 1)
button_grid.setColumnStretch(1, 0)
self.grid3.addLayout(button_grid, 7, 0, 1, 2)
new_tool_grid.addLayout(button_grid, 6, 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'))
@@ -4340,13 +4344,10 @@ class NccUI:
self.deltool_btn.setSizePolicy(QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
button_grid.addWidget(self.deltool_btn, 0, 1, 2, 1)
# #############################################################################################################
# Parameters Frame
# #############################################################################################################
self.add_tool_separator_line = QtWidgets.QFrame()
self.add_tool_separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
self.add_tool_separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.grid3.addWidget(self.add_tool_separator_line, 11, 0, 1, 2)
self.tool_data_label = FCLabel(
"<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), int(1)))
self.tool_data_label.setToolTip(
@@ -4355,7 +4356,15 @@ class NccUI:
"Each tool store it's own set of such data."
)
)
self.grid3.addWidget(self.tool_data_label, 12, 0, 1, 2)
self.tools_box.addWidget(self.tool_data_label)
tt_frame = FCFrame()
self.tools_box.addWidget(tt_frame)
par_grid = FCGridLayout(v_spacing=5, h_spacing=3)
par_grid.setColumnStretch(0, 0)
par_grid.setColumnStretch(1, 1)
tt_frame.setLayout(par_grid)
# Operation
self.op_label = FCLabel('%s:' % _('Operation'))
@@ -4372,8 +4381,8 @@ class NccUI:
], orientation='horizontal', stretch=False)
self.op_radio.setObjectName("n_operation")
self.grid3.addWidget(self.op_label, 13, 0)
self.grid3.addWidget(self.op_radio, 13, 1)
par_grid.addWidget(self.op_label, 0, 0)
par_grid.addWidget(self.op_radio, 0, 1)
# Milling Type Radio Button
self.milling_type_label = FCLabel('%s:' % _('Milling Type'))
@@ -4395,8 +4404,8 @@ class NccUI:
self.milling_type_label.setEnabled(False)
self.milling_type_radio.setEnabled(False)
self.grid3.addWidget(self.milling_type_label, 14, 0)
self.grid3.addWidget(self.milling_type_radio, 14, 1)
par_grid.addWidget(self.milling_type_label, 2, 0)
par_grid.addWidget(self.milling_type_radio, 2, 1)
# Overlap Entry
self.nccoverlabel = FCLabel('%s:' % _('Overlap'))
@@ -4416,8 +4425,8 @@ class NccUI:
self.ncc_overlap_entry.setSingleStep(0.1)
self.ncc_overlap_entry.setObjectName("n_overlap")
self.grid3.addWidget(self.nccoverlabel, 15, 0)
self.grid3.addWidget(self.ncc_overlap_entry, 15, 1)
par_grid.addWidget(self.nccoverlabel, 4, 0)
par_grid.addWidget(self.ncc_overlap_entry, 4, 1)
# Method
self.methodlabel = FCLabel('%s:' % _('Method'))
@@ -4439,8 +4448,8 @@ class NccUI:
)
self.ncc_method_combo.setObjectName("n_method")
self.grid3.addWidget(self.methodlabel, 16, 0)
self.grid3.addWidget(self.ncc_method_combo, 16, 1)
par_grid.addWidget(self.methodlabel, 6, 0)
par_grid.addWidget(self.ncc_method_combo, 6, 1)
# Margin
self.nccmarginlabel = FCLabel('%s:' % _('Margin'))
@@ -4452,8 +4461,8 @@ class NccUI:
self.ncc_margin_entry.set_range(-10000.0000, 10000.0000)
self.ncc_margin_entry.setObjectName("n_margin")
self.grid3.addWidget(self.nccmarginlabel, 17, 0)
self.grid3.addWidget(self.ncc_margin_entry, 17, 1)
par_grid.addWidget(self.nccmarginlabel, 8, 0)
par_grid.addWidget(self.ncc_margin_entry, 8, 1)
# Connect lines
self.ncc_connect_cb = FCCheckBox('%s' % _("Connect"))
@@ -4463,7 +4472,7 @@ class NccUI:
_("Draw lines between resulting\n"
"segments to minimize tool lifts.")
)
self.grid3.addWidget(self.ncc_connect_cb, 18, 0)
par_grid.addWidget(self.ncc_connect_cb, 10, 0)
# Contour
self.ncc_contour_cb = FCCheckBox('%s' % _("Contour"))
@@ -4473,7 +4482,7 @@ class NccUI:
_("Cut around the perimeter of the polygon\n"
"to trim rough edges.")
)
self.grid3.addWidget(self.ncc_contour_cb, 18, 1)
par_grid.addWidget(self.ncc_contour_cb, 10, 1)
# ## NCC Offset choice
self.ncc_choice_offset_cb = FCCheckBox('%s' % _("Offset"))
@@ -4484,7 +4493,7 @@ class NccUI:
"The copper clearing will finish to a distance\n"
"from the copper features.")
)
self.grid3.addWidget(self.ncc_choice_offset_cb, 19, 0)
par_grid.addWidget(self.ncc_choice_offset_cb, 12, 0)
# ## NCC Offset Entry
self.ncc_offset_spinner = FCDoubleSpinner(callback=self.confirmation_message)
@@ -4499,34 +4508,38 @@ class NccUI:
else:
self.ncc_offset_spinner.setSingleStep(0.01)
self.grid3.addWidget(self.ncc_offset_spinner, 19, 1)
par_grid.addWidget(self.ncc_offset_spinner, 12, 1)
self.ois_ncc_offset = OptionalInputSection(self.ncc_choice_offset_cb, [self.ncc_offset_spinner])
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.grid3.addWidget(separator_line, 21, 0, 1, 2)
# #############################################################################################################
# Apply All Parameters Button
# #############################################################################################################
self.apply_param_to_all = FCButton(_("Apply parameters to all tools"))
self.apply_param_to_all.setIcon(QtGui.QIcon(self.app.resource_location + '/param_all32.png'))
self.apply_param_to_all.setToolTip(
_("The parameters in the current form will be applied\n"
"on all the tools from the Tool Table.")
)
self.grid3.addWidget(self.apply_param_to_all, 22, 0, 1, 2)
self.all_param_separator_line2 = QtWidgets.QFrame()
self.all_param_separator_line2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
self.all_param_separator_line2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.grid3.addWidget(self.all_param_separator_line2, 23, 0, 1, 2)
self.tools_box.addWidget(self.apply_param_to_all)
# #############################################################################################################
# General Parameters Frame
# #############################################################################################################
# General Parameters
self.gen_param_label = FCLabel('<b>%s</b>' % _("Common Parameters"))
self.gen_param_label = FCLabel('<span style="color:indigo;"><b>%s</b></span>' % _("Common Parameters"))
self.gen_param_label.setToolTip(
_("Parameters that are common for all tools.")
)
self.grid3.addWidget(self.gen_param_label, 24, 0, 1, 2)
self.tools_box.addWidget(self.gen_param_label)
gp_frame = FCFrame()
self.tools_box.addWidget(gp_frame)
gen_grid = FCGridLayout(v_spacing=5, h_spacing=3)
gen_grid.setColumnStretch(0, 0)
gen_grid.setColumnStretch(1, 1)
gp_frame.setLayout(gen_grid)
# Rest Machining
self.ncc_rest_cb = FCCheckBox('%s' % _("Rest"))
@@ -4542,7 +4555,7 @@ class NccUI:
"If not checked, use the standard algorithm.")
)
self.grid3.addWidget(self.ncc_rest_cb, 25, 0, 1, 2)
gen_grid.addWidget(self.ncc_rest_cb, 0, 0, 1, 2)
# Rest Margin
self.rest_nccmarginlabel = FCLabel('%s:' % _('Margin'))
@@ -4554,8 +4567,8 @@ class NccUI:
self.rest_ncc_margin_entry.set_range(-10000.0000, 10000.0000)
self.rest_ncc_margin_entry.setObjectName("n_margin")
self.grid3.addWidget(self.rest_nccmarginlabel, 26, 0)
self.grid3.addWidget(self.rest_ncc_margin_entry, 26, 1)
gen_grid.addWidget(self.rest_nccmarginlabel, 2, 0)
gen_grid.addWidget(self.rest_ncc_margin_entry, 2, 1)
# Rest Connect lines
self.rest_ncc_connect_cb = FCCheckBox('%s' % _("Connect"))
@@ -4563,7 +4576,7 @@ class NccUI:
_("Draw lines between resulting\n"
"segments to minimize tool lifts.")
)
self.grid3.addWidget(self.rest_ncc_connect_cb, 27, 0)
gen_grid.addWidget(self.rest_ncc_connect_cb, 4, 0)
# Rest Contour
self.rest_ncc_contour_cb = FCCheckBox('%s' % _("Contour"))
@@ -4571,7 +4584,7 @@ class NccUI:
_("Cut around the perimeter of the polygon\n"
"to trim rough edges.")
)
self.grid3.addWidget(self.rest_ncc_contour_cb, 27, 1)
gen_grid.addWidget(self.rest_ncc_contour_cb, 4, 1)
# ## Rest NCC Offset choice
self.rest_ncc_choice_offset_cb = FCCheckBox('%s' % _("Offset"))
@@ -4580,7 +4593,7 @@ class NccUI:
"The copper clearing will finish to a distance\n"
"from the copper features.")
)
self.grid3.addWidget(self.rest_ncc_choice_offset_cb, 28, 0)
gen_grid.addWidget(self.rest_ncc_choice_offset_cb, 6, 0)
# ## Rest NCC Offset Entry
self.rest_ncc_offset_spinner = FCDoubleSpinner(callback=self.confirmation_message)
@@ -4594,7 +4607,7 @@ class NccUI:
else:
self.rest_ncc_offset_spinner.setSingleStep(0.01)
self.grid3.addWidget(self.rest_ncc_offset_spinner, 28, 1)
gen_grid.addWidget(self.rest_ncc_offset_spinner, 6, 1)
self.rest_ois_ncc_offset = OptionalInputSection(self.rest_ncc_choice_offset_cb, [self.rest_ncc_offset_spinner])
@@ -4612,8 +4625,8 @@ class NccUI:
"- 'Area Selection' - left mouse click to start selection of the area to be processed.\n"
"- 'Reference Object' - will process the area specified by another object.")
)
self.grid3.addWidget(self.select_label, 29, 0, )
self.grid3.addWidget(self.select_combo, 29, 1)
gen_grid.addWidget(self.select_label, 8, 0, )
gen_grid.addWidget(self.select_combo, 8, 1)
self.reference_combo_type_label = FCLabel('%s:' % _("Type"))
self.reference_combo_type_label.setToolTip(
@@ -4623,15 +4636,15 @@ class NccUI:
self.reference_combo_type = FCComboBox2()
self.reference_combo_type.addItems([_("Gerber"), _("Excellon"), _("Geometry")])
self.grid3.addWidget(self.reference_combo_type_label, 31, 0, )
self.grid3.addWidget(self.reference_combo_type, 31, 1)
gen_grid.addWidget(self.reference_combo_type_label, 10, 0, )
gen_grid.addWidget(self.reference_combo_type, 10, 1)
self.reference_combo = FCComboBox()
self.reference_combo.setModel(self.app.collection)
self.reference_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
self.reference_combo.is_last = True
self.grid3.addWidget(self.reference_combo, 33, 0, 1, 2)
gen_grid.addWidget(self.reference_combo, 12, 0, 1, 2)
self.reference_combo.hide()
self.reference_combo_type.hide()
@@ -4646,8 +4659,8 @@ class NccUI:
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
{'label': _("Polygon"), 'value': 'polygon'}])
self.grid3.addWidget(self.area_shape_label, 35, 0)
self.grid3.addWidget(self.area_shape_radio, 35, 1)
gen_grid.addWidget(self.area_shape_label, 14, 0)
gen_grid.addWidget(self.area_shape_radio, 14, 1)
self.area_shape_label.hide()
self.area_shape_radio.hide()
@@ -4660,13 +4673,11 @@ class NccUI:
)
self.valid_cb.setObjectName("n_check")
self.grid3.addWidget(self.valid_cb, 37, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
self.grid3.addWidget(separator_line, 39, 0, 1, 2)
gen_grid.addWidget(self.valid_cb, 16, 0, 1, 2)
# #############################################################################################################
# Generate NCC Geometry Button
# #############################################################################################################
self.generate_ncc_button = FCButton(_('Generate Geometry'))
self.generate_ncc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png'))
self.generate_ncc_button.setToolTip(
@@ -4680,6 +4691,7 @@ class NccUI:
}
""")
self.tools_box.addWidget(self.generate_ncc_button)
self.tools_box.addStretch(1)
# ## Reset Tool