Browse Source

wxGUI/iclass: do not allow the users to create training areas out of the region

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54535 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 years ago
parent
commit
26d6949bd2
1 changed files with 13 additions and 1 deletions
  1. 13 1
      gui/wxpython/iclass/digit.py

+ 13 - 1
gui/wxpython/iclass/digit.py

@@ -21,6 +21,7 @@ import wx
 from vdigit.mapwindow import VDigitWindow
 from vdigit.mapwindow import VDigitWindow
 from vdigit.wxdigit   import IVDigit
 from vdigit.wxdigit   import IVDigit
 from vdigit.wxdisplay import DisplayDriver, TYPE_AREA
 from vdigit.wxdisplay import DisplayDriver, TYPE_AREA
+from core.gcmd        import GWarning
 try:
 try:
     from grass.lib.gis    import G_verbose, G_set_verbose
     from grass.lib.gis    import G_verbose, G_set_verbose
     from grass.lib.vector import *
     from grass.lib.vector import *
@@ -28,6 +29,8 @@ try:
 except ImportError:
 except ImportError:
     pass
     pass
 
 
+import grass.script as grass
+
 class IClassVDigitWindow(VDigitWindow):
 class IClassVDigitWindow(VDigitWindow):
     """! Class similar to VDigitWindow but specialized for wxIClass."""
     """! Class similar to VDigitWindow but specialized for wxIClass."""
     def __init__(self, parent, giface, map, frame):
     def __init__(self, parent, giface, map, frame):
@@ -44,7 +47,16 @@ class IClassVDigitWindow(VDigitWindow):
         action = self.toolbar.GetAction()
         action = self.toolbar.GetAction()
         if not action:
         if not action:
             return
             return
-            
+
+        region = grass.region()
+        e, n = self.Pixel2Cell(event.GetPositionTuple())
+        if not ((region['s'] <= n <= region['n']) and (region['w'] <= e <= region['e'])):
+            GWarning(parent = self.parent, 
+                     message = _("You are trying to create a training area "
+                                 "outside the computational region. "
+                                 "Please, use g.region to set the appropriate region first."))
+            return
+
         cat = self.GetCurrentCategory()
         cat = self.GetCurrentCategory()
         
         
         if cat is None and action == "addLine":
         if cat is None and action == "addLine":