Kaynağa Gözat

wxGUI/swipe: check if raster exists

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52686 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 yıl önce
ebeveyn
işleme
93adfdbf37
1 değiştirilmiş dosya ile 18 ekleme ve 3 silme
  1. 18 3
      gui/wxpython/swipe/frame.py

+ 18 - 3
gui/wxpython/swipe/frame.py

@@ -9,7 +9,7 @@ from gui_core.mapdisp   import DoubleMapFrame
 from core.render        import Map
 from core.render        import Map
 from mapdisp            import statusbar as sb
 from mapdisp            import statusbar as sb
 from core.debug         import Debug
 from core.debug         import Debug
-from core.gcmd          import RunCommand
+from core.gcmd          import RunCommand, GError
 from mapdisp.statusbar  import EVT_AUTO_RENDER
 from mapdisp.statusbar  import EVT_AUTO_RENDER
 
 
 from swipe.toolbars  import SwipeMapToolbar, SwipeMainToolbar, SwipeMiscToolbar
 from swipe.toolbars  import SwipeMapToolbar, SwipeMainToolbar, SwipeMiscToolbar
@@ -280,8 +280,17 @@ class SwipeMapFrame(DoubleMapFrame):
         dlg = SwipeMapDialog(self, first = self.rasters['first'], second = self.rasters['second'])
         dlg = SwipeMapDialog(self, first = self.rasters['first'], second = self.rasters['second'])
         if dlg.ShowModal() == wx.ID_OK:
         if dlg.ShowModal() == wx.ID_OK:
             maps = dlg.GetValues()
             maps = dlg.GetValues()
-            self.SetFirstRaster(name = maps[0])
-            self.SetSecondRaster(name = maps[1])
+            res1 = self.SetFirstRaster(name = maps[0])
+            res2 = self.SetSecondRaster(name = maps[1])
+
+            if not (res1 and res2):
+                message = ''
+                if not res1:
+                    message += _("Map <%s> not found. ") % maps[0]
+                if not res2:
+                    message += _("Map <%s> not found.") % maps[1]
+                GError(parent = self, message = message)
+                dlg.Destroy()
 
 
         dlg.Destroy()
         dlg.Destroy()
         self.OnRender(event = None)
         self.OnRender(event = None)
@@ -293,6 +302,9 @@ class SwipeMapFrame(DoubleMapFrame):
             self.rasters['first'] = raster['fullname']
             self.rasters['first'] = raster['fullname']
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetFirstMap())
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetFirstMap())
             self.OnZoomToMap(event = None)
             self.OnZoomToMap(event = None)
+            return True
+
+        return False
 
 
     def SetSecondRaster(self, name):
     def SetSecondRaster(self, name):
         """!Set raster map to second Map"""
         """!Set raster map to second Map"""
@@ -301,6 +313,9 @@ class SwipeMapFrame(DoubleMapFrame):
             self.rasters['second'] = raster['fullname']
             self.rasters['second'] = raster['fullname']
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetSecondMap())
             self.SetLayer(name = raster['fullname'], mapInstance = self.GetSecondMap())
             self.OnZoomToMap(event = None)
             self.OnZoomToMap(event = None)
+            return True
+
+        return False
 
 
     def SetLayer(self, name, mapInstance):
     def SetLayer(self, name, mapInstance):
         """!Sets layer in Map.
         """!Sets layer in Map.