Merge pull request #551 from bensondaled/develop

added fps class variable to ImageView to enable consistent playback f…
This commit is contained in:
Ogi Moore 2020-06-12 21:55:46 -07:00 committed by GitHub
commit e1f6c08365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -176,6 +176,7 @@ class ImageView(QtGui.QWidget):
self.keysPressed = {}
self.playTimer = QtCore.QTimer()
self.playRate = 0
self.fps = 1 # 1 Hz by default
self.lastPlayTime = 0
self.normRgn = LinearRegionItem()
@ -368,11 +369,14 @@ class ImageView(QtGui.QWidget):
self.image = None
self.imageItem.clear()
def play(self, rate):
def play(self, rate=None):
"""Begin automatically stepping frames forward at the given rate (in fps).
This can also be accessed by pressing the spacebar."""
#print "play:", rate
if rate is None:
rate = self.fps
self.playRate = rate
if rate == 0:
self.playTimer.stop()
return
@ -421,9 +425,7 @@ class ImageView(QtGui.QWidget):
#print ev.key()
if ev.key() == QtCore.Qt.Key_Space:
if self.playRate == 0:
fps = (self.getProcessedImage().shape[0]-1) / (self.tVals[-1] - self.tVals[0])
self.play(fps)
#print fps
self.play()
else:
self.play(0)
ev.accept()