[GRASS-SVN] r60055 - in grass/trunk/gui/wxpython: mapdisp mapwin

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 3 10:05:49 PDT 2014


Author: martinl
Date: 2014-05-03 10:05:49 -0700 (Sat, 03 May 2014)
New Revision: 60055

Modified:
   grass/trunk/gui/wxpython/mapdisp/frame.py
   grass/trunk/gui/wxpython/mapwin/base.py
   grass/trunk/gui/wxpython/mapwin/buffered.py
Log:
wxGUI: set computational region extent interactiverly (#2277)


Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2014-05-03 13:49:33 UTC (rev 60054)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2014-05-03 17:05:49 UTC (rev 60055)
@@ -1231,6 +1231,10 @@
         """
         self.MapWindow.SetRegion(zoomOnly=False)
  
+    def OnSetExtentToWind(self, event):
+        """!Set compulational region extent interactively"""
+        self.MapWindow.SetModeDrawRegion()
+
     def OnSaveDisplayRegion(self, event):
         """!Save display extents to named region file.
         """
@@ -1249,8 +1253,9 @@
         for label, handler in ((_('Zoom to default region'), self.OnZoomToDefault),
                                (_('Zoom to saved region'), self.OnZoomToSaved),
                                (None, None),
-                               (_('Set computational region from display extent'), self.OnSetDisplayToWind),
-                               (_('Set computational region from named region'), self.OnSetWindToRegion),
+                               (_('Set computational region extent from display'), self.OnSetDisplayToWind),
+                               (_('Set computational region extent iteractively'), self.OnSetExtentToWind),
+                               (_('Set computational region from named region'),   self.OnSetWindToRegion),
                                (None, None),
                                (_('Save display geometry to named region'), self.OnSaveDisplayRegion),
                                (_('Save computational region to named region'), self.OnSaveWindRegion)):

Modified: grass/trunk/gui/wxpython/mapwin/base.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/base.py	2014-05-03 13:49:33 UTC (rev 60054)
+++ grass/trunk/gui/wxpython/mapwin/base.py	2014-05-03 17:05:49 UTC (rev 60055)
@@ -378,12 +378,18 @@
         self._setModeZoom(zoomType=-1)
 
     def _setModeZoom(self, zoomType):
+        self.zoomtype = zoomType
         self.mouse['use'] = "zoom"
         self.mouse['box'] = "box"
-        self.zoomtype = zoomType
         self.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
         self.SetNamedCursor('cross')
 
+    def SetModeDrawRegion(self):
+        self.mouse['use'] = 'drawRegion'
+        self.mouse['box'] = "box"
+        self.pen = wx.Pen(colour='Red', width=2, style=wx.SHORT_DASH)
+        self.SetNamedCursor('cross')
+
     def DisactivateWin(self):
         """!Use when the class instance is hidden in MapFrame."""
         raise NotImplementedError()

Modified: grass/trunk/gui/wxpython/mapwin/buffered.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/buffered.py	2014-05-03 13:49:33 UTC (rev 60054)
+++ grass/trunk/gui/wxpython/mapwin/buffered.py	2014-05-03 17:05:49 UTC (rev 60055)
@@ -1380,7 +1380,30 @@
             self.dragid = None
 
             self.mouseLeftUpPointer.emit(x=coordinates[0], y=coordinates[1])
-
+        
+        elif self.mouse['use'] == 'drawRegion':
+            coordinatesBegin = self.Pixel2Cell(self.mouse['begin'])
+            
+            if coordinatesBegin[0] < coordinates[0]:
+                west = coordinatesBegin[0]
+                east = coordinates[0]
+            else:
+                west = coordinates[0]
+                east = coordinatesBegin[0]
+            if coordinatesBegin[1] < coordinates[1]:
+                south = coordinatesBegin[1]
+                north = coordinates[1]
+            else:
+                south = coordinates[1]
+                north = coordinatesBegin[1]
+                
+            RunCommand('g.region',
+                       parent = self,
+                       n = north, s = south, e = east, w = west)
+            
+            # redraw map
+            self.UpdateMap(render = False)
+        
        # TODO: decide which coordinates to send (e, n, mouse['begin'], mouse['end'])
         self.mouseLeftUp.emit(x=coordinates[0], y=coordinates[1])
 
@@ -1821,6 +1844,8 @@
         if tmpreg:
             os.environ["GRASS_REGION"] = tmpreg
         
+        self.UpdateMap(render = False)
+        
     def SetRegion(self, zoomOnly=True):
         """!Set display extents/compulational region from named region
         file.



More information about the grass-commit mailing list