Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
export now runs as fast as possible, fixes #3
  • Loading branch information
anitagraser committed Apr 6, 2014
1 parent d74f865 commit 2e88bb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions metadata.txt
@@ -1,12 +1,12 @@
[general]
name=TimeManager
description=TimeManager adds time controls to QGIS. Using these time controls, you can animate vector features based on a time attribute. There is also an experimental raster layer support. You can create animations directly in the map window and export image series.
version=1.0.3
version=1.1.0
qgisMinimumVersion=2.3
author=Anita Graser
email=anitagraser@gmx.at
changelog=1.0.3
- fixed multi-threaded rendering bug #54
changelog=1.1.0
- export now runs as fast as possible, fixes #3
tags=spatio-temporal,time,animation
icon=icon.png
experimental=True
Expand Down
23 changes: 13 additions & 10 deletions timemanagercontrol.py
Expand Up @@ -36,7 +36,7 @@ def restoreDefaults(self):
self.projectHandler.writeSetting('active',True)
self.setTimeFrameType('days')
self.setTimeFrameSize(1)
self.animationActive = False
self.animationActivated = False

def initGui(self):
"""initialize the plugin dock"""
Expand Down Expand Up @@ -133,15 +133,15 @@ def unload(self):

def toggleAnimation(self):
"""toggle animation on/off"""
if self.animationActive: #self.timer.isActive():
self.animationActive = False #self.timer.stop()
if self.animationActivated: #self.timer.isActive():
self.animationActivated = False #self.timer.stop()
else:
self.animationActive = True #self.timer.start(self.animationFrameLength)
self.animationActivated = True #self.timer.start(self.animationFrameLength)
self.startAnimation()
self.animationFrameCounter = 0
expectedNumberOfFrames = self.timeLayerManager.getFrameCount()
if expectedNumberOfFrames == 0: # will be zero if no layer is time managed
self.animationActive = False #self.timer.stop()
self.animationActivated = False #self.timer.stop()
self.exportNameDigits = len(str(expectedNumberOfFrames))

def toggleOnOff(self,turnOn):
Expand All @@ -162,22 +162,25 @@ def startAnimation(self):

def waitAfterRenderComplete(self, painter=None):
"""when the map canvas signals renderComplete, wait defined millisec until next animation step"""
QTimer.singleShot(self.animationFrameLength,self.playAnimation)
if self.saveAnimation: # make animation/export run as fast as possible
self.playAnimation(painter)
else:
QTimer.singleShot(self.animationFrameLength,self.playAnimation)

def playAnimation(self):
def playAnimation(self,painter=None):
"""play animation in map window"""
if not self.animationActive:
if not self.animationActivated:
return

# check if the end of the project time extents has been reached
projectTimeExtents = self.timeLayerManager.getProjectTimeExtents()
currentTime = self.timeLayerManager.getCurrentTimePosition()

if self.saveAnimation:
self.guiControl.renderLabel(painter)
fileName = os.path.join(self.saveAnimationPath,"frame"+str(self.animationFrameCounter).zfill(self.exportNameDigits)+".PNG")
self.saveCurrentMap(fileName)
self.animationFrameCounter += 1

try:
if self.playBackwards:
if currentTime > projectTimeExtents[0]:
Expand Down Expand Up @@ -207,7 +210,7 @@ def stopAnimation(self):
if self.saveAnimation:
QMessageBox.information(self.iface.mainWindow(),'Export finished','The export finished successfully!')
self.saveAnimation = False
self.animationActive = False #self.timer.stop()
self.animationActivated = False #self.timer.stop()
self.guiControl.turnPlayButtonOff()

def resetAnimation(self):
Expand Down

0 comments on commit 2e88bb4

Please sign in to comment.