- in Geometry UI added a button that allow updating all the tools in the Tool Table with the current values in the UI form

This commit is contained in:
Marius Stanciu
2019-12-08 16:58:15 +02:00
committed by Marius
parent 2baae550b5
commit facc077493
3 changed files with 84 additions and 14 deletions

View File

@@ -3826,6 +3826,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.ui.tipangle_entry.valueChanged.connect(self.update_cutz)
self.ui.addtool_from_db_btn.clicked.connect(self.on_tool_add_from_db_clicked)
self.ui.apply_param_to_all.clicked.connect(self.on_apply_param_to_all_clicked)
def set_tool_offset_visibility(self, current_row):
if current_row is None:
@@ -4393,7 +4394,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
try:
# set the form with data from the newly selected tool
for tooluid_key, tooluid_value in self.tools.items():
for tooluid_key, tooluid_value in list(self.tools.items()):
if int(tooluid_key) == tooluid:
for key, value in tooluid_value.items():
if key == 'data':
@@ -4503,8 +4504,70 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
self.ui.ois_mpass_geo.on_cb_change()
self.ui.ois_tcz_geo.on_cb_change()
def gui_form_to_storage(self):
def on_apply_param_to_all_clicked(self):
if self.ui.geo_tools_table.rowCount() == 0:
# there is no tool in tool table so we can't save the GUI elements values to storage
log.debug("FlatCAMGeometry.gui_form_to_storage() --> no tool in Tools Table, aborting.")
return
self.ui_disconnect()
row = self.ui.geo_tools_table.currentRow()
if row < 0:
row = 0
# store all the data associated with the row parameter to the self.tools storage
tooldia_item = float(self.ui.geo_tools_table.item(row, 1).text())
offset_item = self.ui.geo_tools_table.cellWidget(row, 2).currentText()
type_item = self.ui.geo_tools_table.cellWidget(row, 3).currentText()
tool_type_item = self.ui.geo_tools_table.cellWidget(row, 4).currentText()
offset_value_item = float(self.ui.tool_offset_entry.get_value())
# this new dict will hold the actual useful data, another dict that is the value of key 'data'
temp_tools = {}
temp_dia = {}
temp_data = {}
for tooluid_key, tooluid_value in self.tools.items():
for key, value in tooluid_value.items():
if key == 'tooldia':
temp_dia[key] = tooldia_item
# update the 'offset', 'type' and 'tool_type' sections
if key == 'offset':
temp_dia[key] = offset_item
if key == 'type':
temp_dia[key] = type_item
if key == 'tool_type':
temp_dia[key] = tool_type_item
if key == 'offset_value':
temp_dia[key] = offset_value_item
if key == 'data':
# update the 'data' section
for data_key in tooluid_value[key].keys():
for form_key, form_value in self.form_fields.items():
if form_key == data_key:
temp_data[data_key] = form_value.get_value()
# make sure we make a copy of the keys not in the form (we may use 'data' keys that are
# updated from self.app.defaults
if data_key not in self.form_fields:
temp_data[data_key] = value[data_key]
temp_dia[key] = deepcopy(temp_data)
temp_data.clear()
if key == 'solid_geometry':
temp_dia[key] = deepcopy(self.tools[tooluid_key]['solid_geometry'])
temp_tools[tooluid_key] = deepcopy(temp_dia)
self.tools.clear()
self.tools = deepcopy(temp_tools)
temp_tools.clear()
self.ui_connect()
def gui_form_to_storage(self):
if self.ui.geo_tools_table.rowCount() == 0:
# there is no tool in tool table so we can't save the GUI elements values to storage
log.debug("FlatCAMGeometry.gui_form_to_storage() --> no tool in Tools Table, aborting.")
@@ -4544,16 +4607,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
tool_type_item = self.ui.geo_tools_table.cellWidget(row, 4).currentText()
tooluid_item = int(self.ui.geo_tools_table.item(row, 5).text())
try:
offset_value_item = float(self.ui.tool_offset_entry.get_value())
except ValueError:
# try to convert comma to decimal point. if it's still not working error message and return
try:
offset_value_item = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
except ValueError:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Wrong value format entered, use a number."))
return
# this new dict will hold the actual useful data, another dict that is the value of key 'data'
temp_tools = {}
@@ -4592,7 +4646,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
temp_dia[key] = deepcopy(self.tools[tooluid_key]['solid_geometry'])
temp_tools[tooluid_key] = deepcopy(temp_dia)
else:
temp_tools[tooluid_key] = deepcopy(tooluid_value)

View File

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
- in Geometry UI made sure that the Label that points to the Tool parameters show clearly that those parameters apply only for the selected tool
- fixed an small issue in Object UI
- small fixes: selected object in Project used to ask twice for UI build; if scale factor in Object UI is 1 do nothing as there is no point in scaling with a factor of 1
- in Geometry UI added a button that allow updating all the tools in the Tool Table with the current values in the UI form
7.12.2019

View File

@@ -1266,6 +1266,12 @@ class GeometryObjectUI(ObjectUI):
# ##################
# Create CNC Job ###
# ##################
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.geo_tools_box.addWidget(separator_line)
# ### Tools Data ## ##
self.tool_data_label = QtWidgets.QLabel(
"<b>%s: <font color='#0000FF'>%s %d</font></b>" % (_('Parameters for'), _("Tool"), int(1)))
@@ -1584,13 +1590,23 @@ class GeometryObjectUI(ObjectUI):
self.feedrate_probe_label.hide()
self.feedrate_probe_entry.setVisible(False)
separator_line2 = QtWidgets.QFrame()
separator_line2.setFrameShape(QtWidgets.QFrame.HLine)
separator_line2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.grid3.addWidget(separator_line2, 19, 0, 1, 2)
self.apply_param_to_all = FCButton(_("Apply parameters to all tools"))
self.grid3.addWidget(self.apply_param_to_all, 20, 0, 1, 2)
self.grid3.addWidget(QtWidgets.QLabel(''), 21, 0, 1, 2)
warning_lbl = QtWidgets.QLabel(
_(
"Add at least one tool in the tool-table.\n"
"Click the header to select all, or Ctrl + LMB\n"
"for custom selection of tools."
))
self.grid3.addWidget(warning_lbl, 19, 0, 1, 2)
self.grid3.addWidget(warning_lbl, 22, 0, 1, 2)
# Button
self.generate_cnc_button = QtWidgets.QPushButton(_('Generate CNCJob object'))