Explorar el Código

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á hace 12 años
padre
commit
26d6949bd2
Se han modificado 1 ficheros con 13 adiciones y 1 borrados
  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.wxdigit   import IVDigit
 from vdigit.wxdisplay import DisplayDriver, TYPE_AREA
+from core.gcmd        import GWarning
 try:
     from grass.lib.gis    import G_verbose, G_set_verbose
     from grass.lib.vector import *
@@ -28,6 +29,8 @@ try:
 except ImportError:
     pass
 
+import grass.script as grass
+
 class IClassVDigitWindow(VDigitWindow):
     """! Class similar to VDigitWindow but specialized for wxIClass."""
     def __init__(self, parent, giface, map, frame):
@@ -44,7 +47,16 @@ class IClassVDigitWindow(VDigitWindow):
         action = self.toolbar.GetAction()
         if not action:
             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()
         
         if cat is None and action == "addLine":