- remade the handlers for the Enable/Disable Project Tree context menu so they are threaded and activity is shown in the lower right corner of the main window

This commit is contained in:
Marius Stanciu
2019-09-07 10:55:45 +03:00
committed by Marius
parent 5d854a6f1b
commit 2c2bdf5002
3 changed files with 125 additions and 91 deletions

View File

@@ -3465,7 +3465,7 @@ class App(QtCore.QObject):
# here it is done the object plotting
def worker_task(t_obj):
# with self.proc_container.new(_("Plotting")):
with self.proc_container.new(_("Plotting")):
if isinstance(t_obj, FlatCAMCNCjob):
t_obj.plot(kind=self.defaults["cncjob_plot_kind"])
else:
@@ -9379,11 +9379,26 @@ The normal flow when working in FlatCAM is the following:</span></p>
:return:
"""
log.debug("Enabling plots ...")
self.inform.emit(_("Working ..."))
# self.inform.emit(_("Working ..."))
for obj in objects:
if obj.options['plot'] is False:
obj.options.set_change_callback(lambda x: None)
obj.options['plot'] = True
self.plots_updated.emit()
obj.options.set_change_callback(obj.on_options_change)
def worker_task(objects):
with self.proc_container.new(_("Enabling plots ...")):
for obj in objects:
# obj.options['plot'] = True
if isinstance(obj, FlatCAMCNCjob):
obj.plot(visible=True, kind=self.defaults["cncjob_plot_kind"])
else:
obj.plot(visible=True)
self.worker_task.emit({'fcn': worker_task, 'params': [objects]})
# self.plots_updated.emit()
def disable_plots(self, objects):
"""
@@ -9397,11 +9412,25 @@ The normal flow when working in FlatCAM is the following:</span></p>
return
log.debug("Disabling plots ...")
self.inform.emit(_("Working ..."))
# self.inform.emit(_("Working ..."))
for obj in objects:
if obj.options['plot'] is True:
obj.options.set_change_callback(lambda x: None)
obj.options['plot'] = False
self.plots_updated.emit()
obj.options.set_change_callback(obj.on_options_change)
# self.plots_updated.emit()
def worker_task(objects):
with self.proc_container.new(_("Disabling plots ...")):
for obj in objects:
# obj.options['plot'] = True
if isinstance(obj, FlatCAMCNCjob):
obj.plot(visible=False, kind=self.defaults["cncjob_plot_kind"])
else:
obj.plot(visible=False)
self.worker_task.emit({'fcn': worker_task, 'params': [objects]})
def toggle_plots(self, objects):
"""

View File

@@ -1162,6 +1162,11 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
else:
face_color = self.app.defaults['global_plot_fill']
if 'visible' not in kwargs:
visible = self.options['plot']
else:
visible = kwargs['visible']
# if the Follow Geometry checkbox is checked then plot only the follow geometry
if self.ui.follow_cb.get_value():
geometry = self.follow_geometry
@@ -1179,14 +1184,13 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
color[3] = 1
return color
with self.app.proc_container.new(_("Plotting")):
try:
if self.options["solid"]:
for g in geometry:
if type(g) == Polygon or type(g) == LineString:
self.add_shape(shape=g, color=color,
face_color=random_color() if self.options['multicolored']
else face_color, visible=self.options['plot'])
else face_color, visible=visible)
elif type(g) == Point:
pass
else:
@@ -1194,22 +1198,22 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
for el in g:
self.add_shape(shape=el, color=color,
face_color=random_color() if self.options['multicolored']
else face_color, visible=self.options['plot'])
else face_color, visible=visible)
except TypeError:
self.add_shape(shape=g, color=color,
face_color=random_color() if self.options['multicolored']
else face_color, visible=self.options['plot'])
else face_color, visible=visible)
else:
for g in geometry:
if type(g) == Polygon or type(g) == LineString:
self.add_shape(shape=g, color=random_color() if self.options['multicolored'] else 'black',
visible=self.options['plot'])
visible=visible)
elif type(g) == Point:
pass
else:
for el in g:
self.add_shape(shape=el, color=random_color() if self.options['multicolored'] else 'black',
visible=self.options['plot'])
visible=visible)
self.shapes.redraw()
except (ObjectDeleted, AttributeError):
self.shapes.clear(update=True)
@@ -2902,7 +2906,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
# except TypeError: # Element is not iterable...
# self.add_shape(shape=element, color=color, visible=visible, layer=0)
def plot(self, kind=None):
def plot(self, visible=None, kind=None):
# Does all the required setup and returns False
# if the 'ptint' option is set to False.
@@ -2929,25 +2933,26 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
# except (ObjectDeleted, AttributeError, KeyError):
# self.shapes.clear(update=True)
with self.app.proc_container.new(_("Plotting")):
# this stays for compatibility reasons, in case we try to open old projects
try:
__ = iter(self.solid_geometry)
except TypeError:
self.solid_geometry = [self.solid_geometry]
visible = visible if visible else self.options['plot']
try:
# Plot Excellon (All polygons?)
if self.options["solid"]:
for geo in self.solid_geometry:
self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF',
visible=self.options['plot'],
visible=visible,
layer=2)
else:
for geo in self.solid_geometry:
self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
self.add_shape(shape=geo.exterior, color='red', visible=visible)
for ints in geo.interiors:
self.add_shape(shape=ints, color='orange', visible=self.options['plot'])
self.add_shape(shape=ints, color='orange', visible=visible)
self.shapes.redraw()
except (ObjectDeleted, AttributeError):
@@ -6071,7 +6076,6 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
if not FlatCAMObj.plot(self):
return
with self.app.proc_container.new(_("Plotting")):
visible = visible if visible else self.options['plot']
if self.ui.annotation_cb.get_value() and self.ui.plot_cb.get_value():

View File

@@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
- added a method to gracefully exit from threaded tasks and implemented it for the NCC Tool and for the Paint Tool
- modified the on_about() function to reflect the reality in 2019 - FlatCAM it is an Open Source contributed software
- remade the handlers for the Enable/Disable Project Tree context menu so they are threaded and activity is shown in the lower right corner of the main window
6.09.2019