[GRASS-SVN] r32069 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 10 03:50:38 EDT 2008
Author: martinl
Date: 2008-07-10 03:50:38 -0400 (Thu, 10 Jul 2008)
New Revision: 32069
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:
nviz2/wxGUI: data layers can be loaded also to running nviz
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-07-10 06:20:32 UTC (rev 32068)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-07-10 07:50:38 UTC (rev 32069)
@@ -2606,6 +2606,7 @@
# nviz
elif name == "nviz":
import nviz
+
# check for GLCanvas and OpenGL
msg = None
if not nviz.haveGLCanvas:
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-10 06:20:32 UTC (rev 32068)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-10 07:50:38 UTC (rev 32069)
@@ -268,6 +268,13 @@
self.nvizClass.EraseMap()
self.SwapBuffers()
+ def IsLoaded(self, layer):
+ """Check if layer is already loaded"""
+ if self.Map.GetLayerIndex(layer) in self.object.keys():
+ return 1
+
+ return 0
+
def LoadDataLayers(self):
"""Load raster/vector from current layer tree
@@ -1880,7 +1887,7 @@
self.notebook.GetPage(self.page['vector']).Enable(False)
# use default values
- if data == {}:
+ if data == {} or data == None:
# attributes
for attr in ('topo', 'color'): # required
if layer and layer.type == 'raster':
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2008-07-10 06:20:32 UTC (rev 32068)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2008-07-10 07:50:38 UTC (rev 32069)
@@ -656,7 +656,7 @@
Returns list of layers of selected properties or list of all
layers.
- @param l_type layer type, e.g. raster/vector/wms/overlay
+ @param l_type layer type, e.g. raster/vector/wms/overlay (value or tuple of values)
@param l_mapset all layers from given mapset (only for maplayers)
@param l_name all layers with given name
@param l_active only layers with 'active' attribute set to True or False
@@ -667,7 +667,12 @@
selected = []
- if l_type == 'overlay':
+ if type(l_type) == type(''):
+ one_type = True
+ else:
+ one_type = False
+
+ if one_type and l_type == 'overlay':
list = self.overlays
else:
list = self.layers
@@ -675,8 +680,11 @@
# ["raster", "vector", "wms", ... ]
for layer in list:
# specified type only
- if l_type != None and layer.type != l_type:
- continue
+ if l_type != None:
+ if one_type and layer.type != l_type:
+ continue
+ elif not one_type and layer.type not in l_type:
+ continue
# mapset
if (l_mapset != None and type != 'overlay') and \
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-10 06:20:32 UTC (rev 32068)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-10 07:50:38 UTC (rev 32069)
@@ -818,7 +818,8 @@
# update progress bar range (mapwindow statusbar)
self.mapdisplay.onRenderGauge.SetRange(len(self.Map.GetListOfLayers(l_active=True)))
- if self.mapdisplay.toolbars['nviz']:
+ if self.mapdisplay.toolbars['nviz'] and \
+ self.GetPyData(item) is not None:
# nviz - load/unload data layer
mapLayer = self.GetPyData(item)[0]['maplayer']
if checked: # enable
@@ -907,7 +908,9 @@
pass
# update nviz tools
- if self.mapdisplay.toolbars['nviz']:
+ if self.mapdisplay.toolbars['nviz'] and \
+ self.GetPyData(self.layer_selected) is not None:
+ # update Nviz tool window
type = self.GetPyData(self.layer_selected)[0]['maplayer'].type
if type == 'raster':
self.mapdisplay.nvizToolWin.UpdatePage('surface')
@@ -1107,7 +1110,29 @@
# change parameters for item in layers list in render.Map
self.ChangeLayer(layer)
-
+
+ if self.mapdisplay.toolbars['nviz']:
+ # update nviz session
+ mapLayer = self.GetPyData(layer)[0]['maplayer']
+ mapWin = self.mapdisplay.MapWindow
+ if len(mapLayer.GetCmd()) > 0:
+ if mapLayer.type == 'raster':
+ self.mapdisplay.nvizToolWin.UpdatePage('surface')
+ self.mapdisplay.nvizToolWin.SetPage('surface')
+ if not mapWin.IsLoaded(mapLayer):
+ mapWin.LoadRaster(mapLayer)
+ elif mapLayer.type == 'vector':
+ self.mapdisplay.nvizToolWin.UpdatePage('vector')
+ self.mapdisplay.nvizToolWin.SetPage('vector')
+ if not mapWin.IsLoaded(mapLayer):
+ mapWin.LoadVector(mapLayer)
+
+ # reset view when first layer loaded
+ nlayers = len(mapWin.Map.GetListOfLayers(l_type=('raster', 'vector'),
+ l_active=True))
+ if nlayers < 2:
+ mapWin.ResetView()
+
def ReorderLayers(self):
"""Add commands from data associated with
any valid layers (checked or not) to layer list in order to
More information about the grass-commit
mailing list