- modified the Tool Database such that when a tool shape is selected as 'V' any change in the Vdia or Vangle or CutZ parameters will update the tool diameter value

This commit is contained in:
Marius Stanciu 2020-05-30 15:04:42 +03:00 committed by Marius
parent 9eea4f6333
commit 23ee9c8ad1
3 changed files with 55 additions and 2 deletions

View File

@ -8,6 +8,8 @@ import json
from copy import deepcopy from copy import deepcopy
from datetime import datetime from datetime import datetime
import math
import gettext import gettext
import AppTranslation as fcTranslate import AppTranslation as fcTranslate
import builtins import builtins
@ -2353,6 +2355,18 @@ class ToolsDB2(QtWidgets.QWidget):
self.app.tools_db_changed_flag = False self.app.tools_db_changed_flag = False
self.on_save_tools_db() self.on_save_tools_db()
def on_calculate_tooldia(self):
if self.shape_combo.get_value() == 'V':
tip_dia = float(self.vdia_entry.get_value())
half_tip_angle = float(self.vangle_entry.get_value()) / 2.0
cut_z = float(self.cutz_entry.get_value())
cut_z = -cut_z if cut_z < 0 else cut_z
# calculated tool diameter so the cut_z parameter is obeyed
tool_dia = tip_dia + (2 * cut_z * math.tan(math.radians(half_tip_angle)))
self.dia_entry.set_value(tool_dia)
def ui_connect(self): def ui_connect(self):
# make sure that we don't make multiple connections to the widgets # make sure that we don't make multiple connections to the widgets
self.ui_disconnect() self.ui_disconnect()
@ -2382,12 +2396,40 @@ class ToolsDB2(QtWidgets.QWidget):
if isinstance(wdg, FCSpinner) or isinstance(wdg, FCDoubleSpinner): if isinstance(wdg, FCSpinner) or isinstance(wdg, FCDoubleSpinner):
wdg.valueChanged.connect(self.update_storage) wdg.valueChanged.connect(self.update_storage)
# connect the calculate tooldia method to the controls
# if the tool shape is 'V' the tool dia will be calculated to obey Cut Z parameter
self.shape_combo.currentIndexChanged.connect(self.on_calculate_tooldia)
self.cutz_entry.valueChanged.connect(self.on_calculate_tooldia)
self.vdia_entry.valueChanged.connect(self.on_calculate_tooldia)
self.vangle_entry.valueChanged.connect(self.on_calculate_tooldia)
def ui_disconnect(self): def ui_disconnect(self):
try: try:
self.name_entry.editingFinished.disconnect(self.update_tree_name) self.name_entry.editingFinished.disconnect(self.update_tree_name)
except (TypeError, AttributeError): except (TypeError, AttributeError):
pass pass
try:
self.shape_combo.currentIndexChanged.disconnect(self.on_calculate_tooldia)
except (TypeError, AttributeError):
pass
try:
self.cutz_entry.valueChanged.disconnect(self.on_calculate_tooldia)
except (TypeError, AttributeError):
pass
try:
self.vdia_entry.valueChanged.disconnect(self.on_calculate_tooldia)
except (TypeError, AttributeError):
pass
try:
self.vangle_entry.valueChanged.disconnect(self.on_calculate_tooldia)
except (TypeError, AttributeError):
pass
for key in self.form_fields: for key in self.form_fields:
wdg = self.form_fields[key] wdg = self.form_fields[key]

View File

@ -5252,7 +5252,7 @@ class App(QtCore.QObject):
:return: :return:
""" """
self.inform.emit('[WARNING_NOTCL] %s' % _("Tools in Tools Database edited but not saved.")) self.inform[str, bool].emit('[WARNING_NOTCL] %s' % _("Tools in Tools Database edited but not saved."), False)
for idx in range(self.ui.plot_tab_area.count()): for idx in range(self.ui.plot_tab_area.count()):
if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"): if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"):
@ -5270,9 +5270,19 @@ class App(QtCore.QObject):
tool_from_db = deepcopy(tool) tool_from_db = deepcopy(tool)
obj = self.collection.get_active() obj = self.collection.get_active()
if isinstance(obj, GeometryObject): if obj.kind == 'geometry':
obj.on_tool_from_db_inserted(tool=tool_from_db) obj.on_tool_from_db_inserted(tool=tool_from_db)
# close the tab and delete it
for idx in range(self.ui.plot_tab_area.count()):
if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"):
wdg = self.ui.plot_tab_area.widget(idx)
wdg.deleteLater()
self.ui.plot_tab_area.removeTab(idx)
self.inform.emit('[success] %s' % _("Tool from DB added in Tool Table."))
elif obj.kind == 'gerber':
self.isolation_tool.on_tool_from_db_inserted(tool=tool_from_db)
# close the tab and delete it # close the tab and delete it
for idx in range(self.ui.plot_tab_area.count()): for idx in range(self.ui.plot_tab_area.count()):
if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"): if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"):

View File

@ -15,6 +15,7 @@ CHANGELOG for FlatCAM beta
- Isolation Tool: solved some naming issues - Isolation Tool: solved some naming issues
- Isolation Tool: updated the tools dict with the common parameters value on isolating - Isolation Tool: updated the tools dict with the common parameters value on isolating
- Fixed a recent change that made the edited Geometry objects in the Geometry Editor not to be plotted after saving changes - Fixed a recent change that made the edited Geometry objects in the Geometry Editor not to be plotted after saving changes
- modified the Tool Database such that when a tool shape is selected as 'V' any change in the Vdia or Vangle or CutZ parameters will update the tool diameter value
29.05.2020 29.05.2020