[GRASS-SVN] r54015 - in grass/trunk/gui/wxpython: core dbmgr gui_core lmgr mapdisp modules nviz vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 24 14:12:37 PST 2012
Author: annakrat
Date: 2012-11-24 14:12:36 -0800 (Sat, 24 Nov 2012)
New Revision: 54015
Modified:
grass/trunk/gui/wxpython/core/giface.py
grass/trunk/gui/wxpython/core/workspace.py
grass/trunk/gui/wxpython/dbmgr/base.py
grass/trunk/gui/wxpython/gui_core/forms.py
grass/trunk/gui/wxpython/gui_core/mapwindow.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/lmgr/layertree.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/modules/colorrules.py
grass/trunk/gui/wxpython/modules/histogram.py
grass/trunk/gui/wxpython/nviz/mapwindow.py
grass/trunk/gui/wxpython/nviz/tools.py
grass/trunk/gui/wxpython/vdigit/mapwindow.py
grass/trunk/gui/wxpython/vdigit/preferences.py
Log:
wxGUI/layertree: better access to layer info (part 2)
Modified: grass/trunk/gui/wxpython/core/giface.py
===================================================================
--- grass/trunk/gui/wxpython/core/giface.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/core/giface.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -103,3 +103,6 @@
def GetMapWindow(self):
return None
+
+ def GetProgress(self):
+ raise NotImplementedError
Modified: grass/trunk/gui/wxpython/core/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/core/workspace.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/core/workspace.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -661,15 +661,15 @@
self.indent += 4
itemSelected = mapTree.GetSelections()
while item and item.IsOk():
- type = mapTree.GetPyData(item)[0]['type']
+ type = mapTree.GetLayerInfo(item, key = 'type')
if type != 'group':
- maplayer = mapTree.GetPyData(item)[0]['maplayer']
+ maplayer = mapTree.GetLayerInfo(item, key = 'maplayer')
else:
maplayer = None
checked = int(item.IsChecked())
if type == 'command':
- cmd = mapTree.GetPyData(item)[0]['maplayer'].GetCmd(string=True)
+ cmd = mapTree.GetLayerInfo(item, key = 'maplayer').GetCmd(string=True)
self.file.write('%s<layer type="%s" name="%s" checked="%d">\n' % \
(' ' * self.indent, type, EncodeString(cmd), checked));
self.file.write('%s</layer>\n' % (' ' * self.indent));
@@ -683,7 +683,7 @@
self.indent -= 4
self.file.write('%s</group>\n' % (' ' * self.indent));
else:
- cmd = mapTree.GetPyData(item)[0]['maplayer'].GetCmd(string = False)
+ cmd = mapTree.GetLayerInfo(item, key = 'maplayer').GetCmd(string = False)
name = mapTree.GetItemText(item).replace(os.linesep, '\\n')
opacity = maplayer.GetOpacity(float = True)
# remove 'opacity' part
@@ -718,7 +718,7 @@
self.indent -= 4
self.file.write('%s</task>\n' % (' ' * self.indent));
# vector digitizer
- vdigit = mapTree.GetPyData(item)[0]['vdigit']
+ vdigit = mapTree.GetLayerInfo(item, key = 'vdigit')
if vdigit:
self.file.write('%s<vdigit>\n' % (' ' * self.indent))
if 'geomAttr' in vdigit:
@@ -732,7 +732,7 @@
self.indent -= 4
self.file.write('%s</vdigit>\n' % (' ' * self.indent))
# nviz
- nviz = mapTree.GetPyData(item)[0]['nviz']
+ nviz = mapTree.GetLayerInfo(item, key = 'nviz')
if nviz:
self.file.write('%s<nviz>\n' % (' ' * self.indent))
if maplayer.type == 'raster':
Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/dbmgr/base.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -598,7 +598,7 @@
elif self.mapdisplay.tree and \
self.dbMgrData['treeItem'] and not self.dbMgrData['vectName']:
maptree = self.mapdisplay.tree
- name = maptree.GetPyData(self.dbMgrData['treeItem'])[0]['maplayer'].GetName()
+ name = maptree.GetLayerInfo(self.dbMgrData['treeItem'], key = 'maplayer').GetName()
self.dbMgrData['vectName'] = name
# vector attributes can be changed only if vector map is in
@@ -1563,7 +1563,7 @@
if self.parent and self.mapdisplay.tree and \
self.dbMgrData['treeItem']:
maptree = self.mapdisplay.tree
- opacity = maptree.GetPyData(self.dbMgrData['treeItem'])[0]['maplayer'].GetOpacity(float = True)
+ opacity = maptree.GetLayerInfo(self.dbMgrData['treeItem'], key = 'maplayer').GetOpacity(float = True)
self.qlayer.SetOpacity(opacity)
if zoom:
keyColumn = self.dbMgrData['mapDBInfo'].layers[self.selLayer]['key']
Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/gui_core/forms.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -725,10 +725,10 @@
# display decorations and
# pressing OK or cancel after setting layer properties
if self.task.name in ['d.barscale','d.legend','d.histogram'] \
- or len(self.parent.GetPyData(self.layer)[0]['cmd']) >= 1:
+ or len(self.parent.GetLayerInfo(self.layer, key = 'cmd')) >= 1:
self.Hide()
# canceled layer with nothing set
- elif len(self.parent.GetPyData(self.layer)[0]['cmd']) < 1:
+ elif len(self.parent.GetLayerInfo(self.layer, key = 'cmd')) < 1:
self.parent.Delete(self.layer)
self.Destroy()
else:
Modified: grass/trunk/gui/wxpython/gui_core/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/mapwindow.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/gui_core/mapwindow.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -272,7 +272,7 @@
if not item:
return None
if dataType == 'nviz':
- return self.tree.GetPyData(item)[0]['nviz']
+ return self.tree.GetLayerInfo(item, key = 'nviz')
return item
@@ -309,9 +309,9 @@
try:
if type == 'nviz':
- layer = self.tree.GetPyData(item)[0]['nviz']
+ layer = self.tree.GetLayerInfo(item, key = 'nviz')
else:
- layer = self.tree.GetPyData(item)[0]['maplayer']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
except:
layer = None
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -436,9 +436,9 @@
tree = self.GetLayerTree()
if tree:
for layer in tree.GetSelections():
- if tree.GetPyData(layer)[0]['maplayer'].GetType() != 'raster':
+ if tree.GetLayerInfo(layer, key = 'maplayer').GetType() != 'raster':
continue
- rasters.append(tree.GetPyData(layer)[0]['maplayer'].GetName())
+ rasters.append(tree.GetLayerInfo(layer, key = 'maplayer').GetName())
if len(rasters) >= 1:
win.SetFirstRaster(rasters[0])
@@ -685,8 +685,8 @@
try:
layer = self.GetLayerTree().layer_selected
- name = self.GetLayerTree().GetPyData(layer)[0]['maplayer'].name
- type = self.GetLayerTree().GetPyData(layer)[0]['type']
+ name = self.GetLayerTree().GetLayerInfo(layer, key = 'maplayer').name
+ type = self.GetLayerTree().GetLayerInfo(layer, key = 'type')
except:
layer = None
@@ -727,7 +727,7 @@
# available only for vector map layers
try:
- mapLayer = tree.GetPyData(layer)[0]['maplayer']
+ mapLayer = tree.GetLayerInfo(layer, key = 'maplayer')
except:
mapLayer = None
@@ -742,9 +742,9 @@
"current mapset."))
return
- if not tree.GetPyData(layer)[0]:
+ if not tree.GetLayerInfo(layer):
return
- dcmd = tree.GetPyData(layer)[0]['cmd']
+ dcmd = tree.GetLayerInfo(layer, key = 'cmd')
if not dcmd:
return
@@ -1531,7 +1531,7 @@
# available only for vector map layers
try:
- maptype = tree.GetPyData(layer)[0]['maplayer'].type
+ maptype = tree.GetLayerInfo(layer, key = 'maplayer').type
except:
maptype = None
@@ -1540,9 +1540,9 @@
message = _("Selected map layer is not vector."))
return
- if not tree.GetPyData(layer)[0]:
+ if not tree.GetLayerInfo(layer):
return
- dcmd = tree.GetPyData(layer)[0]['cmd']
+ dcmd = tree.GetLayerInfo(layer, key = 'cmd')
if not dcmd:
return
@@ -1919,7 +1919,7 @@
dlg.Destroy()
for layer in self.GetLayerTree().GetSelections():
- if self.GetLayerTree().GetPyData(layer)[0]['type'] == 'group':
+ if self.GetLayerTree().GetLayerInfo(layer, key = 'type') == 'group':
self.GetLayerTree().DeleteChildren(layer)
self.GetLayerTree().Delete(layer)
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -1718,10 +1718,7 @@
def __FindSubItemByData(self, item, key, value):
"""!Support method for FindItemByData"""
while item and item.IsOk():
- try:
- itemValue = self.GetLayerInfo(item, key = 'key')
- except KeyError:
- return None
+ itemValue = self.GetLayerInfo(item, key = key)
if value == itemValue:
return item
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -643,7 +643,7 @@
num = 0
filteredLayers = []
for layer in layers:
- ltype = self.tree.GetPyData(layer)[0]['maplayer'].GetType()
+ ltype = self.tree.GetLayerInfo(layer, key = 'maplayer').GetType()
if ltype in ('raster', 'rgb', 'his',
'vector', 'thememap', 'themechart'):
filteredLayers.append(layer)
@@ -665,7 +665,7 @@
nVectors = 0
isDbConnection = False
for l in layers:
- maplayer = self.tree.GetPyData(l)[0]['maplayer']
+ maplayer = self.tree.GetLayerInfo(l, key = 'maplayer')
if maplayer.GetType() == 'raster':
isRaster = True
break
@@ -699,8 +699,8 @@
vcmd = ['v.what', '--v']
for layer in layers:
- ltype = self.tree.GetPyData(layer)[0]['maplayer'].GetType()
- dcmd = self.tree.GetPyData(layer)[0]['cmd']
+ ltype = self.tree.GetLayerInfo(layer, key = 'maplayer').GetType()
+ dcmd = self.tree.GetLayerInfo(layer, key = 'cmd')
name, found = GetLayerNameFromCmd(dcmd)
if not found:
@@ -778,9 +778,9 @@
Attribute data of selected vector object are displayed in GUI dialog.
Data can be modified (On Submit)
"""
- mapName = self.tree.GetPyData(layer)[0]['maplayer'].name
+ mapName = self.tree.GetLayerInfo(layer, key = 'maplayer').name
- if self.tree.GetPyData(layer)[0]['maplayer'].GetMapset() != \
+ if self.tree.GetLayerInfo(layer, key = 'maplayer').GetMapset() != \
grass.gisenv()['MAPSET']:
mode = 'display'
else:
@@ -826,7 +826,7 @@
qlayer = self.AddTmpVectorMapLayer(mapName, cats, useId = False)
# set opacity based on queried layer
- opacity = self.tree.GetPyData(layer)[0]['maplayer'].GetOpacity(float = True)
+ opacity = self.tree.GetLayerInfo(layer, key = 'maplayer').GetOpacity(float = True)
qlayer.SetOpacity(opacity)
self.MapWindow.UpdateMap(render = False, renderVector = False)
@@ -873,7 +873,7 @@
# icon used in vector display and its size
icon = ''
size = 0
- vparam = self.tree.GetPyData(self.tree.layer_selected)[0]['cmd']
+ vparam = self.tree.GetLayerInfo(self.tree.layer_selected, key = 'cmd')
for p in vparam:
if '=' in p:
parg,pval = p.split('=', 1)
@@ -1002,8 +1002,8 @@
"""
raster = []
if self.tree.layer_selected and \
- self.tree.GetPyData(self.tree.layer_selected)[0]['type'] == 'raster':
- raster.append(self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name)
+ self.tree.GetLayerInfo(self.tree.layer_selected, key = 'type') == 'raster':
+ raster.append(self.tree.GetLayerInfo(self.tree.layer_selected, key = 'maplayer').name)
win = ProfileFrame(parent = self, rasterList = raster)
@@ -1070,9 +1070,9 @@
raster = []
for layer in self.tree.GetSelections():
- if self.tree.GetPyData(layer)[0]['maplayer'].GetType() != 'raster':
+ if self.tree.GetLayerInfo(layer, key = 'maplayer').GetType() != 'raster':
continue
- raster.append(self.tree.GetPyData(layer)[0]['maplayer'].GetName())
+ raster.append(self.tree.GetLayerInfo(layer, key = 'maplayer').GetName())
win = Histogram2Frame(parent = self, rasterList = raster)
win.CentreOnParent
@@ -1087,9 +1087,9 @@
raster = []
for layer in self.tree.GetSelections():
- if self.tree.GetPyData(layer)[0]['maplayer'].GetType() != 'raster':
+ if self.tree.GetLayerInfo(layer, key = 'maplayer').GetType() != 'raster':
continue
- raster.append(self.tree.GetPyData(layer)[0]['maplayer'].GetName())
+ raster.append(self.tree.GetLayerInfo(layer, key = 'maplayer').GetName())
win = ScatterFrame(parent = self, rasterList = raster)
@@ -1153,8 +1153,8 @@
cmd = ['d.legend', 'at=5,50,2,5']
if self.tree and self.tree.layer_selected and \
- self.tree.GetPyData(self.tree.layer_selected)[0]['type'] == 'raster':
- cmd.append('map=%s' % self.tree.GetPyData(self.tree.layer_selected)[0]['maplayer'].name)
+ self.tree.GetLayerInfo(self.tree.layer_selected, key = 'type') == 'raster':
+ cmd.append('map=%s' % self.tree.GetLayerInfo(self.tree.layer_selected, key = 'maplayer').name)
# Decoration overlay control dialog
self.dialogs['legend'] = \
Modified: grass/trunk/gui/wxpython/modules/colorrules.py
===================================================================
--- grass/trunk/gui/wxpython/modules/colorrules.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/modules/colorrules.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -359,14 +359,14 @@
# if not the right type, than select another
try:
sel = self.layerTree.layer_selected
- if sel and self.layerTree.GetPyData(sel)[0]['type'] == self.mapType:
+ if sel and self.layerTree.GetLayerInfo(sel, key = 'type') == self.mapType:
layer = sel
else:
layer = self.layerTree.FindItemByData(key = 'type', value = self.mapType)
except:
layer = None
if layer:
- mapLayer = self.layerTree.GetPyData(layer)[0]['maplayer']
+ mapLayer = self.layerTree.GetLayerInfo(layer, key = 'maplayer')
name = mapLayer.GetName()
type = mapLayer.GetType()
self.selectionInput.SetValue(name)
@@ -1594,9 +1594,9 @@
if not layers:
return
for layer in layers:
- if self.layerTree.GetPyData(layer)[0]['type'] != 'vector':
+ if self.layerTree.GetLayerInfo(layer, key = 'type') != 'vector':
continue
- cmdlist = self.layerTree.GetPyData(layer)[0]['maplayer'].GetCmd()
+ cmdlist = self.layerTree.GetLayerInfo(layer, key = 'maplayer').GetCmd()
if self.attributeType == 'color':
if useAttrColumn:
@@ -1610,7 +1610,7 @@
cmdlist[1].update({'size_column': self.properties['storeColumn']})
elif self.attributeType == 'width':
cmdlist[1].update({'width_column' :self.properties['storeColumn']})
- self.layerTree.GetPyData(layer)[0]['cmd'] = cmdlist
+ self.layerTree.SetLayerInfo(layer, key = 'cmd', value = cmdlist)
def CreateColorTable(self, tmp = False):
"""!Create color rules (color table or color column)"""
Modified: grass/trunk/gui/wxpython/modules/histogram.py
===================================================================
--- grass/trunk/gui/wxpython/modules/histogram.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/modules/histogram.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -287,8 +287,8 @@
if parent.GetName() == "MapWindow" and not parent.IsStandalone():
tree = parent.GetLayerManager().GetLayerTree()
- if tree.layer_selected and tree.GetPyData(tree.layer_selected)[0]['type'] == 'raster':
- self.mapname = tree.GetPyData(tree.layer_selected)[0]['maplayer'].name
+ if tree.layer_selected and tree.GetLayerInfo(tree.layer_selected, key = 'type') == 'raster':
+ self.mapname = tree.GetLayerInfo(tree.layer_selected, key = 'maplayer').name
# Add statusbar
self.statusbar = self.CreateStatusBar(number = 1, style = 0)
Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -874,9 +874,9 @@
dx, dy = x2 - x1, y2 - y1
# find raster and volume
for item in self.layers:
- mapLayer = self.tree.GetPyData(item)[0]['maplayer']
+ mapLayer = self.tree.GetLayerInfo(item, key = 'maplayer')
- data = self.tree.GetPyData(item)[0]['nviz']
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
if mapLayer.GetType() == 'raster':
data['surface']['position']['x'] += dx
data['surface']['position']['y'] += dy
@@ -1009,10 +1009,9 @@
self.log.WriteLog("%-30s: %.3f" % (_("Elevation"), result['z']))
name = ''
for item in self.layers:
- self.tree.GetPyData(item)[0]['nviz']
- if self.tree.GetPyData(item)[0]['maplayer'].type == 'raster' and\
- self.tree.GetPyData(item)[0]['nviz']['surface']['object']['id'] == result['id']:
- name = self.tree.GetPyData(item)[0]['maplayer'].name
+ if self.tree.GetLayerInfo(item, key = 'maplayer').type == 'raster' and\
+ self.tree.GetLayerInfo(item, key = 'nviz')['surface']['object']['id'] == result['id']:
+ name = self.tree.GetLayerInfo(item, key = 'maplayer').name
self.log.WriteLog("%-30s: %s" % (_("Surface map name"), name))
self.log.WriteLog("%-30s: %s" % (_("Surface map elevation"), result['elevation']))
self.log.WriteLog("%-30s: %s" % (_("Surface map color"), result['color']))
@@ -1217,8 +1216,8 @@
@param item layer item
"""
- layer = self.tree.GetPyData(item)[0]['maplayer']
- data = self.tree.GetPyData(item)[0]['nviz']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
if not data:
return 0
@@ -1237,7 +1236,7 @@
"""!Return get list of enabled map layers"""
# load raster & vector maps
while item and item.IsOk():
- type = self.tree.GetPyData(item)[0]['type']
+ type = self.tree.GetLayerInfo(item, key = 'type')
if type == 'group':
subItem = self.tree.GetFirstChild(item)[0]
self._GetDataLayers(subItem, litems)
@@ -1268,12 +1267,12 @@
while(len(listOfItems) > 0):
item = listOfItems.pop()
- type = self.tree.GetPyData(item)[0]['type']
+ type = self.tree.GetLayerInfo(item, key = 'type')
if item in self.layers:
continue
# "raster (double click to set properties)" - tries to load this
# layer - no idea how to fix it
- if ' ' in self.tree.GetPyData(item)[0]['maplayer'].name:
+ if ' ' in self.tree.GetLayerInfo(item, key = 'maplayer').name:
return
try:
if type == 'raster':
@@ -1281,13 +1280,13 @@
elif type == '3d-raster':
self.LoadRaster3d(item)
elif type == 'vector':
- # data = self.tree.GetPyData(item)[0]['nviz']
+ # data = self.tree.GetLayerInfo(item, key = 'nviz')
# vecType = []
# if data and 'vector' in data:
# for v in ('lines', 'points'):
# if data['vector'][v]:
# vecType.append(v)
- layer = self.tree.GetPyData(item)[0]['maplayer']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(layer)
if npoints > 0:
self.LoadVector(item, points = True)
@@ -1322,14 +1321,14 @@
for layer in layersTmp:
if layer in listOfItems:
continue
- ltype = self.tree.GetPyData(layer)[0]['type']
+ ltype = self.tree.GetLayerInfo(layer, key = 'type')
try:
if ltype == 'raster':
self.UnloadRaster(layer)
elif ltype == '3d-raster':
self.UnloadRaster3d(layer)
elif ltype == 'vector':
- maplayer = self.tree.GetPyData(layer)[0]['maplayer']
+ maplayer = self.tree.GetLayerInfo(layer, key = 'maplayer')
npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(maplayer)
if npoints > 0:
self.UnloadVector(layer, points = True)
@@ -1366,7 +1365,7 @@
@param item Layer Tree item
@param nviz data
"""
- cmd = self.tree.GetPyData(item)[0]['cmd']
+ cmd = self.tree.GetLayerInfo(item, key = 'cmd')
if cmd[0] != 'd.vect':
return
for opt in cmd[1:]:
@@ -1389,9 +1388,9 @@
@param nvizType nviz data type (surface, points, vector)
"""
if nvizType != 'constant':
- mapType = self.tree.GetPyData(item)[0]['maplayer'].type
+ mapType = self.tree.GetLayerInfo(item, key = 'maplayer').type
# reference to original layer properties (can be None)
- data = self.tree.GetPyData(item)[0]['nviz']
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
else:
mapType = nvizType
data = self.constants[item]
@@ -1399,8 +1398,8 @@
if not data:
# init data structure
if nvizType != 'constant':
- self.tree.GetPyData(item)[0]['nviz'] = {}
- data = self.tree.GetPyData(item)[0]['nviz']
+ self.tree.SetLayerInfo(item, key = 'nviz', value = {})
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
if mapType == 'raster':
# reset to default properties
@@ -1480,7 +1479,7 @@
@param layer item
"""
- layer = self.tree.GetPyData(item)[0]['maplayer']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
if layer.type not in ('raster', '3d-raster'):
return
@@ -1602,12 +1601,12 @@
@param item layer item
"""
- layer = self.tree.GetPyData(item)[0]['maplayer']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
if layer.type not in ('raster', '3d-raster'):
return
- data = self.tree.GetPyData(item)[0]['nviz']
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
if layer.type == 'raster':
nvizType = 'surface'
@@ -1657,7 +1656,7 @@
to load both
@param append append vector to layer list
"""
- layer = self.tree.GetPyData(item)[0]['maplayer']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
if layer.type != 'vector':
return
@@ -1690,7 +1689,7 @@
self.layers.append(item)
# update properties
- data = self.tree.GetPyData(item)[0]['nviz']
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
event = wxUpdateProperties(data = data)
wx.PostEvent(self, event)
@@ -1711,8 +1710,8 @@
@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']
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
+ data = self.tree.GetLayerInfo(item, key = 'nviz')['vector']
# if vecType is None:
# vecType = []
@@ -2152,7 +2151,7 @@
layerName.append(_("constant#") + str(item['constant']['object']['name']))
else:
for item in self.layers:
- mapLayer = self.tree.GetPyData(item)[0]['maplayer']
+ mapLayer = self.tree.GetLayerInfo(item, key = 'maplayer')
if type != mapLayer.GetType():
continue
@@ -2172,12 +2171,12 @@
for item in self.layers:
- mapLayer = self.tree.GetPyData(item)[0]['maplayer']
+ mapLayer = self.tree.GetLayerInfo(item, key = 'maplayer')
if type != mapLayer.GetType() or \
name != mapLayer.GetName():
continue
- data = self.tree.GetPyData(item)[0]['nviz']
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
try:
if type == 'raster':
@@ -2196,9 +2195,9 @@
def ReloadLayersData(self):
"""!Delete nviz data of all loaded layers and reload them from current settings"""
for item in self.layers:
- type = self.tree.GetPyData(item)[0]['type']
- layer = self.tree.GetPyData(item)[0]['maplayer']
- data = self.tree.GetPyData(item)[0]['nviz']
+ type = self.tree.GetLayerInfo(item, key = 'type')
+ layer = self.tree.GetLayerInfo(item, key = 'maplayer')
+ data = self.tree.GetLayerInfo(item, key = 'nviz')
if type == 'raster':
self.nvizDefault.SetSurfaceDefaultProp(data['surface'])
@@ -2217,11 +2216,11 @@
vectors = []
volumes = []
for item in self.layers:
- if self.tree.GetPyData(item)[0]['type'] == 'raster':
+ if self.tree.GetLayerInfo(item, key = 'type') == 'raster':
rasters.append(item)
- elif self.tree.GetPyData(item)[0]['type'] == '3d-raster':
+ elif self.tree.GetLayerInfo(item, key = 'type') == '3d-raster':
volumes.append(item)
- elif self.tree.GetPyData(item)[0]['type'] == 'vector':
+ elif self.tree.GetLayerInfo(item, key = 'type') == 'vector':
vectors.append(item)
if not rasters and not self.constants:
return _("At least one raster map required")
@@ -2235,7 +2234,7 @@
if rasters:
subcmd = "elevation_map="
for item in rasters:
- subcmd += "%s," % self.tree.GetPyData(item)[0]['maplayer'].GetName()
+ subcmd += "%s," % self.tree.GetLayerInfo(item, key = 'maplayer').GetName()
subcmd = subcmd.strip(', ') + ' '
cmd += subcmd
#
@@ -2249,14 +2248,14 @@
cmdWire = "wire_color="
# test -a flag
flag_a = "-a "
- nvizDataFirst = self.tree.GetPyData(rasters[0])[0]['nviz']['surface']['draw']
+ nvizDataFirst = self.tree.GetLayerInfo(rasters[0], key = 'nviz')['surface']['draw']
for item in rasters:
- nvizData = self.tree.GetPyData(item)[0]['nviz']['surface']['draw']
+ nvizData = self.tree.GetLayerInfo(item, key = 'nviz')['surface']['draw']
if nvizDataFirst != nvizData:
flag_a = ""
cmd += flag_a
for item in rasters:
- nvizData = self.tree.GetPyData(item)[0]['nviz']['surface']['draw']
+ nvizData = self.tree.GetLayerInfo(item, key = 'nviz')['surface']['draw']
cmdMode += "%s," % nvizData['mode']['desc']['mode']
cmdFine += "%s," % nvizData['resolution']['fine']
@@ -2299,9 +2298,9 @@
cmdColorMap = "color_map="
cmdColorVal = "color="
for item in rasters:
- nvizData = self.tree.GetPyData(item)[0]['nviz']['surface']['attribute']
+ nvizData = self.tree.GetLayerInfo(item, key = 'nviz')['surface']['attribute']
if 'color' not in nvizData:
- cmdColorMap += "%s," % self.tree.GetPyData(item)[0]['maplayer'].GetName()
+ cmdColorMap += "%s," % self.tree.GetLayerInfo(item, key = 'maplayer').GetName()
else:
if nvizData['color']['map']:
cmdColorMap += "%s," % nvizData['color']['value']
@@ -2326,17 +2325,17 @@
'dec_tree', 'con_tree', 'aster', 'gyro', 'histogram']
for vector in vectors:
npoints, nlines, nfeatures, mapIs3D = self.lmgr.nviz.VectorInfo(
- self.tree.GetPyData(vector)[0]['maplayer'])
- nvizData = self.tree.GetPyData(vector)[0]['nviz']['vector']
+ self.tree.GetLayerInfo(vector, key = 'maplayer'))
+ nvizData = self.tree.GetLayerInfo(vector, key = 'nviz')['vector']
if nlines > 0:
- cmdLines += "%s," % self.tree.GetPyData(vector)[0]['maplayer'].GetName()
+ cmdLines += "%s," % self.tree.GetLayerInfo(vector, key = 'maplayer').GetName()
cmdLWidth += "%d," % nvizData['lines']['width']['value']
cmdLHeight += "%d," % nvizData['lines']['height']['value']
cmdLColor += "%s," % nvizData['lines']['color']['value']
cmdLMode += "%s," % nvizData['lines']['mode']['type']
cmdLPos += "0,0,%d," % nvizData['lines']['height']['value']
if npoints > 0:
- cmdPoints += "%s," % self.tree.GetPyData(vector)[0]['maplayer'].GetName()
+ cmdPoints += "%s," % self.tree.GetLayerInfo(vector, key = 'maplayer').GetName()
cmdPWidth += "%d," % nvizData['points']['width']['value']
cmdPSize += "%d," % nvizData['points']['size']['value']
cmdPColor += "%s," % nvizData['points']['color']['value']
@@ -2368,8 +2367,8 @@
cmdIsoColorMap = cmdIsoColorVal = cmdIsoTrMap = cmdIsoTrVal = ""
cmdSlice = cmdSliceTransp = cmdSlicePos = ""
for i, volume in enumerate(volumes):
- nvizData = self.tree.GetPyData(volume)[0]['nviz']['volume']
- cmdName += "%s," % self.tree.GetPyData(volume)[0]['maplayer'].GetName()
+ nvizData = self.tree.GetLayerInfo(volume, key = 'nviz')['volume']
+ cmdName += "%s," % self.tree.GetLayerInfo(volume, key = 'maplayer').GetName()
cmdShade += "%s," % nvizData['draw']['shading']['isosurface']['desc']
cmdRes += "%d," % nvizData['draw']['resolution']['isosurface']['value']
if nvizData['position']:
Modified: grass/trunk/gui/wxpython/nviz/tools.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/tools.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/nviz/tools.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -2736,7 +2736,7 @@
name = event.GetString()
try:
data = self.mapWindow.GetLayerByName(name, mapType = 'raster', dataType = 'nviz')['surface']
- except:
+ except TypeError:
self.EnablePage('surface', False)
return
Modified: grass/trunk/gui/wxpython/vdigit/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/mapwindow.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/vdigit/mapwindow.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -196,7 +196,7 @@
mapLayer = self.toolbar.GetLayer()
if self.tree:
item = self.tree.FindItemByData('maplayer', mapLayer)
- vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ vdigit = self.tree.GetLayerInfo(item, key = 'vdigit')
else:
item = vdigit = None
@@ -232,7 +232,7 @@
vectorName = mapLayer.GetName()
if self.tree:
item = self.tree.FindItemByData('maplayer', mapLayer)
- vdigit = self.tree.GetPyData(item)[0]['vdigit']
+ vdigit = self.tree.GetLayerInfo(item, key = 'vdigit')
else:
item = vdigit = None
Modified: grass/trunk/gui/wxpython/vdigit/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/vdigit/preferences.py 2012-11-24 20:26:02 UTC (rev 54014)
+++ grass/trunk/gui/wxpython/vdigit/preferences.py 2012-11-24 22:12:36 UTC (rev 54015)
@@ -448,17 +448,17 @@
# default values
check.SetValue(False)
- if item and tree.GetPyData(item)[0]['vdigit'] and \
- 'geomAttr' in tree.GetPyData(item)[0]['vdigit'] and \
- attrb in tree.GetPyData(item)[0]['vdigit']['geomAttr']:
+ if item and tree.GetLayerInfo(item, key = 'vdigit') and \
+ 'geomAttr' in tree.GetLayerInfo(item, key = 'vdigit') and \
+ attrb in tree.GetLayerInfo(item, key = 'vdigit')['geomAttr']:
check.SetValue(True)
- column.SetStringSelection(tree.GetPyData(item)[0]['vdigit']['geomAttr'][attrb]['column'])
+ column.SetStringSelection(tree.GetLayerInfo(item, key = 'vdigit')['geomAttr'][attrb]['column'])
if attrb == 'area':
type = 'area'
else:
type = 'length'
unitsIdx = Units.GetUnitsIndex(type,
- tree.GetPyData(item)[0]['vdigit']['geomAttr'][attrb]['units'])
+ tree.GetLayerInfo(item, key = 'vdigit')['geomAttr'][attrb]['units'])
win_units.SetSelection(unitsIdx)
if not vectorName:
@@ -722,8 +722,8 @@
checked = self.FindWindowById(val['check']).IsChecked()
column = self.FindWindowById(val['column']).GetValue()
unitsIdx = self.FindWindowById(val['units']).GetSelection()
- if item and not tree.GetPyData(item)[0]['vdigit']:
- tree.GetPyData(item)[0]['vdigit'] = { 'geomAttr' : dict() }
+ if item and not tree.GetLayerInfo(item, key = 'vdigit'):
+ tree.SetLayerInfo(item, key = 'vdigit', value = { 'geomAttr' : dict() })
if checked: # enable
if key == 'area':
@@ -731,12 +731,12 @@
else:
type = 'length'
unitsKey = Units.GetUnitsKey(type, unitsIdx)
- tree.GetPyData(item)[0]['vdigit']['geomAttr'][key] = { 'column' : column,
+ tree.GetLayerInfo(item, key = 'vdigit')['geomAttr'][key] = { 'column' : column,
'units' : unitsKey }
else:
- if item and tree.GetPyData(item)[0]['vdigit'] and \
- key in tree.GetPyData(item)[0]['vdigit']['geomAttr']:
- del tree.GetPyData(item)[0]['vdigit']['geomAttr'][key]
+ if item and tree.GetLayerInfo(item, key = 'vdigit') and \
+ key in tree.GetLayerInfo(item, key = 'vdigit')['geomAttr']:
+ del tree.GetLayerInfo(item, key = 'vdigit')['geomAttr'][key]
# query tool
if self.queryLength.GetValue():
More information about the grass-commit
mailing list