From 2e88bb41e755bfbb04afce384aeeeb452ccec696 Mon Sep 17 00:00:00 2001 From: anitagraser Date: Sun, 6 Apr 2014 18:10:26 +0200 Subject: [PATCH] export now runs as fast as possible, fixes #3 --- metadata.txt | 6 +++--- timemanagercontrol.py | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/metadata.txt b/metadata.txt index 3cfb907..64a81a7 100644 --- a/metadata.txt +++ b/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 diff --git a/timemanagercontrol.py b/timemanagercontrol.py index 34c5c1e..2dab448 100644 --- a/timemanagercontrol.py +++ b/timemanagercontrol.py @@ -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""" @@ -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): @@ -162,11 +162,14 @@ 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 @@ -174,10 +177,10 @@ def playAnimation(self): 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]: @@ -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):