GlobalOptions.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8653 $                                                         *
00038  *   $Author: wilden $                                                      *
00039  *   $Date: 2010-03-02 17:31:49 +0100 (Di, 02. Mär 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  Options used throughout the System
00049 //
00050 //=============================================================================
00051 
00052 #include <QDir>
00053 
00054 #include "GlobalOptions.hh"
00055 #include <stdlib.h>
00056 #include <iostream>
00057 #include <ACG/Scenegraph/DrawModes.hh>
00058 #include <QDir>
00059 #include <QCoreApplication>
00060 
00061 #define STRINGIFY(x) #x
00062 #define TOSTRING(x) STRINGIFY(x) 
00063 
00064 
00065 namespace OpenFlipper {
00066 namespace Options {
00067 
00069 static QString compilerInfo_ = "";
00070   
00072 static QSettings* settings_ = 0;  
00073 
00075 static QDir applicationDir_;
00076 
00078 static QDir configDir_;
00079 
00081 static QDir pluginDir_;
00082 
00084 static QDir shaderDir_;
00085 
00087 static QDir textureDir_;
00088 
00090 static QDir licenseDir_;
00091 
00093 static QDir scriptDir_;
00094 
00096 static QDir iconDir_;
00097 
00099 static QIcon* OpenFlipperIcon_ = 0;
00100 
00102 static QDir translationsDir_;
00103 
00105 static QDir fontsDir_;
00106 
00108 static QDir helpDir_;
00109 
00111 static QDir dataDir_;
00112 
00114 static QStringList optionFiles_;
00115 
00117 static QDir currentDir_;
00118 
00120 static QDir currentScriptDir_;
00121 
00123 static QDir currentTextureDir_;
00124 
00126 static Experience experienceLevel_ = NOVICE;
00127 
00129 static bool nogui_ = false;
00130 
00132 static bool stereo_ = true;
00133 
00135 static bool glStereo_ = true;
00136 
00138 static StereoMode stereoMode_ = OpenGL;
00139 
00141 static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
00142 static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
00143 
00145 static bool synchronization_ = false;
00146 
00148 static bool restrictFrameRate_ = false;
00149 
00151 static int maxFrameRate_ = 35;
00152 
00154 static std::vector<ACG::SceneGraph::DrawModes::DrawMode> defaultDrawMode_ = std::vector<ACG::SceneGraph::DrawModes::DrawMode> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
00155 
00157 static std::vector<int> defaultProjectionMode_ = std::vector<int> (4, 1);
00158 
00160 static std::vector<int> defaultViewingDirection_ = std::vector<int> (4, 0);
00161 
00163 static int defaultViewerLayout_ = 0;
00164 
00166 static int redrawDisabled_ = 0;
00167 
00169 static bool drawModesInContextMenu_ = true;
00170 
00172 static bool gridVisible_ = false;
00173 
00175 static bool hideToolbox_ = false;
00176 
00178 static LoggerState loggerState_ = InScene;
00179 
00181 static bool multiView_ = true;
00182 
00184 static bool fullScreen_ = false;
00185 
00186 static QString defaultToolboxMode_ = "";
00187 
00188 static QString title_ = "OpenFlipper v?";
00189 
00191 static QColor defaultBaseColor_ = QColor("white");
00192 
00194 static bool randomBaseColor_ = false;
00195 
00197 static bool scripting_ = false;
00198 
00200 static bool logToConsole_ = false;
00201 
00203 static bool debug_ = false;
00204 
00206 static bool doSlotDebugging_ = false;
00207 
00209 static QString updateURL_ = "";
00210 
00212 static QString updateUsername_ = "";
00213 
00215 static QString updatePassword_ = "";
00216 
00218 static QString lastDataType_ = "Triangle Mesh";
00219 
00221 static QString translation_ = "en_US";
00222 
00224 static bool enableBackup_ = true;
00225 
00227 static bool loadingSettings_ = false;
00228 
00230 static bool loadingRecentFile_ = false;
00231 
00233 static bool savingSettings_ = false;
00234 
00236 static bool renderPicking_ = false;
00237 
00239 static QString pickingRenderMode_ = "PICK_ANYTHING";
00240 
00241 static int* argc_;
00242 
00243 static char *** argv_;
00244 
00245 static bool remoteControl_ = false;
00246 
00247 # if __WORDSIZE == 64
00248   const bool is64 = true;
00249 #else
00250   const bool is64 = false;
00251 #endif
00252 
00253 #if defined(WIN32)
00254   const bool linux_ = false;
00255   const bool windows_ = true;
00256   const bool darwin_ = false;
00257 #elif defined(ARCH_DARWIN)
00258   const bool darwin_ = true;
00259   const bool linux_ = false;
00260   const bool windows_ = false;
00261 #else
00262   const bool darwin_ = false;
00263   const bool linux_ = true;
00264   const bool windows_ = false;
00265 #endif
00266 
00267 bool is64bit() { return is64; };
00268 bool is32bit() { return !is64; };
00269 
00270 bool isLinux() {
00271   return linux_;
00272 }
00273 
00274 bool isWindows() {
00275   return windows_;
00276 }
00277 
00278 bool isDarwin() {
00279  return darwin_;
00280 }
00281 
00282 
00283 QString lang() {
00284   QString lang = getenv( "LANG" ) ;
00285   return lang;
00286 }
00287 
00288 QString translation() {
00289   return translation_;
00290 }
00291 
00292 void translation(QString _translation) {
00293   translation_ = _translation;
00294 }
00295 
00296 QString dirSeparator() {
00297 //   if (windows_)
00298 //     return QString("\\");
00299 //   if (linux_)
00300 //     return QString("/");
00301 
00302   return QString("/");
00303 }
00304 
00305 QDir applicationDir()   { return applicationDir_; }
00306 QDir configDir()        { return configDir_;  }
00307 QDir pluginDir()        { return pluginDir_;  }
00308 QDir shaderDir()        { return shaderDir_;  }
00309 QDir textureDir()       { return textureDir_; }
00310 QDir licenseDir()       { return licenseDir_; }
00311 QDir scriptDir()        { return scriptDir_; }
00312 QDir iconDir()          { return iconDir_;    }
00313 QDir translationsDir()  { return translationsDir_;   }
00314 QDir fontsDir()         { return fontsDir_;   }
00315 QDir helpDir()          { return helpDir_;    }
00316 QDir dataDir()          { return dataDir_;    }
00317 QDir currentDir()       { return currentDir_; }
00318 QDir currentScriptDir() { return currentScriptDir_; }
00319 QDir currentTextureDir(){ return currentTextureDir_; }
00320 
00321 QString applicationDirStr()    { return applicationDir_.absolutePath();    }
00322 QString configDirStr()         { return configDir_.absolutePath();         }
00323 QString pluginDirStr()         { return pluginDir_.absolutePath();         }
00324 QString shaderDirStr()         { return shaderDir_.absolutePath();         }
00325 QString textureDirStr()        { return textureDir_.absolutePath();        }
00326 QString licenseDirStr()        { return licenseDir_.absolutePath();        }
00327 QString scriptDirStr()         { return scriptDir_.absolutePath();         }
00328 QString iconDirStr()           { return iconDir_.absolutePath();           }
00329 QString translationsDirStr()   { return translationsDir_.absolutePath();   }
00330 QString fontsDirStr()          { return fontsDir_.absolutePath();          }
00331 QString helpDirStr()           { return helpDir_.absolutePath();           }
00332 QString dataDirStr()           { return dataDir_.absolutePath();           }
00333 QString currentDirStr()        { return currentDir_.absolutePath();        }
00334 QString currentScriptDirStr()  { return currentScriptDir_.absolutePath();  }
00335 QString currentTextureDirStr() { return currentTextureDir_.absolutePath(); }
00336 
00337 QStringList optionFiles()   { return optionFiles_; }
00338 
00339 void optionFiles(QStringList _list) { optionFiles_ = _list; }
00340 
00341 QIcon& OpenFlipperIcon() {
00342 
00343   if (OpenFlipperIcon_ == 0){
00344     OpenFlipperIcon_ = new QIcon( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_128x128x32.png");
00345     OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_48x48x32.png", QSize(48,48) );
00346     OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_32x32x32.png", QSize(32,32) );
00347     OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_16x16x32.png", QSize(16,16) );
00348   }
00349 
00350   return *OpenFlipperIcon_;
00351 }
00352 
00353 void currentDir(QDir      _dir) {
00354   currentDir_ = _dir;
00355 }
00356 
00357 bool currentDir(QString      _dir) {
00358   QDir tmp(_dir);
00359   if (tmp.exists()) {
00360     currentDir_     = tmp;
00361     return true;
00362   }
00363   return false;
00364 }
00365 
00366 
00367 bool currentScriptDir(QString _dir) {
00368   QDir tmp(_dir);
00369   if (tmp.exists()) {
00370     currentScriptDir_     = tmp;
00371     return true;
00372   }
00373   return false;
00374 }
00375 
00376 bool currentTextureDir(QString _dir) {
00377   QDir tmp(_dir);
00378   if (tmp.exists()) {
00379     currentTextureDir_ = tmp;
00380     return true;
00381   }
00382   return false;
00383 }
00384 
00386 Experience getExperience() {
00387   return experienceLevel_;
00388 }
00389 
00391 void setExperience( Experience _exp) {
00392   experienceLevel_ = _exp;
00393 }
00394 
00396 void nogui( bool _nogui ) {
00397   nogui_ = _nogui;
00398 }
00399 
00401 bool nogui( ) {
00402   return nogui_;
00403 }
00404 
00406 bool gui( ) {
00407   return !nogui_;
00408 }
00409 
00411 void stereo( bool _stereo ) {
00412   stereo_ = _stereo;
00413 }
00414 
00416 bool stereo( ) {
00417   return stereo_;
00418 }
00419 
00421 void glStereo( bool _glStereo ) {
00422   glStereo_ = _glStereo;
00423 }
00424 
00426 bool glStereo( ) {
00427   return glStereo_;
00428 }
00429 
00431 void stereoMode( StereoMode _mode ) {
00432   stereoMode_ = _mode;
00433 }
00434 
00436 StereoMode stereoMode( ) {
00437   return stereoMode_;
00438 }
00439 
00441 void eyeDistance( double _eye ) {
00442   settings_->setValue("Core/Stereo/EyeDistance",_eye);
00443 }
00444 
00446 double eyeDistance( )
00447 {
00448   return settings_->value("Core/Stereo/EyeDistance",0.07f).toDouble();
00449 }
00450 
00452 void focalDistance( float _focal )
00453 {
00454   settings_->setValue("Core/Stereo/FocalDistance",_focal);
00455 }
00456 
00458 float focalDistance( )
00459 {
00460   return settings_->value("Core/Stereo/FocalDistance",0.5f).toDouble();
00461 }
00462 
00464 void anaglyphLeftEyeColorMatrix( std::vector<float> _mat )
00465 {
00466   for (int i = 0; i < 9; i++)
00467     anaglyphLeftEyeColors_[i] = _mat[i];
00468 }
00469 
00471 std::vector<float> anaglyphLeftEyeColorMatrix( )
00472 {
00473   return anaglyphLeftEyeColors_;
00474 }
00475 
00477 void anaglyphRightEyeColorMatrix( std::vector<float> _mat )
00478 {
00479   for (int i = 0; i < 9; i++)
00480     anaglyphRightEyeColors_[i] = _mat[i];
00481 }
00482 
00484 std::vector<float> anaglyphRightEyeColorMatrix( )
00485 {
00486   return anaglyphRightEyeColors_;
00487 }
00488 
00490 void synchronization( bool _synchronization ) {
00491   synchronization_ = _synchronization;
00492 }
00493 
00495 bool synchronization( ) {
00496   return synchronization_;
00497 }
00498 
00499 void restrictFrameRate( bool _enable ){
00500   restrictFrameRate_ = _enable;
00501 }
00502 
00503 bool restrictFrameRate( ){
00504   return restrictFrameRate_;
00505 }
00506 
00507 void maxFrameRate( int _fps ){
00508   maxFrameRate_ = _fps;
00509 }
00510 
00511 int maxFrameRate(){
00512   return maxFrameRate_;
00513 }
00514 
00515 void defaultDrawMode( ACG::SceneGraph::DrawModes::DrawMode _mode, int _viewer){
00516   defaultDrawMode_[_viewer] = _mode;
00517 }
00518 
00519 ACG::SceneGraph::DrawModes::DrawMode defaultDrawMode(int _viewer){
00520   return defaultDrawMode_[_viewer];
00521 }
00522 
00523 void defaultProjectionMode( int _mode, int _viewer){
00524   defaultProjectionMode_[_viewer] = _mode;
00525 }
00526 
00527 int defaultProjectionMode(int _viewer){
00528   return defaultProjectionMode_[_viewer];
00529 }
00530 
00531 void defaultViewingDirection( int _mode, int _viewer){
00532   defaultViewingDirection_[_viewer] = _mode;
00533 }
00534 
00535 int defaultViewingDirection(int _viewer){
00536   return defaultViewingDirection_[_viewer];
00537 }
00538 
00539 void defaultViewerLayout( int _layout ){
00540   defaultViewerLayout_ = _layout;
00541 }
00542 
00543 int defaultViewerLayout(){
00544   return defaultViewerLayout_;
00545 }
00546 
00547 void redrawDisabled( bool disable ){
00548   if ( disable )
00549     redrawDisabled_++;
00550   else
00551     if ( redrawDisabled_ == 0 )
00552       std::cerr << "Mismatch of redraw enable/disable!!" << std::endl;
00553     else
00554       redrawDisabled_--;
00555 }
00556 
00557 bool redrawDisabled( ){
00558   return (redrawDisabled_ > 0);
00559 }
00560 
00561 bool drawModesInContextMenu() {
00562   return drawModesInContextMenu_;
00563 }
00564 
00565 void drawModesInContextMenu(bool _show) {
00566   drawModesInContextMenu_ = _show;
00567 }
00568 
00569 bool gridVisible() {
00570   return gridVisible_;
00571 }
00572 
00573 void gridVisible(bool _visible) {
00574   gridVisible_ = _visible;
00575 }
00576 
00577 void multiView( bool _multiView) {
00578   multiView_ = _multiView;
00579 }
00580 
00581 bool multiView() {
00582   return multiView_;
00583 }
00584 
00585 unsigned int examinerWidgets() {
00586   if ( multiView_)
00587     return 4;
00588   else
00589     return 1;
00590 }
00591 
00593 void loggerState( LoggerState _state) {
00594   loggerState_ = _state;
00595 }
00596 
00598 LoggerState loggerState( ) {
00599   return loggerState_;
00600 }
00601 
00603 void hideToolbox( bool _hide) {
00604   hideToolbox_ = _hide;
00605 }
00606 
00608 bool hideToolbox( ) {
00609   return hideToolbox_;
00610 }
00611 
00613 void fullScreen( bool _fs ) {
00614   fullScreen_ = _fs;
00615 }
00616 
00618 bool fullScreen( ) {
00619   return fullScreen_;
00620 }
00621 
00623 QString defaultToolboxMode( ) {
00624   return defaultToolboxMode_;
00625 }
00626 
00628 void defaultToolboxMode( QString _mode ) {
00629   defaultToolboxMode_ = _mode;
00630 }
00631 
00632 
00633 QString windowTitle( ) {
00634   return title_;
00635 }
00636 
00637 void windowTitle( QString _titel ) {
00638   title_ = _titel;
00639 }
00640 
00641 void defaultBaseColor( QColor _color ) {
00642   defaultBaseColor_ = _color;
00643 }
00644 
00645 QColor defaultBaseColor() {
00646   return defaultBaseColor_;
00647 }
00648 
00649 void randomBaseColor(bool _random) {
00650   randomBaseColor_ = _random;
00651 }
00652 
00653 bool randomBaseColor() {
00654   return randomBaseColor_;
00655 }
00656 
00658 QString lastDataType(){
00659   return lastDataType_;
00660 }
00661 
00663 void lastDataType(QString _type){
00664    lastDataType_ = _type;
00665 }
00666 
00667 bool scripting( ) {
00668   return scripting_;
00669 }
00670 
00671 void scripting(bool _status ) {
00672   scripting_ = _status;
00673 }
00674 
00675 bool logToConsole( ) {
00676   return logToConsole_;
00677 }
00678 
00679 void logToConsole(bool _logToConsole ) {
00680   logToConsole_ = _logToConsole;
00681 }
00682 
00683 bool debug() {
00684   return debug_;
00685 }
00686 
00687 void debug(bool _debug ) {
00688   debug_ = _debug;
00689 }
00690 
00691 bool backupEnabled( ) {
00692   return enableBackup_;
00693 }
00694 
00695 void enableBackup(bool _enableBackup ) {
00696   enableBackup_ = _enableBackup;
00697 }
00698 
00699 bool loadingSettings( ) {
00700   return loadingSettings_;
00701 }
00702 
00703 void loadingSettings(bool _loadingSettings ) {
00704   loadingSettings_ = _loadingSettings;
00705 }
00706 
00707 bool savingSettings( ) {
00708   return savingSettings_;
00709 }
00710 
00711 void savingSettings(bool _savingSettings ) {
00712   savingSettings_ = _savingSettings;
00713 }
00714 
00715 bool loadingRecentFile( ) {
00716   return loadingRecentFile_;
00717 }
00718 
00719 void loadingRecentFile(bool _loadingRecentFile ) {
00720   loadingRecentFile_ = _loadingRecentFile;
00721 }
00722 
00723 int* argc() {
00724   return argc_;
00725 }
00726 
00727 char *** argv() {
00728   return argv_;
00729 }
00730 
00731 void  argc( int* _argc ) {
00732   argc_ = _argc;
00733 }
00734 
00735 void argv( char*** _argv) {
00736   argv_ = _argv;
00737 }
00738 
00739 bool remoteControl(){
00740   return remoteControl_;
00741 }
00742 
00743 void remoteControl(bool _remote){
00744   remoteControl_ = _remote;
00745 }
00746 
00747 void doSlotDebugging( bool _debugging ) {
00748   doSlotDebugging_ = _debugging;
00749 }
00750 
00751 bool doSlotDebugging( ) {
00752   return doSlotDebugging_;
00753 }
00754 
00755 void updateUrl( QString _url ) {
00756   updateURL_ = _url;
00757 }
00758 
00759 QString updateUrl( ) {
00760   return updateURL_;
00761 }
00762 
00763 void updateUsername( QString _username ) {
00764   updateUsername_ = _username;
00765 }
00766 
00767 QString updateUsername( ) {
00768   return updateUsername_;
00769 }
00770 
00771 void updatePassword( QString _password ) {
00772   updatePassword_ = _password;
00773 }
00774 
00775 QString updatePassword( ) {
00776   return updatePassword_;
00777 }
00778 
00779 QString coreVersion() {
00780   #ifndef CORE_VERSION
00781         #define CORE_VERSION "1.0.0RC2"
00782   #endif
00783   return QString(CORE_VERSION);
00784 }
00785 
00786 void pickingRenderMode( QString _target ) {
00787   pickingRenderMode_ = _target;
00788 }
00789 
00790 QString pickingRenderMode( ) {
00791   return pickingRenderMode_;
00792 }
00793 
00794 void renderPicking(bool _enable) {
00795   renderPicking_ = _enable;
00796 }
00797 
00798 bool renderPicking( ) {
00799   return renderPicking_;
00800 }
00801 
00802 bool initializeSettings() {
00803   
00804   #if defined(__GNUC__)
00805     compilerInfo_ = "Gnu CC: " + QString(  TOSTRING(__GNUC__) ) + "." + QString(  TOSTRING(__GNUC_MINOR__) ) ;
00806     #if defined(__GNUC_PATCHLEVEL__)
00807       compilerInfo_ += "." + QString(  TOSTRING(__GNUC_PATCHLEVEL__) );
00808     #endif
00809   #else 
00810     #if defined (_MSC_FULL_VER)
00811     compilerInfo_ = "MSVC: " + QString(  TOSTRING(_MSC_FULL_VER) );  
00812     #else 
00813       compilerInfo_ = "Unknown";
00814     #endif
00815   #endif
00816   
00817   
00818   //==================================================================================================
00819   // Get the Main config dir in the home directory and possibly create it
00820   //==================================================================================================
00821   configDir_ = QDir::home();
00822   if ( ! configDir_.cd(".OpenFlipper") ) {
00823     std::cerr << "Creating config Dir ~/.OpenFlipper" << std::endl;;
00824     configDir_.mkdir(".OpenFlipper");
00825     if ( ! configDir_.cd(".OpenFlipper") ) {
00826       std::cerr << "Unable to create config dir ~/.OpenFlipper" << std::endl;
00827       return false;
00828     }
00829   }
00830   
00831   //==================================================================================================
00832   // Setup settings. 
00833   //==================================================================================================
00834   // This has to be done as early as possible to set the program options right
00835   
00836   // Force ini format on all platforms
00837   QSettings::setDefaultFormat ( QSettings::IniFormat );
00838   
00839   // Force settings to be stored in the OpenFlipper config directory
00840   QSettings::setPath( QSettings::IniFormat, QSettings::UserScope , configDir_.absolutePath() );
00841 
00842   // Finally attach the settings object.
00843   settings_ = new QSettings(QSettings::IniFormat, QSettings::UserScope, "ACG","OpenFlipper");
00844 
00845   //==================================================================================================
00846   // Now create special directories in th OpenFlipper config dir
00847   //==================================================================================================
00848   
00849   // Create a personal Icon cache dir to save for example user added icons
00850   if ( ! configDir_.exists("Icons") ){
00851     configDir_.mkdir("Icons");
00852     std::cerr << "Creating Icon Cache Dir ~/.OpenFlipper/Icons" << std::endl;    
00853   }
00854   
00855   //==================================================================================================
00856   // Setup main application dir
00857   //==================================================================================================
00858 
00859   // Remember the main application directory (assumed to be one above executable Path)
00860   applicationDir_ =  QCoreApplication::applicationDirPath();
00861 
00863   #ifdef OPENFLIPPER_APPDIR
00864     // When using cmake, we get the absolute path to the Application directory via a define
00865     applicationDir_.cd(OPENFLIPPER_APPDIR);
00866   #else
00867     // For qmake the path of the application will be one directory up.
00868     // Remove this as we will remove qmake support!
00869     applicationDir_.cd(".." + OpenFlipper::Options::dirSeparator() );
00870   #endif
00871   
00872   //==================================================================================================
00873   // Setup directory containing plugins
00874   //==================================================================================================
00875    
00876   // start at application directory 
00877   pluginDir_ = applicationDir_;
00878   
00880   #ifdef OPENFLIPPER_PLUGINDIR
00881     // cmake style: Path is directly given from define!
00882     pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
00883   #else
00884      // qmake stuff. Remove when removing qmake!
00885      pluginDir_.cd("Plugins");
00886 
00887     #if defined(WIN32)
00888       pluginDir_.cd("Windows");
00889     #elif defined(ARCH_DARWIN)
00890       pluginDir_.cd("Darwin");
00891     #else
00892       pluginDir_.cd("Linux");
00893     #endif
00894 
00895     if ( OpenFlipper::Options::is64bit() )
00896       pluginDir_.cd("64");
00897     else
00898       pluginDir_.cd("32");
00899 
00900     #ifdef WIN32
00901       #ifndef NDEBUG
00902         #define DEBUG
00903       #endif
00904     #endif
00905 
00906     #ifdef DEBUG
00907       pluginDir_.cd("Debug");
00908     #else
00909       pluginDir_.cd("Release");
00910     #endif
00911   #endif
00912   
00913   dataDir_ = OpenFlipper::Options::applicationDir();
00914   #ifdef OPENFLIPPER_DATADIR
00915     dataDir_.cd(OPENFLIPPER_DATADIR);
00916   #else
00917     dataDir_ = OpenFlipper::Options::applicationDir();
00918   #endif
00919   
00920   // Set the Path to the Shaders
00921   shaderDir_ = dataDir_;
00922   shaderDir_.cd("Shaders");
00923   
00924   // Set the Path to the textures
00925   textureDir_ = dataDir_;
00926   textureDir_.cd("Textures");
00927 
00928   // Set the Path to the Scripts
00929   scriptDir_ = dataDir_;
00930   scriptDir_.cd("Scripts");
00931   
00932   
00933   // Set the Path to the Icons
00934   iconDir_ = dataDir_;
00935   iconDir_.cd("Icons");
00936   
00937   // Set the Path to the translations
00938   translationsDir_ = dataDir_;
00939   translationsDir_.cd("Translations");
00940   
00941   // Set the Path to the Fonts
00942   fontsDir_ = dataDir_;
00943   fontsDir_.cd("Fonts");
00944   
00945   // Set the Path to the License files
00946   licenseDir_ = dataDir_;
00947   licenseDir_.cd("Licenses");
00948   
00949   // Set the Path to the Help
00950   helpDir_ = dataDir_;
00951   helpDir_.cd("Help");
00952   
00953   //==================================================================================================
00954   // Initialize with default values if not already set
00955   //==================================================================================================  
00956 
00957   // User Interface Settings
00958   if ( ! settings_->contains("Core/Gui/glViewer/defaultBackgroundColor") )
00959     settings_->setValue("Core/Gui/glViewer/defaultBackgroundColor",QColor("black"));  
00960   
00961   if ( ! settings_->contains("Core/Gui/glViewer/showControlWheels") )
00962     settings_->setValue("Core/Gui/glViewer/showControlWheels",false);  
00963   
00964   
00965   // Mouse Controls
00966   if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactor") )
00967     settings_->setValue("Core/Mouse/Wheel/ZoomFactor",1.0);
00968   
00969   if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactorShift") )
00970     settings_->setValue("Core/Mouse/Wheel/ZoomFactorShift",0.2);
00971   
00972   
00973   // General Stereo Settings
00974   if ( ! settings_->contains("Core/Stereo/FocalLength") )
00975     settings_->setValue("Core/Stereo/FocalLength",0.5);
00976   
00977   if ( ! settings_->contains("Core/Stereo/EyeDistance") )
00978     settings_->setValue("Core/Stereo/EyeDistance",0.07);
00979   
00980   
00981   // Philips stereo display settings
00982   if ( ! settings_->contains("Core/Stereo/Philips/Content") )
00983     settings_->setValue("Core/Stereo/Philips/Content",3);
00984   
00985   if ( ! settings_->contains("Core/Stereo/Philips/Factor") )
00986     settings_->setValue("Core/Stereo/Philips/Factor",64);
00987   
00988   if ( ! settings_->contains("Core/Stereo/Philips/Offset") )
00989     settings_->setValue("Core/Stereo/Philips/Offset",128);
00990   
00991   if ( ! settings_->contains("Core/Stereo/Philips/Select") )
00992     settings_->setValue("Core/Stereo/Philips/Select",0);
00993     
00994   return true;
00995   
00996 }
00997 
00998 void closeSettings() {
00999   
01000   // Delete the settings object. This will flush all data to the disk.
01001   delete settings_;
01002 }
01003 
01004 QString compilerInfo() {
01005   return compilerInfo_;
01006 }
01007  
01008 }
01009 }
01010 
01011 QSettings& OpenFlipperSettings() {
01012   // Empty standard settings object if the right settings are not available!
01013   static QSettings emptySettings;
01014   
01015   if ( OpenFlipper::Options::settings_ )
01016     return *OpenFlipper::Options::settings_;
01017   else
01018     return emptySettings;
01019 }
01020 
01021 
01022 
01023 //=============================================================================
01024 

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .