[GRASS-SVN] r37029 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 6 14:10:22 EDT 2009
Author: martinl
Date: 2009-05-06 14:10:21 -0400 (Wed, 06 May 2009)
New Revision: 37029
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
Log:
wxGUI: auto-zomming to selected layer implemented
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2009-05-06 16:10:40 UTC (rev 37028)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2009-05-06 18:10:21 UTC (rev 37029)
@@ -2384,25 +2384,29 @@
"""
Set display extents to match selected raster map (ignore NULLs)
"""
- self.ZoomToMap(zoom=True)
+ self.ZoomToMap(ignoreNulls = True)
- def ZoomToMap(self, layer = None, zoom = False):
+ def ZoomToMap(self, layers = None, ignoreNulls = False, render = True):
"""
Set display extents to match selected raster
- or vector map.
+ or vector map(s).
+
+ @param layer list of layers to be zoom to
+ @param ignoreNulls True to ignore null-values
+ @param render True to re-render display
"""
zoomreg = {}
- if not layer:
- layer = self.GetSelectedLayer(multi = True)
+ if not layers:
+ layers = self.GetSelectedLayer(multi = True)
- if not layer:
+ if not layers:
return
rast = []
vect = []
updated = False
- for l in layer:
+ for l in layers:
# only raster/vector layers are currently supported
if l.type == 'raster':
rast.append(l.name)
@@ -2423,9 +2427,10 @@
self.ZoomHistory(self.Map.region['n'], self.Map.region['s'],
self.Map.region['e'], self.Map.region['w'])
+
+ if render:
+ self.UpdateMap()
- self.UpdateMap()
-
self.parent.StatusbarUpdate()
def ZoomToWind(self, event):
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2009-05-06 16:10:40 UTC (rev 37028)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2009-05-06 18:10:21 UTC (rev 37029)
@@ -104,6 +104,9 @@
'autoRendering': {
'enabled' : False
},
+ 'autoZooming' : {
+ 'enabled' : False
+ },
'statusbarMode': {
'selection' : 0
},
@@ -1093,10 +1096,23 @@
gridSizer.Add(item=autoRendering,
pos=(row, 0), span=(1, 2))
+
+ #
+ # auto-zoom
+ #
+ row += 1
+ autoZooming = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Enable auto-zooming to selected map layer"),
+ name="IsChecked")
+ autoZooming.SetValue(self.settings.Get(group='display', key='autoZooming', subkey='enabled'))
+ self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
+ gridSizer.Add(item=autoZooming,
+ pos=(row, 0), span=(1, 2))
+
sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
-
+
panel.SetSizer(border)
# bindings
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2009-05-06 16:10:40 UTC (rev 37028)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2009-05-06 18:10:21 UTC (rev 37029)
@@ -360,10 +360,8 @@
def OnZoomMap(self, event):
"""Zoom to selected map"""
- layer = self.mapcontent.GetListOfLayers()
+ self.mapdisplay.MapWindow.ZoomToMap(layers = self.mapcontent.GetListOfLayers())
- self.mapdisplay.MapWindow.ZoomToMap(layer=layer)
-
event.Skip()
class GCPToolbar(AbstractToolbar):
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2009-05-06 16:10:40 UTC (rev 37028)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2009-05-06 18:10:21 UTC (rev 37029)
@@ -1071,6 +1071,15 @@
cmd = self.GetPyData(layer)[0]['maplayer'].GetCmd(string=True)
if len(cmd) > 0:
self.lmgr.SetStatusText(cmd)
+
+ # set region if auto-zooming is enabled
+ if self.GetPyData(layer) and self.GetPyData(layer)[0]['cmd'] and \
+ UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
+ mapLayer = self.GetPyData(layer)[0]['maplayer']
+ if mapLayer.GetType() in ('raster', 'vector'):
+ render = self.mapdisplay.autoRender.IsChecked()
+ self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
+ render = render)
#
# update nviz tools
@@ -1280,6 +1289,14 @@
# change parameters for item in layers list in render.Map
self.ChangeLayer(layer)
+
+ # set region if auto-zooming is enabled
+ if dcmd and UserSettings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'):
+ mapLayer = self.GetPyData(layer)[0]['maplayer']
+ if mapLayer.GetType() in ('raster', 'vector'):
+ render = UserSettings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled')
+ self.mapdisplay.MapWindow.ZoomToMap(layers = [mapLayer,],
+ render = render)
if self.mapdisplay.toolbars['nviz'] and dcmd:
# update nviz session
More information about the grass-commit
mailing list