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