[GRASS-SVN] r32056 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 9 05:17:33 EDT 2008


Author: martinl
Date: 2008-07-09 05:17:33 -0400 (Wed, 09 Jul 2008)
New Revision: 32056

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/nviz.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
Log:
nviz2/wxGUI: nviz settings (apply, restore default), todo: save + update dialog

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-07-09 07:55:49 UTC (rev 32055)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-07-09 09:17:33 UTC (rev 32056)
@@ -105,7 +105,8 @@
         """
         if Debug.get_level() == 0:
             # don't redirect when debugging is enabled
-            sys.stderr = self.cmd_stderr
+            # sys.stderr = self.cmd_stderr
+            pass
 
             return True
 

Modified: grass/trunk/gui/wxpython/gui_modules/nviz.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-09 07:55:49 UTC (rev 32055)
+++ grass/trunk/gui/wxpython/gui_modules/nviz.py	2008-07-09 09:17:33 UTC (rev 32056)
@@ -20,6 +20,7 @@
 import os
 import sys
 import time
+import copy
 
 from threading import Thread
 
@@ -76,12 +77,6 @@
 
         self.parent = parent # MapFrame
 
-        # attribList=[wx.WX_GL_RGBA, wx.GLX_RED_SIZE, 1,
-        #             wx.GLX_GREEN_SIZE, 1,
-        #             wx.GLX_BLUE_SIZE, 1,
-        #             wx.GLX_DEPTH_SIZE, 1,
-        #             None])
-
         self.init = False
         self.render = True # render in full resolution
 
@@ -110,6 +105,7 @@
         # default values
         #
         self.view = UserSettings.Get(group='nviz', key='view') # reference
+        self.iview = UserSettings.Get(group='nviz', key='view', internal=True)
         self.update = {} # update view/controls
         self.object = {} # loaded data objects (layer index / gsurf id)
 
@@ -145,7 +141,7 @@
             self.nvizClass.InitView()
             self.LoadDataLayers()
             self.view['z-exag']['value'], \
-                self.view['height']['value'] = self.nvizClass.SetViewDefault()
+                self.iview['height']['value'] = self.nvizClass.SetViewDefault()
             
             if hasattr(self.parent, "nvizToolWin"):
                 self.parent.nvizToolWin.UpdatePage('view')
@@ -180,7 +176,7 @@
                 self.parent.nvizToolWin.UpdateSettings()
 
             self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
-                                   self.view['height']['value'],
+                                   self.iview['height']['value'],
                                    self.view['persp']['value'],
                                    self.view['twist']['value'])
 
@@ -232,7 +228,7 @@
 
         if 'view' in self.update.keys():
             self.nvizClass.SetView(self.view['pos']['x'], self.view['pos']['y'],
-                                   self.view['height']['value'],
+                                   self.iview['height']['value'],
                                    self.view['persp']['value'],
                                    self.view['twist']['value'])
             del self.update['view']
@@ -370,7 +366,7 @@
         self.view['pos']['x'] = wxnviz.VIEW_DEFAULT_POS_X
         self.view['pos']['y'] = wxnviz.VIEW_DEFAULT_POS_Y
         self.view['z-exag']['value'], \
-            self.view['height']['value'] = self.nvizClass.SetViewDefault()
+            self.iview['height']['value'] = self.nvizClass.SetViewDefault()
         self.view['persp']['value'] = wxnviz.VIEW_DEFAULT_PERSP
         self.view['twist']['value'] = wxnviz.VIEW_DEFAULT_TWIST
 
@@ -506,8 +502,9 @@
         gridSizer.Add(item=posSizer, pos=(0, 0))
                   
         # perspective
+        range = UserSettings.Get(group='nviz', key='view', subkey='persp', internal=True)
         self.CreateControl(panel, dict=self.win['view'], name='persp',
-                           range=(self.settings['persp']['min'], self.settings['persp']['max']),
+                           range=(range['min'], range['max']),
                            bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
         gridSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Perspective:")),
                       pos=(1, 0), flag=wx.ALIGN_CENTER)
@@ -516,8 +513,9 @@
                       flag=wx.ALIGN_CENTER)        
 
         # twist
+        range = UserSettings.Get(group='nviz', key='view', subkey='twist', internal=True)
         self.CreateControl(panel, dict=self.win['view'], name='twist',
-                           range=(self.settings['twist']['min'], self.settings['twist']['max']),
+                           range=(range['min'], range['max']),
                            bind=(self.OnViewChange, self.OnViewChanged, self.OnViewChangedSpin))
         gridSizer.Add(item=wx.StaticText(panel, id=wx.ID_ANY, label=_("Twist:")),
                       pos=(1, 1), flag=wx.ALIGN_CENTER)
@@ -1014,15 +1012,18 @@
 
 
         # perspective
+        self.win['settings']['view']['persp'] = {}
         pvals = UserSettings.Get(group='nviz', key='view', subkey='persp')
+        ipvals = UserSettings.Get(group='nviz', key='view', subkey='persp', internal=True)
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Perspective (value):")),
                       pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)
 
         pval = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                            initial=pvals['value'],
-                           min=pvals['min'],
-                           max=pvals['max'])
+                           min=ipvals['min'],
+                           max=ipvals['max'])
+        self.win['settings']['view']['persp']['value'] = pval.GetId()
         gridSizer.Add(item=pval, pos=(0, 1),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1032,12 +1033,14 @@
 
         pstep = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                            initial=pvals['step'],
-                           min=pvals['min'],
-                           max=pvals['max']-1)
+                           min=ipvals['min'],
+                           max=ipvals['max']-1)
+        self.win['settings']['view']['persp']['step'] = pstep.GetId()
         gridSizer.Add(item=pstep, pos=(0, 3),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
         # position
+        self.win['settings']['view']['pos'] = {}
         posvals = UserSettings.Get(group='nviz', key='view', subkey='pos')
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Position") + " (x):"),
@@ -1047,6 +1050,7 @@
                            initial=posvals['x'] * 100,
                            min=0,
                            max=100)
+        self.win['settings']['view']['pos']['x'] = px.GetId()
         gridSizer.Add(item=px, pos=(1, 1),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1058,10 +1062,12 @@
                            initial=posvals['y'] * 100,
                            min=0,
                            max=100)
+        self.win['settings']['view']['pos']['y'] = py.GetId()
         gridSizer.Add(item=py, pos=(1, 3),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
         # height
+        self.win['settings']['view']['height'] = {}
         hvals = UserSettings.Get(group='nviz', key='view', subkey='height')
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Height") + " (min):"),
@@ -1071,6 +1077,7 @@
                            initial=hvals['min'],
                            min=-1e6,
                            max=1e6)
+        self.win['settings']['view']['height']['min'] = hmin.GetId()
         gridSizer.Add(item=hmin, pos=(2, 1),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1082,6 +1089,7 @@
                            initial=hvals['max'],
                            min=-1e6,
                            max=1e6)
+        self.win['settings']['view']['height']['max'] = hmax.GetId()
         gridSizer.Add(item=hmax, pos=(2, 3),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1093,19 +1101,23 @@
                            initial=hvals['step'],
                            min=1,
                            max=hvals['max']-1)
+        self.win['settings']['view']['height']['step'] = hstep.GetId()
         gridSizer.Add(item=hstep, pos=(2, 5),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
         # twist
+        self.win['settings']['view']['twist'] = {}
         tvals = UserSettings.Get(group='nviz', key='view', subkey='twist')
+        itvals = UserSettings.Get(group='nviz', key='view', subkey='twist', internal=True)
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Twist (value):")),
                       pos=(3, 0), flag=wx.ALIGN_CENTER_VERTICAL)
 
         tval = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                            initial=tvals['value'],
-                           min=tvals['min'],
-                           max=tvals['max'])
+                           min=itvals['min'],
+                           max=itvals['max'])
+        self.win['settings']['view']['twist']['value'] = tval.GetId()
         gridSizer.Add(item=tval, pos=(3, 1),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1115,12 +1127,14 @@
 
         tstep = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                            initial=tvals['step'],
-                           min=tvals['min'],
-                           max=tvals['max']-1)
+                           min=itvals['min'],
+                           max=itvals['max']-1)
+        self.win['settings']['view']['twist']['step'] = tstep.GetId()
         gridSizer.Add(item=tstep, pos=(3, 3),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
         # z-exag
+        self.win['settings']['view']['z-exag'] = {}
         zvals = UserSettings.Get(group='nviz', key='view', subkey='z-exag')
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Z-exag (value):")),
@@ -1130,6 +1144,7 @@
                            initial=zvals['value'],
                            min=-1e6,
                            max=1e6)
+        self.win['settings']['view']['z-exag']['value'] = zval.GetId()
         gridSizer.Add(item=zval, pos=(4, 1),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1141,6 +1156,7 @@
                            initial=zvals['step'],
                            min=-1e6,
                            max=1e6)
+        self.win['settings']['view']['z-exag']['step'] = zstep.GetId()
         gridSizer.Add(item=zstep, pos=(4, 3),
                       flag=wx.ALIGN_CENTER_VERTICAL)
 
@@ -1181,7 +1197,32 @@
         pageSizer.Add(item=boxSizer, proportion=0,
                       flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                       border=5)
-        
+
+        #
+        # buttons
+        #
+        btnDefault = wx.Button(panel, wx.ID_CANCEL, label=_("Default"))
+        btnSave = wx.Button(panel, wx.ID_SAVE)
+        btnApply = wx.Button(panel, wx.ID_APPLY)
+
+        btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
+        btnDefault.SetToolTipString(_("Restore default settings"))
+        btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
+        btnApply.SetToolTipString(_("Apply changes for the current session"))
+        btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
+        btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
+        btnSave.SetDefault()
+
+        btnSizer = wx.StdDialogButtonSizer()
+        btnSizer.AddButton(btnDefault)
+        btnSizer.AddButton(btnApply)
+        btnSizer.AddButton(btnSave)
+        btnSizer.Realize()
+
+        pageSizer.Add(item=btnSizer, proportion=1,
+                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM,
+                      border=5)
+
         panel.SetSizer(pageSizer)
 
     def CreateControl(self, parent, dict, name, range, bind, sliderHor=True, size=200):
@@ -1231,7 +1272,12 @@
                         'twist',
                         'z-exag'):
             for win in self.win['view'][control].itervalues():
-                self.FindWindowById(win).SetValue(int(self.settings[control]['value']))
+                if control == 'height':
+                    value = UserSettings.Get(group='nviz', key='view',
+                                             subkey=['height', 'value'], internal=True)
+                else:
+                    value = self.settings[control]['value']
+                self.FindWindowById(win).SetValue(value)
 
         self.FindWindowById(self.win['view']['pos']).Draw()
         self.FindWindowById(self.win['view']['pos']).Refresh(False)
@@ -1320,6 +1366,45 @@
         self.UpdateSettings()
         self.mapWindow.Refresh(False)
 
+    def OnDefault(self, event):
+        """Restore default settings"""
+        self.settings = copy.deepcopy(UserSettings.GetDefaultSettings()['nviz'])
+        UserSettings.Set(group='nviz', key='view',
+                         value=self.settings)
+
+        for subgroup, key in self.settings.iteritems(): # view, surface, vector...
+            if subgroup != 'view':
+                continue
+            for subkey, value in key.iteritems():
+                for subvalue in value.keys():
+                    win = self.FindWindowById(self.win['settings'][subgroup][subkey][subvalue])
+                    val = self.settings[subgroup][subkey][subvalue]
+                    if subkey == 'pos':
+                        val = int(val * 100)
+
+                    win.SetValue(val)
+        
+        event.Skip()
+
+    def OnApply(self, event):
+        """Apply button pressed"""
+        if self.notebook.GetSelection() == self.page['settings']:
+            self.ApplySettings()
+
+        event.Skip()
+
+    def ApplySettings(self):
+        """Apply Nviz settings for current session"""
+        for subgroup, key in self.settings.iteritems(): # view, surface, vector...
+            if subgroup != 'view':
+                continue
+            for subkey, value in key.iteritems():
+                for subvalue in value.keys():
+                    value = self.FindWindowById(self.win['settings'][subgroup][subkey][subvalue]).GetValue()
+                    if subkey == 'pos':
+                        value = float(value) / 100
+                    self.settings[subgroup][subkey][subvalue] = int(value)
+
     def OnSave(self, event):
         """OK button pressed
         

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-09 07:55:49 UTC (rev 32055)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-09 09:17:33 UTC (rev 32056)
@@ -56,183 +56,322 @@
             #
             'general': {
                 # current mapset search path
-                'mapsetPath'  : { 'selection' : 0 }, 
+                'mapsetPath'  : {
+                    'selection' : 0
+                    }, 
                 # use default window layout (layer manager, displays, ...)
-                'defWindowPos' : { 'enabled' : False, 'dim' : '' },
+                'defWindowPos' : {
+                    'enabled' : False,
+                    'dim' : ''
+                    },
                 # expand/collapse element list
-                'elementListExpand' : { 'selection' : 0 },
+                'elementListExpand' : {
+                    'selection' : 0 
+                    },
                 },
             'manager' : {
                 # show opacity level widget
-                'changeOpacityLevel' : { 'enabled' : False }, 
+                'changeOpacityLevel' : {
+                    'enabled' : False
+                    }, 
                 # ask when removing layer from layer tree
-                'askOnRemoveLayer' : { 'enabled' : True },
+                'askOnRemoveLayer' : {
+                    'enabled' : True
+                    },
                 },
             #
             # display
             #
             'display': {
-                'displayFont' : { 'value' : '' },
-                'driver': { 'type': 'default' },
-                'compResolution' : { 'enabled' : False },
-                'autoRendering': { 'enabled' : False },
-                'statusbarMode': { 'selection' : 0 },
+                'displayFont' : {
+                    'value' : ''
+                    },
+                'driver': {
+                    'type': 'default'
+                    },
+                'compResolution' : {
+                    'enabled' : False
+                    },
+                'autoRendering': {
+                    'enabled' : False
+                    },
+                'statusbarMode': {
+                    'selection' : 0
+                    },
                 },
             #
             # advanced
             #
             'advanced' : {
-                'settingsFile'   : { 'type' : 'home' }, # home, gisdbase, location, mapset
-                'digitInterface' : { 'type' : 'vdigit' }, # vedit, vdigit
-                'iconTheme'      : { 'type' : 'silk' }, # grass, silk
+                'settingsFile' : {
+                    'type' : 'home'
+                    }, # home, gisdbase, location, mapset
+                'digitInterface' : {
+                    'type' : 'vdigit'
+                    }, # vedit, vdigit
+                'iconTheme' : {
+                    'type' : 'silk'
+                    }, # grass, silk
                 },
             #
             # Attribute Table Manager
             #
             'atm' : {
-                'highlight' : { 'color' : (255, 255, 0, 255), 'width' : 2},
-                'leftDbClick' : { 'selection' : 0 },
+                'highlight' : {
+                    'color' : (255, 255, 0, 255),
+                    'width' : 2
+                    },
+                'leftDbClick' : {
+                    'selection' : 0
+                    },
             },
             #
             # Command
             #
             'cmd': {
-                'overwrite' : { 'enabled' : False },
-                'closeDlg' : { 'enabled' : False },
-                'verbosity' : { 'selection' : 'grassenv' },
-                'rasterOverlay' : { 'enabled' : False },
+                'overwrite' : {
+                    'enabled' : False
+                    },
+                'closeDlg' : {
+                    'enabled' : False
+                    },
+                'verbosity' : {
+                    'selection' : 'grassenv'
+                    },
+                'rasterOverlay' : {
+                    'enabled' : False
+                    },
                 },
             #
             # Workspace
             #
             'workspace' : {
-                'posDisplay' : { 'enabled' : False },
-                'posManager' : { 'enabled' : False },
+                'posDisplay' : {
+                    'enabled' : False
+                    },
+                'posManager' : {
+                    'enabled' : False
+                    },
                 },
             #
             # vdigit
             #
             'vdigit' : {
                 # symbology
-                'symbolHighlight'   : { 'enabled' : None,  'color' : (255, 255, 0, 255) }, # yellow
-                'symbolHighlightDupl' : { 'enabled' : None,  'color' : (255, 72, 0, 255) }, # red
-                'symbolPoint'       : { 'enabled' : True,  'color' : (0, 0, 0, 255) }, # black
-                'symbolLine'        : { 'enabled' : True,  'color' : (0, 0, 0, 255) }, # black
-                'symbolBoundaryNo'  : { 'enabled' : True,  'color' : (126, 126, 126, 255) }, # grey
-                'symbolBoundaryOne' : { 'enabled' : True,  'color' : (0, 255, 0, 255) }, # green
-                'symbolBoundaryTwo' : { 'enabled' : True,  'color' : (255, 135, 0, 255) }, # orange
-                'symbolCentroidIn'  : { 'enabled' : True,  'color' : (0, 0, 255, 255) }, # blue
-                'symbolCentroidOut' : { 'enabled' : True,  'color' : (165, 42, 42, 255) }, # brown
-                'symbolCentroidDup' : { 'enabled' : True,  'color' : (156, 62, 206, 255) }, # violet
-                'symbolNodeOne'     : { 'enabled' : True,  'color' : (255, 0, 0, 255) }, # red
-                'symbolNodeTwo'     : { 'enabled' : True,  'color' : (0, 86, 45, 255) }, # dark green
-                'symbolVertex'      : { 'enabled' : False, 'color' : (255, 20, 147, 255) }, # deep pink
-                'symbolDirection'   : { 'enabled' : False, 'color' : (255, 0, 0, 255) }, # red
+                'symbolHighlight' : {
+                    'enabled' : None,
+                    'color' : (255, 255, 0, 255)
+                    }, # yellow
+                'symbolHighlightDupl' : {
+                    'enabled' : None,
+                    'color' : (255, 72, 0, 255)
+                    }, # red
+                'symbolPoint' : {
+                    'enabled' : True,
+                    'color' : (0, 0, 0, 255)
+                    }, # black
+                'symbolLine' : {
+                    'enabled' : True,
+                    'color' : (0, 0, 0, 255)
+                    }, # black
+                'symbolBoundaryNo' : {
+                    'enabled' : True,
+                    'color' : (126, 126, 126, 255)
+                    }, # grey
+                'symbolBoundaryOne' : {
+                    'enabled' : True,
+                    'color' : (0, 255, 0, 255)
+                    }, # green
+                'symbolBoundaryTwo' : {
+                    'enabled' : True,
+                    'color' : (255, 135, 0, 255)
+                    }, # orange
+                'symbolCentroidIn' : {
+                    'enabled' : True,
+                    'color' : (0, 0, 255, 255)
+                    }, # blue
+                'symbolCentroidOut' : {
+                    'enabled' : True,
+                    'color' : (165, 42, 42, 255)
+                    }, # brown
+                'symbolCentroidDup' : {
+                    'enabled' : True,
+                    'color' : (156, 62, 206, 255)
+                    }, # violet
+                'symbolNodeOne' : {
+                    'enabled' : True,
+                    'color' : (255, 0, 0, 255)
+                    }, # red
+                'symbolNodeTwo' : {
+                    'enabled' : True,
+                    'color' : (0, 86, 45, 255)
+                    }, # dark green
+                'symbolVertex' : {
+                    'enabled' : False,
+                    'color' : (255, 20, 147, 255)
+                    }, # deep pink
+                'symbolDirection' : {
+                    'enabled' : False,
+                    'color' : (255, 0, 0, 255)
+                    }, # red
                 # display
-                'lineWidth' : { 'value' : 2, 'units' : 'screen pixels' },
+                'lineWidth' : {
+                    'value' : 2,
+                    'units' : 'screen pixels'
+                    },
                 # snapping
-                'snapping' : { 'value' : 10, 'units' : 'screen pixels' },
-                'snapToVertex' : { 'enabled' : False },
-                'backgroundMap' : {'value' : ''},
+                'snapping' : {
+                    'value' : 10,
+                    'units' : 'screen pixels'
+                    },
+                'snapToVertex' : {
+                    'enabled' : False
+                    },
+                'backgroundMap' : {
+                    'value' : ''
+                    },
                 # digitize new record
-                'addRecord' : { 'enabled' : True },
-                'layer' : {'value' : 1 },
-                'category' : {'value' : 1 },
-                'categoryMode' : {'selection' : 0 },
+                'addRecord' : {
+                    'enabled' : True
+                    },
+                'layer' :{
+                    'value' : 1
+                    },
+                'category' : {
+                    'value' : 1
+                    },
+                'categoryMode' : {
+                    'selection' : 0
+                    },
                 # delete existing feature(s)
-                'delRecord' : { 'enabled' : True },
+                'delRecord' : {
+                    'enabled' : True
+                    },
                 # query tool
-                'query'       : { 'selection' : 0, 'box' : True },
-                'queryLength' : { 'than-selection' : 0, 'thresh' : 0 },
-                'queryDangle' : { 'than-selection' : 0, 'thresh' : 0 },
+                'query' : {
+                    'selection' : 0,
+                    'box' : True
+                    },
+                'queryLength' : {
+                    'than-selection' : 0,
+                    'thresh' : 0
+                    },
+                'queryDangle' : {
+                    'than-selection' : 0,
+                    'thresh' : 0
+                    },
                 # select feature (point, line, centroid, boundary)
-                'selectFeaturePoint'    : { 'enabled' : True },
-                'selectFeatureLine'     : { 'enabled' : True },
-                'selectFeatureCentroid' : { 'enabled' : True },
-                'selectFeatureBoundary' : { 'enabled' : True },
-                'selectThresh'          : { 'value' : 10, 'units' : 'screen pixels'},
-                'checkForDupl'          : { 'enabled' : False },
+                'selectFeaturePoint' : {
+                    'enabled' : True
+                    },
+                'selectFeatureLine' : {
+                    'enabled' : True
+                    },
+                'selectFeatureCentroid' : {
+                    'enabled' : True
+                    },
+                'selectFeatureBoundary' : {
+                    'enabled' : True
+                    },
+                'selectThresh' : {
+                    'value' : 10,
+                    'units' : 'screen pixels'
+                    },
+                'checkForDupl' : {
+                    'enabled' : False
+                    },
                 # exit
-                'saveOnExit'            : { 'enabled' : False },
+                'saveOnExit' : {
+                    'enabled' : False
+                    },
                 },
             'profile': {
-                'raster0' : { 'pcolor' : (0, 0, 255, 255), # profile line color
-                              'pwidth' : 1, # profile line width
-                              'pstyle' : 'solid', # profile line pen style
-                              },
-                'raster1' : { 'pcolor' : (255, 0, 0, 255), 
-                              'pwidth' : 1, 
-                              'pstyle' : 'solid', 
-                              },
-                'raster2' : { 'pcolor' : (0, 255, 0, 255), 
-                              'pwidth' : 1, 
-                              'pstyle' : 'solid', 
-                              },
-                'font' : { 'titleSize' : 12,
-                           'axisSize' : 11,
-                           'legendSize' : 10,
-                           },
-                'marker' : { 'color' : wx.Colour(0, 0, 0),
-                             'fill' : 'transparent',
-                             'size' : 2,
-                             'type' : 'triangle',
-                             'legend' : _('Segment break'),
-                             },
-                'grid' : { 'color' : wx.Colour(200,200,200) ,
-                           'enabled' : True,
-                           },
-                'x-axis' : { 'type' : 'auto', # axis format
-                             'min' : 0, # axis min for custom axis range
-                             'max': 0, # axis max for custom axis range
-                             'log' : False,
-                             },
-                'y-axis' : { 'type' : 'auto', # axis format
-                             'min' : 0, # axis min for custom axis range
-                             'max': 0, # axis max for custom axis range
-                             'log' : False,
-                             },
-                'legend' : { 'enabled' : True
-                             },
+                'raster0' : {
+                    'pcolor' : (0, 0, 255, 255), # profile line color
+                    'pwidth' : 1, # profile line width
+                    'pstyle' : 'solid', # profile line pen style
+                    },
+                'raster1' : {
+                    'pcolor' : (255, 0, 0, 255), 
+                    'pwidth' : 1, 
+                    'pstyle' : 'solid', 
+                    },
+                'raster2' : {
+                    'pcolor' : (0, 255, 0, 255), 
+                    'pwidth' : 1, 
+                    'pstyle' : 'solid', 
+                    },
+                'font' : {
+                    'titleSize' : 12,
+                    'axisSize' : 11,
+                    'legendSize' : 10,
+                    },
+                'marker' : {
+                    'color' : wx.Colour(0, 0, 0),
+                    'fill' : 'transparent',
+                    'size' : 2,
+                    'type' : 'triangle',
+                    'legend' : _('Segment break'),
+                    },
+                'grid' : {
+                    'color' : wx.Colour(200,200,200) ,
+                    'enabled' : True,
+                    },
+                'x-axis' : {
+                    'type' : 'auto', # axis format
+                    'min' : 0, # axis min for custom axis range
+                    'max': 0, # axis max for custom axis range
+                    'log' : False,
+                    },
+                'y-axis' : {
+                    'type' : 'auto', # axis format
+                    'min' : 0, # axis min for custom axis range
+                    'max': 0, # axis max for custom axis range
+                    'log' : False,
+                    },
+                'legend' : {
+                    'enabled' : True
+                    },
                 },
             'georect' : {
-                'symbol' : { 'color' : (0, 0, 255, 255),
-                             'width' : 2,
-                             },
+                'symbol' : {
+                    'color' : (0, 0, 255, 255),
+                    'width' : 2,
+                    },
                 },
             'nviz' : {
-                'view' : { 'persp' : { 'value' : 40,
-                                       'min' : 1,
-                                       'max' : 100,
-                                       'step' : 5,
-                                       'update' : False,
-                                       },
-                           'pos' : { 'x' : 0.85,
-                                     'y' : 0.85,
-                                     'update' : False,
-                                     },
-                           'height' : { 'min' : -3000, # TODO: determine min/max height
-                                        'max' : 4000, 
-                                        'step' : 100,
-                                        'update' : False,
-                                       },
-                           'twist' : { 'value' : 0,
-                                       'min' : -180,
-                                       'max' : 180,
-                                       'step' : 5,
-                                       'update' : False,
-                                       },
-                           'z-exag' : { 'value': 1,
-                                        'step' : 1,
-                                        'update' : False
-                                        },
-                           },
+                'view' : {
+                    'persp' : {
+                        'value' : 40,
+                        'step' : 5,
+                        },
+                    'pos' : {
+                        'x' : 0.85,
+                        'y' : 0.85,
+                        },
+                    'height' : {
+                        'min' : -3000, # TODO: determine min/max height
+                        'max' : 4000, 
+                        'step' : 100,
+                        },
+                    'twist' : {
+                        'value' : 0,
+                        'step' : 5,
+                        },
+                    'z-exag' : {
+                        'value': 1,
+                        'step' : 1,
+                        },
+                    },
                 'surface' : {
-                    'shine': { 'map' : False,
-                               'value' : 60.0,
-                               },
-                    'color' : { 'map' : True,
-                                'value' : (0, 0, 0, 255), # constant: black
-                                },
+                    'shine': {
+                        'map' : False,
+                        'value' : 60.0,
+                        },
+                    'color' : {
+                        'map' : True,
+                        'value' : (0, 0, 0, 255), # constant: black
+                        },
                     'draw' : {
                         'color' : (136, 136, 136, 255),
                         'mode' : 1, # fine
@@ -306,6 +445,16 @@
         self.internalSettings['display']['driver']['choices'] = ['default']
         self.internalSettings['display']['statusbarMode']['choices'] = globalvar.MAP_DISPLAY_STATUSBAR_MODE
 
+        self.internalSettings['nviz']['view'] = {}
+        self.internalSettings['nviz']['view']['twist'] = {}
+        self.internalSettings['nviz']['view']['twist']['min'] = -180
+        self.internalSettings['nviz']['view']['twist']['max'] = 180
+        self.internalSettings['nviz']['view']['persp'] = {}
+        self.internalSettings['nviz']['view']['persp']['min'] = 1
+        self.internalSettings['nviz']['view']['persp']['max'] = 100
+        self.internalSettings['nviz']['view']['height'] = {}
+        self.internalSettings['nviz']['view']['height']['value'] = -1
+        
     def GetMapsetPath(self):
         """Store mapset search path"""
         all, access = utils.ListOfMapsets()
@@ -459,9 +608,8 @@
         Raise KeyError if key is not found
         
         @param group settings group
-        @param key
-        @param subkey if not given return dict of key
-        @param subkey1 
+        @param key (value, None)
+        @param subkey (value, list or None)
         @param internal use internal settings instead
 
         @return value
@@ -487,14 +635,14 @@
             raise gcmd.SettingsError("%s %s:%s:%s." % (_("Unable to get value"),
                                                        group, key, subkey))
         
-    def Set(self, group, key, subkey, value, internal=False):
+    def Set(self, group, value, key=None, subkey=None, internal=False):
         """Set value of key/subkey
 
         Raise KeyError if group/key is not found
         
         @param group settings group
-        @param key key
-        @param subkey subkey (value or list)
+        @param key key (value, None)
+        @param subkey subkey (value, list or None)
         @param value value
         @param internal use internal settings instead
         """
@@ -504,10 +652,16 @@
             settings = self.userSettings
 
         try:
-            if type(subkey) == type([]):
-                settings[group][key][subkey[0]][subkey[1]] = value
+            if subkey is None:
+                if key is None:
+                    settings[group] = value
+                else:
+                    settings[group][key] = value
             else:
-                settings[group][key][subkey] = value
+                if type(subkey) == type([]):
+                    settings[group][key][subkey[0]][subkey[1]] = value
+                else:
+                    settings[group][key][subkey] = value
         except KeyError:
             raise gcmd.SettingsError("%s '%s:%s:%s'" % (_("Unable to set "), group, key, subkey))
 



More information about the grass-commit mailing list