- added progress and possibility of graceful exit in Panel Tool
- added graceful exit possibility when creating Isolation
This commit is contained in:
@@ -16,6 +16,8 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
- made changing the Plot kind in CNCJob selected tab, threaded
|
- made changing the Plot kind in CNCJob selected tab, threaded
|
||||||
- fixed an object used before declaring it in NCC Tool - Area option
|
- fixed an object used before declaring it in NCC Tool - Area option
|
||||||
- added progress for the generation of Isolation geometry
|
- added progress for the generation of Isolation geometry
|
||||||
|
- added progress and possibility of graceful exit in Panel Tool
|
||||||
|
- added graceful exit possibility when creating Isolation
|
||||||
|
|
||||||
9.09.2019
|
9.09.2019
|
||||||
|
|
||||||
|
|||||||
@@ -578,6 +578,9 @@ class Geometry(object):
|
|||||||
# yet, it can be done by issuing an unary_union in the end, thus getting rid of the overlapping geo
|
# yet, it can be done by issuing an unary_union in the end, thus getting rid of the overlapping geo
|
||||||
try:
|
try:
|
||||||
for pol in self.solid_geometry:
|
for pol in self.solid_geometry:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
if corner is None:
|
if corner is None:
|
||||||
geo_iso.append(pol.buffer(offset, int(int(self.geo_steps_per_circle) / 4)))
|
geo_iso.append(pol.buffer(offset, int(int(self.geo_steps_per_circle) / 4)))
|
||||||
else:
|
else:
|
||||||
@@ -601,6 +604,7 @@ class Geometry(object):
|
|||||||
self.app.proc_container.update_view_text(' %s' % _("Buffering"))
|
self.app.proc_container.update_view_text(' %s' % _("Buffering"))
|
||||||
geo_iso = unary_union(geo_iso)
|
geo_iso = unary_union(geo_iso)
|
||||||
|
|
||||||
|
self.app.proc_container.update_view_text('')
|
||||||
# end of replaced block
|
# end of replaced block
|
||||||
if follow:
|
if follow:
|
||||||
return geo_iso
|
return geo_iso
|
||||||
|
|||||||
@@ -506,11 +506,24 @@ class Panelize(FlatCAMTool):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
log.warning("Failed to copy option. %s" % str(option))
|
log.warning("Failed to copy option. %s" % str(option))
|
||||||
|
|
||||||
|
geo_len_drills = len(panel_obj.drills) if panel_obj.drills else 0
|
||||||
|
geo_len_slots = len(panel_obj.slots) if panel_obj.slots else 0
|
||||||
|
|
||||||
|
element = 0
|
||||||
for row in range(rows):
|
for row in range(rows):
|
||||||
currentx = 0.0
|
currentx = 0.0
|
||||||
for col in range(columns):
|
for col in range(columns):
|
||||||
|
element += 1
|
||||||
|
disp_number = 0
|
||||||
|
old_disp_number = 0
|
||||||
|
|
||||||
if panel_obj.drills:
|
if panel_obj.drills:
|
||||||
|
drill_nr = 0
|
||||||
for tool_dict in panel_obj.drills:
|
for tool_dict in panel_obj.drills:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
point_offseted = affinity.translate(tool_dict['point'], currentx, currenty)
|
point_offseted = affinity.translate(tool_dict['point'], currentx, currenty)
|
||||||
obj_fin.drills.append(
|
obj_fin.drills.append(
|
||||||
{
|
{
|
||||||
@@ -518,8 +531,24 @@ class Panelize(FlatCAMTool):
|
|||||||
"tool": tool_dict['tool']
|
"tool": tool_dict['tool']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
drill_nr += 1
|
||||||
|
disp_number = int(np.interp(drill_nr, [0, geo_len_drills], [0, 100]))
|
||||||
|
|
||||||
|
if disp_number > old_disp_number and disp_number <= 100:
|
||||||
|
self.app.proc_container.update_view_text(' %s: %d D:%d%%' %
|
||||||
|
(_("Copy"),
|
||||||
|
int(element),
|
||||||
|
disp_number))
|
||||||
|
old_disp_number = disp_number
|
||||||
|
|
||||||
if panel_obj.slots:
|
if panel_obj.slots:
|
||||||
|
slot_nr = 0
|
||||||
for tool_dict in panel_obj.slots:
|
for tool_dict in panel_obj.slots:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
start_offseted = affinity.translate(tool_dict['start'], currentx, currenty)
|
start_offseted = affinity.translate(tool_dict['start'], currentx, currenty)
|
||||||
stop_offseted = affinity.translate(tool_dict['stop'], currentx, currenty)
|
stop_offseted = affinity.translate(tool_dict['stop'], currentx, currenty)
|
||||||
obj_fin.slots.append(
|
obj_fin.slots.append(
|
||||||
@@ -529,12 +558,24 @@ class Panelize(FlatCAMTool):
|
|||||||
"tool": tool_dict['tool']
|
"tool": tool_dict['tool']
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
slot_nr += 1
|
||||||
|
disp_number = int(np.interp(slot_nr, [0, geo_len_slots], [0, 100]))
|
||||||
|
|
||||||
|
if disp_number > old_disp_number and disp_number <= 100:
|
||||||
|
self.app.proc_container.update_view_text(' %s: %d S:%d%%' %
|
||||||
|
(_("Copy"),
|
||||||
|
int(element),
|
||||||
|
disp_number))
|
||||||
|
old_disp_number = disp_number
|
||||||
|
|
||||||
currentx += lenghtx
|
currentx += lenghtx
|
||||||
currenty += lenghty
|
currenty += lenghty
|
||||||
|
|
||||||
obj_fin.create_geometry()
|
obj_fin.create_geometry()
|
||||||
obj_fin.zeros = panel_obj.zeros
|
obj_fin.zeros = panel_obj.zeros
|
||||||
obj_fin.units = panel_obj.units
|
obj_fin.units = panel_obj.units
|
||||||
|
self.app.proc_container.update_view_text('')
|
||||||
|
|
||||||
def job_init_geometry(obj_fin, app_obj):
|
def job_init_geometry(obj_fin, app_obj):
|
||||||
currentx = 0.0
|
currentx = 0.0
|
||||||
@@ -555,46 +596,153 @@ class Panelize(FlatCAMTool):
|
|||||||
|
|
||||||
obj_fin.solid_geometry = []
|
obj_fin.solid_geometry = []
|
||||||
|
|
||||||
|
# create the initial structure on which to create the panel
|
||||||
if isinstance(panel_obj, FlatCAMGeometry):
|
if isinstance(panel_obj, FlatCAMGeometry):
|
||||||
obj_fin.multigeo = panel_obj.multigeo
|
obj_fin.multigeo = panel_obj.multigeo
|
||||||
obj_fin.tools = deepcopy(panel_obj.tools)
|
obj_fin.tools = deepcopy(panel_obj.tools)
|
||||||
if panel_obj.multigeo is True:
|
if panel_obj.multigeo is True:
|
||||||
for tool in panel_obj.tools:
|
for tool in panel_obj.tools:
|
||||||
obj_fin.tools[tool]['solid_geometry'][:] = []
|
obj_fin.tools[tool]['solid_geometry'][:] = []
|
||||||
|
elif isinstance(panel_obj, FlatCAMGerber):
|
||||||
if isinstance(panel_obj, FlatCAMGerber):
|
|
||||||
obj_fin.apertures = deepcopy(panel_obj.apertures)
|
obj_fin.apertures = deepcopy(panel_obj.apertures)
|
||||||
for ap in obj_fin.apertures:
|
for ap in obj_fin.apertures:
|
||||||
obj_fin.apertures[ap]['geometry'] = list()
|
obj_fin.apertures[ap]['geometry'] = list()
|
||||||
|
|
||||||
|
# find the number of polygons in the source solid_geometry
|
||||||
|
geo_len = 0
|
||||||
|
if isinstance(panel_obj, FlatCAMGeometry):
|
||||||
|
if panel_obj.multigeo is True:
|
||||||
|
for tool in panel_obj.tools:
|
||||||
|
try:
|
||||||
|
for pol in panel_obj.tools[tool]['solid_geometry']:
|
||||||
|
geo_len += 1
|
||||||
|
except TypeError:
|
||||||
|
geo_len = 1
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
for pol in panel_obj.solid_geometry:
|
||||||
|
geo_len += 1
|
||||||
|
except TypeError:
|
||||||
|
geo_len = 1
|
||||||
|
elif isinstance(panel_obj, FlatCAMGerber):
|
||||||
|
for ap in panel_obj.apertures:
|
||||||
|
for elem in panel_obj.apertures[ap]['geometry']:
|
||||||
|
geo_len += 1
|
||||||
|
|
||||||
self.app.progress.emit(0)
|
self.app.progress.emit(0)
|
||||||
|
element = 0
|
||||||
for row in range(rows):
|
for row in range(rows):
|
||||||
currentx = 0.0
|
currentx = 0.0
|
||||||
|
|
||||||
for col in range(columns):
|
for col in range(columns):
|
||||||
|
element += 1
|
||||||
|
disp_number = 0
|
||||||
|
old_disp_number = 0
|
||||||
|
|
||||||
if isinstance(panel_obj, FlatCAMGeometry):
|
if isinstance(panel_obj, FlatCAMGeometry):
|
||||||
if panel_obj.multigeo is True:
|
if panel_obj.multigeo is True:
|
||||||
for tool in panel_obj.tools:
|
for tool in panel_obj.tools:
|
||||||
geo = translate_recursion(panel_obj.tools[tool]['solid_geometry'])
|
if self.app.abort_flag:
|
||||||
if isinstance(geo, list):
|
# graceful abort requested by the user
|
||||||
obj_fin.tools[tool]['solid_geometry'] += geo
|
raise FlatCAMApp.GracefulException
|
||||||
else:
|
|
||||||
obj_fin.tools[tool]['solid_geometry'].append(geo)
|
# geo = translate_recursion(panel_obj.tools[tool]['solid_geometry'])
|
||||||
|
# if isinstance(geo, list):
|
||||||
|
# obj_fin.tools[tool]['solid_geometry'] += geo
|
||||||
|
# else:
|
||||||
|
# obj_fin.tools[tool]['solid_geometry'].append(geo)
|
||||||
|
|
||||||
|
# calculate the number of polygons
|
||||||
|
geo_len = len(panel_obj.tools[tool]['solid_geometry'])
|
||||||
|
pol_nr = 0
|
||||||
|
for geo_el in panel_obj.tools[tool]['solid_geometry']:
|
||||||
|
trans_geo = translate_recursion(geo_el)
|
||||||
|
obj_fin.tools[tool]['solid_geometry'].append(trans_geo)
|
||||||
|
|
||||||
|
pol_nr += 1
|
||||||
|
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
|
||||||
|
|
||||||
|
if disp_number > old_disp_number and disp_number <= 100:
|
||||||
|
self.app.proc_container.update_view_text(' %s: %d %d%%' %
|
||||||
|
(_("Copy"),
|
||||||
|
int(element),
|
||||||
|
disp_number))
|
||||||
|
old_disp_number = disp_number
|
||||||
else:
|
else:
|
||||||
geo = translate_recursion(panel_obj.solid_geometry)
|
# geo = translate_recursion(panel_obj.solid_geometry)
|
||||||
if isinstance(geo, list):
|
# if isinstance(geo, list):
|
||||||
obj_fin.solid_geometry += geo
|
# obj_fin.solid_geometry += geo
|
||||||
else:
|
# else:
|
||||||
obj_fin.solid_geometry.append(geo)
|
# obj_fin.solid_geometry.append(geo)
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
|
try:
|
||||||
|
# calculate the number of polygons
|
||||||
|
geo_len = len(panel_obj.solid_geometry)
|
||||||
|
except TypeError:
|
||||||
|
geo_len = 1
|
||||||
|
pol_nr = 0
|
||||||
|
try:
|
||||||
|
for geo_el in panel_obj.solid_geometry:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
|
trans_geo = translate_recursion(geo_el)
|
||||||
|
obj_fin.solid_geometry.append(trans_geo)
|
||||||
|
|
||||||
|
pol_nr += 1
|
||||||
|
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
|
||||||
|
|
||||||
|
if disp_number > old_disp_number and disp_number <= 100:
|
||||||
|
self.app.proc_container.update_view_text(' %s: %d %d%%' %
|
||||||
|
(_("Copy"),
|
||||||
|
int(element),
|
||||||
|
disp_number))
|
||||||
|
old_disp_number = disp_number
|
||||||
|
except TypeError:
|
||||||
|
trans_geo = translate_recursion(panel_obj.solid_geometry)
|
||||||
|
obj_fin.solid_geometry.append(trans_geo)
|
||||||
else:
|
else:
|
||||||
geo = translate_recursion(panel_obj.solid_geometry)
|
# geo = translate_recursion(panel_obj.solid_geometry)
|
||||||
if isinstance(geo, list):
|
# if isinstance(geo, list):
|
||||||
obj_fin.solid_geometry += geo
|
# obj_fin.solid_geometry += geo
|
||||||
else:
|
# else:
|
||||||
obj_fin.solid_geometry.append(geo)
|
# obj_fin.solid_geometry.append(geo)
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
|
try:
|
||||||
|
for geo_el in panel_obj.solid_geometry:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
|
trans_geo = translate_recursion(geo_el)
|
||||||
|
obj_fin.solid_geometry.append(trans_geo)
|
||||||
|
except TypeError:
|
||||||
|
trans_geo = translate_recursion(panel_obj.solid_geometry)
|
||||||
|
obj_fin.solid_geometry.append(trans_geo)
|
||||||
|
|
||||||
for apid in panel_obj.apertures:
|
for apid in panel_obj.apertures:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
|
try:
|
||||||
|
# calculate the number of polygons
|
||||||
|
geo_len = len(panel_obj.apertures[apid]['geometry'])
|
||||||
|
except TypeError:
|
||||||
|
geo_len = 1
|
||||||
|
pol_nr = 0
|
||||||
for el in panel_obj.apertures[apid]['geometry']:
|
for el in panel_obj.apertures[apid]['geometry']:
|
||||||
|
if self.app.abort_flag:
|
||||||
|
# graceful abort requested by the user
|
||||||
|
raise FlatCAMApp.GracefulException
|
||||||
|
|
||||||
new_el = dict()
|
new_el = dict()
|
||||||
if 'solid' in el:
|
if 'solid' in el:
|
||||||
geo_aper = translate_recursion(el['solid'])
|
geo_aper = translate_recursion(el['solid'])
|
||||||
@@ -610,14 +758,25 @@ class Panelize(FlatCAMTool):
|
|||||||
|
|
||||||
obj_fin.apertures[apid]['geometry'].append(deepcopy(new_el))
|
obj_fin.apertures[apid]['geometry'].append(deepcopy(new_el))
|
||||||
|
|
||||||
|
pol_nr += 1
|
||||||
|
disp_number = int(np.interp(pol_nr, [0, geo_len], [0, 100]))
|
||||||
|
|
||||||
|
if disp_number > old_disp_number and disp_number <= 100:
|
||||||
|
self.app.proc_container.update_view_text(' %s: %d %d%%' %
|
||||||
|
(_("Copy"),
|
||||||
|
int(element),
|
||||||
|
disp_number))
|
||||||
|
old_disp_number = disp_number
|
||||||
|
|
||||||
currentx += lenghtx
|
currentx += lenghtx
|
||||||
currenty += lenghty
|
currenty += lenghty
|
||||||
|
|
||||||
app_obj.log.debug("Found %s geometries. Creating a panel geometry cascaded union ..." %
|
# app_obj.log.debug("Found %s geometries. Creating a panel geometry cascaded union ..." %
|
||||||
len(obj_fin.solid_geometry))
|
# len(obj_fin.solid_geometry))
|
||||||
|
|
||||||
# obj_fin.solid_geometry = cascaded_union(obj_fin.solid_geometry)
|
# obj_fin.solid_geometry = cascaded_union(obj_fin.solid_geometry)
|
||||||
app_obj.log.debug("Finished creating a cascaded union for the panel.")
|
# app_obj.log.debug("Finished creating a cascaded union for the panel.")
|
||||||
|
self.app.proc_container.update_view_text('')
|
||||||
|
|
||||||
if isinstance(panel_obj, FlatCAMExcellon):
|
if isinstance(panel_obj, FlatCAMExcellon):
|
||||||
self.app.progress.emit(50)
|
self.app.progress.emit(50)
|
||||||
@@ -635,7 +794,7 @@ class Panelize(FlatCAMTool):
|
|||||||
"Final panel has {col} columns and {row} rows").format(
|
"Final panel has {col} columns and {row} rows").format(
|
||||||
text='[WARNING] ', col=columns, row=rows))
|
text='[WARNING] ', col=columns, row=rows))
|
||||||
|
|
||||||
proc = self.app.proc_container.new(_("Generating panel..."))
|
proc = self.app.proc_container.new(_("Working..."))
|
||||||
|
|
||||||
def job_thread(app_obj):
|
def job_thread(app_obj):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user