- Isolation Tool - added a check for having a complete isolation
This commit is contained in:
@@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
- small change in the NCC Tool UI
|
- small change in the NCC Tool UI
|
||||||
- some strings are changed and therefore the translation strings source are updated
|
- some strings are changed and therefore the translation strings source are updated
|
||||||
|
- Isolation Tool - added a check for having a complete isolation
|
||||||
|
|
||||||
7.10.2020
|
7.10.2020
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"])
|
self.grb_circle_steps = int(self.app.defaults["gerber_circle_steps"])
|
||||||
|
|
||||||
self.tooldia = None
|
self.tooldia = None
|
||||||
|
# store here the tool diameter that is guaranteed to isolate the object
|
||||||
|
self.safe_tooldia = None
|
||||||
|
|
||||||
# multiprocessing
|
# multiprocessing
|
||||||
self.pool = self.app.pool
|
self.pool = self.app.pool
|
||||||
@@ -225,6 +227,9 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
def set_tool_ui(self):
|
def set_tool_ui(self):
|
||||||
self.units = self.app.defaults['units'].upper()
|
self.units = self.app.defaults['units'].upper()
|
||||||
|
|
||||||
|
# reset the value to prepare for another isolation
|
||||||
|
self.safe_tooldia = None
|
||||||
|
|
||||||
# try to select in the Gerber combobox the active object
|
# try to select in the Gerber combobox the active object
|
||||||
try:
|
try:
|
||||||
selected_obj = self.app.collection.get_active()
|
selected_obj = self.app.collection.get_active()
|
||||||
@@ -888,6 +893,9 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def on_find_optimal_tooldia(self):
|
def on_find_optimal_tooldia(self):
|
||||||
|
self.find_safe_tooldia_worker(is_displayed=True)
|
||||||
|
|
||||||
|
def find_safe_tooldia_worker(self, is_displayed):
|
||||||
self.units = self.app.defaults['units'].upper()
|
self.units = self.app.defaults['units'].upper()
|
||||||
|
|
||||||
obj_name = self.ui.object_combo.currentText()
|
obj_name = self.ui.object_combo.currentText()
|
||||||
@@ -903,9 +911,8 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), str(obj_name)))
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), str(obj_name)))
|
||||||
return
|
return
|
||||||
|
|
||||||
proc = self.app.proc_container.new(_("Working..."))
|
def job_thread(app_obj, is_display):
|
||||||
|
with self.app.proc_container.new(_("Working...")) as proc:
|
||||||
def job_thread(app_obj):
|
|
||||||
try:
|
try:
|
||||||
old_disp_number = 0
|
old_disp_number = 0
|
||||||
pol_nr = 0
|
pol_nr = 0
|
||||||
@@ -970,18 +977,43 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
min_dist = min(min_list)
|
min_dist = min(min_list)
|
||||||
|
|
||||||
min_dist_truncated = self.app.dec_format(float(min_dist), self.decimals)
|
min_dist_truncated = self.app.dec_format(float(min_dist), self.decimals)
|
||||||
|
self.safe_tooldia = min_dist_truncated
|
||||||
|
|
||||||
|
if is_display:
|
||||||
self.optimal_found_sig.emit(min_dist_truncated)
|
self.optimal_found_sig.emit(min_dist_truncated)
|
||||||
|
|
||||||
app_obj.inform.emit('[success] %s: %s %s' %
|
app_obj.inform.emit('[success] %s: %s %s' %
|
||||||
(_("Optimal tool diameter found"), str(min_dist_truncated), self.units.lower()))
|
(_("Optimal tool diameter found"), str(min_dist_truncated),
|
||||||
|
self.units.lower()))
|
||||||
|
else:
|
||||||
|
if self.safe_tooldia:
|
||||||
|
# find the selected tool ID's
|
||||||
|
sorted_tools = []
|
||||||
|
table_items = self.ui.tools_table.selectedItems()
|
||||||
|
sel_rows = {t.row() for t in table_items}
|
||||||
|
for row in sel_rows:
|
||||||
|
tid = int(self.ui.tools_table.item(row, 3).text())
|
||||||
|
sorted_tools.append(tid)
|
||||||
|
if not sorted_tools:
|
||||||
|
self.app.inform.emit('[ERROR_NOTCL] %s' % _("No selected tools in Tool Table."))
|
||||||
|
return 'fail'
|
||||||
|
|
||||||
|
# check if the tools diameters are less then the safe tool diameter
|
||||||
|
for tool in sorted_tools:
|
||||||
|
tool_dia = float(self.iso_tools[tool]['tooldia'])
|
||||||
|
if tool_dia > self.safe_tooldia:
|
||||||
|
msg = _("Incomplete isolation. "
|
||||||
|
"At least one tool could not do a complete isolation.")
|
||||||
|
self.app.inform.emit('[WARNING] %s' % msg)
|
||||||
|
break
|
||||||
|
|
||||||
|
# reset the value to prepare for another isolation
|
||||||
|
self.safe_tooldia = None
|
||||||
except Exception as ee:
|
except Exception as ee:
|
||||||
proc.done()
|
|
||||||
log.debug(str(ee))
|
log.debug(str(ee))
|
||||||
return
|
return
|
||||||
proc.done()
|
|
||||||
|
|
||||||
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
|
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app, is_displayed]})
|
||||||
|
|
||||||
def on_tool_add(self, custom_dia=None):
|
def on_tool_add(self, custom_dia=None):
|
||||||
self.blockSignals(True)
|
self.blockSignals(True)
|
||||||
@@ -1335,12 +1367,14 @@ class ToolIsolation(AppTool, Gerber):
|
|||||||
self.grb_obj = self.app.collection.get_by_name(self.obj_name)
|
self.grb_obj = self.app.collection.get_by_name(self.obj_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), str(self.obj_name)))
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), str(self.obj_name)))
|
||||||
return "Could not retrieve object: %s with error: %s" % (self.obj_name, str(e))
|
return
|
||||||
|
|
||||||
if self.grb_obj is None:
|
if self.grb_obj is None:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), str(self.obj_name)))
|
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Object not found"), str(self.obj_name)))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.find_safe_tooldia_worker(is_displayed=False)
|
||||||
|
|
||||||
def worker_task(iso_obj):
|
def worker_task(iso_obj):
|
||||||
with self.app.proc_container.new(_("Isolating...")):
|
with self.app.proc_container.new(_("Isolating...")):
|
||||||
self.isolate_handler(iso_obj)
|
self.isolate_handler(iso_obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user