Bläddra i källkod

wxGUI/animation: fix legend hiding

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57827 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 11 år sedan
förälder
incheckning
64c2a6a545

+ 9 - 6
gui/wxpython/animation/controller.py

@@ -409,6 +409,8 @@ class AnimationController(wx.EvtHandler):
                 self.mapwindows[animationData.windowIndex].SetOverlay(bitmap, x, y)
             except GException:
                 GError(message=_("Failed to display legend."))
+        else:
+            self.mapwindows[animationData.windowIndex].ClearOverlay()
 
     def EvaluateInput(self, animationData):
         stds = 0
@@ -486,6 +488,7 @@ class AnimationController(wx.EvtHandler):
         animWinSize = []
         animWinPos = []
         animWinIndex = []
+        legends = [anim.legendCmd for anim in self.animationData]
         # determine position and sizes of bitmaps
         for i, (win, anim) in enumerate(zip(self.mapwindows, self.animations)):
             if anim.IsActive():
@@ -501,16 +504,16 @@ class AnimationController(wx.EvtHandler):
             image = wx.EmptyImage(*size)
             image.Replace(0, 0, 0, 255, 255, 255)
             # collect bitmaps of all windows and paste them into the one
-            for i in range(len(animWinSize)):
-                frameId = self.animations[animWinIndex[i]].GetFrame(frameIndex)
-                bitmap = self.bitmapProviders[animWinIndex[i]].GetBitmap(frameId)
+            for i in animWinIndex:
+                frameId = self.animations[i].GetFrame(frameIndex)
+                bitmap = self.bitmapProviders[i].GetBitmap(frameId)
                 im = wx.ImageFromBitmap(bitmap)
 
                 # add legend if used
-                legend = self.animationData[animWinIndex[i]].legendCmd
+                legend = legends[i]
                 if legend:
-                    legendBitmap = self.bitmapProviders[animWinIndex[i]].LoadOverlay(legend)
-                    x, y = self.mapwindows[animWinIndex[i]].GetOverlayPos()
+                    legendBitmap = self.bitmapProviders[i].LoadOverlay(legend)
+                    x, y = self.mapwindows[i].GetOverlayPos()
                     legImage = wx.ImageFromBitmap(legendBitmap)
                     # not so nice result, can we handle the transparency otherwise?
                     legImage.ConvertAlphaToMask()

+ 1 - 0
gui/wxpython/animation/dialogs.py

@@ -530,6 +530,7 @@ class InputDialog(wx.Dialog):
         self.animationData.inputData = self.dataSelect.GetValue()
         sel = self.nDChoice.GetSelection()
         self.animationData.viewMode = self.nDChoice.GetClientData(sel)
+        self.animationData.legendCmd = None
         if self._tmpLegendCmd:
             if self.legend.IsChecked():
                 self.animationData.legendCmd = self._tmpLegendCmd

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

@@ -179,6 +179,13 @@ class AnimationWindow(BufferedWindow):
             self._pdc.RemoveAll()
         self.UpdateDrawing()
 
+    def ClearOverlay(self):
+        """!Clear overlay (legend) """
+        Debug.msg(3, "AnimationWindow.ClearOverlay()")
+        self._overlay = None
+        self._pdc.RemoveAll()
+        self.UpdateDrawing()
+
     def OnPaint(self, event):
         Debug.msg(5, "AnimationWindow.OnPaint()")
         # All that is needed here is to draw the buffer to screen