[GRASS-SVN] r47986 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 30 14:25:22 EDT 2011
Author: annakrat
Date: 2011-08-30 11:25:21 -0700 (Tue, 30 Aug 2011)
New Revision: 47986
Modified:
grass/trunk/gui/wxpython/gui_modules/layertree.py
grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
grass/trunk/gui/wxpython/gui_modules/wxnviz.py
Log:
wxNviz:fix reordering maps in layer tree
Modified: grass/trunk/gui/wxpython/gui_modules/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-08-30 17:58:19 UTC (rev 47985)
+++ grass/trunk/gui/wxpython/gui_modules/layertree.py 2011-08-30 18:25:21 UTC (rev 47986)
@@ -230,7 +230,9 @@
"""
if self.rerender:
if self.mapdisplay.statusbarWin['render'].GetValue():
- self.mapdisplay.MapWindow.UpdateMap(render = True)
+ self.mapdisplay.MapWindow2D.UpdateMap(render = True)
+ if self.lmgr.IsPaneShown('toolbarNviz'): # nviz
+ self.mapdisplay.MapWindow3D.UpdateMap(render = True)
self.rerender = False
event.Skip()
@@ -1082,7 +1084,7 @@
# nviz
#
if self.lmgr.IsPaneShown('toolbarNviz') and \
- self.GetPyData(item) is not None:
+ self.GetPyData(item) is not None and not self.rerender:
# nviz - load/unload data layer
mapLayer = self.GetPyData(item)[0]['maplayer']
self.mapdisplay.SetStatusText(_("Please wait, updating data..."), 0)
@@ -1275,6 +1277,8 @@
self.StopDragging()
dropTarget = event.GetItem()
self.flag = self.HitTest(event.GetPoint())[1]
+ if self.lmgr.IsPaneShown('toolbarNviz'):
+ self.mapdisplay.MapWindow.UnloadDataLayers(True)
if self.IsValidDropTarget(dropTarget):
self.UnselectAll()
if dropTarget != None:
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-30 17:58:19 UTC (rev 47985)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_mapdisp.py 2011-08-30 18:25:21 UTC (rev 47986)
@@ -99,6 +99,8 @@
self.layers = list()
# list of constant surfaces
self.constants = list()
+ # id of base surface (when vector is loaded and no surface exist)
+ self.baseId = -1
# list of cutting planes
self.cplanes = list()
# list of query points
@@ -926,13 +928,20 @@
elif ltype == '3d-raster':
self.UnloadRaster3d(layer)
elif ltype == 'vector':
- self.UnloadVector(layer, True)
- self.UnloadVector(layer, False)
-
+ maplayer = self.tree.GetPyData(layer)[0]['maplayer']
+ npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(maplayer)
+ if npoints > 0:
+ self.UnloadVector(layer, points = True)
+ if nlines > 0:
+ self.UnloadVector(layer, points = False)
+
except gcmd.GException, e:
gcmd.GError(parent = self,
message = e.value)
+ if force and self.baseId > 0: # unload base surface when quitting
+ ret = self._display.UnloadSurface(self.baseId)
+ self.baseId = -1
if update:
self.lmgr.nviz.UpdateSettings()
self.UpdateView(None)
@@ -1040,7 +1049,7 @@
# set id
if id > 0:
if mapType in ('raster', '3d-raster'):
- data[nvizType]['object'] = { 'id' : id,
+ data[nvizType]['object'] = { 'id' : id,
'init' : False }
elif mapType == 'vector':
data['vector'][nvizType]['object'] = { 'id' : id,
@@ -1232,12 +1241,13 @@
win = toolWin.FindWindowById(toolWin.win['vector']['map'])
win.SetValue('')
- def LoadVector(self, item, points = None):
+ def LoadVector(self, item, points = None, append = True):
"""!Load 2D or 3D vector map overlay
@param item layer item
@param points True to load points, False to load lines, None
to load both
+ @param append append vector to layer list
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
if layer.type != 'vector':
@@ -1258,17 +1268,19 @@
id = -1
for vecType in vecTypes:
if vecType == 'lines':
- id = self._display.LoadVector(str(layer.GetName()), False)
+ id, baseId = self._display.LoadVector(str(layer.GetName()), False)
else:
- id = self._display.LoadVector(str(layer.GetName()), True)
+ id, baseId = self._display.LoadVector(str(layer.GetName()), True)
if id < 0:
self.log.WriteError(_("Loading vector map <%(name)s> (%(type)s) failed") % \
{ 'name' : layer.name, 'type' : vecType })
# update layer properties
self.SetMapObjProperties(item, id, vecType)
+ if baseId > 0:
+ self.baseId = baseId # id of base surface (when no surface is loaded)
+ if append:
+ self.layers.append(item)
- self.layers.append(item)
-
# update properties
data = self.tree.GetPyData(item)[0]['nviz']
event = wxUpdateProperties(data = data)
@@ -1284,11 +1296,12 @@
return id
- def UnloadVector(self, item, points = None):
+ def UnloadVector(self, item, points = None, remove = True):
"""!Unload vector map overlay
@param item layer item
@param points,lines True to unload given feature type
+ @param remove remove layer from list
"""
layer = self.tree.GetPyData(item)[0]['maplayer']
data = self.tree.GetPyData(item)[0]['nviz']['vector']
@@ -1326,7 +1339,8 @@
data[vecType].pop('object')
- ### self.layers.remove(id)
+ if remove:
+ self.layers.remove(item)
def OnZoomToMap(self, event):
"""!Set display extents to match selected raster or vector
@@ -1385,7 +1399,7 @@
try:
id = data['surface']['object']['id']
except KeyError:
- pass
+ return
self.UpdateSurfaceProperties(id, data['surface'])
# -> initialized
data['surface']['object']['init'] = True
@@ -1752,7 +1766,6 @@
if _("constant#") + str(item['constant']['object']['name']) == name:
return item['constant']['object']['id']
- return self.constants
for item in self.layers:
mapLayer = self.tree.GetPyData(item)[0]['maplayer']
Modified: grass/trunk/gui/wxpython/gui_modules/nviz_tools.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-30 17:58:19 UTC (rev 47985)
+++ grass/trunk/gui/wxpython/gui_modules/nviz_tools.py 2011-08-30 18:25:21 UTC (rev 47986)
@@ -1423,7 +1423,6 @@
maps = list()
for layer in self.mapWindow.Map.GetListOfLayers(l_type = ltype, l_active = True):
maps.append(layer.GetName())
- maps.append('aaaaaaaa')
return maps, exclude
def _createVolumePage(self, parent):
@@ -3066,9 +3065,9 @@
data = self.GetLayerData('vector')['vector']
if checked:
- self.mapWindow.LoadVector(item, points = points)
+ self.mapWindow.LoadVector(item, points = points, append = False)
else:
- self.mapWindow.UnloadVector(item, points = points)
+ self.mapWindow.UnloadVector(item, points = points, remove = False)
self.UpdateVectorShow(vecType, checked)
Modified: grass/trunk/gui/wxpython/gui_modules/wxnviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-08-30 17:58:19 UTC (rev 47985)
+++ grass/trunk/gui/wxpython/gui_modules/wxnviz.py 2011-08-30 18:25:21 UTC (rev 47986)
@@ -356,16 +356,17 @@
@param name vector map name
@param points if true load 2d points rather then 2d lines
- @return object id
+ @return object id, id of base surface (or -1 if it is not loaded)
@return -1 on failure
"""
+ baseId = -1
if GS_num_surfs() == 0: # load base surface if no loaded
- Nviz_new_map_obj(MAP_OBJ_SURF, None, 0.0, self.data)
+ baseId = Nviz_new_map_obj(MAP_OBJ_SURF, None, 0.0, self.data)
nsurf = c_int()
surf_list = GS_get_surf_list(byref(nsurf))
GS_set_att_const(surf_list[0], ATT_TRANSP, 255)
-
+
mapset = G_find_vector2 (name, "")
if mapset is None:
G_warning(_("Vector map <%s> not found"),
@@ -382,7 +383,7 @@
Debug.msg(1, "Nviz::LoadVector(): name=%s -> id=%d", name, id)
- return id
+ return id, baseId
def UnloadVector(self, id, points):
"""!Unload vector set
More information about the grass-commit
mailing list