[GRASS-SVN] r31229 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 3 06:32:50 EDT 2008


Author: martinl
Date: 2008-05-03 06:32:50 -0400 (Sat, 03 May 2008)
New Revision: 31229

Modified:
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: 'set computational region from selected map' added to contextual menu (currently only for raster and vector elements) [sync'ed with develbr6]

Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-05-03 10:31:27 UTC (rev 31228)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-05-03 10:32:50 UTC (rev 31229)
@@ -213,7 +213,8 @@
             self.popupID7 = wx.NewId()
             self.popupID8 = wx.NewId()
             self.popupID9 = wx.NewId()
-                        
+            self.popupID10 = wx.NewId()
+
         self.popupMenu = wx.Menu()
         # general item
         self.popupMenu.Append(self.popupID1, text=_("Remove"))
@@ -238,6 +239,8 @@
             self.Bind(wx.EVT_MENU, self.OnPopupProperties, id=self.popupID3)
             self.popupMenu.Append(self.popupID9, text=_("Zoom to selected map"))
             self.Bind(wx.EVT_MENU, self.mapdisplay.MapWindow.ZoomToMap, id=self.popupID9)
+            self.popupMenu.Append(self.popupID10, text=_("Set computational region from selected map"))
+            self.Bind(wx.EVT_MENU, self.OnSetCompRegFromMap, id=self.popupID10)
 
         # specific items
         try:
@@ -306,6 +309,23 @@
         # print output to command log area
         self.gismgr.goutput.RunCmd(cmd)
 
+    def OnSetCompRegFromMap(self, event):
+        """Set computational region from selected map"""
+        mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+        mltype = self.GetPyData(self.layer_selected)[0]['type']
+
+        cmd = ['g.region',
+               '-p'] # print by default
+
+        # TODO: other elements
+        if mltype == 'raster':
+            cmd.append('rast=%s' % mapLayer.name)
+        elif mltype == 'vector':
+            cmd.append('vect=%s' % mapLayer.name)
+
+        # print output to command log area
+        self.gismgr.goutput.RunCmd(cmd)
+        
     def OnProfile(self, event):
         """Plot profile of given raster map layer"""
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']



More information about the grass-commit mailing list