[GRASS-SVN] r44730 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 26 08:52:15 EST 2010


Author: martinl
Date: 2010-12-26 05:52:15 -0800 (Sun, 26 Dec 2010)
New Revision: 44730

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: print warning when map is not found
(merge r44728 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-12-26 13:50:45 UTC (rev 44729)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/layertree.py	2010-12-26 13:52:15 UTC (rev 44730)
@@ -47,7 +47,7 @@
 from icon import Icons as Icons
 from preferences import globalSettings as UserSettings
 from vdigit import haveVDigit
-from gcmd import GError
+from gcmd import GWarning
 try:
     import subprocess
 except:
@@ -1329,13 +1329,19 @@
         # set layer text to map name
         if dcmd:
             self.GetPyData(layer)[0]['cmd'] = dcmd
-            mapname = self._getLayerName(layer)
-            if not mapname:
-                GError(parent = self,
-                       message = _("Map <%s> not found.") % utils.GetLayerNameFromCmd(dcmd))
+            mapText  = self._getLayerName(layer)
+            mapName  = utils.GetLayerNameFromCmd(dcmd)
+            mapLayer = self.GetPyData(layer)[0]['maplayer']
+            self.SetItemText(layer, mapName)
+            
+            if not mapText or \
+                    (mapLayer and \
+                         not grass.find_file(name = mapName, element = mapLayer.GetType())['fullname']):
+                propwin.Hide()
+                GWarning(parent = self,
+                         message = _("Map <%s> not found.") % mapName)
                 return
-            self.SetItemText(layer, mapname)
-        
+            
         # update layer data
         if params:
             self.SetPyData(layer, (self.GetPyData(layer)[0], params))
@@ -1351,9 +1357,9 @@
                 render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
                 self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
                                                     render = render)
-        
+
+        # update nviz session        
         if self.mapdisplay.toolbars['nviz'] and dcmd:
-            # update nviz session
             mapLayer = self.GetPyData(layer)[0]['maplayer']
             mapWin = self.mapdisplay.MapWindow
             if len(mapLayer.GetCmd()) > 0:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-12-26 13:50:45 UTC (rev 44729)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py	2010-12-26 13:52:15 UTC (rev 44730)
@@ -75,7 +75,7 @@
 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'
@@ -131,12 +131,10 @@
                         findType = 'cell'
                     else:
                         findType = layerType
-                    result = grass.find_file(mapname, element=findType)
+                    mapset = grass.find_file(mapname, element=findType)['mapset']
                 except AttributeError, e: # not found
                     return ''
-                if result:
-                    mapset = result['mapset']
-                else:
+                if not mapset:
                     mapset = grass.gisenv()['MAPSET']
             else:
                 mapset = grass.gisenv()['MAPSET']



More information about the grass-commit mailing list