53#include <ACG/GL/ShaderGenerator.hh>
54#include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh>
55#include <QCoreApplication>
57namespace OpenFlipper {
61static QString compilerInfo_ =
"";
67static QDir applicationDir_;
70static QDir configDir_;
73static QDir pluginDir_;
76static QDir shaderDir_;
79static QDir textureDir_;
82static QDir licenseDir_;
85static QDir scriptDir_;
91static QIcon* OpenFlipperIcon_ = 0;
94static QDir translationsDir_;
106static QDir currentDir_;
109static QDir currentScriptDir_;
112static QDir currentTextureDir_;
115static bool startup_ =
false;
118static bool deleteIniFile_ =
false;
121static bool nogui_ =
false;
124static bool stereo_ =
true;
127static bool coreProfile_ =
false;
128static bool profileOverride_ =
false;
131static QPair<int,int> version_ {4,6};
132static bool versionOverride_ =
false;
135static int samples_ = 4;
136static bool samplesOverride_ =
false;
139static bool glStereo_ =
true;
140static bool overrideGLStereo_ =
false;
141static bool requestedGLStereo =
false;
142static bool GLStereoSet =
false;
148static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
149static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
152static bool synchronization_ =
false;
158static int defaultViewerLayout_ = 0;
161static int redrawDisabled_ = 0;
164static bool drawModesInContextMenu_ =
true;
167static QString currentViewMode_ =
"";
169static QString title_ =
TOSTRING(PRODUCT_NAME)
" v?";
172static QColor defaultColor_ = QColor(
"white");
175static bool randomDefaultColor_ =
false;
178static bool scripting_ =
false;
181static bool logToConsole_ =
false;
184static bool debug_ =
false;
187static bool doSlotDebugging_ =
false;
190static QString lastDataType_ =
"Triangle Mesh";
193static bool enableBackup_ =
true;
196static int sceneGraphUpdatesBlocked_ = 0;
199static bool loadingRecentFile_ =
false;
202static bool savingSettings_ =
false;
206static char *** argv_;
208static bool remoteControl_ =
false;
210static int remoteControlPort_ = 2000;
213 const bool is64 =
true;
215 const bool is64 =
false;
219 const bool linux_ =
false;
220 const bool windows_ =
true;
221 const bool darwin_ =
false;
222#elif defined(ARCH_DARWIN)
223 const bool darwin_ =
true;
224 const bool linux_ =
false;
225 const bool windows_ =
false;
227 const bool darwin_ =
false;
228 const bool linux_ =
true;
229 const bool windows_ =
false;
232bool is64bit() {
return is64; };
233bool is32bit() {
return !is64; };
249 QString lang = getenv(
"LANG" ) ;
253QString dirSeparator() {
262QDir applicationDir() {
return applicationDir_; }
263QDir configDir() {
return configDir_; }
264QDir pluginDir() {
return pluginDir_; }
265QDir shaderDir() {
return shaderDir_; }
266QDir textureDir() {
return textureDir_; }
267QDir licenseDir() {
return licenseDir_; }
268QDir scriptDir() {
return scriptDir_; }
269QDir iconDir() {
return iconDir_; }
270QDir translationsDir() {
return translationsDir_; }
271QDir fontsDir() {
return fontsDir_; }
272QDir helpDir() {
return helpDir_; }
273QDir dataDir() {
return dataDir_; }
274QDir currentDir() {
return currentDir_; }
275QDir currentScriptDir() {
return currentScriptDir_; }
276QDir currentTextureDir(){
return currentTextureDir_; }
278QString applicationDirStr() {
return applicationDir_.absolutePath(); }
279QString configDirStr() {
return configDir_.absolutePath(); }
280QString pluginDirStr() {
return pluginDir_.absolutePath(); }
281QString shaderDirStr() {
return shaderDir_.absolutePath(); }
282QString textureDirStr() {
return textureDir_.absolutePath(); }
283QString licenseDirStr() {
return licenseDir_.absolutePath(); }
284QString scriptDirStr() {
return scriptDir_.absolutePath(); }
285QString iconDirStr() {
return iconDir_.absolutePath(); }
286QString translationsDirStr() {
return translationsDir_.absolutePath(); }
287QString fontsDirStr() {
return fontsDir_.absolutePath(); }
288QString helpDirStr() {
return helpDir_.absolutePath(); }
289QString dataDirStr() {
return dataDir_.absolutePath(); }
290QString currentDirStr() {
return currentDir_.absolutePath(); }
291QString currentScriptDirStr() {
return currentScriptDir_.absolutePath(); }
292QString currentTextureDirStr() {
return currentTextureDir_.absolutePath(); }
295QString getGlobalIniFullPath()
297 return OpenFlipper::Options::applicationDir().absolutePath() + OpenFlipper::Options::dirSeparator() +
"OpenFlipper.ini";
300QString getLocalIniFullPath()
302 return OpenFlipper::Options::configDirStr() + OpenFlipper::Options::dirSeparator() +
"OpenFlipper.ini";
305QStringList optionFiles()
308 for (
const auto &filename: {getGlobalIniFullPath(), getLocalIniFullPath()}) {
309 if (QFile(filename).exists()) {
310 names.push_back(filename);
316bool startup() {
return startup_; };
318void finishedStartup() { startup_ =
false;};
320QIcon& OpenFlipperIcon() {
322 if (OpenFlipperIcon_ == 0){
323 OpenFlipperIcon_ =
new QIcon( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_128x128x32.png");
324 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_48x48x32.png", QSize(48,48) );
325 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_32x32x32.png", QSize(32,32) );
326 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_16x16x32.png", QSize(16,16) );
329 return *OpenFlipperIcon_;
332void currentDir(QDir _dir) {
336bool currentDir(QString _dir) {
346bool currentScriptDir(QString _dir) {
349 currentScriptDir_ = tmp;
355bool currentTextureDir(QString _dir) {
358 currentTextureDir_ = tmp;
364void deleteIniFile(
bool _delete) {
365 deleteIniFile_ = _delete;
368bool deleteIniFile() {
369 return deleteIniFile_;
373void nogui(
bool _nogui ) {
388void stereo(
bool _stereo ) {
398void coreProfile(
bool _enableCoreProfile,
bool _temporary ) {
401 profileOverride_ =
true;
402 coreProfile_ = _enableCoreProfile;
405 OpenFlipperSettings().
setValue(
"Core/OpenGL/CoreProfile",_enableCoreProfile);
413 return OpenFlipperSettings().
value(
"Core/OpenGL/CoreProfile",
false).toBool();
417QPair<int,int> glVersion(){
423 int major = OpenFlipperSettings().
value(
"Core/OpenGL/VersionMajor", 1).value<
int>();
424 int minor = OpenFlipperSettings().
value(
"Core/OpenGL/VersionMinor", 0).value<
int>();
425 return QPair<int, int>(major,minor);
430void glVersion(
const QPair<int,int> & _version,
bool _temporary)
436 versionOverride_ =
true;
440 OpenFlipperSettings().
setValue(
"Core/OpenGL/VersionMajor",_version.first);
441 OpenFlipperSettings().
setValue(
"Core/OpenGL/VersionMinor",_version.second);
445void samples(
int _samples,
bool _temporary) {
449 samplesOverride_ =
true;
452 OpenFlipperSettings().
setValue(
"Core/OpenGL/Samples",_samples);
460 return OpenFlipperSettings().
value(
"Core/OpenGL/Samples",4).toInt();
464void glStereo(
bool _glStereo,
bool _temporary ) {
467 requestedGLStereo = _glStereo;
472 glStereo_ = _glStereo;
473 overrideGLStereo_ =
true;
476 OpenFlipperSettings().
setValue(
"Core/OpenGL/Stereo",_glStereo);
481 if(overrideGLStereo_)
484 return OpenFlipperSettings().
value(
"Core/OpenGL/Stereo",
false).toBool();
488bool glStereoRequested( ) {
489 return requestedGLStereo;
493void stereoMode( StereoMode _mode ) {
503void eyeDistance(
double _eye ) {
504 settings_->
setValue(
"Core/Stereo/EyeDistance",_eye);
510 return settings_->
value(
"Core/Stereo/EyeDistance",0.07f).toDouble();
514void focalDistance(
float _focal )
516 settings_->
setValue(
"Core/Stereo/FocalDistance",_focal);
520float focalDistance( )
522 return settings_->
value(
"Core/Stereo/FocalDistance",0.5f).toDouble();
526void anaglyphLeftEyeColorMatrix( std::vector<float> _mat )
528 for (
int i = 0; i < 9; i++)
529 anaglyphLeftEyeColors_[i] = _mat[i];
533std::vector<float> anaglyphLeftEyeColorMatrix( )
535 return anaglyphLeftEyeColors_;
539void anaglyphRightEyeColorMatrix( std::vector<float> _mat )
541 for (
int i = 0; i < 9; i++)
542 anaglyphRightEyeColors_[i] = _mat[i];
546std::vector<float> anaglyphRightEyeColorMatrix( )
548 return anaglyphRightEyeColors_;
552void synchronization(
bool _synchronization ) {
553 synchronization_ = _synchronization;
557bool synchronization( ) {
558 return synchronization_;
562 defaultDrawMode_[_viewer] = _mode;
566 return defaultDrawMode_[_viewer];
569void defaultPerspectiveProjectionMode(
bool _mode,
int _viewer){
573 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
574 OpenFlipperSettings().
setValue(entry,_mode);
578bool defaultPerspectiveProjectionMode(
int _viewer){
580 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
584 return OpenFlipperSettings().
value(entry,
true).toBool();
586 return OpenFlipperSettings().
value(entry,
false).toBool();
588 return OpenFlipperSettings().
value(entry,
false).toBool();
590 return OpenFlipperSettings().
value(entry,
false).toBool();
592 std::cerr <<
"defaultProjectionMode: illegal viewer id: " << _viewer << std::endl;
599void defaultViewingDirection(
int _mode,
int _viewer){
600 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
601 OpenFlipperSettings().
setValue(entry,_mode);
604int defaultViewingDirection(
int _viewer){
606 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
610 return OpenFlipperSettings().
value(entry,PluginFunctions::VIEW_FREE).toInt();
612 return OpenFlipperSettings().
value(entry,PluginFunctions::VIEW_FRONT).toInt();
614 return OpenFlipperSettings().
value(entry,PluginFunctions::VIEW_RIGHT).toInt();
616 return OpenFlipperSettings().
value(entry,PluginFunctions::VIEW_TOP).toInt();
618 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
622 return PluginFunctions::VIEW_FREE;
625void defaultLockRotation(
bool _lock,
int _viewer ) {
626 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
627 OpenFlipperSettings().
setValue(entry,_lock);
630bool defaultLockRotation(
int _viewer ) {
632 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
636 return OpenFlipperSettings().
value(entry,
false).toBool();
638 return OpenFlipperSettings().
value(entry,
true).toBool();
640 return OpenFlipperSettings().
value(entry,
true).toBool();
642 return OpenFlipperSettings().
value(entry,
true).toBool();
644 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
652void defaultViewerLayout(
int _layout ){
653 defaultViewerLayout_ = _layout;
656int defaultViewerLayout(){
657 return defaultViewerLayout_;
660void redrawDisabled(
bool disable ){
664 if ( redrawDisabled_ == 0 )
665 std::cerr <<
"Mismatch of redraw enable/disable!!" << std::endl;
670bool redrawDisabled( ){
671 return (redrawDisabled_ > 0);
674bool drawModesInContextMenu() {
675 return drawModesInContextMenu_;
678void drawModesInContextMenu(
bool _show) {
679 drawModesInContextMenu_ = _show;
682unsigned int examinerWidgets() {
683 if ( OpenFlipperSettings().value(
"Core/Gui/glViewer/useMultipleViewers",
true).toBool() )
690void loggerState( LoggerState _state) {
691 OpenFlipperSettings().
setValue(
"Core/Gui/LogWindow/LogWindowMode",_state);
699 if(coreProfile_ && state == LoggerState::InScene)
700 return LoggerState::Normal;
707QString currentViewMode( ) {
708 return currentViewMode_;
712void currentViewMode( QString _mode ) {
713 currentViewMode_ = _mode;
717QString windowTitle( ) {
721void windowTitle( QString _titel ) {
725void defaultColor( QColor _color ) {
726 defaultColor_ = _color;
729QColor defaultColor() {
730 return defaultColor_;
733void randomDefaultColor(
bool _random) {
734 randomDefaultColor_ = _random;
737bool randomDefaultColor() {
738 return randomDefaultColor_;
742QString lastDataType(){
743 return lastDataType_;
747void lastDataType(QString _type){
748 lastDataType_ = _type;
755void scripting(
bool _status ) {
756 scripting_ = _status;
759bool logToConsole( ) {
760 return logToConsole_;
763void logToConsole(
bool _logToConsole ) {
764 logToConsole_ = _logToConsole;
771void debug(
bool _debug ) {
775bool backupEnabled( ) {
776 return enableBackup_;
779void enableBackup(
bool _enableBackup ) {
780 enableBackup_ = _enableBackup;
783void blockSceneGraphUpdates( ) {
784 ++sceneGraphUpdatesBlocked_;
787void unblockSceneGraphUpdates() {
788 if ( sceneGraphUpdatesBlocked_ <= 0)
789 std::cerr <<
"Error: More unblocks than blocks! Ignoring this request" << std::endl;
791 --sceneGraphUpdatesBlocked_;
794bool sceneGraphUpdatesBlocked( ) {
795 if ( sceneGraphUpdatesBlocked_ < 0)
796 std::cerr <<
"Error: updates blocked < 0 ... more unblocks than blocks" << std::endl;
798 return (sceneGraphUpdatesBlocked_ > 0);
801bool savingSettings( ) {
802 return savingSettings_;
805void savingSettings(
bool _savingSettings ) {
806 savingSettings_ = _savingSettings;
809bool loadingRecentFile( ) {
810 return loadingRecentFile_;
813void loadingRecentFile(
bool _loadingRecentFile ) {
814 loadingRecentFile_ = _loadingRecentFile;
825void argc(
int* _argc ) {
829void argv(
char*** _argv) {
834 return remoteControl_;
837void remoteControl(
bool _remote){
838 remoteControl_ = _remote;
841int remoteControlPort(){
842 return remoteControlPort_;
845void remoteControlPort(
int _remotePort){
846 remoteControlPort_ = _remotePort;
849void doSlotDebugging(
bool _debugging ) {
850 doSlotDebugging_ = _debugging;
853bool doSlotDebugging( ) {
854 return doSlotDebugging_;
857QString coreVersion() {
859 #define CORE_VERSION "5.1.0"
861 return QString(CORE_VERSION);
864static const char *
const CONFIG_DIR =
"." TOSTRING(PRODUCT_STRING);
866bool initializeSettings() {
867 if (OpenFlipper::Options::settings_ ==
nullptr)
870#if defined(__INTEL_COMPILER)
871 compilerInfo_ =
"Intel: " + QString(
TOSTRING(__INTEL_COMPILER)) +
"." + QString(
TOSTRING(__GNUC_MINOR__));
872#if defined(__INTEL_COMPILER_BUILD_DATE)
873 compilerInfo_ +=
" BuildDate " + QString(
TOSTRING(__INTEL_COMPILER_BUILD_DATE));
875#elif defined(__GNUC__)
876 compilerInfo_ =
"Gnu CC: " + QString(
TOSTRING(__GNUC__)) +
"." + QString(
TOSTRING(__GNUC_MINOR__));
877#if defined(__GNUC_PATCHLEVEL__)
878 compilerInfo_ +=
"." + QString(
TOSTRING(__GNUC_PATCHLEVEL__));
880#elif defined (_MSC_FULL_VER)
881 compilerInfo_ =
"MSVC: " + QString(
TOSTRING(_MSC_FULL_VER));
883 compilerInfo_ =
"Unknown Compiler";
890#if defined(ARCH_DARWIN)
891 configDir_ = QDir::home();
893 if (!configDir_.cd(
"Library"))
894 configDir_.mkdir(
"Library");
896 if (!configDir_.cd(
"Application Support"))
897 configDir_.mkdir(
"Application Support");
899 if (!configDir_.cd(
"de.rwth-aachen.graphics.openflipper")) {
900 configDir_.mkdir(
"de.rwth-aachen.graphics.openflipper");
901 if (!configDir_.cd(
"de.rwth-aachen.graphics.openflipper")) {
902 std::cerr <<
"Unable to create config dir ~/Library/de.rwth-aachen.graphics.openflipper" << std::endl;
907 configDir_ = QDir::home();
908 if (!configDir_.cd(CONFIG_DIR)) {
909 std::cerr <<
"Creating config Dir ~/" << CONFIG_DIR << std::endl;;
910 configDir_.mkdir(CONFIG_DIR);
911 if (!configDir_.cd(CONFIG_DIR)) {
912 std::cerr <<
"Unable to create config dir ~/" << CONFIG_DIR << std::endl;
926 QSettings::setDefaultFormat(QSettings::IniFormat);
929 QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, configDir_.absolutePath());
932 settings_ =
new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope,
"VCI",
"OpenFlipper");
939 if (!configDir_.exists(
"Icons")) {
940 configDir_.mkdir(
"Icons");
941 std::cerr <<
"Creating Icon Cache Dir ~/" << CONFIG_DIR <<
"/Icons" << std::endl;
949 applicationDir_.setPath( QCoreApplication::applicationDirPath() );
952 applicationDir_.cd(OPENFLIPPER_APPDIR);
959 pluginDir_ = applicationDir_;
962 pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
964 dataDir_ = OpenFlipper::Options::applicationDir();
966#ifdef OPENFLIPPER_DATADIR
967 dataDir_.cd(OPENFLIPPER_DATADIR);
969 dataDir_ = OpenFlipper::Options::applicationDir();
973 shaderDir_ = dataDir_;
974 shaderDir_.cd(
"Shaders");
978 textureDir_ = dataDir_;
979 textureDir_.cd(
"Textures");
982 scriptDir_ = dataDir_;
983 scriptDir_.cd(
"Scripts");
988 iconDir_.cd(
"Icons");
991 translationsDir_ = dataDir_;
992 translationsDir_.cd(
"Translations");
995 fontsDir_ = dataDir_;
996 fontsDir_.cd(
"Fonts");
999 licenseDir_ = dataDir_;
1000 licenseDir_.cd(
"Licenses");
1003 helpDir_ = dataDir_;
1004 helpDir_.cd(
"Help");
1011 if (!settings_->contains(
"Core/Gui/glViewer/defaultBackgroundColor"))
1012 settings_->
setValue(
"Core/Gui/glViewer/defaultBackgroundColor", QColor(
"black"));
1014 if (!settings_->contains(
"Core/Gui/glViewer/showControlWheels"))
1015 settings_->
setValue(
"Core/Gui/glViewer/showControlWheels",
false);
1019 if (!settings_->contains(
"Core/Mouse/Wheel/ZoomFactor"))
1020 settings_->
setValue(
"Core/Mouse/Wheel/ZoomFactor", 1.0);
1022 if (!settings_->contains(
"Core/Mouse/Wheel/ZoomFactorShift"))
1023 settings_->
setValue(
"Core/Mouse/Wheel/ZoomFactorShift", 0.2);
1025 if (!settings_->contains(
"Core/Mouse/Wheel/Invert"))
1026 settings_->
setValue(
"Core/Mouse/Wheel/Invert",
false);
1029 if (!settings_->contains(
"Core/Stereo/FocalLength"))
1030 settings_->
setValue(
"Core/Stereo/FocalLength", 0.5);
1032 if (!settings_->contains(
"Core/Stereo/EyeDistance"))
1033 settings_->
setValue(
"Core/Stereo/EyeDistance", 0.07);
1040void closeSettings() {
1046QString compilerInfo() {
1047 return compilerInfo_;
1057 if ( OpenFlipper::Options::settings_ !=
nullptr )
1058 return *OpenFlipper::Options::settings_;
1060 return emptySettings;
#define TOSTRING(x)
QSettings object containing all program settings of OpenFlipper.
LoggerState
State of the logging widget.
static void setShaderDir(QString _dir)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)