Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GlobalOptions.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 //=============================================================================
54 //
55 // Options used throughout the System
56 //
57 //=============================================================================
58 
59 #include <QDir>
60 
61 #include "GlobalOptions.hh"
62 #include <iostream>
63 #include <ACG/GL/ShaderGenerator.hh>
64 #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
65 #include <QCoreApplication>
66 
67 namespace OpenFlipper {
68 namespace Options {
69 
71 static QString compilerInfo_ = "";
72 
74 static OpenFlipperQSettings* settings_ = 0;
75 
77 static QDir applicationDir_;
78 
80 static QDir configDir_;
81 
83 static QDir pluginDir_;
84 
86 static QDir shaderDir_;
87 
89 static QDir textureDir_;
90 
92 static QDir licenseDir_;
93 
95 static QDir scriptDir_;
96 
98 static QDir iconDir_;
99 
101 static QIcon* OpenFlipperIcon_ = 0;
102 
104 static QDir translationsDir_;
105 
107 static QDir fontsDir_;
108 
110 static QDir helpDir_;
111 
113 static QDir dataDir_;
114 
116 static QStringList optionFiles_;
117 
119 static QDir currentDir_;
120 
122 static QDir currentScriptDir_;
123 
125 static QDir currentTextureDir_;
126 
128 static bool startup_ = false;
129 
131 static bool deleteIniFile_ = false;
132 
134 static bool nogui_ = false;
135 
137 static bool stereo_ = true;
138 
140 static bool glStereo_ = true;
141 
143 static StereoMode stereoMode_ = OpenGL;
144 
146 static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
147 static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
148 
150 static bool synchronization_ = false;
151 
153 static std::vector<ACG::SceneGraph::DrawModes::DrawMode> defaultDrawMode_ = std::vector<ACG::SceneGraph::DrawModes::DrawMode> (4, ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED);
154 
156 static int defaultViewerLayout_ = 0;
157 
159 static int redrawDisabled_ = 0;
160 
162 static bool drawModesInContextMenu_ = true;
163 
165 static QString currentViewMode_ = "";
166 
167 static QString title_ = TOSTRING(PRODUCT_NAME)" v?";
168 
170 static QColor defaultColor_ = QColor("white");
171 
173 static bool randomDefaultColor_ = false;
174 
176 static bool scripting_ = false;
177 
179 static bool logToConsole_ = false;
180 
182 static bool debug_ = false;
183 
185 static bool doSlotDebugging_ = false;
186 
188 static QString lastDataType_ = "Triangle Mesh";
189 
191 static bool enableBackup_ = true;
192 
194 static int sceneGraphUpdatesBlocked_ = 0;
195 
197 static bool loadingRecentFile_ = false;
198 
200 static bool savingSettings_ = false;
201 
202 static int* argc_;
203 
204 static char *** argv_;
205 
206 static bool remoteControl_ = false;
207 
208 static int remoteControlPort_ = 2000;
209 
210 # if __WORDSIZE == 64
211  const bool is64 = true;
212 #else
213  const bool is64 = false;
214 #endif
215 
216 #if defined(WIN32)
217  const bool linux_ = false;
218  const bool windows_ = true;
219  const bool darwin_ = false;
220 #elif defined(ARCH_DARWIN)
221  const bool darwin_ = true;
222  const bool linux_ = false;
223  const bool windows_ = false;
224 #else
225  const bool darwin_ = false;
226  const bool linux_ = true;
227  const bool windows_ = false;
228 #endif
229 
230 bool is64bit() { return is64; };
231 bool is32bit() { return !is64; };
232 
233 bool isLinux() {
234  return linux_;
235 }
236 
237 bool isWindows() {
238  return windows_;
239 }
240 
241 bool isDarwin() {
242  return darwin_;
243 }
244 
245 
246 QString lang() {
247  QString lang = getenv( "LANG" ) ;
248  return lang;
249 }
250 
251 QString dirSeparator() {
252 // if (windows_)
253 // return QString("\\");
254 // if (linux_)
255 // return QString("/");
256 
257  return QString("/");
258 }
259 
260 QDir applicationDir() { return applicationDir_; }
261 QDir configDir() { return configDir_; }
262 QDir pluginDir() { return pluginDir_; }
263 QDir shaderDir() { return shaderDir_; }
264 QDir textureDir() { return textureDir_; }
265 QDir licenseDir() { return licenseDir_; }
266 QDir scriptDir() { return scriptDir_; }
267 QDir iconDir() { return iconDir_; }
268 QDir translationsDir() { return translationsDir_; }
269 QDir fontsDir() { return fontsDir_; }
270 QDir helpDir() { return helpDir_; }
271 QDir dataDir() { return dataDir_; }
272 QDir currentDir() { return currentDir_; }
273 QDir currentScriptDir() { return currentScriptDir_; }
274 QDir currentTextureDir(){ return currentTextureDir_; }
275 
276 QString applicationDirStr() { return applicationDir_.absolutePath(); }
277 QString configDirStr() { return configDir_.absolutePath(); }
278 QString pluginDirStr() { return pluginDir_.absolutePath(); }
279 QString shaderDirStr() { return shaderDir_.absolutePath(); }
280 QString textureDirStr() { return textureDir_.absolutePath(); }
281 QString licenseDirStr() { return licenseDir_.absolutePath(); }
282 QString scriptDirStr() { return scriptDir_.absolutePath(); }
283 QString iconDirStr() { return iconDir_.absolutePath(); }
284 QString translationsDirStr() { return translationsDir_.absolutePath(); }
285 QString fontsDirStr() { return fontsDir_.absolutePath(); }
286 QString helpDirStr() { return helpDir_.absolutePath(); }
287 QString dataDirStr() { return dataDir_.absolutePath(); }
288 QString currentDirStr() { return currentDir_.absolutePath(); }
289 QString currentScriptDirStr() { return currentScriptDir_.absolutePath(); }
290 QString currentTextureDirStr() { return currentTextureDir_.absolutePath(); }
291 
292 QStringList optionFiles() { return optionFiles_; }
293 
294 void optionFiles(QStringList _list) { optionFiles_ = _list; }
295 
296 bool startup() { return startup_; };
297 
298 void finishedStartup() { startup_ = false;};
299 
300 QIcon& OpenFlipperIcon() {
301 
302  if (OpenFlipperIcon_ == 0){
303  OpenFlipperIcon_ = new QIcon( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_128x128x32.png");
304  OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_48x48x32.png", QSize(48,48) );
305  OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_32x32x32.png", QSize(32,32) );
306  OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() + "OpenFlipper_Icon_16x16x32.png", QSize(16,16) );
307  }
308 
309  return *OpenFlipperIcon_;
310 }
311 
312 void currentDir(QDir _dir) {
313  currentDir_ = _dir;
314 }
315 
316 bool currentDir(QString _dir) {
317  QDir tmp(_dir);
318  if (tmp.exists()) {
319  currentDir_ = tmp;
320  return true;
321  }
322  return false;
323 }
324 
325 
326 bool currentScriptDir(QString _dir) {
327  QDir tmp(_dir);
328  if (tmp.exists()) {
329  currentScriptDir_ = tmp;
330  return true;
331  }
332  return false;
333 }
334 
335 bool currentTextureDir(QString _dir) {
336  QDir tmp(_dir);
337  if (tmp.exists()) {
338  currentTextureDir_ = tmp;
339  return true;
340  }
341  return false;
342 }
343 
344 void deleteIniFile(bool _delete) {
345  deleteIniFile_ = _delete;
346 }
347 
348 bool deleteIniFile() {
349  return deleteIniFile_;
350 }
351 
353 void nogui( bool _nogui ) {
354  nogui_ = _nogui;
355 }
356 
358 bool nogui( ) {
359  return nogui_;
360 }
361 
363 bool gui( ) {
364  return !nogui_;
365 }
366 
368 void stereo( bool _stereo ) {
369  stereo_ = _stereo;
370 }
371 
373 bool stereo( ) {
374  return stereo_;
375 }
376 
378 void glStereo( bool _glStereo ) {
379  glStereo_ = _glStereo;
380 }
381 
383 bool glStereo( ) {
384  return glStereo_;
385 }
386 
388 void stereoMode( StereoMode _mode ) {
389  stereoMode_ = _mode;
390 }
391 
393 StereoMode stereoMode( ) {
394  return stereoMode_;
395 }
396 
398 void eyeDistance( double _eye ) {
399  settings_->setValue("Core/Stereo/EyeDistance",_eye);
400 }
401 
403 double eyeDistance( )
404 {
405  return settings_->value("Core/Stereo/EyeDistance",0.07f).toDouble();
406 }
407 
409 void focalDistance( float _focal )
410 {
411  settings_->setValue("Core/Stereo/FocalDistance",_focal);
412 }
413 
415 float focalDistance( )
416 {
417  return settings_->value("Core/Stereo/FocalDistance",0.5f).toDouble();
418 }
419 
421 void anaglyphLeftEyeColorMatrix( std::vector<float> _mat )
422 {
423  for (int i = 0; i < 9; i++)
424  anaglyphLeftEyeColors_[i] = _mat[i];
425 }
426 
428 std::vector<float> anaglyphLeftEyeColorMatrix( )
429 {
430  return anaglyphLeftEyeColors_;
431 }
432 
434 void anaglyphRightEyeColorMatrix( std::vector<float> _mat )
435 {
436  for (int i = 0; i < 9; i++)
437  anaglyphRightEyeColors_[i] = _mat[i];
438 }
439 
441 std::vector<float> anaglyphRightEyeColorMatrix( )
442 {
443  return anaglyphRightEyeColors_;
444 }
445 
447 void synchronization( bool _synchronization ) {
448  synchronization_ = _synchronization;
449 }
450 
452 bool synchronization( ) {
453  return synchronization_;
454 }
455 
456 void defaultDrawMode( ACG::SceneGraph::DrawModes::DrawMode _mode, int _viewer){
457  defaultDrawMode_[_viewer] = _mode;
458 }
459 
460 ACG::SceneGraph::DrawModes::DrawMode defaultDrawMode(int _viewer){
461  return defaultDrawMode_[_viewer];
462 }
463 
464 void defaultPerspectiveProjectionMode( bool _mode, int _viewer){
465 
466  // Core/Gui/glViewer<viewer> Orthogonal = false,Perspective = true (bool)\n
467 
468  QString entry = "Viewer" + QString::number(_viewer) + "/perspectiveProjection";
469  OpenFlipperSettings().setValue(entry,_mode);
470 
471 }
472 
473 bool defaultPerspectiveProjectionMode(int _viewer){
474 
475  QString entry = "Viewer" + QString::number(_viewer) + "/perspectiveProjection";
476 
477  switch (_viewer) {
478  case 0:
479  return OpenFlipperSettings().value(entry,true).toBool();
480  case 1:
481  return OpenFlipperSettings().value(entry,false).toBool();
482  case 2:
483  return OpenFlipperSettings().value(entry,false).toBool();
484  case 3:
485  return OpenFlipperSettings().value(entry,false).toBool();
486  default:
487  std::cerr << "defaultProjectionMode: illegal viewer id: " << _viewer << std::endl;
488  break;
489  }
490 
491  return true;
492 }
493 
494 void defaultViewingDirection( int _mode, int _viewer){
495  QString entry = "Viewer" + QString::number(_viewer) + "/defaultViewingDirection";
496  OpenFlipperSettings().setValue(entry,_mode);
497 }
498 
499 int defaultViewingDirection(int _viewer){
500 
501  QString entry = "Viewer" + QString::number(_viewer) + "/defaultViewingDirection";
502 
503  switch (_viewer) {
504  case 0:
505  return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_FREE).toInt();
506  case 1:
507  return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_FRONT).toInt();
508  case 2:
509  return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_RIGHT).toInt();
510  case 3:
511  return OpenFlipperSettings().value(entry,PluginFunctions::VIEW_TOP).toInt();
512  default:
513  std::cerr << "defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
514  break;
515  }
516 
517  return PluginFunctions::VIEW_FREE;
518 }
519 
520 void defaultLockRotation( bool _lock, int _viewer ) {
521  QString entry = "Viewer" + QString::number(_viewer) + "/defaultLockRotation";
522  OpenFlipperSettings().setValue(entry,_lock);
523 }
524 
525 bool defaultLockRotation( int _viewer ) {
526 
527  QString entry = "Viewer" + QString::number(_viewer) + "/defaultLockRotation";
528 
529  switch (_viewer) {
530  case 0:
531  return OpenFlipperSettings().value(entry,false).toBool();
532  case 1:
533  return OpenFlipperSettings().value(entry,true).toBool();
534  case 2:
535  return OpenFlipperSettings().value(entry,true).toBool();
536  case 3:
537  return OpenFlipperSettings().value(entry,true).toBool();
538  default:
539  std::cerr << "defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
540  break;
541  }
542 
543  return false;
544 }
545 
546 
547 void defaultViewerLayout( int _layout ){
548  defaultViewerLayout_ = _layout;
549 }
550 
551 int defaultViewerLayout(){
552  return defaultViewerLayout_;
553 }
554 
555 void redrawDisabled( bool disable ){
556  if ( disable )
557  redrawDisabled_++;
558  else
559  if ( redrawDisabled_ == 0 )
560  std::cerr << "Mismatch of redraw enable/disable!!" << std::endl;
561  else
562  redrawDisabled_--;
563 }
564 
565 bool redrawDisabled( ){
566  return (redrawDisabled_ > 0);
567 }
568 
569 bool drawModesInContextMenu() {
570  return drawModesInContextMenu_;
571 }
572 
573 void drawModesInContextMenu(bool _show) {
574  drawModesInContextMenu_ = _show;
575 }
576 
577 unsigned int examinerWidgets() {
578  if ( OpenFlipperSettings().value("Core/Gui/glViewer/useMultipleViewers",true).toBool() )
579  return 4;
580  else
581  return 1;
582 }
583 
585 void loggerState( LoggerState _state) {
586  OpenFlipperSettings().setValue("Core/Gui/LogWindow/LogWindowMode",_state);
587 }
588 
590 LoggerState loggerState( ) {
591  return static_cast<OpenFlipper::Options::LoggerState> (OpenFlipperSettings().value("Core/Gui/LogWindow/LogWindowMode",0).toInt() );
592 }
593 
595 QString currentViewMode( ) {
596  return currentViewMode_;
597 }
598 
600 void currentViewMode( QString _mode ) {
601  currentViewMode_ = _mode;
602 }
603 
604 
605 QString windowTitle( ) {
606  return title_;
607 }
608 
609 void windowTitle( QString _titel ) {
610  title_ = _titel;
611 }
612 
613 void defaultColor( QColor _color ) {
614  defaultColor_ = _color;
615 }
616 
617 QColor defaultColor() {
618  return defaultColor_;
619 }
620 
621 void randomDefaultColor(bool _random) {
622  randomDefaultColor_ = _random;
623 }
624 
625 bool randomDefaultColor() {
626  return randomDefaultColor_;
627 }
628 
630 QString lastDataType(){
631  return lastDataType_;
632 }
633 
635 void lastDataType(QString _type){
636  lastDataType_ = _type;
637 }
638 
639 bool scripting( ) {
640  return scripting_;
641 }
642 
643 void scripting(bool _status ) {
644  scripting_ = _status;
645 }
646 
647 bool logToConsole( ) {
648  return logToConsole_;
649 }
650 
651 void logToConsole(bool _logToConsole ) {
652  logToConsole_ = _logToConsole;
653 }
654 
655 bool debug() {
656  return debug_;
657 }
658 
659 void debug(bool _debug ) {
660  debug_ = _debug;
661 }
662 
663 bool backupEnabled( ) {
664  return enableBackup_;
665 }
666 
667 void enableBackup(bool _enableBackup ) {
668  enableBackup_ = _enableBackup;
669 }
670 
671 void blockSceneGraphUpdates( ) {
672  ++sceneGraphUpdatesBlocked_;
673 }
674 
675 void unblockSceneGraphUpdates() {
676  if ( sceneGraphUpdatesBlocked_ <= 0)
677  std::cerr << "Error: More unblocks than blocks! Ignoring this request" << std::endl;
678  else
679  --sceneGraphUpdatesBlocked_;
680 }
681 
682 bool sceneGraphUpdatesBlocked( ) {
683  if ( sceneGraphUpdatesBlocked_ < 0)
684  std::cerr << "Error: updates blocked < 0 ... more unblocks than blocks" << std::endl;
685 
686  return (sceneGraphUpdatesBlocked_ > 0);
687 }
688 
689 bool savingSettings( ) {
690  return savingSettings_;
691 }
692 
693 void savingSettings(bool _savingSettings ) {
694  savingSettings_ = _savingSettings;
695 }
696 
697 bool loadingRecentFile( ) {
698  return loadingRecentFile_;
699 }
700 
701 void loadingRecentFile(bool _loadingRecentFile ) {
702  loadingRecentFile_ = _loadingRecentFile;
703 }
704 
705 int* argc() {
706  return argc_;
707 }
708 
709 char *** argv() {
710  return argv_;
711 }
712 
713 void argc( int* _argc ) {
714  argc_ = _argc;
715 }
716 
717 void argv( char*** _argv) {
718  argv_ = _argv;
719 }
720 
721 bool remoteControl(){
722  return remoteControl_;
723 }
724 
725 void remoteControl(bool _remote){
726  remoteControl_ = _remote;
727 }
728 
729 int remoteControlPort(){
730  return remoteControlPort_;
731 }
732 
733 void remoteControlPort(int _remotePort){
734  remoteControlPort_ = _remotePort;
735 }
736 
737 void doSlotDebugging( bool _debugging ) {
738  doSlotDebugging_ = _debugging;
739 }
740 
741 bool doSlotDebugging( ) {
742  return doSlotDebugging_;
743 }
744 
745 QString coreVersion() {
746  #ifndef CORE_VERSION
747  #define CORE_VERSION "1.0.0RC2"
748  #endif
749  return QString(CORE_VERSION);
750 }
751 
752 static const char * const CONFIG_DIR = "." TOSTRING(PRODUCT_STRING);
753 
754 bool initializeSettings() {
755 
756  #if defined(__INTEL_COMPILER)
757  compilerInfo_ = "Intel: " + QString( TOSTRING(__INTEL_COMPILER) ) + "." + QString( TOSTRING(__GNUC_MINOR__) ) ;
758  #if defined(__INTEL_COMPILER_BUILD_DATE)
759  compilerInfo_ += " BuildDate " + QString( TOSTRING(__INTEL_COMPILER_BUILD_DATE) );
760  #endif
761  #elif defined(__GNUC__)
762  compilerInfo_ = "Gnu CC: " + QString( TOSTRING(__GNUC__) ) + "." + QString( TOSTRING(__GNUC_MINOR__) ) ;
763  #if defined(__GNUC_PATCHLEVEL__)
764  compilerInfo_ += "." + QString( TOSTRING(__GNUC_PATCHLEVEL__) );
765  #endif
766  #elif defined (_MSC_FULL_VER)
767  compilerInfo_ = "MSVC: " + QString( TOSTRING(_MSC_FULL_VER) );
768  #else
769  compilerInfo_ = "Unknown Compiler";
770  #endif
771 
772 
773  //==================================================================================================
774  // Get the Main config dir in the home directory and possibly create it
775  //==================================================================================================
776  #if defined(ARCH_DARWIN)
777  configDir_ = QDir::home();
778 
779  if ( ! configDir_.cd("Library") )
780  configDir_.mkdir("Library");
781 
782  if ( ! configDir_.cd("Application Support") )
783  configDir_.mkdir("Application Support");
784 
785  if ( ! configDir_.cd("de.rwth-aachen.graphics.openflipper") ) {
786  configDir_.mkdir("de.rwth-aachen.graphics.openflipper");
787  if ( ! configDir_.cd("de.rwth-aachen.graphics.openflipper") ) {
788  std::cerr << "Unable to create config dir ~/Library/de.rwth-aachen.graphics.openflipper" << std::endl;
789  return false;
790  }
791  }
792  #else
793  configDir_ = QDir::home();
794  if ( ! configDir_.cd(CONFIG_DIR) ) {
795  std::cerr << "Creating config Dir ~/" << CONFIG_DIR << std::endl;;
796  configDir_.mkdir(CONFIG_DIR);
797  if ( ! configDir_.cd(CONFIG_DIR) ) {
798  std::cerr << "Unable to create config dir ~/" << CONFIG_DIR << std::endl;
799  return false;
800  }
801  }
802 
803  #endif
804 
805 
806  //==================================================================================================
807  // Setup settings.
808  //==================================================================================================
809  // This has to be done as early as possible to set the program options right
810 
811  // Force ini format on all platforms
812  QSettings::setDefaultFormat ( QSettings::IniFormat );
813 
814  // Force settings to be stored in the OpenFlipper config directory
815  QSettings::setPath( QSettings::IniFormat, QSettings::UserScope , configDir_.absolutePath() );
816 
817  // Finally attach the settings object.
818  settings_ = new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope, "ACG", "OpenFlipper");
819 
820  //==================================================================================================
821  // Now create special directories in th OpenFlipper config dir
822  //==================================================================================================
823 
824  // Create a personal Icon cache dir to save for example user added icons
825  if ( ! configDir_.exists("Icons") ){
826  configDir_.mkdir("Icons");
827  std::cerr << "Creating Icon Cache Dir ~/" << CONFIG_DIR << "/Icons" << std::endl;
828  }
829 
830  //==================================================================================================
831  // Setup main application dir
832  //==================================================================================================
833 
834  // Remember the main application directory (assumed to be one above executable Path)
835  applicationDir_ = QCoreApplication::applicationDirPath();
836 
837  // When using cmake, we get the absolute path to the Application directory via a define
838  applicationDir_.cd(OPENFLIPPER_APPDIR);
839 
840  //==================================================================================================
841  // Setup directory containing plugins
842  //==================================================================================================
843 
844  // start at application directory
845  pluginDir_ = applicationDir_;
846 
847  // cmake style: Path is directly given from define!
848  pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
849 
850  dataDir_ = OpenFlipper::Options::applicationDir();
851 
852  #ifdef OPENFLIPPER_DATADIR
853  dataDir_.cd(OPENFLIPPER_DATADIR);
854  #else
855  dataDir_ = OpenFlipper::Options::applicationDir();
856  #endif
857 
858  // Set the Path to the Shaders
859  shaderDir_ = dataDir_;
860  shaderDir_.cd("Shaders");
861  ACG::ShaderProgGenerator::setShaderDir(OpenFlipper::Options::shaderDirStr());
862 
863  // Set the Path to the textures
864  textureDir_ = dataDir_;
865  textureDir_.cd("Textures");
866 
867  // Set the Path to the Scripts
868  scriptDir_ = dataDir_;
869  scriptDir_.cd("Scripts");
870 
871 
872  // Set the Path to the Icons
873  iconDir_ = dataDir_;
874  iconDir_.cd("Icons");
875 
876  // Set the Path to the translations
877  translationsDir_ = dataDir_;
878  translationsDir_.cd("Translations");
879 
880  // Set the Path to the Fonts
881  fontsDir_ = dataDir_;
882  fontsDir_.cd("Fonts");
883 
884  // Set the Path to the License files
885  licenseDir_ = dataDir_;
886  licenseDir_.cd("Licenses");
887 
888  // Set the Path to the Help
889  helpDir_ = dataDir_;
890  helpDir_.cd("Help");
891 
892  //==================================================================================================
893  // Initialize with default values if not already set
894  //==================================================================================================
895 
896  // User Interface Settings
897  if ( ! settings_->contains("Core/Gui/glViewer/defaultBackgroundColor") )
898  settings_->setValue("Core/Gui/glViewer/defaultBackgroundColor",QColor("black"));
899 
900  if ( ! settings_->contains("Core/Gui/glViewer/showControlWheels") )
901  settings_->setValue("Core/Gui/glViewer/showControlWheels",false);
902 
903 
904  // Mouse Controls
905  if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactor") )
906  settings_->setValue("Core/Mouse/Wheel/ZoomFactor",1.0);
907 
908  if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactorShift") )
909  settings_->setValue("Core/Mouse/Wheel/ZoomFactorShift",0.2);
910 
911  if ( ! settings_->contains("Core/Mouse/Wheel/Invert") )
912  settings_->setValue("Core/Mouse/Wheel/Invert",false);
913 
914  // General Stereo Settings
915  if ( ! settings_->contains("Core/Stereo/FocalLength") )
916  settings_->setValue("Core/Stereo/FocalLength",0.5);
917 
918  if ( ! settings_->contains("Core/Stereo/EyeDistance") )
919  settings_->setValue("Core/Stereo/EyeDistance",0.07);
920 
921  return true;
922 
923 }
924 
925 void closeSettings() {
926 
927  // Delete the settings object. This will flush all data to the disk.
928  delete settings_;
929 }
930 
931 QString compilerInfo() {
932  return compilerInfo_;
933 }
934 
935 }
936 }
937 
939  // Empty standard settings object if the right settings are not available!
940  static OpenFlipperQSettings emptySettings;
941 
942  if ( OpenFlipper::Options::settings_ )
943  return *OpenFlipper::Options::settings_;
944  else
945  return emptySettings;
946 }
947 
948 
949 
950 //=============================================================================
951 
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
Definition: DrawModes.cc:88
#define TOSTRING(x)
QSettings object containing all program settings of OpenFlipper.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
static void setShaderDir(QString _dir)
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...