[GRASS-SVN] r43009 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 5 12:12:41 EDT 2010


Author: martinl
Date: 2010-08-05 16:12:41 +0000 (Thu, 05 Aug 2010)
New Revision: 43009

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
Log:
wxGUI/nviz: fix query surface/vector toolbar


Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2010-08-04 21:53:25 UTC (rev 43008)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2010-08-05 16:12:41 UTC (rev 43009)
@@ -1194,30 +1194,34 @@
     def GetWindow(self):
         """!Get map window"""
         return self.MapWindow
-    
+
+    def _OnQuery(self):
+        """!Internal method used by OnQuery*() methods"""
+        # switch GIS Manager to output console to show query results
+        self._layerManager.notebook.SetSelection(1)
+        
+        self.MapWindow.mouse['box'] = "point"
+        self.MapWindow.zoomtype = 0
+        
+        # change the cursor
+        self.MapWindow.SetCursor(self.cursors["cross"])
+        
     def OnQueryDisplay(self, event):
-        """!Query currrent raster/vector map layers (display mode)
+        """!Query currrent raster/vector map layers (display mode) -
+        2D view mode
         """
         if self.toolbars['map'].GetAction() == 'displayAttrb': # select previous action
             self.toolbars['map'].SelectDefault(event)
             return
-
+        
         self.toolbars['map'].action['desc'] = 'displayAttrb'
         
-        # switch GIS Manager to output console to show query results
-        self._layerManager.notebook.SetSelection(1)
-
         self.MapWindow.mouse['use'] = "query"
-        self.MapWindow.mouse['box'] = "point"
-        self.MapWindow.zoomtype = 0
-
-        # change the cursor
-        self.MapWindow.SetCursor(self.cursors["cross"])
-
+        self._OnQuery()
+        
     def OnQueryModify(self, event):
+        """!Query vector map layer (edit mode) - 2D view mode
         """
-        Query vector map layer (edit mode)
-        """
         if self.toolbars['map'].GetAction() == 'modifyAttrb': # select previous action
             self.toolbars['map'].SelectDefault(event)
             return
@@ -1225,13 +1229,31 @@
         self.toolbars['map'].action['desc'] = 'modifyAttrb'
         
         self.MapWindow.mouse['use'] = "queryVector"
-        self.MapWindow.mouse['box'] = "point"
         self.MapWindow.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
-        self.MapWindow.zoomtype = 0
+        self._OnQuery()
+        
+    def OnNvizQuerySurface(self, event):
+        """!Query current surface in 3D view mode"""
+        if self.toolbars['map'].GetAction() == 'nvizQuerySurface':
+            self.toolbars['map'].SelectDefault(event)
+            return
+        
+        self.toolbars['map'].action['desc'] = 'nvizQuerySurface'
+        
+        self.MapWindow.mouse['use'] = "nvizQuerySurface"
+        self._OnQuery()
 
-        # change the cursor
-        self.MapWindow.SetCursor(self.cursors["cross"])
+    def OnNvizQueryVector(self, event):
+        """!Query current vector in 3D view mode"""
+        if self.toolbars['map'].GetAction() == 'nvizQueryVector':
+            self.toolbars['map'].SelectDefault(event)
+            return
         
+        self.toolbars['map'].action['desc'] = 'nvizQueryVector'
+        
+        self.MapWindow.mouse['use'] = "nvizQueryVector"
+        self._OnQuery()
+        
     def QueryMap(self, x, y):
         """!Query map layer features
         
@@ -1431,14 +1453,16 @@
                                  text = _("Query surface (raster map)"),
                                  kind = wx.ITEM_CHECK)
             toolsmenu.AppendItem(raster)
-            self.Bind(wx.EVT_MENU, self.OnQueryDisplay, raster)
-            if action == "displayAttrb":
-                display.Check(True)
+            self.Bind(wx.EVT_MENU, self.OnNvizQuerySurface, raster)
+            if action == "nvizQuerySurface":
+                raster.Check(True)
             vector = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
                                  text = _("Query vector map"),
                                  kind = wx.ITEM_CHECK)
             toolsmenu.AppendItem(vector)
-            self.Bind(wx.EVT_MENU, self.OnQueryDisplay, vector)
+            self.Bind(wx.EVT_MENU, self.OnNvizQueryVector, vector)
+            if action == "nvizQueryVector":
+                vector.Check(True)
         else:
             display = wx.MenuItem(parentMenu=toolsmenu, id=wx.ID_ANY,
                                   text=_("Query raster/vector map(s) (display mode)"),
@@ -1478,9 +1502,8 @@
         self.PopupMenu(toolsmenu)
         toolsmenu.Destroy()
 
-    def AddTmpVectorMapLayer(self, name, cats, useId=False, addLayer=True):
-        """
-        Add temporal vector map layer to map composition
+    def AddTmpVectorMapLayer(self, name, cats, useId = False, addLayer = True):
+        """!Add temporal vector map layer to map composition
 
         @param name name of map layer
         @param useId use feature id instead of category 
@@ -1539,9 +1562,8 @@
             return cmd
 
     def OnAnalyze(self, event):
+        """!Analysis tools menu
         """
-        Analysis tools menu
-        """
         point = wx.GetMousePosition()
         toolsmenu = wx.Menu()
         # Add items to the menu
@@ -1566,12 +1588,9 @@
         toolsmenu.Destroy()
 
     def OnMeasure(self, event):
+        """!Init measurement routine that calculates map distance
+        along transect drawn on map display
         """
-        Init measurement routine that calculates
-        map distance along transect drawn on
-        map display
-        """
-
         self.totaldist = 0.0 # total measured distance
 
         # switch GIS Manager to output console to show measure results
@@ -1638,9 +1657,8 @@
         return dist
 
     def Profile(self, event):
+        """!Init profile canvas and tools
         """
-        Init profile canvas and tools
-        """
         raster = []
         if self.tree.layer_selected and \
                 self.tree.GetPyData(self.tree.layer_selected)[0]['type'] == 'raster':
@@ -1702,9 +1720,8 @@
 
 
     def Histogram(self, event):
+        """!Init histogram display canvas and tools
         """
-        Init histogram display canvas and tools
-        """
         self.histogram = histogram.HistFrame(self,
                                              id=wx.ID_ANY, size=globalvar.HIST_WINDOW_SIZE,
                                              style=wx.DEFAULT_FRAME_STYLE)
@@ -1716,9 +1733,8 @@
 
 
     def OnDecoration(self, event):
+        """!Decorations overlay menu
         """
-        Decorations overlay menu
-        """
         point = wx.GetMousePosition()
         decmenu = wx.Menu()
         # Add items to the menu
@@ -1743,9 +1759,8 @@
         decmenu.Destroy()
 
     def OnAddBarscale(self, event):
+        """!Handler for scale/arrow map decoration menu selection.
         """
-        Handler for scale/arrow map decoration menu selection.
-        """
         if self.dialogs['barscale']:
             return
 
@@ -1776,9 +1791,8 @@
         self.MapWindow.mouse['use'] = 'pointer'        
 
     def OnAddLegend(self, event):
+        """!Handler for legend map decoration menu selection.
         """
-        Handler for legend map decoration menu selection.
-        """
         if self.dialogs['legend']:
             return
         
@@ -1807,9 +1821,8 @@
         self.MapWindow.mouse['use'] = 'pointer'
 
     def OnAddText(self, event):
+        """!Handler for text decoration menu selection.
         """
-        Handler for text decoration menu selection.
-        """
         if self.MapWindow.dragid > -1:
             id = self.MapWindow.dragid
         else:
@@ -1852,8 +1865,7 @@
         self.MapWindow.mouse['use'] = 'pointer'
 
     def GetOptData(self, dcmd, type, params, propwin):
-        """
-        Callback method for decoration overlay command generated by
+        """!Callback method for decoration overlay command generated by
         dialog created in menuform.py
         """
         # Reset comand and rendering options in render.Map. Always render decoration.
@@ -1871,8 +1883,7 @@
         self.MapWindow.ZoomToMap()
 
     def OnZoomToRaster(self, event):
-        """!
-        Set display extents to match selected raster map (ignore NULLs)
+        """!Set display extents to match selected raster map (ignore NULLs)
         """
         self.MapWindow.ZoomToMap(ignoreNulls = True)
 
@@ -1966,10 +1977,6 @@
 # end of class MapFrame
 
 class MapApp(wx.App):
-    """
-    MapApp class
-    """
-
     def OnInit(self):
         wx.InitAllImageHandlers()
         if __name__ == "__main__":

Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2010-08-04 21:53:25 UTC (rev 43008)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py	2010-08-05 16:12:41 UTC (rev 43009)
@@ -98,10 +98,12 @@
         # create nviz instance
         #
         if self.lmgr:
+            self.log = self.lmgr.goutput
             logerr = self.lmgr.goutput.cmd_stderr
             logmsg = self.lmgr.goutput.cmd_output
         else:
-            logerr = logmsg = None
+            self.log = logmsg = sys.stdout
+            logerr = sys.stderr
         self.nvizThread = NvizThread(logerr,
                                      self.parent.statusbarWin['progress'],
                                      logmsg)
@@ -246,40 +248,50 @@
     
     def OnLeftUp(self, event):
         self.ReleaseMouse()
-        if self.mouse["use"] == "query":
-            result = self._display.QueryMap(event.GetX(), event.GetY())
-            log = self.lmgr.goutput
-            if result:
-                self.qpoints.append((result['x'], result['y'], result['z']))
-                log.WriteLog("%-30s: %.3f" % (_("Easting"),   result['x']))
-                log.WriteLog("%-30s: %.3f" % (_("Northing"),  result['y']))
-                log.WriteLog("%-30s: %.3f" % (_("Elevation"), result['z']))
-                log.WriteLog("%-30s: %s" % (_("Surface map elevation"), result['elevation']))
-                log.WriteLog("%-30s: %s" % (_("Surface map color"), result['color']))
-                if len(self.qpoints) > 1:
-                    prev = self.qpoints[-2]
-                    curr = self.qpoints[-1]
-                    dxy = math.sqrt(pow(prev[0]-curr[0], 2) +
-                                    pow(prev[1]-curr[1], 2))
-                    dxyz = math.sqrt(pow(prev[0]-curr[0], 2) +
-                                     pow(prev[1]-curr[1], 2) +
-                                     pow(prev[2]-curr[2], 2))
-                    log.WriteLog("%-30s: %.3f" % (_("XY distance from previous"), dxy))
-                    log.WriteLog("%-30s: %.3f" % (_("XYZ distance from previous"), dxyz))
-                    log.WriteLog("%-30s: %.3f" % (_("Distance along surface"),
-                                                self._display.GetDistanceAlongSurface(result['id'],
-                                                                                      (curr[0], curr[1]),
-                                                                                      (prev[0], prev[1]),
-                                                                                      useExag = False)))
-                    log.WriteLog("%-30s: %.3f" % (_("Distance along exag. surface"),
-                                                self._display.GetDistanceAlongSurface(result['id'],
-                                                                                      (curr[0], curr[1]),
-                                                                                      (prev[0], prev[1]),
+        if self.mouse["use"] == "nvizQuerySurface":
+            self.OnQuerySurface(event)
+        elif self.mouse["use"] == "nvizQueryVector":
+            self.OnQueryVector(event)
+    
+    def OnQuerySurface(self, event):
+        """!Query surface on given position"""
+        result = self._display.QueryMap(event.GetX(), event.GetY())
+        if result:
+            self.qpoints.append((result['x'], result['y'], result['z']))
+            self.log.WriteLog("%-30s: %.3f" % (_("Easting"),   result['x']))
+            self.log.WriteLog("%-30s: %.3f" % (_("Northing"),  result['y']))
+            self.log.WriteLog("%-30s: %.3f" % (_("Elevation"), result['z']))
+            self.log.WriteLog("%-30s: %s" % (_("Surface map elevation"), result['elevation']))
+            self.log.WriteLog("%-30s: %s" % (_("Surface map color"), result['color']))
+            if len(self.qpoints) > 1:
+                prev = self.qpoints[-2]
+                curr = self.qpoints[-1]
+                dxy = math.sqrt(pow(prev[0]-curr[0], 2) +
+                                pow(prev[1]-curr[1], 2))
+                dxyz = math.sqrt(pow(prev[0]-curr[0], 2) +
+                                 pow(prev[1]-curr[1], 2) +
+                                 pow(prev[2]-curr[2], 2))
+                self.log.WriteLog("%-30s: %.3f" % (_("XY distance from previous"), dxy))
+                self.log.WriteLog("%-30s: %.3f" % (_("XYZ distance from previous"), dxyz))
+                self.log.WriteLog("%-30s: %.3f" % (_("Distance along surface"),
+                                              self._display.GetDistanceAlongSurface(result['id'],
+                                                                                    (curr[0], curr[1]),
+                                                                                    (prev[0], prev[1]),
+                                                                                    useExag = False)))
+                self.log.WriteLog("%-30s: %.3f" % (_("Distance along exag. surface"),
+                                              self._display.GetDistanceAlongSurface(result['id'],
+                                                                                    (curr[0], curr[1]),
+                                                                                    (prev[0], prev[1]),
                                                                                       useExag = True)))
-                log.WriteLog('-' * 80)
-            else:
-                log.WriteLog(_("No point on surface"))
-                log.WriteLog('-' * 80)
+            self.log.WriteCmdLog('-' * 80)
+        else:
+            self.log.WriteLog(_("No point on surface"))
+            self.log.WriteCmdLog('-' * 80)
+    
+    def OnQueryVector(self, event):
+        """!Query vector on given position"""
+        self.log.WriteWarning(_("Function not implemented yet"))
+        self.log.WriteCmdLog('-' * 80)
         
     def UpdateView(self, event):
         """!Change view settings"""



More information about the grass-commit mailing list