[GRASS-SVN] r32074 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 11 06:35:00 EDT 2008
Author: martinl
Date: 2008-07-11 06:34:59 -0400 (Fri, 11 Jul 2008)
New Revision: 32074
Modified:
grass/trunk/gui/wxpython/gui_modules/nviz.py
grass/trunk/gui/wxpython/gui_modules/workspace.py
grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
grass/trunk/gui/wxpython/wxgui.py
Log:
nviz2/wxGUI: reading nviz layer properties from workspace file (initial, surface/attribute)
Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-10 20:41:25 UTC (rev 32073)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py 2008-07-11 10:34:59 UTC (rev 32074)
@@ -1,5 +1,4 @@
-"""
- at package nviz.py
+"""@package nviz.py
@brief 2.5/3D visialization mode for Map Display Window
@@ -1726,7 +1725,7 @@
if self.pageUpdated:
# reset updates
self.mapWindow.update['surface']['draw'] = {}
- self.mapWindow.update['surface']['draw']['style'] = (value, all)
+ self.mapWindow.update['surface']['draw']['mode'] = (value, all)
self.UpdateLayerProperties()
def OnSurfaceMode(self, event):
@@ -1863,48 +1862,58 @@
self.notebook.GetPage(self.page['surface']).Enable(True)
self.notebook.GetPage(self.page['vector']).Enable(False)
- # use default values
- if data == {} or data == None:
- # attributes
- for attr in ('topo', 'color'): # required
- if layer and layer.type == 'raster':
- self.FindWindowById(self.win['surface'][attr]['map']).SetValue(layer.name)
- else:
- self.FindWindowById(self.win['surface'][attr]['map']).SetValue('')
- self.SetSurfaceUseMap(attr, True) # -> map
- if UserSettings.Get(group='nviz', key='surface', subkey=['shine', 'map']) is False:
- self.SetSurfaceUseMap('shine', False)
- value = UserSettings.Get(group='nviz', key='surface', subkey=['shine', 'value'])
- self.FindWindowById(self.win['surface']['shine']['const']).SetValue(value)
+ #
+ # set default values
+ #
+ # attributes
+ for attr in ('topo', 'color'): # required
+ if layer and layer.type == 'raster':
+ self.FindWindowById(self.win['surface'][attr]['map']).SetValue(layer.name)
+ else:
+ self.FindWindowById(self.win['surface'][attr]['map']).SetValue('')
+ self.SetSurfaceUseMap(attr, True) # -> map
+
+ if UserSettings.Get(group='nviz', key='surface', subkey=['shine', 'map']) is False:
+ self.SetSurfaceUseMap('shine', False)
+ value = UserSettings.Get(group='nviz', key='surface', subkey=['shine', 'value'])
+ self.FindWindowById(self.win['surface']['shine']['const']).SetValue(value)
- #
- # draw
- #
- for control, value in UserSettings.Get(group='nviz', key='surface', subkey='draw').iteritems():
- win = self.FindWindowById(self.win['surface']['draw'][control])
-
- name = win.GetName()
-
- if name == "selection":
- win.SetSelection(value)
- elif name == "colour":
- win.SetColour(value)
- else:
- win.SetValue(value)
- # enable/disable res widget + set draw mode
- self.SetSurfaceMode()
- color = self.FindWindowById(self.win['surface']['draw']['color'])
- self.SetSurfaceWireColor(color.GetColour())
-
- elif layer.type == 'raster':
+ #
+ # draw
+ #
+ for control, value in UserSettings.Get(group='nviz', key='surface', subkey='draw').iteritems():
+ win = self.FindWindowById(self.win['surface']['draw'][control])
+
+ name = win.GetName()
+
+ if name == "selection":
+ win.SetSelection(value)
+ elif name == "colour":
+ win.SetColour(value)
+ else:
+ win.SetValue(value)
+ # enable/disable res widget + set draw mode
+ self.SetSurfaceMode()
+ color = self.FindWindowById(self.win['surface']['draw']['color'])
+ self.SetSurfaceWireColor(color.GetColour())
+
+ if layer.type == 'raster':
+ surfProp = data['surface']
# surface attributes
- for attr in data['attr']:
- if attr['map']:
+ for attr in surfProp['attribute'].iterkeys():
+ print attr
+ if surfProp['attribute'][attr]['map']:
win = self.FindWindowById(self.win['surface'][attr]['map'])
else:
win = self.FindWindowById(self.win['surface'][attr]['const'])
- win.SetValue(data['value'])
+ if attr == 'color':
+ color = tuple(map(int, surfProp['attribute'][attr]['value'].split(':')))
+ # TODO: save as tuple
+ win.SetColour(color)
+ else:
+ win.SetValue(surfProp['attribute'][attr]['value'])
+
elif pageId == 'vector':
# disable surface and enable current
self.notebook.GetPage(self.page['surface']).Enable(False)
Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-07-10 20:41:25 UTC (rev 32073)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py 2008-07-11 10:34:59 UTC (rev 32074)
@@ -53,6 +53,7 @@
#
self.inNviz = False
self.inAttribute = False
+ self.refAttribute = None
#
# layer manager properties
@@ -125,7 +126,8 @@
self.layerName = attrs.get('name', None)
self.layerChecked = attrs.get('checked', None)
self.layerOpacity = attrs.get('opacity', None)
- self.layerSelected = False;
+ self.layerSelected = False
+ self.layerNviz = None
self.cmd = []
elif name == 'task':
@@ -168,10 +170,28 @@
#
elif name == 'nviz':
self.inNviz = True
+ # init nviz layer properties
+ self.layerNviz = {}
+ self.layerNviz['view'] = None
+ self.layerNviz['surface'] = {}
+ for sec in ('attribute', 'draw', 'mask', 'position'):
+ self.layerNviz['surface'][sec] = {}
+ self.layerNviz['vector'] = {}
+ for sec in ('lines', ):
+ self.layerNviz['vector'][sec] = {}
elif name == 'attribute':
self.inAttribute = True
+ tagName = str(name)
+ attrbName = str(attrs.get('name', ''))
+ self.layerNviz['surface'][tagName][attrbName] = {}
+ if attrs.get('map', '0'):
+ self.layerNviz['surface'][tagName][attrbName]['map'] = False
+ else:
+ self.layerNviz['surface'][tagName][attrbName]['map'] = True
+ self.refAttribute = self.layerNviz['surface'][tagName][attrbName]
+
def endElement(self, name):
if name == 'gxw':
self.inGxw = False
@@ -193,7 +213,8 @@
"cmd" : None,
"group" : self.inGroup,
"display" : self.displayIndex,
- "selected" : self.layerSelected})
+ "selected" : self.layerSelected,
+ "nviz" : self.layerNviz})
if self.layerOpacity:
self.layers[-1]["opacity"] = float(self.layerOpacity)
@@ -225,9 +246,10 @@
#
elif name == 'nviz':
self.inNviz = False
-
+
elif name == 'attribute':
self.inAttribute = False
+ self.refAttribute['value'] = str(self.value)
def characters(self, ch):
self.my_characters(ch)
@@ -411,7 +433,7 @@
i += 1
self.indent -= 4
# end tag
- self.file.write('%s<%s>\n' % (' ' * self.indent, attrb))
+ self.file.write('%s</%s>\n' % (' ' * self.indent, attrb))
self.indent -= 4
def __writeNvizVector(self, data):
Modified: grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-10 20:41:25 UTC (rev 32073)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py 2008-07-11 10:34:59 UTC (rev 32074)
@@ -485,11 +485,17 @@
self.EditLabel(self.layer_selected)
def AddLayer(self, ltype, lname=None, lchecked=None,
- lopacity=None, lcmd=None, lgroup=None):
+ lopacity=None, lcmd=None, lgroup=None, lnviz=None):
"""Add new item to the layer tree, create corresponding MapLayer instance.
Launch property dialog if needed (raster, vector, etc.)
- Note: lcmd is given as a list
+ @param ltyle layer type (raster, vector, ...)
+ @param lname layer name
+ @param lchecked if True layer is checked
+ @param lopacity layer opacity level
+ @param lcmd command (given as a list)
+ @param lgroup group name or None
+ @param lnviz layer Nviz properties
"""
self.first = True
@@ -636,7 +642,7 @@
'type' : ltype,
'ctrl' : ctrlId,
'maplayer' : None,
- 'nviz' : None,
+ 'nviz' : lnviz,
'prowin' : None},
None))
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-07-10 20:41:25 UTC (rev 32073)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-07-11 10:34:59 UTC (rev 32074)
@@ -667,7 +667,8 @@
lchecked=layer['checked'],
lopacity=layer['opacity'],
lcmd=layer['cmd'],
- lgroup=layer['group'])
+ lgroup=layer['group'],
+ lnviz=layer['nviz'])
# tag 'selected' added 2008/04
if layer.has_key('selected'):
More information about the grass-commit
mailing list