[GRASS-SVN] r57755 - grass/trunk/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Sep 19 21:31:50 PDT 2013


Author: annakrat
Date: 2013-09-19 21:31:50 -0700 (Thu, 19 Sep 2013)
New Revision: 57755

Modified:
   grass/trunk/gui/wxpython/animation/controller.py
   grass/trunk/gui/wxpython/animation/mapwindow.py
Log:
wxGUI/animation: export also legend overlay

Modified: grass/trunk/gui/wxpython/animation/controller.py
===================================================================
--- grass/trunk/gui/wxpython/animation/controller.py	2013-09-20 03:32:53 UTC (rev 57754)
+++ grass/trunk/gui/wxpython/animation/controller.py	2013-09-20 04:31:50 UTC (rev 57755)
@@ -498,6 +498,17 @@
                 frameId = self.animations[animWinIndex[i]].GetFrame(frameIndex)
                 bitmap = self.bitmapProviders[animWinIndex[i]].GetBitmap(frameId)
                 im = wx.ImageFromBitmap(bitmap)
+
+                # add legend if used
+                legend = self.animationData[animWinIndex[i]].legendCmd
+                if legend:
+                    legendBitmap = self.bitmapProviders[animWinIndex[i]].LoadOverlay(legend)
+                    x, y = self.mapwindows[animWinIndex[i]].GetOverlayPos()
+                    legImage = wx.ImageFromBitmap(legendBitmap)
+                    # not so nice result, can we handle the transparency otherwise?
+                    legImage.ConvertAlphaToMask()
+                    im.Paste(legImage, x, y)
+
                 if im.GetSize() != animWinSize[i]:
                     im.Rescale(*animWinSize[i])
                 image.Paste(im, *animWinPos[i])

Modified: grass/trunk/gui/wxpython/animation/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/animation/mapwindow.py	2013-09-20 03:32:53 UTC (rev 57754)
+++ grass/trunk/gui/wxpython/animation/mapwindow.py	2013-09-20 04:31:50 UTC (rev 57755)
@@ -212,7 +212,12 @@
             self.UpdateDrawing()
             self._tmpMousePos = current
 
+    def GetOverlayPos(self):
+        """!Returns x, y position in pixels"""
+        rect = self._pdc.GetIdBounds(1)
+        return rect.GetX(), rect.GetY()
 
+
 class BitmapProvider(object):
     """!Class responsible for loading data and providing bitmaps"""
     def __init__(self, frame, bitmapPool, imageWidth=640, imageHeight=480, nprocs=4):



More information about the grass-commit mailing list