[GRASS-SVN] r31984 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 3 11:59:35 EDT 2008
Author: martinl
Date: 2008-07-03 11:59:34 -0400 (Thu, 03 Jul 2008)
New Revision: 31984
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/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
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-07-03 15:21:55 UTC (rev 31983)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-07-03 15:59:34 UTC (rev 31984)
@@ -157,7 +157,7 @@
def OnMouseMotion(self, event):
pass
- def ZoomToMap(self, event):
+ def OnZoomToMap(self, event):
pass
def GetSelectedLayer(self, nviz=False, index=False):
@@ -2138,8 +2138,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.
"""
@@ -2155,7 +2168,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':
@@ -3651,7 +3667,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/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-03 15:21:55 UTC (rev 31983)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-03 15:59:34 UTC (rev 31984)
@@ -290,7 +290,7 @@
self.nvizClass.Reset()
self.init = False
- def ZoomToMap(self, event):
+ def OnZoomToMap(self, event):
"""
Set display extents to match selected raster
or vector map or volume.
@@ -302,7 +302,7 @@
if layer is None:
return
- Debug.msg (3, "GLWindow.ZoomToMap(): layer=%s, type=%s" % \
+ Debug.msg (3, "GLWindow.OnZoomToMap(): layer=%s, type=%s" % \
(layer.name, layer.type))
self.nvizClass.SetViewportDefault()
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2008-07-03 15:21:55 UTC (rev 31983)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2008-07-03 15:59:34 UTC (rev 31984)
@@ -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/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-03 15:21:55 UTC (rev 31983)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-03 15:59:34 UTC (rev 31984)
@@ -215,7 +215,9 @@
self.popupID9 = wx.NewId()
self.popupID10 = wx.NewId()
self.popupID11 = wx.NewId() # nviz
-
+ self.popupID12 = wx.NewId()
+ self.popupID13 = wx.NewId()
+
self.popupMenu = wx.Menu()
# general item
self.popupMenu.Append(self.popupID1, text=_("Remove"))
@@ -239,7 +241,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)
@@ -285,6 +287,10 @@
# raster layers (specific items)
#
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)
@@ -316,8 +322,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