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

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 4 20:23:21 PDT 2013


Author: annakrat
Date: 2013-09-04 20:23:21 -0700 (Wed, 04 Sep 2013)
New Revision: 57594

Modified:
   grass/trunk/gui/wxpython/animation/mapwindow.py
Log:
wxGUI/animation: move with legend

Modified: grass/trunk/gui/wxpython/animation/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/animation/mapwindow.py	2013-09-05 01:41:36 UTC (rev 57593)
+++ grass/trunk/gui/wxpython/animation/mapwindow.py	2013-09-05 03:23:21 UTC (rev 57594)
@@ -114,13 +114,14 @@
         self.parent = parent
         self._pdc = wx.PseudoDC()
         self._overlay = None
+        self._tmpMousePos = None
 
         BufferedWindow.__init__(self, parent=parent, id=id, style=style)
         self.SetBackgroundColour(wx.BLACK)
         self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
         self.Bind(wx.EVT_SIZE, self.OnSize)
+        self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseEvents)
 
-
     def Draw(self, dc):
         """!Draws bitmap."""
         Debug.msg(5, "AnimationWindow.Draw()")
@@ -151,7 +152,10 @@
 
     def DrawOverlay(self):
         self._pdc.BeginDrawing()
+        self._pdc.SetId(1)
         self._pdc.DrawBitmap(bmp=self._overlay, x=0, y=0)
+        self._pdc.SetIdBounds(1, wx.Rect(0, 0, self._overlay.GetWidth(),
+                                         self._overlay.GetHeight()))
         self._pdc.EndDrawing()
 
     def SetOverlay(self, bitmap):
@@ -161,9 +165,7 @@
             if self._overlay:
                 self._pdc.RemoveAll()
             self._overlay = bitmap
-            self._pdc.BeginDrawing()
-            self._pdc.DrawBitmap(bmp=bitmap, x=0, y=0)
-            self._pdc.EndDrawing()
+            self.DrawOverlay()
         else:
             self._overlay = None
             self._pdc.RemoveAll()
@@ -176,6 +178,33 @@
         if self._overlay:
             self._pdc.DrawToDC(dc)
 
+
+    def OnMouseEvents(self, event):
+        """!Handle mouse events."""
+        # If it grows larger, split it.
+        current = event.GetPosition()
+        if event.LeftDown():
+            self._dragid = None
+            idlist = self._pdc.FindObjects(current[0], current[1],
+                                           radius=10)
+            if 1 in idlist:
+                self._dragid = 1
+            self._tmpMousePos = current
+
+        elif event.LeftUp():
+            self._dragid = None
+            self._tmpMousePos = None
+
+        elif event.Dragging():
+            if self._dragid is None:
+                return
+            dx = current[0] - self._tmpMousePos[0]
+            dy = current[1] - self._tmpMousePos[1]
+            self._pdc.TranslateId(self._dragid, dx, dy)
+            self.UpdateDrawing()
+            self._tmpMousePos = current
+
+
 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