[GRASS-SVN] r31985 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 3 12:05:41 EDT 2008


Author: martinl
Date: 2008-07-03 12:05:41 -0400 (Thu, 03 Jul 2008)
New Revision: 31985

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: 'Zoom to selected map (ignore NULLs)' and 'Set computational region from selected map (ignore NULLs)' added to popup menu for raster layers, related to trac #157 
(merged from trunk, r31984)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-07-03 15:59:34 UTC (rev 31984)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp.py	2008-07-03 16:05:41 UTC (rev 31985)
@@ -2074,8 +2074,21 @@
 
         return removed
 
-    def ZoomToMap(self, event):
+    def OnZoomToMap(self, event):
         """
+        Set display extents to match selected raster (including NULLs)
+        or vector map.
+        """
+        self.ZoomToMap()
+
+    def OnZoomToRaster(self, event):
+        """
+        Set display extents to match selected raster map (ignore NULLs)
+        """
+        self.ZoomToMap(zoom=True)
+        
+    def ZoomToMap(self, zoom=False):
+        """
         Set display extents to match selected raster
         or vector map.
         """
@@ -2099,7 +2112,10 @@
 
         # selected layer must be a valid map
         if layer.type in ('raster', 'rgb', 'his', 'shaded', 'arrow'):
-            self.Map.region = self.Map.GetRegion(rast="%s" % layer.name)
+            if layer.type == 'raster':
+                self.Map.region = self.Map.GetRegion(rast="%s" % layer.name, zoom=zoom)
+            else:
+                self.Map.region = self.Map.GetRegion(rast="%s" % layer.name)
         elif layer.type in ('vector', 'thememap', 'themechart'):
             if self.parent.digit and layer.name == self.parent.digit.map and \
                self.parent.digit.type == 'vdigit':
@@ -3509,7 +3525,7 @@
         # Add items to the menu
         zoommap = wx.MenuItem(zoommenu, wx.ID_ANY, _('Zoom to selected map'))
         zoommenu.AppendItem(zoommap)
-        self.Bind(wx.EVT_MENU, self.MapWindow.ZoomToMap, zoommap)
+        self.Bind(wx.EVT_MENU, self.MapWindow.OnZoomToMap, zoommap)
 
         zoomwind = wx.MenuItem(zoommenu, wx.ID_ANY, _('Zoom to computational region (set with g.region)'))
         zoommenu.AppendItem(zoomwind)

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-07-03 15:59:34 UTC (rev 31984)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/render.py	2008-07-03 16:05:41 UTC (rev 31985)
@@ -474,7 +474,7 @@
             self.height = 480
             return False
 
-    def GetRegion(self, rast=None, vect=None,
+    def GetRegion(self, rast=None, zoom=False, vect=None,
                   n=None, s=None, e=None, w=None, default=False):
         """
         Get region settings (g.region -upgc)
@@ -483,6 +483,7 @@
 
         @param rast raster name or None
         @param vect vector name or None
+        @param zoom zoom to raster (ignore NULLs)
         @param n,s,e,w force extent
         @param default force default region settings
         
@@ -516,10 +517,14 @@
             cmdList.append('w=%s' % w)
 
         if rast:
-            cmdList.append('rast=%s' % rast)
+            if zoom:
+                cmdList.append('zoom=%s' % rast)
+            else:
+                cmdList.append('rast=%s' % rast)
+
         if vect:
             cmdList.append('vect=%s' % vect)
-
+        
         try:
             cmdRegion = gcmd.Command(cmdList)
         except gcmd.CmdError, e:

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-07-03 15:59:34 UTC (rev 31984)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/wxgui_utils.py	2008-07-03 16:05:41 UTC (rev 31985)
@@ -214,7 +214,9 @@
             self.popupID8 = wx.NewId()
             self.popupID9 = wx.NewId()
             self.popupID10 = wx.NewId()
-
+            self.popupID12 = wx.NewId()
+            self.popupID13 = wx.NewId()
+            
         self.popupMenu = wx.Menu()
         # general item
         self.popupMenu.Append(self.popupID1, text=_("Remove"))
@@ -238,7 +240,7 @@
             self.popupMenu.Append(self.popupID3, text=_("Properties"))
             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.Bind(wx.EVT_MENU, self.mapdisplay.MapWindow.OnZoomToMap, 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)
 
@@ -281,6 +283,10 @@
 
         # raster
         elif mltype and mltype == "raster":
+            self.popupMenu.Append(self.popupID12, text=_("Zoom to selected map (ignore NULLs)"))
+            self.Bind(wx.EVT_MENU, self.mapdisplay.MapWindow.OnZoomToRaster, id=self.popupID12)
+            self.popupMenu.Append(self.popupID13, text=_("Set computational region from selected map (ignore NULLs)"))
+            self.Bind(wx.EVT_MENU, self.OnSetCompRegFromRaster, id=self.popupID13)
             self.popupMenu.AppendSeparator()
             self.popupMenu.Append(self.popupID4, _("Histogram"))
             self.Bind (wx.EVT_MENU, self.OnHistogram, id=self.popupID4)
@@ -309,8 +315,19 @@
         # print output to command log area
         self.gismgr.goutput.RunCmd(cmd)
 
+    def OnSetCompRegFromRaster(self, event):
+        """Set computational region from selected raster map (ignore NULLs)"""
+        mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
+
+        cmd = ['g.region',
+               '-p',
+               'zoom=%s' % mapLayer.name]
+        
+        # print output to command log area
+        self.gismgr.goutput.RunCmd(cmd)
+         
     def OnSetCompRegFromMap(self, event):
-        """Set computational region from selected map"""
+        """Set computational region from selected raster/vector map"""
         mapLayer = self.GetPyData(self.layer_selected)[0]['maplayer']
         mltype = self.GetPyData(self.layer_selected)[0]['type']
 



More information about the grass-commit mailing list