[GRASS-SVN] r55397 - grass/trunk/gui/wxpython/nviz
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Mar 15 12:47:42 PDT 2013
Author: annakrat
Date: 2013-03-15 12:47:42 -0700 (Fri, 15 Mar 2013)
New Revision: 55397
Modified:
grass/trunk/gui/wxpython/nviz/animation.py
grass/trunk/gui/wxpython/nviz/tools.py
Log:
wxGUI: continue replacing events (animationFinished, animationUpdateIndex)
Modified: grass/trunk/gui/wxpython/nviz/animation.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/animation.py 2013-03-15 19:13:56 UTC (rev 55396)
+++ grass/trunk/gui/wxpython/nviz/animation.py 2013-03-15 19:47:42 UTC (rev 55397)
@@ -18,10 +18,8 @@
import copy
import wx
-from wx.lib.newevent import NewEvent
-wxAnimationFinished, EVT_ANIM_FIN = NewEvent()
-wxAnimationUpdateIndex, EVT_ANIM_UPDATE_IDX = NewEvent()
+from grass.pydispatch.signal import Signal
class Animation:
"""!Class represents animation as a sequence of states (views).
@@ -32,9 +30,17 @@
def __init__(self, mapWindow, timer):
"""!Animation constructor
+ Signals:
+ animationFinished - emitted when animation finished
+ - attribute 'mode'
+ animationUpdateIndex - emitted during animation to update gui
+ - attributes 'index' and 'mode'
+
@param mapWindow glWindow where rendering takes place
@param timer timer for recording and replaying
"""
+ self.animationFinished = Signal('Animation.animationFinished')
+ self.animationUpdateIndex = Signal('Animation.animationUpdateIndex')
self.animationList = [] # view states
self.timer = timer
@@ -149,15 +155,11 @@
def PostFinishedEvent(self):
"""!Animation ends"""
- toolWin = self.mapWindow.GetToolWin()
- event = wxAnimationFinished(mode = self.mode)
- wx.PostEvent(toolWin, event)
+ self.animationFinished.emit(mode=self.mode)
def PostUpdateIndexEvent(self, index):
"""!Frame index changed, update tool window"""
- toolWin = self.mapWindow.GetToolWin()
- event = wxAnimationUpdateIndex(index = index, mode = self.mode)
- wx.PostEvent(toolWin, event)
+ self.animationUpdateIndex(index=index, mode=self.mode)
def StopSaving(self):
"""!Abort image files generation"""
Modified: grass/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py 2013-03-15 19:13:56 UTC (rev 55396)
+++ grass/trunk/gui/wxpython/nviz/tools.py 2013-03-15 19:47:42 UTC (rev 55397)
@@ -50,7 +50,6 @@
from core.gcmd import GMessage, RunCommand
from modules.colorrules import ThematicVectorTable
from core.settings import UserSettings
-from nviz.animation import EVT_ANIM_FIN, EVT_ANIM_UPDATE_IDX
from gui_core.widgets import ScrolledPanel, NumTextCtrl, FloatSlider, SymbolButton
from gui_core.gselect import Select
from core.debug import Debug
@@ -115,8 +114,8 @@
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
self.Bind(wx.EVT_SIZE, self.OnSize)
- self.Bind(EVT_ANIM_FIN, self.OnAnimationFinished)
- self.Bind(EVT_ANIM_UPDATE_IDX, self.OnAnimationUpdateIndex)
+ self.mapWindow.GetAnimation().animationFinished.connect(self.OnAnimationFinished)
+ self.mapWindow.GetAnimation().animationUpdateIndex.connect(self.OnAnimationUpdateIndex)
Debug.msg(3, "NvizToolWindow.__init__()")
@@ -2202,7 +2201,7 @@
count = anim.GetFrameCount()
self.FindWindowById(self.win['anim']['info']).SetLabel(str(count))
- def OnAnimationFinished(self, event):
+ def OnAnimationFinished(self, mode):
"""!Animation finished"""
anim = self.mapWindow.GetAnimation()
self.UpdateFrameIndex(index = 0)
@@ -2210,7 +2209,7 @@
slider = self.FindWindowById(self.win['anim']['frameIndex']['slider'])
text = self.FindWindowById(self.win['anim']['frameIndex']['text'])
- if event.mode == 'record':
+ if mode == 'record':
count = anim.GetFrameCount()
slider.SetMax(count)
self.UpdateFrameCount()
@@ -2226,12 +2225,12 @@
self.mapWindow.render['quick'] = False
self.mapWindow.Refresh(False)
- def OnAnimationUpdateIndex(self, event):
+ def OnAnimationUpdateIndex(self, index, mode):
"""!Animation: frame index changed"""
- if event.mode == 'record':
+ if mode == 'record':
self.UpdateFrameCount()
- elif event.mode == 'play':
- self.UpdateFrameIndex(index = event.index, goToFrame = False)
+ elif mode == 'play':
+ self.UpdateFrameIndex(index = index, goToFrame = False)
def OnSaveAnimation(self, event):
"""!Save animation as a sequence of images"""
More information about the grass-commit
mailing list