[GRASS-SVN] r60390 - grass/branches/releasebranch_7_0/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 21 05:55:27 PDT 2014


Author: annakrat
Date: 2014-05-21 05:55:26 -0700 (Wed, 21 May 2014)
New Revision: 60390

Modified:
   grass/branches/releasebranch_7_0/gui/wxpython/animation/controller.py
   grass/branches/releasebranch_7_0/gui/wxpython/animation/data.py
   grass/branches/releasebranch_7_0/gui/wxpython/animation/frame.py
Log:
wxGUI/animation: backport some fixes for rendering and storing temporary files from trunk (r59560, r59561)

Modified: grass/branches/releasebranch_7_0/gui/wxpython/animation/controller.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/animation/controller.py	2014-05-21 12:21:06 UTC (rev 60389)
+++ grass/branches/releasebranch_7_0/gui/wxpython/animation/controller.py	2014-05-21 12:55:26 UTC (rev 60390)
@@ -327,7 +327,8 @@
                     self.animations[i].SetActive(False)
                     continue
                 anim = [anim for anim in self.animationData if anim.windowIndex == i][0]
-                regions = anim.GetRegions()
+                w, h = self.mapwindows[i].GetClientSize()
+                regions = anim.GetRegions(w, h)
                 self.animations[i].SetFrames([HashCmds(cmdList, region)
                                               for cmdList, region in zip(anim.cmdMatrix, regions)])
                 self.animations[i].SetActive(True)
@@ -337,7 +338,8 @@
                     self.animations[i].SetActive(False)
                     continue
                 anim = [anim for anim in self.animationData if anim.windowIndex == i][0]
-                regions = anim.GetRegions()
+                w, h = self.mapwindows[i].GetClientSize()
+                regions = anim.GetRegions(w, h)
                 identifiers = sampleCmdMatrixAndCreateNames(anim.cmdMatrix,
                                                             mapNamesDict[anim.firstStdsNameType[0]],
                                                             regions)
@@ -371,7 +373,8 @@
 
     def _set2DData(self, animationData):
         opacities = [layer.opacity for layer in animationData.layerList if layer.active]
-        regions = animationData.GetRegions()
+        w, h = self.mapwindows[animationData.GetWindowIndex()].GetClientSize()
+        regions = animationData.GetRegions(w, h)
         self.bitmapProvider.SetCmds(animationData.cmdMatrix, opacities, regions)
 
     def _load3DData(self, animationData):

Modified: grass/branches/releasebranch_7_0/gui/wxpython/animation/data.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/animation/data.py	2014-05-21 12:21:06 UTC (rev 60389)
+++ grass/branches/releasebranch_7_0/gui/wxpython/animation/data.py	2014-05-21 12:55:26 UTC (rev 60390)
@@ -210,12 +210,12 @@
 
     zoomRegionValue = property(fset=SetZoomRegionValue, fget=GetZoomRegionValue)
 
-    def GetRegions(self):
-        self._computeRegions(self._mapCount, self._startRegion,
+    def GetRegions(self, width, height):
+        self._computeRegions(width, height, self._mapCount, self._startRegion,
                              self._endRegion, self._zoomRegionValue)
         return self._regions
 
-    def _computeRegions(self, count, startRegion, endRegion=None, zoomValue=None):
+    def _computeRegions(self, width, height, count, startRegion, endRegion=None, zoomValue=None):
         """Computes regions based on start region and end region or zoom value
         for each of the animation frames."""
         currRegion = dict(gcore.region())  # cast to dict, otherwise deepcopy error
@@ -255,6 +255,13 @@
                 if regions[i]['n'] < regions[i]['s'] or \
                    regions[i]['e'] < regions[i]['w']:
                         regions[i] = regions[i - 1]
+
+        for region in regions:
+            mapwidth = abs(region['e'] - region['w'])
+            mapheight = abs(region['n'] - region['s'])
+            region['nsres'] = mapheight / height
+            region['ewres'] = mapwidth / width
+
         self._regions = regions
 
     def __repr__(self):

Modified: grass/branches/releasebranch_7_0/gui/wxpython/animation/frame.py
===================================================================
--- grass/branches/releasebranch_7_0/gui/wxpython/animation/frame.py	2014-05-21 12:21:06 UTC (rev 60389)
+++ grass/branches/releasebranch_7_0/gui/wxpython/animation/frame.py	2014-05-21 12:55:26 UTC (rev 60390)
@@ -60,17 +60,15 @@
         # Make sure the temporal database exists
         tgis.init()
 
+        # create temporal directory and ensure it's deleted after programs ends (stored in MAPSET/.tmp/)
         global TMP_DIR
-        TMP_DIR = tempfile.mkdtemp()
+        TMP_DIR = gcore.tempdir()
 
         self.animations = [Animation() for i in range(MAX_COUNT)]
         self.windows = []
         self.animationPanel = AnimationsPanel(self, self.windows, initialCount=MAX_COUNT)
         bitmapPool = BitmapPool()
         mapFilesPool = MapFilesPool()
-        # create temporal directory and ensure it's deleted after programs ends
-#        tempDir = tempfile.mkdtemp()
-#        self.cleanUp = CleanUp(tempDir)
 
         self._progressDlg = None
         self._progressDlgMax = None



More information about the grass-commit mailing list