[GRASS-SVN] r53631 - grass-addons/grass7/gui/wxpython/wx.animation/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Oct 31 15:12:29 PDT 2012


Author: annakrat
Date: 2012-10-31 15:12:28 -0700 (Wed, 31 Oct 2012)
New Revision: 53631

Modified:
   grass-addons/grass7/gui/wxpython/wx.animation/animation/controller.py
   grass-addons/grass7/gui/wxpython/wx.animation/animation/dialogs.py
   grass-addons/grass7/gui/wxpython/wx.animation/animation/frame.py
   grass-addons/grass7/gui/wxpython/wx.animation/animation/temporal_manager.py
Log:
wx.animation: fix speed

Modified: grass-addons/grass7/gui/wxpython/wx.animation/animation/controller.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.animation/animation/controller.py	2012-10-31 21:24:42 UTC (rev 53630)
+++ grass-addons/grass7/gui/wxpython/wx.animation/animation/controller.py	2012-10-31 22:12:28 UTC (rev 53631)
@@ -176,7 +176,7 @@
 
     def GetTimeGranularity(self):
         if self.temporalMode == TemporalMode.TEMPORAL:
-            return self.temporalManager.GetGranularity(original = False)
+            return self.temporalManager.GetGranularity()
 
         return None
 

Modified: grass-addons/grass7/gui/wxpython/wx.animation/animation/dialogs.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.animation/animation/dialogs.py	2012-10-31 21:24:42 UTC (rev 53630)
+++ grass-addons/grass7/gui/wxpython/wx.animation/animation/dialogs.py	2012-10-31 22:12:28 UTC (rev 53631)
@@ -239,9 +239,9 @@
 
     def _timedelta(self, unit, number):
         if unit == "years":
-            delta = datetime.timedelta(days = 365 * number)
+            delta = datetime.timedelta(days = 365.25 * number)
         elif unit == "months":
-            delta = datetime.timedelta(days = 30 * number)
+            delta = datetime.timedelta(days = 30.4375 * number) # 365.25/12
         elif unit == "days":
             delta = datetime.timedelta(days = 1 * number)
         elif unit == "hours":

Modified: grass-addons/grass7/gui/wxpython/wx.animation/animation/frame.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.animation/animation/frame.py	2012-10-31 21:24:42 UTC (rev 53630)
+++ grass-addons/grass7/gui/wxpython/wx.animation/animation/frame.py	2012-10-31 22:12:28 UTC (rev 53631)
@@ -311,11 +311,11 @@
         self.indexField.Bind(wx.EVT_TEXT_ENTER, self.OnFrameIndexChanged)
 
     def UpdateFrame(self, index):
+        self._updateFrameIndex(index)
         if not self.enable:
             return
 
         self.slider.SetValue(index)
-        self._updateFrameIndex(index)
 
     def _updateFrameIndex(self, index):
         raise NotImplementedError

Modified: grass-addons/grass7/gui/wxpython/wx.animation/animation/temporal_manager.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.animation/animation/temporal_manager.py	2012-10-31 21:24:42 UTC (rev 53630)
+++ grass-addons/grass7/gui/wxpython/wx.animation/animation/temporal_manager.py	2012-10-31 22:12:28 UTC (rev 53631)
@@ -37,7 +37,11 @@
     POINT = 1
     INTERVAL = 2
 
+class GranularityMode:
+    ONE_UNIT = 1
+    ORIGINAL = 2
 
+
 class TemporalManager(object):
     """!Class for temporal data processing."""
     def __init__(self):
@@ -48,6 +52,8 @@
         self.temporalType = None
         self.temporalMapTime = None
 
+        self.granularityMode = GranularityMode.ONE_UNIT
+
         # Make sure the temporal database exists
         tgis.init()
 
@@ -133,31 +139,42 @@
 
         return True, None
 
-    def GetGranularity(self, original = True):
+    def GetGranularity(self):
         """!Returns temporal granularity of currently loaded timeseries."""
         if self.dataMode == DataMode.SIMPLE:
             gran = self.timeseriesInfo[self.timeseriesList[0]]['granularity']
-            if not original and 'unit' in self.timeseriesInfo[self.timeseriesList[0]]:
+            if 'unit' in self.timeseriesInfo[self.timeseriesList[0]]: # relative
+                if self.granularityMode == GranularityMode.ONE_UNIT:
+                    gran = 1
                 gran = "%(gran)s %(unit)s" % {'gran': gran,
                                               'unit': self.timeseriesInfo[self.timeseriesList[0]]['unit']}
+            elif self.granularityMode == GranularityMode.ONE_UNIT: # absolute
+                number, unit = gran.split()
+                gran = "1 %s" % unit
+
             return gran
 
         if self.dataMode == DataMode.MULTIPLE:
-            return self._getCommonGranularity(original)
+            return self._getCommonGranularity()
 
-    def _getCommonGranularity(self, original = True):
+    def _getCommonGranularity(self):
         allMaps = []
         for dataset in self.timeseriesList:
             maps = self.timeseriesInfo[dataset]['maps']
             allMaps.extend(maps)
 
         if self.temporalType == TemporalType.ABSOLUTE:
-            return tgis.compute_absolute_time_granularity(allMaps)
+            gran = tgis.compute_absolute_time_granularity(allMaps)
+            if self.granularityMode == GranularityMode.ONE_UNIT:
+                number, unit = gran.split()
+                gran = "1 %s" % unit
+            return gran
         if self.temporalType == TemporalType.RELATIVE:
             gran = tgis.compute_relative_time_granularity(allMaps)
-            if not original:
-                gran = "%(gran)s %(unit)s" % {'gran': gran,
-                                              'unit': self.timeseriesInfo[self.timeseriesList[0]]['unit']}
+            if self.granularityMode == GranularityMode.ONE_UNIT:
+                gran = 1
+            gran = "%(gran)s %(unit)s" % {'gran': gran,
+                                          'unit': self.timeseriesInfo[self.timeseriesList[0]]['unit']}
             return gran
 
 
@@ -204,13 +221,16 @@
         listOfMaps = []
         timeLabels = []
         gran = self.GetGranularity()
-        if self.temporalType == TemporalType.ABSOLUTE:
+        unit = None
+        if self.temporalType == TemporalType.ABSOLUTE and \
+           self.granularityMode == GranularityMode.ONE_UNIT:
             gran, unit = gran.split()
             gran = '%(one)d %(unit)s' % {'one': 1, 'unit': unit}
 
-        unit = None
-        if self.temporalType == TemporalType.RELATIVE:
+        elif self.temporalType == TemporalType.RELATIVE:
             unit = self.timeseriesInfo[timeseries]['unit']
+            if self.granularityMode == GranularityMode.ONE_UNIT:
+                gran = 1
         maps = sp.get_registered_maps_as_objects_by_granularity(gran = gran)
         if maps is not None:
             for map in maps:
@@ -245,13 +265,16 @@
         listOfMaps = []
         timeLabels = []
         gran = self.GetGranularity()
-        if self.temporalType == TemporalType.ABSOLUTE:
+        unit = None
+        if self.temporalType == TemporalType.ABSOLUTE and \
+           self.granularityMode == GranularityMode.ONE_UNIT:
             gran, unit = gran.split()
             gran = '%(one)d %(unit)s' % {'one': 1, 'unit': unit}
 
-        unit = None
         if self.temporalType == TemporalType.RELATIVE:
             unit = self.timeseriesInfo[timeseries]['unit']
+            if self.granularityMode == GranularityMode.ONE_UNIT:
+                gran = 1
 
         start, end = sp.get_valid_time()
 



More information about the grass-commit mailing list