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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 4 09:13:57 PDT 2013


Author: wenzeslaus
Date: 2013-08-04 09:13:56 -0700 (Sun, 04 Aug 2013)
New Revision: 57396

Modified:
   grass/trunk/gui/wxpython/gui_core/toolbars.py
   grass/trunk/gui/wxpython/mapdisp/frame.py
   grass/trunk/gui/wxpython/nviz/mapwindow.py
Log:
wxGUI/mapwindow: implementing mouse moving signal (r57383) and zoom history signals (r57078) for nviz

Modified: grass/trunk/gui/wxpython/gui_core/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/toolbars.py	2013-08-04 15:07:32 UTC (rev 57395)
+++ grass/trunk/gui/wxpython/gui_core/toolbars.py	2013-08-04 16:13:56 UTC (rev 57396)
@@ -206,7 +206,9 @@
         try:
             id = getattr(self, tool)
         except AttributeError:
-            # this should raise an error
+            # TODO: test everything that this is not raised
+            # this error was ignored for a long time
+            raise AttributeError("Toolbar does not have a tool %s." % tool)
             return
         
         self.EnableTool(id, enable)

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2013-08-04 15:07:32 UTC (rev 57395)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2013-08-04 16:13:56 UTC (rev 57396)
@@ -329,6 +329,7 @@
         if not self.MapWindow3D:
             self.MapWindow3D = GLWindow(self, giface = self._giface, id = wx.ID_ANY, frame = self,
                                         Map = self.Map, tree = self.tree, lmgr = self._layerManager)
+            self._setUpMapWindow(self.MapWindow3D)
             self.MapWindow = self.MapWindow3D
             self.MapWindow.SetCursor(self.cursors["default"])
             

Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py	2013-08-04 15:07:32 UTC (rev 57395)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py	2013-08-04 16:13:56 UTC (rev 57396)
@@ -33,6 +33,7 @@
 from wx.glcanvas       import WX_GL_DEPTH_SIZE
 
 import grass.script as grass
+from grass.pydispatch.signal import Signal
 
 from core.gcmd          import GMessage, GException, GError
 from core.debug         import Debug
@@ -89,7 +90,20 @@
 
         MapWindow.__init__(self, parent=parent, giface=giface, Map=Map)
         self.Hide()
-        
+
+        # TODO: same signals as in BufferedWindow
+        # same interface is good, but how to ensure same names
+        # or avoid duplication, define in map window base class?
+
+        # Emitted when mouse us moving (mouse motion event)
+        # Parametres are x and y of the mouse position in map (cell) units
+        self.mouseMoving = Signal('GLWindow.mouseMoving')
+
+        # Emitted when the zoom history stack is emptied
+        self.zoomHistoryUnavailable = Signal('GLWindow.zoomHistoryUnavailable')
+        # Emitted when the zoom history stack is not empty
+        self.zoomHistoryAvailable = Signal('GLWindow.zoomHistoryAvailable')
+
         self.init = False
         self.initView = False
         self.context = None
@@ -658,7 +672,15 @@
         # double click    
         elif event.ButtonDClick():
             self.OnDClick(event)
-        
+
+        elif event.Moving():
+            pixelCoordinates = event.GetPositionTuple()[:]
+            coordinates = self.Pixel2Cell(pixelCoordinates)
+            # coordinates are none when no map is loaded
+            # TODO: handle in more clever way: check the state
+            if coordinates is not None:
+                self.mouseMoving.emit(x=coordinates[0], y=coordinates[1])
+
         event.Skip()
 
     def OnMouseWheel(self, event):
@@ -670,7 +692,7 @@
             return
             
         wheel = event.GetWheelRotation()
-        Debug.msg (5, "GLWindow.OnMouseMotion(): wheel = %d" % wheel)
+        Debug.msg (5, "GLWindow.OnMouseWheel(): wheel = %d" % wheel)
         if self.timerFly.IsRunning() and self.fly['mouseControl']:
             if wheel > 0:
                 self.ChangeFlySpeed(increase = True)
@@ -972,8 +994,7 @@
         
         # disable tool if stack is empty
         if len(self.viewhistory) < 2: # disable tool
-            toolbar = self.parent.GetMapToolbar()
-            toolbar.Enable('zoomback', enable = False)
+            self.zoomHistoryUnavailable.emit()
             
         # set view and update nviz view page
         self.lmgr.nviz.UpdateState(view = view[0], iview = view[1])
@@ -1008,13 +1029,10 @@
         
         # update toolbar
         if len(self.viewhistory) > 1:
-            enable = True
+            self.zoomHistoryAvailable.emit()
         else:
-            enable = False
-        
-        toolbar = self.parent.GetMapToolbar()
-        toolbar.Enable('zoomback', enable)
-        
+            self.zoomHistoryUnavailable.emit()
+
         return removed     
     
     def ResetViewHistory(self):



More information about the grass-commit mailing list