- NCC Plugin - minor code refactoring
This commit is contained in:
@@ -10,6 +10,7 @@ CHANGELOG for FlatCAM Evo beta
|
|||||||
14.05.2023
|
14.05.2023
|
||||||
|
|
||||||
- Isolation Plugin, NCC Plugin and Find Optimal Plugin: fixed not finding the optimal tool diameter (the one that will isolate completely a Gerber object)
|
- Isolation Plugin, NCC Plugin and Find Optimal Plugin: fixed not finding the optimal tool diameter (the one that will isolate completely a Gerber object)
|
||||||
|
- NCC Plugin - minor code refactoring
|
||||||
|
|
||||||
05.05.2023
|
05.05.2023
|
||||||
|
|
||||||
|
|||||||
@@ -907,7 +907,7 @@ class GerberObject(FlatCAMObj, Gerber):
|
|||||||
|
|
||||||
Gerber.convert_units(self, units)
|
Gerber.convert_units(self, units)
|
||||||
|
|
||||||
# self.obj_options['isotooldia'] = float(self.obj_options['isotooldia']) * factor
|
# self.obj_options['isotd_list'] = float(self.obj_options['isotd_list']) * factor
|
||||||
# self.obj_options['bboxmargin'] = float(self.obj_options['bboxmargin']) * factor
|
# self.obj_options['bboxmargin'] = float(self.obj_options['bboxmargin']) * factor
|
||||||
|
|
||||||
def plot(self, kind=None, **kwargs):
|
def plot(self, kind=None, **kwargs):
|
||||||
|
|||||||
@@ -1563,7 +1563,7 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
|
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Wrong value format entered, use a number."))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# find out which tools is for isolation and which are for copper clearing
|
# find out which tools are for isolation and which are for copper clearing
|
||||||
for uid_k, uid_v in self.ncc_tools.items():
|
for uid_k, uid_v in self.ncc_tools.items():
|
||||||
if round(uid_v['tooldia'], self.decimals) == round(self.tooldia, self.decimals):
|
if round(uid_v['tooldia'], self.decimals) == round(self.tooldia, self.decimals):
|
||||||
if uid_v['data']['tools_ncc_operation'] == "iso":
|
if uid_v['data']['tools_ncc_operation'] == "iso":
|
||||||
@@ -1587,8 +1587,8 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
return "Could not retrieve object: %s with error: %s" % (self.bound_obj_name, str(e))
|
return "Could not retrieve object: %s with error: %s" % (self.bound_obj_name, str(e))
|
||||||
|
|
||||||
self.clear_copper(ncc_obj=self.ncc_obj,
|
self.clear_copper(ncc_obj=self.ncc_obj,
|
||||||
ncctooldia=self.ncc_dia_list,
|
ncctd_list=self.ncc_dia_list,
|
||||||
isotooldia=self.iso_dia_list,
|
isotd_list=self.iso_dia_list,
|
||||||
outname=self.o_name,
|
outname=self.o_name,
|
||||||
tools_storage=self.ncc_tools)
|
tools_storage=self.ncc_tools)
|
||||||
elif self.select_method == 1: # Area Selection
|
elif self.select_method == 1: # Area Selection
|
||||||
@@ -1611,7 +1611,6 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
self.area_sel_disconnect_flag = True
|
self.area_sel_disconnect_flag = True
|
||||||
# disable the "notebook UI" until finished
|
# disable the "notebook UI" until finished
|
||||||
self.app.ui.notebook.setDisabled(True)
|
self.app.ui.notebook.setDisabled(True)
|
||||||
|
|
||||||
elif self.select_method == 2: # Reference Object
|
elif self.select_method == 2: # Reference Object
|
||||||
self.bound_obj_name = self.ui.reference_combo.currentText()
|
self.bound_obj_name = self.ui.reference_combo.currentText()
|
||||||
# Get source object.
|
# Get source object.
|
||||||
@@ -1623,8 +1622,8 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
|
|
||||||
self.clear_copper(ncc_obj=self.ncc_obj,
|
self.clear_copper(ncc_obj=self.ncc_obj,
|
||||||
sel_obj=self.bound_obj,
|
sel_obj=self.bound_obj,
|
||||||
ncctooldia=self.ncc_dia_list,
|
ncctd_list=self.ncc_dia_list,
|
||||||
isotooldia=self.iso_dia_list,
|
isotd_list=self.iso_dia_list,
|
||||||
outname=self.o_name)
|
outname=self.o_name)
|
||||||
|
|
||||||
# To be called after clicking on the plot.
|
# To be called after clicking on the plot.
|
||||||
@@ -1741,8 +1740,8 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
|
|
||||||
self.sel_rect = unary_union(self.sel_rect)
|
self.sel_rect = unary_union(self.sel_rect)
|
||||||
|
|
||||||
self.clear_copper(ncc_obj=self.ncc_obj, sel_obj=self.bound_obj, ncctooldia=self.ncc_dia_list,
|
self.clear_copper(ncc_obj=self.ncc_obj, sel_obj=self.bound_obj, ncctd_list=self.ncc_dia_list,
|
||||||
isotooldia=self.iso_dia_list, outname=self.o_name)
|
isotd_list=self.iso_dia_list, outname=self.o_name)
|
||||||
|
|
||||||
self.app.ui.notebook.setDisabled(False)
|
self.app.ui.notebook.setDisabled(False)
|
||||||
|
|
||||||
@@ -2254,17 +2253,17 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
self.app.inform_shell.emit('%s %s' % (_('Polygon could not be cleared. Location:'), str(coords)))
|
self.app.inform_shell.emit('%s %s' % (_('Polygon could not be cleared. Location:'), str(coords)))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def clear_copper(self, ncc_obj, ncctooldia, isotooldia, sel_obj=None, outname=None, order=None,
|
def clear_copper(self, ncc_obj, ncctd_list, isotd_list, sel_obj=None, outname=None, order=None,
|
||||||
tools_storage=None, run_threaded=True):
|
tools_storage=None, run_threaded=True):
|
||||||
"""
|
"""
|
||||||
Clear the excess copper from the entire object.
|
Clear the excess copper from the entire object.
|
||||||
|
|
||||||
:param ncc_obj: ncc cleared object
|
:param ncc_obj: ncc cleared object
|
||||||
:type ncc_obj: appObjects.GerberObject.GerberObject
|
:type ncc_obj: appObjects.GerberObject.GerberObject
|
||||||
:param ncctooldia: a list of diameters of the tools to be used to ncc clear
|
:param ncctd_list: a list of diameters of the tools to be used to ncc clear
|
||||||
:type ncctooldia: list
|
:type ncctd_list: list
|
||||||
:param isotooldia: a list of diameters of the tools to be used for isolation
|
:param isotd_list: a list of diameters of the tools to be used for isolation
|
||||||
:type isotooldia: list
|
:type isotd_list: list
|
||||||
:param sel_obj:
|
:param sel_obj:
|
||||||
:type sel_obj:
|
:type sel_obj:
|
||||||
:param outname: name of the resulting object
|
:param outname: name of the resulting object
|
||||||
@@ -2301,7 +2300,7 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
prog_plot = True if self.app.options["tools_ncc_plotting"] == 'progressive' else False
|
prog_plot = True if self.app.options["tools_ncc_plotting"] == 'progressive' else False
|
||||||
|
|
||||||
tools_storage = tools_storage if tools_storage is not None else self.ncc_tools
|
tools_storage = tools_storage if tools_storage is not None else self.ncc_tools
|
||||||
sorted_clear_tools = ncctooldia
|
sorted_clear_tools = ncctd_list
|
||||||
|
|
||||||
if not sorted_clear_tools:
|
if not sorted_clear_tools:
|
||||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("There is no copper clearing tool in the selection "
|
self.app.inform.emit('[ERROR_NOTCL] %s' % _("There is no copper clearing tool in the selection "
|
||||||
@@ -2389,8 +2388,8 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
ncc_offset = float(self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_value"])
|
ncc_offset = float(self.ncc_tools[tool_uid]["data"]["tools_ncc_offset_value"])
|
||||||
|
|
||||||
# Area to clear
|
# Area to clear
|
||||||
result = self.get_tool_empty_area(name=name, ncc_obj=ncc_obj, geo_obj=geo_obj, isotooldia=isotooldia,
|
result = self.get_tool_empty_area(name=name, ncc_obj=ncc_obj, geo_obj=geo_obj, isotooldia=isotd_list,
|
||||||
ncc_margin=ncc_margin, has_offset=has_offset, ncc_offset=ncc_offset,
|
ncc_margin=ncc_margin, has_offset=has_offset, ncc_offset=ncc_offset,
|
||||||
tools_storage=tools_storage, bounding_box=bbox)
|
tools_storage=tools_storage, bounding_box=bbox)
|
||||||
|
|
||||||
area, warning_flag = result
|
area, warning_flag = result
|
||||||
@@ -2603,7 +2602,7 @@ class NonCopperClear(AppTool, Gerber):
|
|||||||
|
|
||||||
# Area to clear
|
# Area to clear
|
||||||
area, warning_flag = self.get_tool_empty_area(name=name, ncc_obj=ncc_obj, geo_obj=geo_obj,
|
area, warning_flag = self.get_tool_empty_area(name=name, ncc_obj=ncc_obj, geo_obj=geo_obj,
|
||||||
isotooldia=isotooldia,
|
isotooldia=isotd_list,
|
||||||
has_offset=has_offset, ncc_offset=ncc_offset,
|
has_offset=has_offset, ncc_offset=ncc_offset,
|
||||||
ncc_margin=ncc_margin, tools_storage=tools_storage,
|
ncc_margin=ncc_margin, tools_storage=tools_storage,
|
||||||
bounding_box=bbox)
|
bounding_box=bbox)
|
||||||
|
|||||||
Reference in New Issue
Block a user