- fixed issue #319 where generating a CNCJob from a geometry made with NCC Tool made the app crash
- replaced in FlatCAM Tools and in FLatCAMObj.py and in Editors all references to hardcoded decimals in string formats for tools with a variable declared in the __init__()
This commit is contained in:
@@ -488,6 +488,11 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
# store here solid_geometry when there are tool with isolation job
|
||||
self.solid_geometry = []
|
||||
|
||||
# the number of decimals for the tools used in this FlatCAM Tool
|
||||
self.decimals = 4
|
||||
|
||||
self.select_method = None
|
||||
|
||||
self.tool_type_item_options = []
|
||||
|
||||
self.addtool_btn.clicked.connect(self.on_tool_add)
|
||||
@@ -546,6 +551,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.app.ui.notebook.setTabText(2, _("NCC Tool"))
|
||||
|
||||
def set_tool_ui(self):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
else:
|
||||
self.decimals = 2
|
||||
|
||||
self.tools_frame.show()
|
||||
|
||||
self.ncc_order_radio.set_value(self.app.defaults["tools_nccorder"])
|
||||
@@ -619,7 +631,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.tooluid += 1
|
||||
self.ncc_tools.update({
|
||||
int(self.tooluid): {
|
||||
'tooldia': float('%.4f' % tool_dia),
|
||||
'tooldia': float('%.*f' % (self.decimals, tool_dia)),
|
||||
'offset': 'Path',
|
||||
'offset_value': 0.0,
|
||||
'type': 'Iso',
|
||||
@@ -651,7 +663,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.ncc_tools.items():
|
||||
sorted_tools.append(float('%.4f' % float(v['tooldia'])))
|
||||
if self.units == "IN":
|
||||
sorted_tools.append(float('%.*f' % (self.decimals, float(v['tooldia']))))
|
||||
else:
|
||||
sorted_tools.append(float('%.*f' % (self.decimals, float(v['tooldia']))))
|
||||
|
||||
order = self.ncc_order_radio.get_value()
|
||||
if order == 'fwd':
|
||||
@@ -667,7 +682,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
|
||||
for tool_sorted in sorted_tools:
|
||||
for tooluid_key, tooluid_value in self.ncc_tools.items():
|
||||
if float('%.4f' % tooluid_value['tooldia']) == tool_sorted:
|
||||
if float('%.*f' % (self.decimals, tooluid_value['tooldia'])) == tool_sorted:
|
||||
tool_id += 1
|
||||
id_ = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
|
||||
id_.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
@@ -675,12 +690,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.tools_table.setItem(row_no, 0, id_) # Tool name/id
|
||||
|
||||
# Make sure that the drill diameter when in MM is with no more than 2 decimals
|
||||
# There are no drill bits in MM with more than 3 decimals diameter
|
||||
# For INCH the decimals should be no more than 3. There are no drills under 10mils
|
||||
if self.units == 'MM':
|
||||
dia = QtWidgets.QTableWidgetItem('%.2f' % tooluid_value['tooldia'])
|
||||
else:
|
||||
dia = QtWidgets.QTableWidgetItem('%.4f' % tooluid_value['tooldia'])
|
||||
# There are no drill bits in MM with more than 2 decimals diameter
|
||||
# For INCH the decimals should be no more than 4. There are no drills under 10mils
|
||||
dia = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, tooluid_value['tooldia']))
|
||||
|
||||
dia.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
@@ -921,10 +933,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Please enter a tool diameter to add, in Float format."))
|
||||
return
|
||||
|
||||
if self.units == 'MM':
|
||||
tool_dia = float('%.2f' % tool_dia)
|
||||
else:
|
||||
tool_dia = float('%.4f' % tool_dia)
|
||||
|
||||
tool_dia = float('%.*f' % (self.decimals, tool_dia))
|
||||
|
||||
if tool_dia == 0:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Please enter a tool diameter with non-zero value, "
|
||||
@@ -948,9 +958,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
for k, v in self.ncc_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % self.decimals, (v[tool_v])))
|
||||
|
||||
if float('%.4f' % tool_dia) in tool_dias:
|
||||
if float('%.*f' % (self.decimals, tool_dia)) in tool_dias:
|
||||
if muted is None:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding tool cancelled. Tool already in Tool Table."))
|
||||
self.tools_table.itemChanged.connect(self.on_tool_edit)
|
||||
@@ -960,7 +970,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
self.app.inform.emit('[success] %s' % _("New tool added to Tool Table."))
|
||||
self.ncc_tools.update({
|
||||
int(self.tooluid): {
|
||||
'tooldia': float('%.4f' % tool_dia),
|
||||
'tooldia': float('%.*f' % (self.decimals, tool_dia)),
|
||||
'offset': 'Path',
|
||||
'offset_value': 0.0,
|
||||
'type': 'Iso',
|
||||
@@ -981,7 +991,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
for k, v in self.ncc_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % (self.decimals, v[tool_v])))
|
||||
|
||||
for row in range(self.tools_table.rowCount()):
|
||||
|
||||
@@ -1641,7 +1651,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
break
|
||||
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_iso):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
||||
tool_iso)):
|
||||
current_uid = int(k)
|
||||
# add the solid_geometry to the current too in self.paint_tools dictionary
|
||||
# and then reset the temporary list that stored that solid_geometry
|
||||
@@ -1799,7 +1810,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool
|
||||
# solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
||||
tool)):
|
||||
current_uid = int(k)
|
||||
|
||||
# add the solid_geometry to the current too in self.paint_tools dictionary
|
||||
@@ -1972,7 +1984,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
break
|
||||
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_iso):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
||||
tool_iso)):
|
||||
current_uid = int(k)
|
||||
# add the solid_geometry to the current too in self.paint_tools dictionary
|
||||
# and then reset the temporary list that stored that solid_geometry
|
||||
@@ -2172,7 +2185,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
|
||||
# find the tooluid associated with the current tool_dia so we know
|
||||
# where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals,
|
||||
tool)):
|
||||
current_uid = int(k)
|
||||
|
||||
# add the solid_geometry to the current too in self.paint_tools dictionary
|
||||
|
||||
@@ -376,6 +376,9 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
self.sel_rect = []
|
||||
|
||||
# Number of decimals for tools used in this Tool
|
||||
self.decimals = 4
|
||||
|
||||
# store here the default data for Geometry Data
|
||||
self.default_data = {}
|
||||
self.default_data.update({
|
||||
@@ -540,8 +543,10 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
self.addtool_entry.set_value(0.039)
|
||||
else:
|
||||
self.decimals = 2
|
||||
self.addtool_entry.set_value(1)
|
||||
|
||||
self.tools_table.setupContextMenu()
|
||||
@@ -608,7 +613,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.paint_tools.items():
|
||||
sorted_tools.append(float('%.4f' % float(v['tooldia'])))
|
||||
sorted_tools.append(float('%.*f' % (self.decimals, float(v['tooldia']))))
|
||||
|
||||
order = self.order_radio.get_value()
|
||||
if order == 'fwd':
|
||||
@@ -624,7 +629,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
for tool_sorted in sorted_tools:
|
||||
for tooluid_key, tooluid_value in self.paint_tools.items():
|
||||
if float('%.4f' % tooluid_value['tooldia']) == tool_sorted:
|
||||
if float('%.*f' % (self.decimals, tooluid_value['tooldia'])) == tool_sorted:
|
||||
tool_id += 1
|
||||
id = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
|
||||
id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
@@ -632,12 +637,10 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
self.tools_table.setItem(row_no, 0, id) # Tool name/id
|
||||
|
||||
# Make sure that the drill diameter when in MM is with no more than 2 decimals
|
||||
# There are no drill bits in MM with more than 3 decimals diameter
|
||||
# For INCH the decimals should be no more than 3. There are no drills under 10mils
|
||||
if self.units == 'MM':
|
||||
dia = QtWidgets.QTableWidgetItem('%.2f' % tooluid_value['tooldia'])
|
||||
else:
|
||||
dia = QtWidgets.QTableWidgetItem('%.4f' % tooluid_value['tooldia'])
|
||||
# There are no drill bits in MM with more than 2 decimals diameter
|
||||
# For INCH the decimals should be no more than 4. There are no drills under 10mils
|
||||
|
||||
dia = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, tooluid_value['tooldia']))
|
||||
|
||||
dia.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
@@ -736,9 +739,9 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
for k, v in self.paint_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % (self.decimals, v[tool_v])))
|
||||
|
||||
if float('%.4f' % tool_dia) in tool_dias:
|
||||
if float('%.*f' % (self.decimals, tool_dia)) in tool_dias:
|
||||
if muted is None:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' %
|
||||
_("Adding tool cancelled. Tool already in Tool Table."))
|
||||
@@ -750,7 +753,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
_("New tool added to Tool Table."))
|
||||
self.paint_tools.update({
|
||||
int(self.tooluid): {
|
||||
'tooldia': float('%.4f' % tool_dia),
|
||||
'tooldia': float('%.*f' % (self.decimals, tool_dia)),
|
||||
'offset': 'Path',
|
||||
'offset_value': 0.0,
|
||||
'type': 'Iso',
|
||||
@@ -774,7 +777,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
for k, v in self.paint_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % (self.decimals, v[tool_v])))
|
||||
|
||||
for row in range(self.tools_table.rowCount()):
|
||||
try:
|
||||
@@ -1392,7 +1395,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
for tool_dia in sorted_tools:
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_dia):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool_dia)):
|
||||
current_uid = int(k)
|
||||
break
|
||||
|
||||
@@ -1688,7 +1691,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_dia):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool_dia)):
|
||||
current_uid = int(k)
|
||||
break
|
||||
|
||||
@@ -1916,7 +1919,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_dia):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool_dia)):
|
||||
current_uid = int(k)
|
||||
break
|
||||
|
||||
@@ -2162,7 +2165,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_dia):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool_dia)):
|
||||
current_uid = int(k)
|
||||
break
|
||||
|
||||
@@ -2391,7 +2394,7 @@ class ToolPaint(FlatCAMTool, Gerber):
|
||||
|
||||
# find the tooluid associated with the current tool_dia so we know where to add the tool solid_geometry
|
||||
for k, v in tools_storage.items():
|
||||
if float('%.4f' % v['tooldia']) == float('%.4f' % tool_dia):
|
||||
if float('%.*f' % (self.decimals, v['tooldia'])) == float('%.*f' % (self.decimals, tool_dia)):
|
||||
current_uid = int(k)
|
||||
break
|
||||
|
||||
|
||||
@@ -402,6 +402,9 @@ class SolderPaste(FlatCAMTool):
|
||||
self.units = ''
|
||||
self.name = ""
|
||||
|
||||
# Number of decimals to be used for tools/nozzles in this FlatCAM Tool
|
||||
self.decimals = 4
|
||||
|
||||
# this will be used in the combobox context menu, for delete entry
|
||||
self.obj_to_be_deleted_name = ''
|
||||
|
||||
@@ -499,7 +502,7 @@ class SolderPaste(FlatCAMTool):
|
||||
self.tooluid += 1
|
||||
self.tooltable_tools.update({
|
||||
int(self.tooluid): {
|
||||
'tooldia': float('%.4f' % tool_dia),
|
||||
'tooldia': float('%.*f' % (self.decimals, tool_dia)),
|
||||
'data': deepcopy(self.options),
|
||||
'solid_geometry': []
|
||||
}
|
||||
@@ -510,6 +513,11 @@ class SolderPaste(FlatCAMTool):
|
||||
|
||||
self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
|
||||
|
||||
if self.units == "IN":
|
||||
self.decimals = 4
|
||||
else:
|
||||
self.decimals = 2
|
||||
|
||||
for name in list(self.app.postprocessors.keys()):
|
||||
# populate only with postprocessor files that start with 'Paste_'
|
||||
if name.partition('_')[0] != 'Paste':
|
||||
@@ -530,7 +538,7 @@ class SolderPaste(FlatCAMTool):
|
||||
|
||||
sorted_tools = []
|
||||
for k, v in self.tooltable_tools.items():
|
||||
sorted_tools.append(float('%.4f' % float(v['tooldia'])))
|
||||
sorted_tools.append(float('%.*f' % (self.decimals, float(v['tooldia']))))
|
||||
sorted_tools.sort(reverse=True)
|
||||
|
||||
n = len(sorted_tools)
|
||||
@@ -539,7 +547,7 @@ class SolderPaste(FlatCAMTool):
|
||||
|
||||
for tool_sorted in sorted_tools:
|
||||
for tooluid_key, tooluid_value in self.tooltable_tools.items():
|
||||
if float('%.4f' % tooluid_value['tooldia']) == tool_sorted:
|
||||
if float('%.*f' % (self.decimals, tooluid_value['tooldia'])) == tool_sorted:
|
||||
tool_id += 1
|
||||
id = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
|
||||
id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
|
||||
@@ -547,12 +555,9 @@ class SolderPaste(FlatCAMTool):
|
||||
self.tools_table.setItem(row_no, 0, id) # Tool name/id
|
||||
|
||||
# Make sure that the drill diameter when in MM is with no more than 2 decimals
|
||||
# There are no drill bits in MM with more than 3 decimals diameter
|
||||
# For INCH the decimals should be no more than 3. There are no drills under 10mils
|
||||
if self.units == 'MM':
|
||||
dia = QtWidgets.QTableWidgetItem('%.2f' % tooluid_value['tooldia'])
|
||||
else:
|
||||
dia = QtWidgets.QTableWidgetItem('%.4f' % tooluid_value['tooldia'])
|
||||
# There are no drill bits in MM with more than 2 decimals diameter
|
||||
# For INCH the decimals should be no more than 4. There are no drills under 10mils
|
||||
dia = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, tooluid_value['tooldia']))
|
||||
|
||||
dia.setFlags(QtCore.Qt.ItemIsEnabled)
|
||||
|
||||
@@ -791,9 +796,9 @@ class SolderPaste(FlatCAMTool):
|
||||
for k, v in self.tooltable_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % (self.decimals, v[tool_v])))
|
||||
|
||||
if float('%.4f' % tool_dia) in tool_dias:
|
||||
if float('%.*f' % (self.decimals, tool_dia)) in tool_dias:
|
||||
if muted is None:
|
||||
self.app.inform.emit('[WARNING_NOTCL] %s' %
|
||||
_("Adding Nozzle tool cancelled. Tool already in Tool Table."))
|
||||
@@ -805,7 +810,7 @@ class SolderPaste(FlatCAMTool):
|
||||
_("New Nozzle tool added to Tool Table."))
|
||||
self.tooltable_tools.update({
|
||||
int(self.tooluid): {
|
||||
'tooldia': float('%.4f' % tool_dia),
|
||||
'tooldia': float('%.*f' % (self.decimals, tool_dia)),
|
||||
'data': deepcopy(self.options),
|
||||
'solid_geometry': []
|
||||
}
|
||||
@@ -824,7 +829,7 @@ class SolderPaste(FlatCAMTool):
|
||||
for k, v in self.tooltable_tools.items():
|
||||
for tool_v in v.keys():
|
||||
if tool_v == 'tooldia':
|
||||
tool_dias.append(float('%.4f' % v[tool_v]))
|
||||
tool_dias.append(float('%.*f' % (self.decimals, v[tool_v])))
|
||||
|
||||
for row in range(self.tools_table.rowCount()):
|
||||
|
||||
@@ -991,7 +996,7 @@ class SolderPaste(FlatCAMTool):
|
||||
for k, v in self.tooltable_tools.items():
|
||||
# make sure that the tools diameter is more than zero and not zero
|
||||
if float(v['tooldia']) > 0:
|
||||
sorted_tools.append(float('%.4f' % float(v['tooldia'])))
|
||||
sorted_tools.append(float('%.*f' % (self.decimals, float(v['tooldia']))))
|
||||
sorted_tools.sort(reverse=True)
|
||||
|
||||
if not sorted_tools:
|
||||
@@ -1049,7 +1054,7 @@ class SolderPaste(FlatCAMTool):
|
||||
for tool in sorted_tools:
|
||||
offset = tool / 2
|
||||
for uid, vl in self.tooltable_tools.items():
|
||||
if float('%.4f' % float(vl['tooldia'])) == tool:
|
||||
if float('%.*f' % (self.decimals, float(vl['tooldia']))) == tool:
|
||||
tooluid = int(uid)
|
||||
break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user