[GRASS-SVN] r32081 - in grass/trunk/gui/wxpython: gui_modules xml

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 12 09:42:02 EDT 2008


Author: martinl
Date: 2008-07-12 09:42:01 -0400 (Sat, 12 Jul 2008)
New Revision: 32081

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/nviz.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/workspace.py
   grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py
   grass/trunk/gui/wxpython/xml/grass-gxw.dtd
Log:
nviz2/wxGUI: workspace definition updated (surface attributes, draw mode) -- read/write

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-07-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-07-12 13:42:01 UTC (rev 32081)
@@ -2635,8 +2635,15 @@
             #
             self.toolbars['nviz'] = toolbars.NvizToolbar(self, self.Map)
             self.toolbars['map'].Enable2D(False)
-            
+
+            #
+            # update status bar
+            #
+            self.toggleStatus.Enable(False)
+
+            #
             # erase map window
+            #
             self.MapWindow.EraseMap()
 
             busy = wx.BusyInfo(message=_("Please wait, loading data..."),
@@ -2649,15 +2656,10 @@
             if not self.MapWindow3D:
                 self.MapWindow3D = nviz.GLWindow(self, id=wx.ID_ANY,
                                                  Map=self.Map, tree=self.tree, gismgr=self.gismanager)
+                self.MapWindow3D.OnPaint(None) # -> LoadData
                 self.nvizToolWin = nviz.NvizToolWindow(self, id=wx.ID_ANY,
                                                        mapWindow=self.MapWindow3D)
             
-            #
-            # update status bar
-            #
-            self.toggleStatus.Enable(False)
-            self.SetStatusText("")
-            
             busy.Destroy()
 
             self.nvizToolWin.Show()
@@ -2680,6 +2682,7 @@
                               BottomDockable(False).TopDockable(True).
                               CloseButton(False).Layer(2))
             self.MapWindow = self.MapWindow3D
+            self.SetStatusText("", 0)
             
         self._mgr.Update()
 

Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-12 13:42:01 UTC (rev 32081)
@@ -794,7 +794,7 @@
         color = csel.ColourSelect(panel, id=wx.ID_ANY)
         color.SetName("colour")
         color.Bind(csel.EVT_COLOURSELECT, self.OnSurfaceWireColor)
-        self.win['surface']['draw']['color'] = color.GetId()
+        self.win['surface']['draw']['wire-color'] = color.GetId()
         gridSizer.Add(item=color, flag=wx.ALIGN_CENTER_VERTICAL,
                       pos=(2, 1))
 
@@ -1445,27 +1445,35 @@
         data = self.mapWindow.GetSelectedLayer(nviz=True)
         id = self.mapWindow.GetMapObjId(mapLayer)
 
+        if len(data.keys()) < 1:
+            data['surface'] = {}
+            for sec in ('attribute', 'draw', 'mask', 'position'):
+                data['surface'][sec] = {}
+            data['vector'] = {}
+            for sec in ('lines', ):
+                data['vector'][sec] = {}
+
         if mapLayer.type == 'raster':
-            self.UpdateRasterProperties(id, data)
+            self.UpdateRasterProperties(id, data['surface'])
             # reset updates
             for sec in self.mapWindow.update['surface'].keys():
                 self.mapWindow.update['surface'][sec] = {}
         elif mapLayer.type == 'vector':
-            self.UpdateVectorProperties(id, data)
+            self.UpdateVectorProperties(id, data['vector'])
             # reset updates
             for sec in self.mapWindow.update['vector'].keys():
                 self.mapWindow.update['vector'][sec] = {}
 
-        print self.mapWindow.GetSelectedLayer(nviz=True)
-
     def UpdateRasterProperties(self, id, data):
         """Apply changes for surfaces"""
+
         # surface attributes
         for attrb in ('topo', 'color', 'mask',
                      'transp', 'shine', 'emit'):
             if self.mapWindow.update['surface']['attribute'].has_key(attrb):
                 map = self.mapWindow.update['surface']['attribute'][attrb]['map']
                 value = self.mapWindow.update['surface']['attribute'][attrb]['value']
+
                 if map is None: # unset
                     # only optional attributes
                     if attrb == 'mask':
@@ -1477,7 +1485,8 @@
                     elif attrb == 'emit':
                         self.mapWindow.nvizClass.UnsetSurfaceEmit(id) 
                 else:
-                    if len(value) <= 0: # ignore empty values (TODO: warning)
+                    if type(value) == type('') and \
+                            len(value) <= 0: # ignore empty values (TODO: warning)
                         continue
                     if attrb == 'topo':
                         self.mapWindow.nvizClass.SetSurfaceTopo(id, map, str(value)) 
@@ -1496,24 +1505,26 @@
 
         # draw res
         if self.mapWindow.update['surface']['draw'].has_key('resolution'):
-            coarse, fine, all = self.mapWindow.update['surface']['draw']['resolution']
-            if all:
+            coarse = self.mapWindow.update['surface']['draw']['resolution']['coarse']
+            fine = self.mapWindow.update['surface']['draw']['resolution']['fine']
+
+            if self.mapWindow.update['surface']['draw']['resolution']['all']:
                 self.mapWindow.nvizClass.SetSurfaceRes(-1, fine, coarse)
             else:
                 self.mapWindow.nvizClass.SetSurfaceRes(id, fine, coarse)
 
         # draw style
         if self.mapWindow.update['surface']['draw'].has_key('mode'):
-            style, all = self.mapWindow.update['surface']['draw']['mode']
-            if all:
+            style = self.mapWindow.update['surface']['draw']['mode']['value']
+            if self.mapWindow.update['surface']['draw']['mode']['all']:
                 self.mapWindow.nvizClass.SetSurfaceStyle(-1, style)
             else:
                 self.mapWindow.nvizClass.SetSurfaceStyle(id, style)
 
         # wire color
-        if self.mapWindow.update['surface']['draw'].has_key('color'):
-            color, all = self.mapWindow.update['surface']['draw']['color']
-            if all:
+        if self.mapWindow.update['surface']['draw'].has_key('wire-color'):
+            color = self.mapWindow.update['surface']['draw']['wire-color']['value']
+            if self.mapWindow.update['surface']['draw']['wire-color']['all']:
                 self.mapWindow.nvizClass.SetWireColor(id, str(color))
             else:
                 self.mapWindow.nvizClass.SetWireColor(-1, str(color))
@@ -1536,7 +1547,12 @@
             if not data.has_key(sec):
                 data[sec] = {}
             for prop in self.mapWindow.update['surface'][sec].keys():
-                data[sec][prop] = self.mapWindow.update['surface'][sec][prop]
+                if sec == 'attribute' and \
+                      self.mapWindow.update['surface'][sec][prop]['map'] is None: # unset
+                    if data[sec].has_key(prop):
+                        del data[sec][prop]
+                else:
+                    data[sec][prop] = self.mapWindow.update['surface'][sec][prop]
 
     def UpdateVectorProperties(self, id, data):
         """Apply changes for vector"""
@@ -1578,6 +1594,8 @@
         if not self.mapWindow.init:
             return
 
+        wx.Yield()
+
         # find attribute row
         attrb = self.__GetWindowName(self.win['surface'], event.GetId())
         if not attrb:
@@ -1658,6 +1676,7 @@
         else: # constant
             if attrb == 'color':
                 value = self.FindWindowById(self.win['surface'][attrb]['const']).GetColour()
+                # tuple to string
                 value = str(value[0]) + ':' + str(value[1]) + ':' + str(value[2])
             else:
                 value = self.FindWindowById(self.win['surface'][attrb]['const']).GetValue()
@@ -1686,7 +1705,9 @@
             
         # reset updates
         self.mapWindow.update['surface']['draw'] = {}
-        self.mapWindow.update['surface']['draw']['resolution'] = (coarse, fine, all) 
+        self.mapWindow.update['surface']['draw']['resolution'] = { 'coarse' : coarse,
+                                                                   'fine' : fine,
+                                                                   'all' : all } 
 
         self.UpdateLayerProperties()
 
@@ -1696,37 +1717,47 @@
         @param apply allow auto-rendering
         """
         value = 0
+        desc = {}
 
         mode = self.FindWindowById(self.win['surface']['draw']['mode']).GetSelection()
         if mode == 0: # coarse
             value |= wxnviz.DM_WIRE
+            desc['mode'] = 'coarse'
             self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
             self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(False)
         elif mode == 1: # fine
             value |= wxnviz.DM_POLY
+            desc['mode'] = 'file'
             self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(False)
             self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
         else: # both
             value |= wxnviz.DM_WIRE_POLY
+            desc['mode'] = 'both'
             self.FindWindowById(self.win['surface']['draw']['res-coarse']).Enable(True)
             self.FindWindowById(self.win['surface']['draw']['res-fine']).Enable(True)
 
         style = self.FindWindowById(self.win['surface']['draw']['style']).GetSelection()
         if style == 0: # wire
             value |= wxnviz.DM_GRID_WIRE
+            desc['style'] = 'wire'
         else: # surface
             value |= wxnviz.DM_GRID_SURF
+            desc['style'] = 'surface'
 
         shade = self.FindWindowById(self.win['surface']['draw']['shading']).GetSelection()
         if shade == 0:
             value |= wxnviz.DM_FLAT
+            desc['shading'] = 'flat'
         else: # surface
             value |= wxnviz.DM_GOURAUD
-
+            desc['shading'] = 'gouraud'
+        
         if self.pageUpdated:
             # reset updates
             self.mapWindow.update['surface']['draw'] = {}
-            self.mapWindow.update['surface']['draw']['mode'] = (value, all)
+            self.mapWindow.update['surface']['draw']['mode'] = { 'value' : value,
+                                                                 'all' : all,
+                                                                 'desc' : desc }
             self.UpdateLayerProperties()
 
     def OnSurfaceMode(self, event):
@@ -1740,7 +1771,7 @@
         """Set draw mode (including wire color) for all loaded surfaces"""
         self.SetSurfaceMode(all=True)
         self.SetSurfaceResolution(all=True)
-        color = self.FindWindowById(self.win['surface']['draw']['color']).GetColour()
+        color = self.FindWindowById(self.win['surface']['draw']['wire-color']).GetColour()
         self.SetSurfaceWireColor(color, all=True)
 
         if apply and self.parent.autoRender.IsChecked():
@@ -1753,7 +1784,8 @@
         if self.pageUpdated:
             # reset updates
             self.mapWindow.update['surface']['draw'] = {}
-            self.mapWindow.update['surface']['draw']['color'] = (value, all)
+            self.mapWindow.update['surface']['draw']['wire-color'] = { 'value' : value,
+                                                                       'all' : all }
             self.UpdateLayerProperties()
 
     def OnSurfaceWireColor(self, event):
@@ -1895,26 +1927,85 @@
                     win.SetValue(value)
             # enable/disable res widget + set draw mode
             self.SetSurfaceMode()
-            color = self.FindWindowById(self.win['surface']['draw']['color'])
+            color = self.FindWindowById(self.win['surface']['draw']['wire-color'])
             self.SetSurfaceWireColor(color.GetColour())
-            
-            if layer.type == 'raster':
+
+            #
+            # check for properties in workspace
+            #
+            if layer.type == 'raster' and data:
+                self.pageUpdated = True # -> updates properties (TODO)
+
                 surfProp = data['surface']
+                #
                 # surface attributes
+                #
                 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'])
-                        
+
+                    value = surfProp['attribute'][attr]['value']                        
                     if attr == 'color':
-                        color = tuple(map(int, surfProp['attribute'][attr]['value'].split(':')))
-                        # TODO: save as tuple
+                        color = tuple(map(int, value.split(':')))
                         win.SetColour(color)
                     else:
-                        win.SetValue(surfProp['attribute'][attr]['value'])
+                        win.SetValue(value)
+                    
+                    useMap = surfProp['attribute'][attr]['map']
+                    self.SetSurfaceUseMap(attr, useMap) # update widgets
 
+                    self.mapWindow.update['surface']['attribute'][attr] = { 'map' : useMap,
+                                                                            'value' : value,
+                                                                            }
+                #
+                # draw
+                #
+                # mode
+                if surfProp['draw'].has_key('mode'):
+
+                    mode = surfProp['draw']['mode']['desc']['mode']
+                    style = surfProp['draw']['mode']['desc']['style']
+                    shade = surfProp['draw']['mode']['desc']['shading']
+
+                    if mode == 'coarse':
+                        self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(0)
+                    elif mode == 'fine':
+                        self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(1)
+                    else: # both
+                        self.FindWindowById(self.win['surface']['draw']['mode']).SetSelection(2)
+
+                    if style == 'wire':
+                        self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(0)
+                    else: # surface
+                        self.FindWindowById(self.win['surface']['draw']['style']).SetSelection(1)
+
+                    if shade == 'flat':
+                        self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(0)
+                    else: # gouraud
+                        self.FindWindowById(self.win['surface']['draw']['shading']).SetSelection(1)
+                    
+                    self.SetSurfaceMode(all=False)
+
+                # resolution
+                if surfProp['draw'].has_key('resolution'):
+                    self.FindWindowById(self.win['surface']['draw']['res-coarse']). \
+                        SetValue(surfProp['draw']['resolution']['coarse'])
+                    self.FindWindowById(self.win['surface']['draw']['res-fine']). \
+                        SetValue(surfProp['draw']['resolution']['fine'])
+                    
+                    self.SetSurfaceResolution(all=False)
+
+                # wire-color
+                if surfProp['draw'].has_key('wire-color'):
+                    color = map(int, surfProp['draw']['wire-color']['value'].split(':'))
+                    self.FindWindowById(self.win['surface']['draw']['wire-color']).SetColour(color)
+
+                    self.SetSurfaceWireColor(color, all=False)
+
+                self.UpdateLayerProperties()
+
         elif pageId == 'vector':
             # disable surface and enable current
             self.notebook.GetPage(self.page['surface']).Enable(False)

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-12 13:42:01 UTC (rev 32081)
@@ -373,7 +373,7 @@
                         'value' : (0, 0, 0, 255), # constant: black
                         },
                     'draw' : {
-                        'color' : (136, 136, 136, 255),
+                        'wire-color' : (136, 136, 136, 255),
                         'mode' : 1, # fine
                         'style' : 1, # surface
                         'shading' : 1, # gouraud

Modified: grass/trunk/gui/wxpython/gui_modules/workspace.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/workspace.py	2008-07-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/gui_modules/workspace.py	2008-07-12 13:42:01 UTC (rev 32081)
@@ -38,24 +38,15 @@
     defined in grass-gxw.dtd.
     """
     def __init__(self):
-        self.inGxw       = False
-        self.inLayer     = False
-        self.inTask      = False
-        self.inParameter = False
-        self.inFlag      = False
-        self.inValue     = False
-        self.inGroup     = False
-        self.inDisplay   = False
-        self.inLayerManager = False
+        self.inTag = {}
+        for tag in ('gxw', 'layer', 'task', 'parameter',
+                    'flag', 'value', 'group', 'display',
+                    'layer_manager',
+                    'nviz', 'attribute', 'draw', 'resolution',
+                    'wire_color'):
+            self.inTag[tag] = False
 
         #
-        # Nviz section
-        #
-        self.inNviz = False
-        self.inAttribute = False
-        self.refAttribute = None
-
-        #
         # layer manager properties
         #
         self.layerManager = {}
@@ -71,11 +62,9 @@
         self.displayIndex = -1 # first display has index '0'
 
     def startElement(self, name, attrs):
-        if name == 'gxw':
-            self.inGxw = True
+        self.inTag[name] = True
 
-        elif name == 'display':
-            self.inDisplay = True
+        if name == 'display':
             self.displayIndex += 1
 
             # window position and size
@@ -116,12 +105,10 @@
                 "checked" : int(self.groupChecked),
                 "opacity" : None,
                 "cmd"     : None,
-                "group"   : self.inGroup,
+                "group"   : self.inTag['group'],
                 "display" : self.displayIndex})
-            self.inGroup = True
 
         elif name == 'layer':
-            self.inLayer = True
             self.layerType     = attrs.get('type', None)
             self.layerName     = attrs.get('name', None)
             self.layerChecked  = attrs.get('checked', None)
@@ -131,29 +118,24 @@
             self.cmd = []
 
         elif name == 'task':
-            self.inTask = True;
             name = attrs.get('name', None)
             self.cmd.append(name)
 
         elif name == 'parameter':
-            self.inParameter = True;
             self.parameterName = attrs.get('name', None)
 
         elif name == 'value':
-            self.inValue = True
             self.value = ''
 
         elif name == 'flag':
-            self.inFlag = True;
             name = attrs.get('name', None)
             self.cmd.append('-' + name)
 
         elif name == 'selected':
-            if self.inLayer:
+            if self.inTag['layer']:
                 self.layerSelected = True;
 
         elif name == 'layer_manager':
-            self.inLayerManager = True
             posAttr = attrs.get('dim', '')
             if posAttr:
                 posVal = map(int, posAttr.split(','))
@@ -169,7 +151,6 @@
         # Nviz section
         #
         elif name == 'nviz':
-            self.inNviz = True
             # init nviz layer properties
             self.layerNviz = {}
             self.layerNviz['view'] = None
@@ -181,37 +162,48 @@
                 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'):
+            if attrs.get('map', '0') == '0':
                 self.layerNviz['surface'][tagName][attrbName]['map'] = False
             else:
                 self.layerNviz['surface'][tagName][attrbName]['map'] = True
 
             self.refAttribute = self.layerNviz['surface'][tagName][attrbName]
+        
+        elif name == 'draw':
+            tagName = str(name)
+            self.layerNviz['surface'][tagName]['mode'] = {}
+            self.layerNviz['surface'][tagName]['mode']['all'] = False
+            self.layerNviz['surface'][tagName]['mode']['value'] = -1 # to be calculated
+            self.layerNviz['surface'][tagName]['mode']['desc'] = {}
+            self.layerNviz['surface'][tagName]['mode']['desc']['shading'] = \
+                str(attrs.get('shading', ''))
+            self.layerNviz['surface'][tagName]['mode']['desc']['style'] = \
+                str(attrs.get('style', ''))
+            self.layerNviz['surface'][tagName]['mode']['desc']['mode'] = \
+                str(attrs.get('mode', ''))
 
+        elif name == 'resolution':
+            self.resolutionType = str(attrs.get('type', ''))
+            if not self.layerNviz['surface']['draw'].has_key(str(name)):
+                self.layerNviz['surface']['draw'][str(name)] = {}
+                
     def endElement(self, name):
-        if name == 'gxw':
-            self.inGxw = False
+        self.inTag[name] = False
 
-        elif name == 'display':
-            self.inDisplay = False
-
-        elif name == 'group':
-            self.inGroup = False
+        if name == 'group':
             self.groupName = self.groupChecked = None
 
         elif name == 'layer':
-            self.inLayer = False
             self.layers.append({
                     "type"     : self.layerType,
                     "name"     : self.layerName,
                     "checked"  : int(self.layerChecked),
                     "opacity"  : None,
                     "cmd"      : None,
-                    "group"    : self.inGroup,
+                    "group"    : self.inTag['group'],
                     "display"  : self.displayIndex,
                     "selected" : self.layerSelected,
                     "nviz"     : self.layerNviz})
@@ -224,38 +216,37 @@
             self.layerType = self.layerName = self.Checked = \
                 self.Opacity = self.cmd = None
 
-        elif name == 'task':
-            self.inTask = False
-
         elif name == 'parameter':
-            self.inParameter = False
             self.cmd.append('%s=%s' % (self.parameterName, self.value))
             self.parameterName = self.value = None
 
-        elif name == 'value':
-            self.inValue = False
-
-        elif name == 'flag':
-            self.inFlag = False
-
-        elif name == 'layer_manager':
-            self.inLayerManager = False
-
         #
         # Nviz section
         #
-        elif name == 'nviz':
-            self.inNviz = False
-
         elif name == 'attribute':
-            self.inAttribute = False
-            self.refAttribute['value'] = str(self.value)
+            try:
+                self.refAttribute['value'] = int(self.value)
+            except ValueError:
+                try:
+                    self.refAttribute['value'] = float(self.value)
+                except ValueError:
+                    self.refAttribute['value'] = str(self.value)
 
+        elif name == 'resolution':
+            self.layerNviz['surface']['draw']['resolution']['all'] = False
+            self.layerNviz['surface']['draw']['resolution'][self.resolutionType] = int(self.value)
+            del self.resolutionType
+
+        elif name == 'wire_color':
+            self.layerNviz['surface']['draw']['wire-color'] = {}
+            self.layerNviz['surface']['draw']['wire-color']['all'] = False
+            self.layerNviz['surface']['draw']['wire-color']['value'] = str(self.value)
+
     def characters(self, ch):
         self.my_characters(ch)
 
     def my_characters(self, ch):
-        if self.inValue:
+        if self.inTag['value']:
             self.value += ch
 
 class WriteWorkspaceFile(object):
@@ -374,9 +365,9 @@
                 if nviz:
                     self.file.write('%s<nviz>\n' % (' ' * self.indent));
                     if maplayer.type == 'raster':
-                        self.__writeNvizSurface(nviz)
+                        self.__writeNvizSurface(nviz['surface'])
                     elif maplayer.type == 'vector':
-                        self.__writeNvizVector(nviz)
+                        self.__writeNvizVector(nviz['vector'])
                     self.file.write('%s</nviz>\n' % (' ' * self.indent));
                 self.indent -= 4
                 self.file.write('%s</layer>\n' % (' ' * self.indent));
@@ -400,40 +391,51 @@
                     self.indent += 4
                     self.file.write('%s<value>%s</value>\n' % (' ' * self.indent, data[attrb][name]['value']))
                     self.indent -= 4
+                    # end tag
+                    self.file.write('%s</%s>\n' % (' ' * self.indent, attrb))
+
             # draw mode
             if attrb == 'draw':
                 self.file.write('%s<%s' %(' ' * self.indent, attrb))
-                resTag = None
-                for name in data[attrb]:
-                    if name == 'resolution':
+                if data[attrb].has_key('mode'):
+                    for tag, value in data[attrb]['mode']['desc'].iteritems():
+                        self.file.write(' %s="%s"' % (tag, value))
+                self.file.write('>\n') # <draw ...>
+
+                if data[attrb].has_key('resolution'):
+                    self.indent += 4
+                    for type in ('coarse', 'fine'):
+                        self.file.write('%s<resolution type="%s">\n' % (' ' * self.indent, type))
                         self.indent += 4
-                        resTag = ''
-                        for type, value in (('coarse', data[attrb][name][0]),
-                                            ('fine', data[attrb][name][1])):
-                            resTag += '%s<resolution type="%s">\n' % (' ' * self.indent, type)
-                            self.indent += 4
-                            resTag += '%s<value>%s</value>\n' % (' ' * self.indent, value)
-                            self.indent -= 4
-                            resTag += '%s</resolution>\n' % (' ' * self.indent)
+                        self.file.write('%s<value>%d</value>\n' % (' ' * self.indent,
+                                                                   data[attrb]['resolution'][type]))
                         self.indent -= 4
-                    else:
-                        # note: second argument is 'all' -> skip
-                        self.file.write(' %s="%s"' % (name, data[attrb][name][0]))
-                self.file.write('>\n') # <draw ...>
-                if resTag:
-                    self.file.write(resTag)
+                        self.file.write('%s</resolution>\n' % (' ' * self.indent))
+
+                if data[attrb].has_key('wire-color'):
+                    self.file.write('%s<wire_color>\n' % (' ' * self.indent))
+                    self.indent += 4
+                    self.file.write('%s<value>%s</value>\n' % (' ' * self.indent,
+                                                               data[attrb]['wire-color']['value']))
+                    self.indent -= 4
+                    self.file.write('%s</wire_color>\n' % (' ' * self.indent))
+            
             # position
             elif attrb == 'position':
                 self.file.write('%s<%s>\n' %(' ' * self.indent, attrb))
                 i = 0
                 for tag in ('x', 'y', 'z'):
                     self.indent += 4
-                    self.file.write('%s<%s>%s<%s>\n' % (' ' * self.indent, tag,
+                    file.write('%s<%s>%s<%s>\n' % (' ' * self.indent, tag,
                                                    data[attrb][name][i], tag))
                     i += 1
                     self.indent -= 4
-            # end tag
-            self.file.write('%s</%s>\n' % (' ' * self.indent, attrb))
+
+            if attrb != 'attribute':
+                # end tag
+                self.indent -= 4
+                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-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/gui_modules/wxgui_utils.py	2008-07-12 13:42:01 UTC (rev 32081)
@@ -828,11 +828,19 @@
                 self.GetPyData(item) is not None:
             # nviz - load/unload data layer
             mapLayer = self.GetPyData(item)[0]['maplayer']
+
             if checked: # enable
+                
+                busy = wx.BusyInfo(message=_("Please wait, loading data..."),
+                                   parent=self.mapdisplay)
+                wx.Yield()
+
                 if mapLayer.type == 'raster':
                     self.mapdisplay.MapWindow.LoadRaster(mapLayer)
                 elif mapLayer.type == 'vector':
                     self.mapdisplay.MapWindow.LoadVector(mapLayer)
+
+                busy.Destroy()
             else: # disable
                 if mapLayer.type == 'raster':
                     self.mapdisplay.MapWindow.UnloadRaster(mapLayer)
@@ -918,6 +926,7 @@
                 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')
                 self.mapdisplay.nvizToolWin.SetPage('surface')

Modified: grass/trunk/gui/wxpython/xml/grass-gxw.dtd
===================================================================
--- grass/trunk/gui/wxpython/xml/grass-gxw.dtd	2008-07-11 21:54:30 UTC (rev 32080)
+++ grass/trunk/gui/wxpython/xml/grass-gxw.dtd	2008-07-12 13:42:01 UTC (rev 32081)
@@ -77,9 +77,24 @@
 
 <!--    nviz layer properties
 -->
-<!ELEMENT nviz	        (attribute*)>
+<!ELEMENT nviz	        (attribute*, draw?)>
 
-<!--    nviz  surface attribute parameter
+<!--    nviz surface attribute parameter
 -->
 <!ELEMENT attribute     (value)>
 <!ATTLIST attribute	map		(0 | 1) #REQUIRED>
+
+<!--    nviz surface draw mode parameter
+-->
+<!ELEMENT draw          (resolution*, wire-color?)>
+<!ATTLIST draw	        mode		(coarse | fine | both) #IMPLIED>
+<!ATTLIST draw	        style		(wire | surface) #IMPLIED>
+<!ATTLIST draw	        shading		(gouraud | flat) #IMPLIED>
+
+<!--    nviz surface draw resolution
+-->
+<!ELEMENT resolution    (value)>
+
+<!--    nviz surface wire color
+-->
+<!ELEMENT wire_color    (value)>



More information about the grass-commit mailing list