Introduce activity monitor FlatCAMProcess.py.
This commit is contained in:
parent
87fdf0a581
commit
a34ca26a24
|
@ -23,6 +23,7 @@ from FlatCAMCommon import LoudDict
|
|||
from FlatCAMTool import *
|
||||
from FlatCAMShell import FCShell
|
||||
from FlatCAMDraw import FlatCAMDraw
|
||||
from FlatCAMProcess import *
|
||||
|
||||
|
||||
########################################
|
||||
|
@ -160,6 +161,8 @@ class App(QtCore.QObject):
|
|||
|
||||
self.clipboard = QtGui.QApplication.clipboard()
|
||||
|
||||
self.proc_container = FCVisibleProcessContainer(self.ui.activity_view)
|
||||
|
||||
self.project_filename = None
|
||||
|
||||
self.toggle_units_ignore = False
|
||||
|
@ -1552,6 +1555,7 @@ class App(QtCore.QObject):
|
|||
|
||||
App.log.debug("open_gerber()")
|
||||
|
||||
proc = self.proc_container.new("Opening Gerber")
|
||||
self.progress.emit(10)
|
||||
|
||||
# How the object should be initialized
|
||||
|
@ -1600,6 +1604,7 @@ class App(QtCore.QObject):
|
|||
self.file_opened.emit("gerber", filename)
|
||||
|
||||
self.progress.emit(100)
|
||||
proc.done()
|
||||
|
||||
# GUI feedback
|
||||
self.inform.emit("Opened: " + filename)
|
||||
|
|
|
@ -248,7 +248,7 @@ class FlatCAMActivityView(QtGui.QWidget):
|
|||
|
||||
self.icon = QtGui.QLabel(self)
|
||||
self.icon.setGeometry(0, 0, 12, 12)
|
||||
self.movie = QtGui.QMovie("share/717.GIF")
|
||||
self.movie = QtGui.QMovie("share/active.gif")
|
||||
self.icon.setMovie(self.movie)
|
||||
#self.movie.start()
|
||||
|
||||
|
@ -270,6 +270,7 @@ class FlatCAMActivityView(QtGui.QWidget):
|
|||
self.movie.start()
|
||||
self.text.setText(msg)
|
||||
|
||||
|
||||
class FlatCAMInfoBar(QtGui.QWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
|
|
@ -982,6 +982,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||
self.app.inform.emit('[warning] No polygon found.')
|
||||
return
|
||||
|
||||
proc = self.app.proc_container.new("Painting polygon.")
|
||||
|
||||
# Initializes the new geometry object
|
||||
def gen_paintarea(geo_obj, app_obj):
|
||||
assert isinstance(geo_obj, FlatCAMGeometry)
|
||||
|
@ -1000,6 +1002,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
|
|||
def job_thread(app_obj):
|
||||
name = self.options["name"] + "_paint"
|
||||
app_obj.new_object("geometry", name, gen_paintarea)
|
||||
proc.done()
|
||||
|
||||
self.app.inform.emit("Polygon Paint started ...")
|
||||
self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
from FlatCAMGUI import FlatCAMActivityView
|
||||
from PyQt4 import QtCore
|
||||
import weakref
|
||||
|
||||
|
||||
class FCProcess(object):
|
||||
|
||||
|
@ -8,7 +11,11 @@ class FCProcess(object):
|
|||
}
|
||||
self.descr = descr
|
||||
|
||||
def __del__(self):
|
||||
self.done()
|
||||
|
||||
def done(self):
|
||||
print "FCProcess.done()"
|
||||
for fcn in self.callbacks["done"]:
|
||||
fcn(self)
|
||||
|
||||
|
@ -34,40 +41,74 @@ class FCProcessContainer(object):
|
|||
|
||||
def add(self, proc):
|
||||
|
||||
self.procs.append(proc)
|
||||
self.procs.append(weakref.ref(proc))
|
||||
|
||||
def new(self, descr):
|
||||
proc = FCProcess(descr)
|
||||
|
||||
proc.connect(self.on_done, event="done")
|
||||
|
||||
def on_done(self, proc):
|
||||
# if proc not in self.procs:
|
||||
# self.procs.append(proc)
|
||||
self.add(proc)
|
||||
|
||||
self.on_change(proc)
|
||||
|
||||
return proc
|
||||
|
||||
def on_change(self, proc):
|
||||
pass
|
||||
|
||||
def on_done(self, proc):
|
||||
self.remove(proc)
|
||||
|
||||
def remove(self, proc):
|
||||
|
||||
if proc in self.procs:
|
||||
self.procs.remove(proc)
|
||||
to_be_removed = []
|
||||
|
||||
for pref in self.procs:
|
||||
if pref() == proc or pref() is None:
|
||||
to_be_removed.append(pref)
|
||||
|
||||
for pref in to_be_removed:
|
||||
self.procs.remove(pref)
|
||||
|
||||
|
||||
class FCVisibleProcessContainer(FCProcessContainer):
|
||||
class FCVisibleProcessContainer(QtCore.QObject, FCProcessContainer):
|
||||
something_changed = QtCore.pyqtSignal()
|
||||
|
||||
def __init__(self, view):
|
||||
assert isinstance(view, FlatCAMActivityView)
|
||||
|
||||
super(FCVisibleProcessContainer, self).__init__()
|
||||
#super(FCVisibleProcessContainer, self).__init__()
|
||||
FCProcessContainer.__init__(self)
|
||||
QtCore.QObject.__init__(self)
|
||||
|
||||
self.view = view
|
||||
|
||||
self.something_changed.connect(self.update_view)
|
||||
|
||||
def on_done(self, proc):
|
||||
print "FCVisibleProcessContainer.on_done()"
|
||||
super(FCVisibleProcessContainer, self).on_done(proc)
|
||||
|
||||
self.update_view()
|
||||
#self.update_view()
|
||||
self.something_changed.emit()
|
||||
|
||||
def on_change(self, proc):
|
||||
print "FCVisibleProcessContainer.on_change()"
|
||||
super(FCVisibleProcessContainer, self).on_change(proc)
|
||||
|
||||
#self.update_view()
|
||||
self.something_changed.emit()
|
||||
|
||||
def update_view(self):
|
||||
|
||||
print "FCVisibleProcessContainer.update_view()"
|
||||
if len(self.procs) == 0:
|
||||
self.view.set_idle()
|
||||
|
||||
elif len(self.procs) == 1:
|
||||
self.view.set_busy(self.procs[0].status_msg())
|
||||
self.view.set_busy(self.procs[0]().status_msg())
|
||||
|
||||
else:
|
||||
self.view.set_busy("%d processes running." % len(self.procs))
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in New Issue