Bläddra i källkod

wxGUI/animation: export also legend overlay

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57755 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 år sedan
förälder
incheckning
cc38987ed9
2 ändrade filer med 16 tillägg och 0 borttagningar
  1. 11 0
      gui/wxpython/animation/controller.py
  2. 5 0
      gui/wxpython/animation/mapwindow.py

+ 11 - 0
gui/wxpython/animation/controller.py

@@ -498,6 +498,17 @@ class AnimationController(wx.EvtHandler):
                 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])

+ 5 - 0
gui/wxpython/animation/mapwindow.py

@@ -212,6 +212,11 @@ class AnimationWindow(BufferedWindow):
             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"""