[GRASS-SVN] r47189 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 20 12:10:33 EDT 2011
Author: annakrat
Date: 2011-07-20 09:10:33 -0700 (Wed, 20 Jul 2011)
New Revision: 47189
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
Log:
wxNviz: fix surface query (broken in r47169)
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-07-20 14:02:39 UTC (rev 47188)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2011-07-20 16:10:33 UTC (rev 47189)
@@ -1213,29 +1213,7 @@
def GetWindow(self):
"""!Get map window"""
return self.MapWindow
-
- 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()
-
- 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 raster or vector map layers by r/v.what
@@ -1429,40 +1407,20 @@
if self.toolbars['map']:
self.toolbars['map'].OnTool(event)
action = self.toolbars['map'].GetAction()
-
- if self.toolbars['nviz']:
- toolsmenu = wx.Menu()
- raster = wx.MenuItem(parentMenu = toolsmenu, id = wx.ID_ANY,
- text = _("Query surface (raster map)"),
- kind = wx.ITEM_CHECK)
- toolsmenu.AppendItem(raster)
- 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.OnNvizQueryVector, vector)
- if action == "nvizQueryVector":
- vector.Check(True)
-
- self.PopupMenu(toolsmenu)
- toolsmenu.Destroy()
- else:
- self.toolbars['map'].action['desc'] = 'queryMap'
- self.MapWindow.mouse['use'] = "query"
- if not self.IsStandalone():
- # switch to output console to show query results
- self._layerManager.notebook.SetSelectionByName('output')
-
- self.MapWindow.mouse['box'] = "point"
- self.MapWindow.zoomtype = 0
-
- # change the cursor
- self.MapWindow.SetCursor(self.cursors["cross"])
+ self.toolbars['map'].action['desc'] = 'queryMap'
+ self.MapWindow.mouse['use'] = "query"
+ if not self.IsStandalone():
+ # switch to output console to show query results
+ self._layerManager.notebook.SetSelectionByName('output')
+
+ self.MapWindow.mouse['box'] = "point"
+ self.MapWindow.zoomtype = 0
+
+ # change the cursor
+ self.MapWindow.SetCursor(self.cursors["cross"])
+
def AddTmpVectorMapLayer(self, name, cats, useId = False, addLayer = True):
"""!Add temporal vector map layer to map composition
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-07-20 14:02:39 UTC (rev 47188)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-07-20 16:10:33 UTC (rev 47189)
@@ -150,7 +150,6 @@
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_PAINT, self.OnPaint)
- self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouseAction)
self.Bind(wx.EVT_MOTION, self.OnMotion)
@@ -356,10 +355,15 @@
def OnLeftUp(self, event):
self.ReleaseMouse()
- if self.mouse["use"] == "nvizQuerySurface":
- self.OnQuerySurface(event)
- elif self.mouse["use"] == "nvizQueryVector":
- self.OnQueryVector(event)
+ if self.mouse["use"] == "query":
+ layers = self.GetSelectedLayer(multi = True)
+
+ for l in layers:
+ if l.GetType() == 'raster':
+ self.OnQuerySurface(event)
+ if l.GetType() == 'vector':
+ self.OnQueryVector(event)
+
elif self.mouse["use"] == 'cplane':
self.lmgr.nviz.OnCPlaneChangeDone(None)
idx = self._display.GetCPlaneCurrent()
@@ -371,15 +375,25 @@
self.lmgr.nviz.FindWindowByName('placeArrow').SetValue(False)
self.mouse['use'] = 'default'
self.SetCursor(self.cursors['default'])
-
+
+ event.Skip()
+
def OnQuerySurface(self, event):
"""!Query surface on given position"""
- result = self._display.QueryMap(event.GetX(), event.GetY())
+ size = self.GetClientSizeTuple()
+ result = self._display.QueryMap(event.GetX(), size[1] - 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']))
+ name = ''
+ for item in self.layers:
+ self.tree.GetPyData(item)[0]['nviz']
+ if self.tree.GetPyData(item)[0]['maplayer'].type == 'raster' and\
+ self.tree.GetPyData(item)[0]['nviz']['surface']['object']['id'] == result['id']:
+ name = self.tree.GetPyData(item)[0]['maplayer'].name
+ self.log.WriteLog("%-30s: %s" % (_("Surface map name"), name))
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:
@@ -409,7 +423,7 @@
def OnQueryVector(self, event):
"""!Query vector on given position"""
- self.log.WriteWarning(_("Function not implemented yet"))
+ self.log.WriteWarning(_("Vector querying is not implemented yet"))
self.log.WriteCmdLog('-' * 80)
def UpdateView(self, event):
More information about the grass-commit
mailing list