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

View File

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