diff --git a/Core/Core.cc b/Core/Core.cc index e1dadb9c5b340c7df3e5c31f80531490f8f8f088..0bc333c0d429fe0ddab6ad4bc4f0a467720473b8 100644 --- a/Core/Core.cc +++ b/Core/Core.cc @@ -949,6 +949,7 @@ void Core::slotExit() { if (logFile_) logFile_->close(); + OpenFlipper::Options::closeSettings(); qApp->quit(); } diff --git a/Core/ParseIni.cc b/Core/ParseIni.cc index d6c84407810eaef3422579be34060d15241bde79..89f01e555e8f63c83748ac35d8aa39268c79ec6c 100644 --- a/Core/ParseIni.cc +++ b/Core/ParseIni.cc @@ -186,36 +186,6 @@ void Core::readApplicationOptions(INIFile& _ini) { if ( _ini.get_entry( stereoMode, "Options" , "StereoMode") ) OpenFlipper::Options::stereoMode(static_cast (stereoMode)); - //============================================================================ - // Load stereo view settings - //============================================================================ - - float val; - if ( _ini.get_entry( val, "Options" , "EyeDistance") ) - OpenFlipper::Options::eyeDistance(val); - if ( _ini.get_entry( val, "Options" , "FocalDistance") ) - OpenFlipper::Options::focalDistance(val); - - //============================================================================ - // Load philips stereo mode settings - //============================================================================ - - int philipsContent = 0; - if ( _ini.get_entry( philipsContent, "Options" , "PhilipsContent") ) - OpenFlipper::Options::stereoPhilipsContent(philipsContent); - - int philipsFactor = 0; - if ( _ini.get_entry( philipsFactor, "Options" , "PhilipsFactor") ) - OpenFlipper::Options::stereoPhilipsFactor(philipsFactor); - - int philipsOffset = 0; - if ( _ini.get_entry( philipsOffset, "Options" , "PhilipsOffset") ) - OpenFlipper::Options::stereoPhilipsOffset(philipsOffset); - - int philipsSelect = 0; - if ( _ini.get_entry( philipsSelect, "Options" , "PhilipsSelect") ) - OpenFlipper::Options::stereoPhilipsSelect(philipsSelect); - //============================================================================ // Load the custom anaglyph stereo mode color matrices //============================================================================ @@ -693,20 +663,11 @@ void Core::writeApplicationOptions(INIFile& _ini) { _ini.add_entry("Options", "StereoMode",OpenFlipper::Options::stereoMode() ); - _ini.add_entry("Options" , "EyeDistance", OpenFlipper::Options::eyeDistance()); - _ini.add_entry("Options" , "FocalDistance", OpenFlipper::Options::focalDistance()); - _ini.add_entry("Options" , "CustomAnaglyphLeftEye", OpenFlipper::Options::anaglyphLeftEyeColorMatrix() ); _ini.add_entry("Options" , "CustomAnaglyphRightEye", OpenFlipper::Options::anaglyphRightEyeColorMatrix() ); _ini.add_entry("Options", "StereoMousePick", OpenFlipper::Options::stereoMousePick() ); - // Philips stereo mode - _ini.add_entry("Options" , "PhilipsContent", OpenFlipper::Options::stereoPhilipsContent()); - _ini.add_entry("Options" , "PhilipsFactor", OpenFlipper::Options::stereoPhilipsFactor()); - _ini.add_entry("Options" , "PhilipsOffset", OpenFlipper::Options::stereoPhilipsOffset()); - _ini.add_entry("Options" , "PhilipsSelect", OpenFlipper::Options::stereoPhilipsSelect()); - _ini.add_entry("Options", "GlMouse", OpenFlipper::Options::glMouse() ); } diff --git a/Core/optionHandling.cc b/Core/optionHandling.cc index cd5324cf398d964496eb5ee057b7cf2a7a81e8f8..349e7c87462618b85e81cd34aef9723f4b694c1f 100644 --- a/Core/optionHandling.cc +++ b/Core/optionHandling.cc @@ -57,10 +57,13 @@ // -------------------- ACG #include -#include "OpenFlipper/INIFile/INIFile.hh" -#include "OpenFlipper/common/GlobalOptions.hh" +#include +#include #include +#include + + //== IMPLEMENTATION ========================================================== void Core::applyOptions(){ @@ -188,145 +191,6 @@ void Core::setupOptions() { // initialize the Settings: OpenFlipper::Options::initializeSettings(); - - // Get the Main config dir in the home directory and possibly create it - QDir configDir = QDir::home(); - - if ( ! configDir.cd(".OpenFlipper") ) { - emit log(LOGOUT,tr("Creating config Dir ~/.OpenFlipper")); - configDir.mkdir(".OpenFlipper"); - if ( ! configDir.cd(".OpenFlipper") ) { - emit log(LOGERR,tr("Unable to create config dir ~/.OpenFlipper")); - return; - } - - } - - // Create a local directory to cache icons - QDir iconCacheDir = configDir; - - // Create a personal Icon cache dir to save for example user added icons - if ( ! iconCacheDir.exists("Icons") ){ - configDir.mkdir("Icons"); - emit log(LOGOUT,tr("Creating Icon Cache Dir ~/.OpenFlipper/Icons")); - } - - OpenFlipper::Options::configDir(configDir); - - // Remember the main application directory (assumed to be one above executable Path) - QDir tempDir = QDir(qApp->applicationDirPath()); - #ifdef OPENFLIPPER_APPDIR - tempDir.cd(OPENFLIPPER_APPDIR); - #else - tempDir.cd(".." + OpenFlipper::Options::dirSeparator() ); - #endif - OpenFlipper::Options::applicationDir(tempDir.absolutePath()); - - // Set the standard path to the plugins - #ifdef OPENFLIPPER_PLUGINDIR - tempDir.cd(OPENFLIPPER_PLUGINDIR); - #else - tempDir.cd("Plugins"); - - #if defined(WIN32) - tempDir.cd("Windows"); - #elif defined(ARCH_DARWIN) - tempDir.cd("Darwin"); - #else - tempDir.cd("Linux"); - #endif - - if ( OpenFlipper::Options::is64bit() ) - tempDir.cd("64"); - else - tempDir.cd("32"); - - #ifdef WIN32 - #ifndef NDEBUG - #define DEBUG - #endif - #endif - - #ifdef DEBUG - tempDir.cd("Debug"); - #else - tempDir.cd("Release"); - #endif - #endif - - OpenFlipper::Options::pluginDir(tempDir.absolutePath()); - - // Set the Path to the shaders - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Shaders"); - OpenFlipper::Options::shaderDir(tempDir.absolutePath()); - - - // Set the Path to the textures - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Textures"); - OpenFlipper::Options::textureDir(tempDir.absolutePath()); - - // Set the Path to the Scripts - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Scripts"); - OpenFlipper::Options::scriptDir(tempDir.absolutePath()); - - // Set the Path to the Icons - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Icons"); - OpenFlipper::Options::iconDir(tempDir.absolutePath()); - - // Set the Path to the translations - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Translations"); - OpenFlipper::Options::translationsDir(tempDir.absolutePath()); - - // Set the Path to the Fonts - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Fonts"); - OpenFlipper::Options::fontsDir(tempDir.absolutePath()); - - // Set the Path to the License files - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Licenses"); - OpenFlipper::Options::licenseDir(tempDir.absolutePath()); - - // Set the Path to the Help - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - tempDir.cd("Help"); - OpenFlipper::Options::helpDir(tempDir.absolutePath()); - - // Set the Path to the main data directory - tempDir = QDir(OpenFlipper::Options::applicationDir()); - #ifdef OPENFLIPPER_DATADIR - tempDir.cd(OPENFLIPPER_DATADIR); - #endif - OpenFlipper::Options::dataDir(tempDir.absolutePath()); QStringList optionFiles; diff --git a/common/GlobalOptions.cc b/common/GlobalOptions.cc index 8a24a33a020dfc44f5a68cdbb14ad717003e1841..7d4f4f3d58ae7104df4ceb0d3bb3db97e729afc8 100644 --- a/common/GlobalOptions.cc +++ b/common/GlobalOptions.cc @@ -55,10 +55,16 @@ #include #include #include +#include +#include +#include namespace OpenFlipper { namespace Options { + +/// Pointer to the internal settings object storing OpenFlippers program options ( and the pplugins Options) +static QSettings* settings_ = 0; /// Stores the base Path of the application static QDir applicationDir_; @@ -126,12 +132,6 @@ static bool glStereo_ = true; /// Stereo mode static StereoMode stereoMode_ = OpenGL; -/// get stereo eye distance (default = 7cm) -static float eyeDistance_ = 0.07f; - -/// stereo focal distance relative to scene near plane (default = to center of scene) -static float focalDistance_ = 0.5; - /// vectroy containing left/right color matrices for custom anaglyph mode static std::vector anaglyphLeftEyeColors_ = std::vector (9, 0.0); static std::vector anaglyphRightEyeColors_ = std::vector (9, 0.0); @@ -139,18 +139,6 @@ static std::vector anaglyphRightEyeColors_ = std::vector (9, 0.0); /// mouse cursor depth picking in stereo mode static bool stereoMousePick_ = true; -/// philips stereo header content type -static int stereoPhilipsContent_ = 3; // Game - -/// philips stereo header factor -static int stereoPhilipsFactor_ = 64; - -/// philips stereo header offset -static int stereoPhilipsOffset_ = 128; - -/// philips stereo header select -static int stereoPhilipsSelect_ = 0; // Display's defaults - /// Store the synchronization mode static bool synchronization_ = false; @@ -370,96 +358,8 @@ QString currentTextureDirStr() { return currentTextureDir_.absolutePath(); } QStringList optionFiles() { return optionFiles_; } -void applicationDir(QDir _dir) { applicationDir_ = _dir; } -void pluginDir(QDir _dir) { pluginDir_ = _dir; } -void shaderDir(QDir _dir) { shaderDir_ = _dir; } -void textureDir(QDir _dir) { textureDir_ = _dir; } -void licenseDir(QDir _dir) { licenseDir_ = _dir; } -void scriptDir(QDir _dir) { scriptDir_ = _dir; } -void iconDir(QDir _dir) { iconDir_ = _dir; } -void tanslationsDir(QDir _dir) { translationsDir_ = _dir; } -void fontsDir(QDir _dir) { fontsDir_ = _dir; } -void helpDir(QDir _dir) { helpDir_ = _dir; } -void dataDir(QDir _dir) { dataDir_ = _dir; } -void configDir(QDir _dir) { configDir_ = _dir; } -void currentDir(QDir _dir) { currentDir_ = _dir; } -void currentScriptDir(QDir _dir) { currentScriptDir_ = _dir; } -void currentTextureDir(QDir _dir) { currentTextureDir_ = _dir; } - void optionFiles(QStringList _list) { optionFiles_ = _list; } -bool applicationDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - applicationDir_ = tmp; - return true; - } - return false; -} - -bool pluginDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - pluginDir_ = tmp; - return true; - } - return false; -} - -bool shaderDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - shaderDir_ = tmp; - return true; - } - return false; -} - -bool textureDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - textureDir_ = tmp; - return true; - } - return false; -} - -bool licenseDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - licenseDir_ = tmp; - return true; - } - return false; -} - -bool scriptDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - scriptDir_ = tmp; - return true; - } - return false; -} - -bool iconDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - iconDir_ = tmp; - return true; - } - return false; -} - -bool dataDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - dataDir_ = tmp; - return true; - } - return false; -} - QIcon& OpenFlipperIcon() { if (OpenFlipperIcon_ == 0){ @@ -472,41 +372,8 @@ QIcon& OpenFlipperIcon() { return *OpenFlipperIcon_; } - -bool translationsDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - translationsDir_ = tmp; - return true; - } - return false; -} - -bool fontsDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - fontsDir_ = tmp; - return true; - } - return false; -} - -bool helpDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - helpDir_ = tmp; - return true; - } - return false; -} - -bool configDir(QString _dir) { - QDir tmp(_dir); - if (tmp.exists()) { - configDir_ = tmp; - return true; - } - return false; +void currentDir(QDir _dir) { + currentDir_ = _dir; } bool currentDir(QString _dir) { @@ -518,6 +385,7 @@ bool currentDir(QString _dir) { return false; } + bool currentScriptDir(QString _dir) { QDir tmp(_dir); if (tmp.exists()) { @@ -591,28 +459,27 @@ StereoMode stereoMode( ) { return stereoMode_; } -/// Store stereo eye distance -void eyeDistance( float _eye ) -{ - eyeDistance_ = _eye; +/// get stereo eye distance (default = 7cm) +void eyeDistance( double _eye ) { + settings_->setValue("Core/Stereo/EyeDistance",_eye); } /// get stereo eye distance -float eyeDistance( ) +double eyeDistance( ) { - return eyeDistance_; + return settings_->value("Core/Stereo/EyeDistance",0.07f).toDouble(); } /// Store stereo focal distance relative to scene near plane void focalDistance( float _focal ) { - focalDistance_ = _focal; + settings_->setValue("Core/Stereo/FocalDistance",_focal); } /// get stereo focal distance relative to scene near plane float focalDistance( ) { - return focalDistance_; + return settings_->value("Core/Stereo/FocalDistance",0.5f).toDouble(); } /// Store the 3x3 left eye color matrix values for custom anaglyph stereo mode @@ -651,54 +518,6 @@ bool stereoMousePick( ) { return stereoMousePick_; } -/// Store philips stereo header content type -void stereoPhilipsContent( int _content ) -{ - stereoPhilipsContent_ = _content; -} - -/// get philips stereo header content type -int stereoPhilipsContent( ) -{ - return stereoPhilipsContent_; -} - -/// Store philips stereo header factor -void stereoPhilipsFactor( int _factor ) -{ - stereoPhilipsFactor_ = _factor; -} - -/// get philips stereo header factor -int stereoPhilipsFactor( ) -{ - return stereoPhilipsFactor_; -} - -/// Store philips stereo header offset -void stereoPhilipsOffset( int _offset ) -{ - stereoPhilipsOffset_ = _offset; -} - -/// get philips stereo header offset -int stereoPhilipsOffset( ) -{ - return stereoPhilipsOffset_; -} - -/// Store philips stereo header select -void stereoPhilipsSelect( int _select ) -{ - stereoPhilipsSelect_ = _select; -} - -/// get philips stereo header select -int stereoPhilipsSelect( ) -{ - return stereoPhilipsSelect_; -} - /// Store synchronization mode setting void synchronization( bool _synchronization ) { synchronization_ = _synchronization; @@ -1082,14 +901,191 @@ bool renderPicking( ) { return renderPicking_; } -/// Internal function called by the core to connect to the program options -DLLEXPORT bool initializeSettings() { -} + std::cerr << "Initialize settings" << std::endl; + + //================================================================================================== + // Get the Main config dir in the home directory and possibly create it + //================================================================================================== + configDir_ = QDir::home(); + if ( ! configDir_.cd(".OpenFlipper") ) { + std::cerr << "Creating config Dir ~/.OpenFlipper" << std::endl;; + configDir_.mkdir(".OpenFlipper"); + if ( ! configDir_.cd(".OpenFlipper") ) { + std::cerr << "Unable to create config dir ~/.OpenFlipper" << std::endl; + return false; + } + } + + //================================================================================================== + // Setup settings. + //================================================================================================== + // This has to be done as early as possible to set the program options right + + // Force ini format on all platforms + QSettings::setDefaultFormat ( QSettings::IniFormat ); + + // Force settings to be stored in the OpenFlipper config directory + QSettings::setPath( QSettings::IniFormat, QSettings::UserScope , configDir_.absolutePath() ); + + // Finally attach the settings object. + settings_ = new QSettings(QSettings::IniFormat, QSettings::UserScope, "ACG","OpenFlipper"); + + //================================================================================================== + // Now create special directories in th OpenFlipper config dir + //================================================================================================== + + // Create a personal Icon cache dir to save for example user added icons + if ( ! configDir_.exists("Icons") ){ + configDir_.mkdir("Icons"); + std::cerr << "Creating Icon Cache Dir ~/.OpenFlipper/Icons" << std::endl; + } + + //================================================================================================== + // Setup main application dir + //================================================================================================== + + // Remember the main application directory (assumed to be one above executable Path) + applicationDir_ = QCoreApplication::applicationDirPath(); + + /// \todo remove the else branch here which is only used by qmake + #ifdef OPENFLIPPER_APPDIR + // When using cmake, we get the absolute path to the Application directory via a define + applicationDir_.cd(OPENFLIPPER_APPDIR); + #else + // For qmake the path of the application will be one directory up. + // Remove this as we will remove qmake support! + applicationDir_.cd(".." + OpenFlipper::Options::dirSeparator() ); + #endif + + //================================================================================================== + // Setup directory containing plugins + //================================================================================================== + + // start at application directory + pluginDir_ = applicationDir_; + + /// \todo remove the qmake specific else branch here! + #ifdef OPENFLIPPER_PLUGINDIR + // cmake style: Path is directly given from define! + pluginDir_.cd(OPENFLIPPER_PLUGINDIR); + #else + // qmake stuff. Remove when removing qmake! + pluginDir_.cd("Plugins"); + + #if defined(WIN32) + pluginDir_.cd("Windows"); + #elif defined(ARCH_DARWIN) + pluginDir_.cd("Darwin"); + #else + pluginDir_.cd("Linux"); + #endif + + if ( OpenFlipper::Options::is64bit() ) + pluginDir_.cd("64"); + else + pluginDir_.cd("32"); + + #ifdef WIN32 + #ifndef NDEBUG + #define DEBUG + #endif + #endif + + #ifdef DEBUG + pluginDir_.cd("Debug"); + #else + pluginDir_.cd("Release"); + #endif + #endif + + dataDir_ = OpenFlipper::Options::applicationDir(); + #ifdef OPENFLIPPER_DATADIR + dataDir_.cd(OPENFLIPPER_DATADIR); + #else + dataDir_ = OpenFlipper::Options::applicationDir(); + #endif + + // Set the Path to the Shaders + shaderDir_ = dataDir_; + shaderDir_.cd("Shaders"); + + // Set the Path to the textures + textureDir_ = dataDir_; + textureDir_.cd("Textures"); + // Set the Path to the Scripts + scriptDir_ = dataDir_; + scriptDir_.cd("Scripts"); + + + // Set the Path to the Icons + iconDir_ = dataDir_; + iconDir_.cd("Icons"); + + // Set the Path to the translations + translationsDir_ = dataDir_; + translationsDir_.cd("Translations"); + + // Set the Path to the Fonts + fontsDir_ = dataDir_; + fontsDir_.cd("Fonts"); + + // Set the Path to the License files + licenseDir_ = dataDir_; + licenseDir_.cd("Licenses"); + + // Set the Path to the Help + helpDir_ = dataDir_; + helpDir_.cd("Help"); + + //================================================================================================== + // Initialize with default values if not already set + //================================================================================================== + + // Stereo defaults + if ( ! settings_->contains("Core/Stereo/FocalLength") ) + settings_->setValue("Core/Stereo/FocalLength",0.5); + + if ( ! settings_->contains("Core/Stereo/EyeDistance") ) + settings_->setValue("Core/Stereo/EyeDistance",0.07); + + + // Philips Stereo + if ( ! settings_->contains("Core/Stereo/Philips/Content") ) + settings_->setValue("Core/Stereo/Philips/Content",3); + + if ( ! settings_->contains("Core/Stereo/Philips/Factor") ) + settings_->setValue("Core/Stereo/Philips/Factor",64); + + if ( ! settings_->contains("Core/Stereo/Philips/Offset") ) + settings_->setValue("Core/Stereo/Philips/Offset",128); + + if ( ! settings_->contains("Core/Stereo/Philips/Select") ) + settings_->setValue("Core/Stereo/Philips/Select",0); + + return true; + +} +void closeSettings() { + + // Delete the settings object. This will flush all data to the disk. + delete settings_; } + +} +} + +QSettings& OpenFlipperSettings() { + // Empty standard settings object if the right settings are not available! + static QSettings emptySettings; + + if ( OpenFlipper::Options::settings_ ) + return *OpenFlipper::Options::settings_; + else + return emptySettings; } //============================================================================= diff --git a/common/GlobalOptions.hh b/common/GlobalOptions.hh index 6fc84f38542f7e362118ffbf8a5377825e1a819d..77385cd396b4a5b83f92d6489751d75f9ec64179 100644 --- a/common/GlobalOptions.hh +++ b/common/GlobalOptions.hh @@ -63,6 +63,42 @@ #include #include #include +#include + +//=========================================================================== +/** @name Persistent settings +* @{ */ +//=========================================================================== + +/** \brief QSettings object containing all program settings of OpenFlipper. +* +* To get the settings use: +* OpenFlipperSettings().value("").toDouble(); +* OpenFlipperSettings().value("").toBool(); +* +* To change settings do: +* OpenFlipperSettings().setValue("",); +* For detailed info about the values see the documentation of QSettings and the QVariant. +* +* The following entries are available through the settings: +* +* General Stereo Settings:\n +* * Core/Stereo/EyeDistance \t Distance between eyes. Defaults to 7 cm (double)\n +* * Core/Stereo/FocalDistance \t Focal distance. Defaults to center of scene (double)\n +* +* \n +* Philips stereo display settings:\n +* * Core/Stereo/Philips/Content \t Philips stereo header content type (int) +* * Core/Stereo/Philips/Factor \t Philips stereo header factor (int) +* * Core/Stereo/Philips/Offset \t Philips stereo header offset cc (int) +* * Core/Stereo/Philips/Select \t Philips stereo header select (int) +* \n +* Anaglyph stereo mode settings:\n +*/ +QSettings& OpenFlipperSettings(); + +/** @} */ + namespace OpenFlipper { namespace Options { @@ -155,95 +191,6 @@ QString fontsDirStr(); DLLEXPORT QString helpDirStr(); -/// Sets the base Path of the application -DLLEXPORT -void applicationDir(QDir _dir); - -/// Sets the Path to the Plugins -DLLEXPORT -void pluginDir(QDir _dir); - -/// Sets the Path to the shaders -DLLEXPORT -void shaderDir(QDir _dir); - -/// Sets the Path to the Textures -DLLEXPORT -void textureDir(QDir _dir); - -/// Sets the Path to the Licenses -DLLEXPORT -void licenseDir(QDir _dir); - -/// Sets the Path to the Scripts -DLLEXPORT -void scriptDir( QDir _dir); - -/// Sets the Path to the Icons -DLLEXPORT -void iconDir(QDir _dir); - -/// Sets the Path to the translation files -DLLEXPORT -void translationsDir( QDir _dir); - -/// Sets the Path to the Fonts -DLLEXPORT -void fontsDir(QDir _dir); - -/// Sets the Path to the Help -DLLEXPORT -void helpDir(QDir _dir); - -/// Sets the Path to the data directory -DLLEXPORT -void dataDir(QDir _dir); - -/// Sets the base Path of the application -DLLEXPORT -bool applicationDir(QString _dir); - -/// Sets the Path to the Plugins -DLLEXPORT -bool pluginDir(QString _dir); - -/// Sets the Path to the shaders -DLLEXPORT -bool shaderDir(QString _dir); - -/// Sets the Path to the Textures -DLLEXPORT -bool textureDir(QString _dir); - -/// Sets the Path to the License files -DLLEXPORT -bool licenseDir(QString _dir); - -/// Sets the Path to the Scripts -DLLEXPORT -bool scriptDir(QString _dir); - -/// Sets the Path to the Icons -DLLEXPORT -bool iconDir(QString _dir); - -/// Sets the Path to the translation files -DLLEXPORT -bool translationsDir(QString _dir); - -/// Sets the Path to the Fonts -DLLEXPORT -void fontsDir(QDir _dir); - -/// Sets the Path to the Help -DLLEXPORT -void helpDir(QDir _dir); - -/// Sets the Path to the data direcotry -DLLEXPORT -bool dataDir(QString _dir); - - //=========================================================================== /** @name Option files / paths * @{ */ @@ -456,22 +403,6 @@ bool dataDir(QString _dir); DLLEXPORT StereoMode stereoMode( ); - /// Store stereo eye distance - DLLEXPORT - void eyeDistance( float _eye ); - - /// get stereo eye distance - DLLEXPORT - float eyeDistance( ); - - /// Store stereo focal distance relative to scene near plane - DLLEXPORT - void focalDistance( float _focal ); - - /// get stereo focal distance relative to scene near plane - DLLEXPORT - float focalDistance( ); - /// Store the 3x3 left eye color matrix values for custom anaglyph stereo mode DLLEXPORT void anaglyphLeftEyeColorMatrix( std::vector _mat ); @@ -496,38 +427,6 @@ bool dataDir(QString _dir); DLLEXPORT bool stereoMousePick( ); - /// Store philips stereo header content type - DLLEXPORT - void stereoPhilipsContent( int _content ); - - /// get philips stereo header content type - DLLEXPORT - int stereoPhilipsContent( ); - - /// Store philips stereo header factor - DLLEXPORT - void stereoPhilipsFactor( int _factor ); - - /// get philips stereo header factor - DLLEXPORT - int stereoPhilipsFactor( ); - - /// Store philips stereo header offset cc - DLLEXPORT - void stereoPhilipsOffset( int _offset ); - - /// get philips stereo header offset cc - DLLEXPORT - int stereoPhilipsOffset( ); - - /// Store philips stereo header select - DLLEXPORT - void stereoPhilipsSelect( int _select ); - - /// get philips stereo header select - DLLEXPORT - int stereoPhilipsSelect( ); - /// Store synchronization setting DLLEXPORT void synchronization( bool _synchronization ); @@ -974,6 +873,9 @@ bool renderPicking( ); DLLEXPORT bool initializeSettings(); +/// Internal function called by the core to write the program options on exit +DLLEXPORT +void closeSettings(); } } diff --git a/widgets/coreWidget/viewMode.cc b/widgets/coreWidget/viewMode.cc index 8cf4e06f2609c7517fcc2c0182e313a2d3be859c..bde0745fbc117afbb970bf4bb90af997f6de3e9e 100644 --- a/widgets/coreWidget/viewMode.cc +++ b/widgets/coreWidget/viewMode.cc @@ -349,8 +349,8 @@ void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) { stereoSettingsWidget_->stereoCustomAnaglyph->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphCustom); stereoSettingsWidget_->stereoPhilips->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::Philips); - stereoSettingsWidget_->eyeDistance->setValue(OpenFlipper::Options::eyeDistance()); - stereoSettingsWidget_->focalDistance->setValue(OpenFlipper::Options::focalDistance() * 1000); + stereoSettingsWidget_->eyeDistance->setValue( OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() ); + stereoSettingsWidget_->focalDistance->setValue( OpenFlipperSettings().value("Core/Stereo/FocalLength").toDouble() * 1000); // Philips stereo mode part @@ -359,12 +359,12 @@ void CoreWidget::stereoButtonContextMenu(const QPoint& _pos) { stereoSettingsWidget_->headerContentType->blockSignals(true); stereoSettingsWidget_->headerSelect->blockSignals(true); - stereoSettingsWidget_->headerContentType->setCurrentIndex(OpenFlipper::Options::stereoPhilipsContent()); - stereoSettingsWidget_->headerFactor->setValue(OpenFlipper::Options::stereoPhilipsFactor()); - stereoSettingsWidget_->headerOffsetCC->setValue(OpenFlipper::Options::stereoPhilipsOffset()); - stereoSettingsWidget_->factorCounter->setNum(OpenFlipper::Options::stereoPhilipsFactor()); - stereoSettingsWidget_->offsetCounter->setNum(OpenFlipper::Options::stereoPhilipsOffset()); - stereoSettingsWidget_->headerSelect->setCurrentIndex(OpenFlipper::Options::stereoPhilipsSelect()); + stereoSettingsWidget_->headerContentType->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Content").toInt()); + stereoSettingsWidget_->headerFactor->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt()); + stereoSettingsWidget_->headerOffsetCC->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt()); + stereoSettingsWidget_->factorCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt()); + stereoSettingsWidget_->offsetCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt()); + stereoSettingsWidget_->headerSelect->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Select").toInt()); // Unblock signals stereoSettingsWidget_->headerContentType->blockSignals(false); @@ -403,18 +403,18 @@ void CoreWidget::slotApplyStereoSettings(int /*_tmpParam*/) { } // Save everything - OpenFlipper::Options::eyeDistance(stereoSettingsWidget_->eyeDistance->value()); - OpenFlipper::Options::focalDistance((float) stereoSettingsWidget_->focalDistance->value() / 1000); + OpenFlipperSettings().setValue("Core/Stereo/EyeDistance",stereoSettingsWidget_->eyeDistance->value()); + OpenFlipperSettings().setValue("Core/Stereo/FocalLength",double(stereoSettingsWidget_->focalDistance->value()/1000.0)); // Update labels that display the current values stereoSettingsWidget_->factorCounter->setNum(stereoSettingsWidget_->headerFactor->value()); stereoSettingsWidget_->offsetCounter->setNum(stereoSettingsWidget_->headerOffsetCC->value()); // Set option entries - OpenFlipper::Options::stereoPhilipsContent(stereoSettingsWidget_->headerContentType->currentIndex()); - OpenFlipper::Options::stereoPhilipsFactor(stereoSettingsWidget_->headerFactor->value()); - OpenFlipper::Options::stereoPhilipsOffset(stereoSettingsWidget_->headerOffsetCC->value()); - OpenFlipper::Options::stereoPhilipsSelect(stereoSettingsWidget_->headerSelect->currentIndex()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Content",stereoSettingsWidget_->headerContentType->currentIndex()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Factor",stereoSettingsWidget_->headerFactor->value()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Offset",stereoSettingsWidget_->headerOffsetCC->value()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Select",stereoSettingsWidget_->headerSelect->currentIndex()); // Update all views for (unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i) { diff --git a/widgets/glWidget/QtBaseViewerStereo.cc b/widgets/glWidget/QtBaseViewerStereo.cc index 692f3faf117231acd6caf798b55c41840c34a4c6..d95b7afbb6f6dcf19ee3d11ed3d41463e7ed78ab 100644 --- a/widgets/glWidget/QtBaseViewerStereo.cc +++ b/widgets/glWidget/QtBaseViewerStereo.cc @@ -119,7 +119,7 @@ glViewer::drawScene_glStereo() radians = fovy_ * 0.5 / 180.0 * M_PI; wd2 = near_ * tan(radians); - zerop = near_ + ((far_ - near_) * OpenFlipper::Options::focalDistance ()); + zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); ndfl = near_ / zerop ; xrange = a * wd2 * 2 * zerop / near_; @@ -128,7 +128,7 @@ glViewer::drawScene_glStereo() t = wd2; b = -wd2; - double offset = 0.5 * OpenFlipper::Options::eyeDistance () * xrange; + double offset = 0.5 * OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() * xrange; double offset2 = offset * ndfl; // left eye @@ -285,7 +285,7 @@ void glViewer::drawScenePhilipsStereo() { // 3 Game // 4 CGI // 5 Still - header[1] = OpenFlipper::Options::stereoPhilipsContent(); // Hdr_Content_type (Game) = 00000011 (Gaming Mode) + header[1] = OpenFlipperSettings().value("Core/Stereo/Philips/Content").toInt(); // Hdr_Content_type (Game) = 00000011 (Gaming Mode) // Header Factor // Each 3D Display has a 'Display recommended depth value', which corresponds to an @@ -296,7 +296,7 @@ void glViewer::drawScenePhilipsStereo() { // works on a linear scale and is multiplied with the factor controlled by the user in the Display // Control Tool. // Value range: 0-255 (default 64) - header[2] = OpenFlipper::Options::stereoPhilipsFactor(); // Hdr_Factor + header[2] = OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt(); // Hdr_Factor // Header Offset CC // Values in the Depth map equal to the header-offset value will be located on the plane of the @@ -305,7 +305,7 @@ void glViewer::drawScenePhilipsStereo() { // Offset_CC is the offset controlled by the Content Creator. In the system there is also an // Offset_user present, which is controlled by the user using the Display Control Tool. // Value Range: 0-255 (default 128) - header[3] = OpenFlipper::Options::stereoPhilipsOffset(); // Hdr_Offset_CC + header[3] = OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt(); // Hdr_Offset_CC // Header select // When all select signals are low the rendering settings are set to optimal settings for the content @@ -316,7 +316,7 @@ void glViewer::drawScenePhilipsStereo() { // 1 Use Header provided factor // 2 Use Header provided offset // 3 Use both factor and offset - header[4] = OpenFlipper::Options::stereoPhilipsSelect(); // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6) + header[4] = OpenFlipperSettings().value("Core/Stereo/Philips/Select").toInt(); // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6) // Unused Header entry (leave at 0 !) header[5] = 0; // Reserved @@ -515,7 +515,7 @@ glViewer::drawScene_anaglyphStereo() radians = fovy_ * 0.5 / 180.0 * M_PI; wd2 = near_ * tan(radians); - zerop = near_ + ((far_ - near_) * OpenFlipper::Options::focalDistance ()); + zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); ndfl = near_ / zerop ; xrange = a * wd2 * 2 * zerop / near_; @@ -524,7 +524,7 @@ glViewer::drawScene_anaglyphStereo() t = wd2; b = -wd2; - double offset = 0.5 * OpenFlipper::Options::eyeDistance () * xrange; + double offset = 0.5 * OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() * xrange; double offset2 = offset * ndfl; // left eye @@ -646,7 +646,7 @@ glViewer::drawScene_customAnaglyphStereo() radians = fovy_ * 0.5 / 180.0 * M_PI; wd2 = near_ * tan(radians); - zerop = near_ + ((far_ - near_) * OpenFlipper::Options::focalDistance ()); + zerop = near_ + ((far_ - near_) * OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() ); ndfl = near_ / zerop ; xrange = a * wd2 * 2 * zerop / near_; @@ -655,7 +655,7 @@ glViewer::drawScene_customAnaglyphStereo() t = wd2; b = -wd2; - double offset = 0.5 * OpenFlipper::Options::eyeDistance () * xrange; + double offset = 0.5 * OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() * xrange; double offset2 = offset * ndfl; int vp_l, vp_b, vp_w, vp_h; diff --git a/widgets/optionsWidget/optionsWidget.cc b/widgets/optionsWidget/optionsWidget.cc index f000c299e12428e02f4cbda327f0c9ab38929e0f..0333f4537ee35e54eb114ca388f7d5000ca051c0 100644 --- a/widgets/optionsWidget/optionsWidget.cc +++ b/widgets/optionsWidget/optionsWidget.cc @@ -251,16 +251,16 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { stereoCustomAnaglyph->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphCustom); stereoPhilips->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::Philips); - eyeDistance->setValue (OpenFlipper::Options::eyeDistance()); - focalDistance->setValue (OpenFlipper::Options::focalDistance() * 1000); + eyeDistance->setValue ( OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() ); + focalDistance->setValue ( OpenFlipperSettings().value("Core/Stereo/FocalLength").toDouble() * 1000); // Philips stereo mode part - headerContentType->setCurrentIndex(OpenFlipper::Options::stereoPhilipsContent()); - headerFactor->setValue(OpenFlipper::Options::stereoPhilipsFactor()); - headerOffsetCC->setValue(OpenFlipper::Options::stereoPhilipsOffset()); - factorCounter->setNum(OpenFlipper::Options::stereoPhilipsFactor()); - offsetCounter->setNum(OpenFlipper::Options::stereoPhilipsOffset()); - headerSelect->setCurrentIndex(OpenFlipper::Options::stereoPhilipsSelect()); + headerContentType->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Content").toInt()); + headerFactor->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt()); + headerOffsetCC->setValue(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt()); + factorCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Factor").toInt()); + offsetCounter->setNum(OpenFlipperSettings().value("Core/Stereo/Philips/Offset").toInt()); + headerSelect->setCurrentIndex(OpenFlipperSettings().value("Core/Stereo/Philips/Select").toInt()); std::vector mat = OpenFlipper::Options::anaglyphLeftEyeColorMatrix (); lcm0->setValue (mat[0]); @@ -556,17 +556,18 @@ void OptionsWidget::slotApply() { else OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL); - OpenFlipper::Options::eyeDistance(eyeDistance->value ()); - OpenFlipper::Options::focalDistance((float)focalDistance->value () / 1000); + OpenFlipperSettings().setValue("Core/Stereo/EyeDistance",eyeDistance->value ()); + OpenFlipperSettings().setValue("Core/Stereo/FocalLength",double(focalDistance->value() ) / 1000.0); OpenFlipper::Options::stereoMousePick(!noMousePick->isChecked ()); // Set option entries for philips stereo mode - OpenFlipper::Options::stereoPhilipsContent(headerContentType->currentIndex()); - OpenFlipper::Options::stereoPhilipsFactor(headerFactor->value()); - OpenFlipper::Options::stereoPhilipsOffset(headerOffsetCC->value()); - OpenFlipper::Options::stereoPhilipsSelect(headerSelect->currentIndex()); - + // Set option entries + OpenFlipperSettings().setValue("Core/Stereo/Philips/Content",headerContentType->currentIndex()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Factor",headerFactor->value()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Offset",headerOffsetCC->value()); + OpenFlipperSettings().setValue("Core/Stereo/Philips/Select",headerSelect->currentIndex()); + std::vector mat (9, 0); mat[0] = lcm0->value (); mat[1] = lcm1->value ();