[GRASS-SVN] r32663 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 10 06:39:01 EDT 2008
Author: martinl
Date: 2008-08-10 06:39:01 -0400 (Sun, 10 Aug 2008)
New Revision: 32663
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: check all mapsets in search patch when given layer name is not qualified
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-08-10 09:37:04 UTC (rev 32662)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2008-08-10 10:39:01 UTC (rev 32663)
@@ -17,6 +17,8 @@
import os
import sys
+import grass
+
import globalvar
import gcmd
import grassenv
@@ -57,12 +59,16 @@
except:
return None
-def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None):
+def GetLayerNameFromCmd(dcmd, fullyQualified=False, param=None,
+ layerType=None):
"""Get map name from GRASS command
@param dcmd GRASS command (given as list)
@param fullyQualified change map name to be fully qualified
@param force parameter otherwise 'input'/'map'
+ @param update change map name in command
+ @param layerType check also layer type ('raster', 'vector', '3d-raster', ...)
+
@return map name
@return '' if no map name found in command
"""
@@ -94,10 +100,23 @@
if idx < len(dcmd):
mapname = dcmd[idx].split('=')[1]
if fullyQualified and '@' not in mapname:
- dcmd[idx] = dcmd[idx].split('=')[0] + '=' + \
- mapname + '@' + grassenv.GetGRASSVariable('MAPSET')
- mapname = dcmd[idx].split('=')[1]
-
+ if layerType in ('raster', 'vector', '3d-raster'):
+ try:
+ if layerType == 'raster':
+ findType = 'cell'
+ else:
+ findType = layerType
+ result = grass.find_file(mapname, element=findType)
+ except AttributeError, e: # not found
+ return ''
+ if result:
+ mapname = result['fullname']
+ else:
+ mapname += '@' + grassenv.GetGRASSVariable('MAPSET')
+ else:
+ mapname += '@' + grassenv.GetGRASSVariable('MAPSET')
+ dcmd[idx] = dcmd[idx].split('=')[0] + '=' + mapname
+
return mapname
def GetValidLayerName(name):
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-10 09:37:04 UTC (rev 32662)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py 2008-08-10 10:39:01 UTC (rev 32663)
@@ -1131,8 +1131,18 @@
# set layer text to map name
if dcmd:
- opacity = int(self.GetPyData(layer)[0]['maplayer'].GetOpacity(float=True) * 100)
- mapname = utils.GetLayerNameFromCmd(dcmd, fullyQualified=True)
+ mapLayer = self.GetPyData(layer)[0]['maplayer']
+ opacity = int(mapLayer.GetOpacity(float=True) * 100)
+ mapname = utils.GetLayerNameFromCmd(dcmd, layerType=mapLayer.type,
+ fullyQualified=True)
+ if not mapname:
+ wx.MessageBox(parent=self,
+ message=_("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd),
+ caption=_("Error"),
+ style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+
+ return
+
self.SetItemText(layer, mapname + ' (opacity: ' + str(opacity) + '%)')
# update layer data
@@ -1142,12 +1152,9 @@
self.GetPyData(layer)[0]['cmd'] = dcmd
self.GetPyData(layer)[0]['propwin'] = propwin
- # check layer as active
- # self.CheckItem(layer, checked=True)
-
# change parameters for item in layers list in render.Map
self.ChangeLayer(layer)
-
+
if self.mapdisplay.toolbars['nviz'] and dcmd:
# update nviz session
mapLayer = self.GetPyData(layer)[0]['maplayer']
More information about the grass-commit
mailing list