63 #include <ACG/GL/ShaderGenerator.hh>
64 #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
65 #include <QCoreApplication>
71 static QString compilerInfo_ =
"";
77 static QDir applicationDir_;
80 static QDir configDir_;
83 static QDir pluginDir_;
86 static QDir shaderDir_;
89 static QDir textureDir_;
92 static QDir licenseDir_;
95 static QDir scriptDir_;
101 static QIcon* OpenFlipperIcon_ = 0;
104 static QDir translationsDir_;
107 static QDir fontsDir_;
110 static QDir helpDir_;
113 static QDir dataDir_;
116 static QStringList optionFiles_;
119 static QDir currentDir_;
122 static QDir currentScriptDir_;
125 static QDir currentTextureDir_;
128 static bool startup_ =
false;
131 static bool deleteIniFile_ =
false;
134 static bool nogui_ =
false;
137 static bool stereo_ =
true;
140 static bool glStereo_ =
true;
143 static StereoMode stereoMode_ = OpenGL;
146 static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
147 static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
150 static bool synchronization_ =
false;
156 static int defaultViewerLayout_ = 0;
159 static int redrawDisabled_ = 0;
162 static bool drawModesInContextMenu_ =
true;
165 static QString currentViewMode_ =
"";
167 static QString title_ =
TOSTRING(PRODUCT_NAME)
" v?";
170 static QColor defaultColor_ = QColor(
"white");
173 static bool randomDefaultColor_ =
false;
176 static bool scripting_ =
false;
179 static bool logToConsole_ =
false;
182 static bool debug_ =
false;
185 static bool doSlotDebugging_ =
false;
188 static QString lastDataType_ =
"Triangle Mesh";
191 static bool enableBackup_ =
true;
194 static int sceneGraphUpdatesBlocked_ = 0;
197 static bool loadingRecentFile_ =
false;
200 static bool savingSettings_ =
false;
204 static char *** argv_;
206 static bool remoteControl_ =
false;
208 static int remoteControlPort_ = 2000;
210 # if __WORDSIZE == 64
211 const bool is64 =
true;
213 const bool is64 =
false;
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;
225 const bool darwin_ =
false;
226 const bool linux_ =
true;
227 const bool windows_ =
false;
230 bool is64bit() {
return is64; };
231 bool is32bit() {
return !is64; };
247 QString lang = getenv(
"LANG" ) ;
251 QString dirSeparator() {
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_; }
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(); }
292 QStringList optionFiles() {
return optionFiles_; }
294 void optionFiles(QStringList _list) { optionFiles_ = _list; }
296 bool startup() {
return startup_; };
298 void finishedStartup() { startup_ =
false;};
300 QIcon& OpenFlipperIcon() {
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) );
309 return *OpenFlipperIcon_;
312 void currentDir(QDir _dir) {
316 bool currentDir(QString _dir) {
326 bool currentScriptDir(QString _dir) {
329 currentScriptDir_ = tmp;
335 bool currentTextureDir(QString _dir) {
338 currentTextureDir_ = tmp;
344 void deleteIniFile(
bool _delete) {
345 deleteIniFile_ = _delete;
348 bool deleteIniFile() {
349 return deleteIniFile_;
353 void nogui(
bool _nogui ) {
368 void stereo(
bool _stereo ) {
378 void glStereo(
bool _glStereo ) {
379 glStereo_ = _glStereo;
388 void stereoMode( StereoMode _mode ) {
393 StereoMode stereoMode( ) {
398 void eyeDistance(
double _eye ) {
399 settings_->
setValue(
"Core/Stereo/EyeDistance",_eye);
403 double eyeDistance( )
405 return settings_->
value(
"Core/Stereo/EyeDistance",0.07f).toDouble();
409 void focalDistance(
float _focal )
411 settings_->
setValue(
"Core/Stereo/FocalDistance",_focal);
415 float focalDistance( )
417 return settings_->
value(
"Core/Stereo/FocalDistance",0.5f).toDouble();
421 void anaglyphLeftEyeColorMatrix( std::vector<float> _mat )
423 for (
int i = 0; i < 9; i++)
424 anaglyphLeftEyeColors_[i] = _mat[i];
428 std::vector<float> anaglyphLeftEyeColorMatrix( )
430 return anaglyphLeftEyeColors_;
434 void anaglyphRightEyeColorMatrix( std::vector<float> _mat )
436 for (
int i = 0; i < 9; i++)
437 anaglyphRightEyeColors_[i] = _mat[i];
441 std::vector<float> anaglyphRightEyeColorMatrix( )
443 return anaglyphRightEyeColors_;
447 void synchronization(
bool _synchronization ) {
448 synchronization_ = _synchronization;
452 bool synchronization( ) {
453 return synchronization_;
457 defaultDrawMode_[_viewer] = _mode;
461 return defaultDrawMode_[_viewer];
464 void defaultPerspectiveProjectionMode(
bool _mode,
int _viewer){
468 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
473 bool defaultPerspectiveProjectionMode(
int _viewer){
475 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
487 std::cerr <<
"defaultProjectionMode: illegal viewer id: " << _viewer << std::endl;
494 void defaultViewingDirection(
int _mode,
int _viewer){
495 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
499 int defaultViewingDirection(
int _viewer){
501 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
513 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
517 return PluginFunctions::VIEW_FREE;
520 void defaultLockRotation(
bool _lock,
int _viewer ) {
521 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
525 bool defaultLockRotation(
int _viewer ) {
527 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
539 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
547 void defaultViewerLayout(
int _layout ){
548 defaultViewerLayout_ = _layout;
551 int defaultViewerLayout(){
552 return defaultViewerLayout_;
555 void redrawDisabled(
bool disable ){
559 if ( redrawDisabled_ == 0 )
560 std::cerr <<
"Mismatch of redraw enable/disable!!" << std::endl;
565 bool redrawDisabled( ){
566 return (redrawDisabled_ > 0);
569 bool drawModesInContextMenu() {
570 return drawModesInContextMenu_;
573 void drawModesInContextMenu(
bool _show) {
574 drawModesInContextMenu_ = _show;
577 unsigned int examinerWidgets() {
585 void loggerState( LoggerState _state) {
590 LoggerState loggerState( ) {
591 return static_cast<OpenFlipper::Options::LoggerState
> (
OpenFlipperSettings().
value(
"Core/Gui/LogWindow/LogWindowMode",0).toInt() );
595 QString currentViewMode( ) {
596 return currentViewMode_;
600 void currentViewMode( QString _mode ) {
601 currentViewMode_ = _mode;
605 QString windowTitle( ) {
609 void windowTitle( QString _titel ) {
613 void defaultColor( QColor _color ) {
614 defaultColor_ = _color;
617 QColor defaultColor() {
618 return defaultColor_;
621 void randomDefaultColor(
bool _random) {
622 randomDefaultColor_ = _random;
625 bool randomDefaultColor() {
626 return randomDefaultColor_;
630 QString lastDataType(){
631 return lastDataType_;
635 void lastDataType(QString _type){
636 lastDataType_ = _type;
643 void scripting(
bool _status ) {
644 scripting_ = _status;
647 bool logToConsole( ) {
648 return logToConsole_;
651 void logToConsole(
bool _logToConsole ) {
652 logToConsole_ = _logToConsole;
659 void debug(
bool _debug ) {
663 bool backupEnabled( ) {
664 return enableBackup_;
667 void enableBackup(
bool _enableBackup ) {
668 enableBackup_ = _enableBackup;
671 void blockSceneGraphUpdates( ) {
672 ++sceneGraphUpdatesBlocked_;
675 void unblockSceneGraphUpdates() {
676 if ( sceneGraphUpdatesBlocked_ <= 0)
677 std::cerr <<
"Error: More unblocks than blocks! Ignoring this request" << std::endl;
679 --sceneGraphUpdatesBlocked_;
682 bool sceneGraphUpdatesBlocked( ) {
683 if ( sceneGraphUpdatesBlocked_ < 0)
684 std::cerr <<
"Error: updates blocked < 0 ... more unblocks than blocks" << std::endl;
686 return (sceneGraphUpdatesBlocked_ > 0);
689 bool savingSettings( ) {
690 return savingSettings_;
693 void savingSettings(
bool _savingSettings ) {
694 savingSettings_ = _savingSettings;
697 bool loadingRecentFile( ) {
698 return loadingRecentFile_;
701 void loadingRecentFile(
bool _loadingRecentFile ) {
702 loadingRecentFile_ = _loadingRecentFile;
713 void argc(
int* _argc ) {
717 void argv(
char*** _argv) {
721 bool remoteControl(){
722 return remoteControl_;
725 void remoteControl(
bool _remote){
726 remoteControl_ = _remote;
729 int remoteControlPort(){
730 return remoteControlPort_;
733 void remoteControlPort(
int _remotePort){
734 remoteControlPort_ = _remotePort;
737 void doSlotDebugging(
bool _debugging ) {
738 doSlotDebugging_ = _debugging;
741 bool doSlotDebugging( ) {
742 return doSlotDebugging_;
745 QString coreVersion() {
747 #define CORE_VERSION "1.0.0RC2"
749 return QString(CORE_VERSION);
752 static const char *
const CONFIG_DIR =
"." TOSTRING(PRODUCT_STRING);
754 bool initializeSettings() {
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) );
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__) );
766 #elif defined (_MSC_FULL_VER)
767 compilerInfo_ =
"MSVC: " + QString(
TOSTRING(_MSC_FULL_VER) );
769 compilerInfo_ =
"Unknown Compiler";
776 #if defined(ARCH_DARWIN)
777 configDir_ = QDir::home();
779 if ( ! configDir_.cd(
"Library") )
780 configDir_.mkdir(
"Library");
782 if ( ! configDir_.cd(
"Application Support") )
783 configDir_.mkdir(
"Application Support");
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;
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;
812 QSettings::setDefaultFormat ( QSettings::IniFormat );
815 QSettings::setPath( QSettings::IniFormat, QSettings::UserScope , configDir_.absolutePath() );
818 settings_ =
new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope,
"ACG",
"OpenFlipper");
825 if ( ! configDir_.exists(
"Icons") ){
826 configDir_.mkdir(
"Icons");
827 std::cerr <<
"Creating Icon Cache Dir ~/" << CONFIG_DIR <<
"/Icons" << std::endl;
835 applicationDir_ = QCoreApplication::applicationDirPath();
838 applicationDir_.cd(OPENFLIPPER_APPDIR);
845 pluginDir_ = applicationDir_;
848 pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
850 dataDir_ = OpenFlipper::Options::applicationDir();
852 #ifdef OPENFLIPPER_DATADIR
853 dataDir_.cd(OPENFLIPPER_DATADIR);
855 dataDir_ = OpenFlipper::Options::applicationDir();
859 shaderDir_ = dataDir_;
860 shaderDir_.cd(
"Shaders");
864 textureDir_ = dataDir_;
865 textureDir_.cd(
"Textures");
868 scriptDir_ = dataDir_;
869 scriptDir_.cd(
"Scripts");
874 iconDir_.cd(
"Icons");
877 translationsDir_ = dataDir_;
878 translationsDir_.cd(
"Translations");
881 fontsDir_ = dataDir_;
882 fontsDir_.cd(
"Fonts");
885 licenseDir_ = dataDir_;
886 licenseDir_.cd(
"Licenses");
897 if ( ! settings_->contains(
"Core/Gui/glViewer/defaultBackgroundColor") )
898 settings_->setValue(
"Core/Gui/glViewer/defaultBackgroundColor",QColor(
"black"));
900 if ( ! settings_->contains(
"Core/Gui/glViewer/showControlWheels") )
901 settings_->setValue(
"Core/Gui/glViewer/showControlWheels",
false);
905 if ( ! settings_->contains(
"Core/Mouse/Wheel/ZoomFactor") )
906 settings_->setValue(
"Core/Mouse/Wheel/ZoomFactor",1.0);
908 if ( ! settings_->contains(
"Core/Mouse/Wheel/ZoomFactorShift") )
909 settings_->setValue(
"Core/Mouse/Wheel/ZoomFactorShift",0.2);
911 if ( ! settings_->contains(
"Core/Mouse/Wheel/Invert") )
912 settings_->setValue(
"Core/Mouse/Wheel/Invert",
false);
915 if ( ! settings_->contains(
"Core/Stereo/FocalLength") )
916 settings_->setValue(
"Core/Stereo/FocalLength",0.5);
918 if ( ! settings_->contains(
"Core/Stereo/EyeDistance") )
919 settings_->setValue(
"Core/Stereo/EyeDistance",0.07);
925 void closeSettings() {
931 QString compilerInfo() {
932 return compilerInfo_;
942 if ( OpenFlipper::Options::settings_ )
943 return *OpenFlipper::Options::settings_;
945 return emptySettings;
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
#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...