[GRASS-SVN] r54224 - in grass/trunk/gui/wxpython: gui_core mapdisp mapswipe nviz

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 6 09:34:58 PST 2012


Author: annakrat
Date: 2012-12-06 09:34:57 -0800 (Thu, 06 Dec 2012)
New Revision: 54224

Modified:
   grass/trunk/gui/wxpython/gui_core/mapdisp.py
   grass/trunk/gui/wxpython/mapdisp/mapwindow.py
   grass/trunk/gui/wxpython/mapswipe/frame.py
   grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
   grass/trunk/gui/wxpython/mapswipe/mapwindow.py
   grass/trunk/gui/wxpython/mapswipe/toolbars.py
   grass/trunk/gui/wxpython/nviz/mapwindow.py
Log:
wxGUI/mapswipe: add text label with map name

Modified: grass/trunk/gui/wxpython/gui_core/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapdisp.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/gui_core/mapdisp.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -564,7 +564,14 @@
         self._preparePan(mapWindow = win)
         
     def OnPointer(self, event):
+        """!Set pointer mode (dragging overlays)"""
+        toolbar = self.GetMapToolbar()
+        self.SwitchTool(toolbar, event)
+
         self.GetFirstWindow().mouse['use'] = 'pointer'
+        self.GetFirstWindow().SetCursor(self.cursors["default"])
+        self.GetSecondWindow().mouse['use'] = 'pointer'
+        self.GetSecondWindow().SetCursor(self.cursors["default"])
 
     def OnRender(self, event):
         """!Re-render map composition (each map layer)

Modified: grass/trunk/gui/wxpython/mapdisp/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/mapdisp/mapwindow.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -796,14 +796,14 @@
         self.dragimg.DoDrawImage(dc, moveto)
         self.dragimg.EndDrag()
         
-    def DragItem(self, id, event):
+    def DragItem(self, id, coords):
         """!Drag an overlay decoration item
         """
         if id == 99 or id == '' or id == None: return
         Debug.msg (5, "BufferedWindow.DragItem(): id=%d" % id)
         x, y = self.lastpos
-        dx = event.GetX() - x
-        dy = event.GetY() - y
+        dx = coords[0] - x
+        dy = coords[1] - y
         self.pdc.SetBackground(wx.Brush(self.GetBackgroundColour()))
         r = self.pdc.GetIdBounds(id)
         
@@ -826,7 +826,7 @@
         r = r.Union(r2)
         r.Inflate(4,4)
         self.RefreshRect(r, False)
-        self.lastpos = (event.GetX(), event.GetY())
+        self.lastpos = (coords[0], coords[1])
                 
     def MouseDraw(self, pdc = None, begin = None, end = None):
         """!Mouse box or line from 'begin' to 'end'
@@ -1083,7 +1083,8 @@
         elif (self.mouse['use'] == 'pointer' and 
                 not digitToolbar and 
                 self.dragid != None):
-            self.DragItem(self.dragid, event)
+            coords = event.GetPositionTuple()
+            self.DragItem(self.dragid, coords)
         
         # dragging anything else - rubber band box or line
         else:
@@ -1128,13 +1129,13 @@
         
         elif self.mouse['use'] == 'pointer':
             # get decoration or text id
-            self.idlist = []
+            idlist = []
             self.dragid = ''
             self.lastpos = self.mouse['begin']
             idlist = self.pdc.FindObjects(self.lastpos[0], self.lastpos[1],
                                           self.hitradius)
             if 99 in idlist:
-                idlist.remove(99)                             
+                idlist.remove(99)
             if idlist != []:
                 self.dragid = idlist[0] #drag whatever is on top
         else:

Modified: grass/trunk/gui/wxpython/mapswipe/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/frame.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/mapswipe/frame.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -314,6 +314,7 @@
                     message += _("Map <%s> not found.") % maps[1]
                 GError(parent = self, message = message)
                 dlg.Destroy()
+            self.SetRasterNames()
             self.ZoomToMap()
 
         dlg.Destroy()
@@ -452,7 +453,21 @@
         self._mgr.Update()
         splitter.OnSashChanged(None)
         self.OnSize(None)
+        self.SetRasterNames()
 
+    def OnAddText(self, event):
+        """!Double click on text overlay
+
+        So far not implemented.
+        """
+        pass
+
+    def SetRasterNames(self):
+        if self.rasters['first']:
+            self.GetFirstWindow().SetRasterNameText(self.rasters['first'], 101)
+        if self.rasters['second']:
+            self.GetSecondWindow().SetRasterNameText(self.rasters['second'], 102)
+
     def GetMapToolbar(self):
         """!Returns toolbar with zooming tools"""
         return self.toolbars['swipeMap']

Modified: grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/mapswipe/g.gui.mapswipe.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -80,6 +80,8 @@
     if second:
         frame.SetSecondRaster(second)
 
+    frame.SetRasterNames()
+    frame.ZoomToMap()
     frame.Show()
 
     app.MainLoop()

Modified: grass/trunk/gui/wxpython/mapswipe/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/mapwindow.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/mapswipe/mapwindow.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -119,6 +119,38 @@
 
         return super(SwipeBufferedWindow, self).Draw(pdc, img, drawid, pdctype, coords)
         
+    def OnLeftDown(self, event):
+        """!Left mouse button pressed.
+
+        In case of 'pointer' mode, coordinates must be adjusted.
+        """
+        if self.mouse['use'] == 'pointer':
+            evX, evY = event.GetPositionTuple()[:]
+            imX, imY = self.GetImageCoords()
+            self.lastpos = evX + imX, evY + imY
+            # get decoration or text id
+            self.dragid = None
+            idlist = self.pdc.FindObjects(self.lastpos[0], self.lastpos[1],
+                                          self.hitradius)
+            if 99 in idlist:
+                idlist.remove(99)
+            if idlist:
+                self.dragid = idlist[0] #drag whatever is on top
+        else:
+            super(SwipeBufferedWindow, self).OnLeftDown(event)
+
+    def OnDragging(self, event):
+        """!Mouse dragging - overlay (text) is moving.
+
+        Coordinates must be adjusted.
+        """
+        if (self.mouse['use'] == 'pointer' and self.dragid != None):
+            evX, evY = event.GetPositionTuple()
+            imX, imY = self.GetImageCoords()
+            self.DragItem(self.dragid, (evX + imX, evY + imY))
+        else:
+            super(SwipeBufferedWindow, self).OnDragging(event)
+
     def TranslateImage(self, dx, dy):
         """!Translate image and redraw.
         """
@@ -126,8 +158,14 @@
 
         self.pdc.TranslateId(self.imageId, dx, dy)
         self.Refresh()
-        
 
+    def SetRasterNameText(self, name, textId):
+        """!Sets text label with map name."""
+        self.textdict[textId] = {'bbox': wx.Rect(), 'coords': [10, 10],
+                                 'font': self.GetFont(), 'color': wx.BLACK,
+                                 'rotation': 0, 'text': name,
+                                 'active': True}
+
     def MouseActions(self, event):
         """!Handle mouse events and if needed let parent frame know"""
         super(SwipeBufferedWindow, self).MouseActions(event)

Modified: grass/trunk/gui/wxpython/mapswipe/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/mapswipe/toolbars.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/mapswipe/toolbars.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -58,6 +58,9 @@
                                      ("erase", icons["erase"],
                                       self.parent.OnErase),
                                      (None, ), # creates separator
+                                     ("pointer", icons["pointer"],
+                                      self.parent.OnPointer,
+                                      wx.ITEM_CHECK),
                                      ("pan", icons["pan"],
                                       self.parent.OnPan,
                                       wx.ITEM_CHECK), # toggle tool

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-12-06 14:04:05 UTC (rev 54223)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2012-12-06 17:34:57 UTC (rev 54224)
@@ -693,7 +693,7 @@
                 
         if self.mouse['use'] == 'pointer':
             if self.dragid > 0:
-                self.DragItem(self.dragid, event)
+                self.DragItem(self.dragid, event.GetPositionTuple())
             
         if self.mouse['use'] == 'rotate':    
             dx, dy = event.GetX() - self.mouse['tmp'][0], event.GetY() - self.mouse['tmp'][1]
@@ -909,14 +909,14 @@
             self.render['quick'] = True
             self.Refresh(False)
             
-    def DragItem(self, id, event):
+    def DragItem(self, id, coords):
         """!Drag an overlay decoration item
         """
         if not id: return
         Debug.msg (5, "GLWindow.DragItem(): id=%d" % id)
         x, y = self.mouse['tmp']
-        dx = event.GetX() - x
-        dy = event.GetY() - y
+        dx = coords[0] - x
+        dy = coords[1] - y
         for texture in self.imagelist:
             if texture.id == id:
                 texture.MoveTexture(dx, dy)
@@ -925,7 +925,7 @@
         self.render['quick'] = True
         self.Refresh(False)
         
-        self.mouse['tmp'] = (event.GetX(), event.GetY()) 
+        self.mouse['tmp'] = coords
         
     def ZoomBack(self):
         """!Set previous view in history list



More information about the grass-commit mailing list