Parcourir la source

wxGUI: print warning when map is not found

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44728 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa il y a 14 ans
Parent
commit
864585ff42
2 fichiers modifiés avec 18 ajouts et 14 suppressions
  1. 15 9
      gui/wxpython/gui_modules/layertree.py
  2. 3 5
      gui/wxpython/gui_modules/utils.py

+ 15 - 9
gui/wxpython/gui_modules/layertree.py

@@ -47,7 +47,7 @@ from debug import Debug as Debug
 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:
@@ -1328,13 +1328,19 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         # 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))
@@ -1350,9 +1356,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                 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:

+ 3 - 5
gui/wxpython/gui_modules/utils.py

@@ -75,7 +75,7 @@ def GetTempfile(pref=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'
@@ -131,12 +131,10 @@ def GetLayerNameFromCmd(dcmd, fullyQualified = False, param = None,
                         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']