[OpendTect_Developers] Settings and scopes

Bert Bril bert at opendtect.org
Tue Jun 1 15:13:08 CEST 2010


Hi all,


Just explained a few things on support about how user-specific settings 
are handled, so I thought I'd share that here.

In general, there are a couple of scopes for settings that are interesting:

1) Survey scope
2) Installation scope
3) User scope

(1) Defaults for survey scope are in the .survey file (ending up in the 
global object 'SI()') and the .defs file, which ends up in the 
SI().pars(). If you have any setting that is specific for a survey, just 
set it using SI().getPars() and save it. Example from uiSeis/uisegyread.cc:

SI().getPars().set( sKeySEGYRev1Pol, storepol );
SI().savePars();


(2) You can also read files with settings on installation scope. 
Usually, you'll put these files in the 'data' directory, and then you 
can get the filename like this one from uiCoin/keybindings.cc:

StreamData sd = StreamProvider( mGetSetupFileName("MouseControls") )
                         .makeIStream();
if ( !sd.usable() ) return;


(3) Lastly, user scope. A complicating factor is that OpendTect can 
sub-scope the user login via the DTECT_USER variable.

Anyway, if you have settings that need to be stored for that particular 
user, you can simply use the 'Settings' object. You have the possibility 
to define your own Settings files, like in:

Settings& mycompsett = Settings::fetch( "mycomp" );
mycompsett.set( "Throttle", "Max" );

Settings (see settings.h) is simply a subclass of IOPar, but it is read 
automatically when needed. You still need to write it when you want it 
stored (usually after a change):

mycompsett.write()

The file name of storage is OS and DTECT_USER dependent, so it can end 
up in $HOME/.od/settings_mycomp.johnny - but you don't need to worry 
about that.


/Bert

-- 
-- Bert Bril / OpendTect developer at dGB
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org





More information about the Developers mailing list