53 #include <ACG/GL/ShaderGenerator.hh> 54 #include <OpenFlipper/BasePlugin/PluginFunctionsViewControls.hh> 55 #include <QCoreApplication> 61 static QString compilerInfo_ =
"";
67 static QDir applicationDir_;
70 static QDir configDir_;
73 static QDir pluginDir_;
76 static QDir shaderDir_;
79 static QDir textureDir_;
82 static QDir licenseDir_;
85 static QDir scriptDir_;
91 static QIcon* OpenFlipperIcon_ = 0;
94 static QDir translationsDir_;
97 static QDir fontsDir_;
100 static QDir helpDir_;
103 static QDir dataDir_;
106 static QStringList optionFiles_;
109 static QDir currentDir_;
112 static QDir currentScriptDir_;
115 static QDir currentTextureDir_;
118 static bool startup_ =
false;
121 static bool deleteIniFile_ =
false;
124 static bool nogui_ =
false;
127 static bool stereo_ =
true;
130 static bool coreProfile_ =
false;
131 static bool profileOverride_ =
false;
134 static QPair<int,int> version_ {4,6};
135 static bool versionOverride_ =
false;
138 static int samples_ = 4;
139 static bool samplesOverride_ =
false;
142 static bool glStereo_ =
true;
143 static bool overrideGLStereo_ =
false;
144 static bool requestedGLStereo =
false;
145 static bool GLStereoSet =
false;
151 static std::vector<float> anaglyphLeftEyeColors_ = std::vector<float> (9, 0.0);
152 static std::vector<float> anaglyphRightEyeColors_ = std::vector<float> (9, 0.0);
155 static bool synchronization_ =
false;
161 static int defaultViewerLayout_ = 0;
164 static int redrawDisabled_ = 0;
167 static bool drawModesInContextMenu_ =
true;
170 static QString currentViewMode_ =
"";
172 static QString title_ =
TOSTRING(PRODUCT_NAME)
" v?";
175 static QColor defaultColor_ = QColor(
"white");
178 static bool randomDefaultColor_ =
false;
181 static bool scripting_ =
false;
184 static bool logToConsole_ =
false;
187 static bool debug_ =
false;
190 static bool doSlotDebugging_ =
false;
193 static QString lastDataType_ =
"Triangle Mesh";
196 static bool enableBackup_ =
true;
199 static int sceneGraphUpdatesBlocked_ = 0;
202 static bool loadingRecentFile_ =
false;
205 static bool savingSettings_ =
false;
209 static char *** argv_;
211 static bool remoteControl_ =
false;
213 static int remoteControlPort_ = 2000;
215 # if __WORDSIZE == 64 216 const bool is64 =
true;
218 const bool is64 =
false;
222 const bool linux_ =
false;
223 const bool windows_ =
true;
224 const bool darwin_ =
false;
225 #elif defined(ARCH_DARWIN) 226 const bool darwin_ =
true;
227 const bool linux_ =
false;
228 const bool windows_ =
false;
230 const bool darwin_ =
false;
231 const bool linux_ =
true;
232 const bool windows_ =
false;
235 bool is64bit() {
return is64; };
236 bool is32bit() {
return !is64; };
252 QString lang = getenv(
"LANG" ) ;
256 QString dirSeparator() {
265 QDir applicationDir() {
return applicationDir_; }
266 QDir configDir() {
return configDir_; }
267 QDir pluginDir() {
return pluginDir_; }
268 QDir shaderDir() {
return shaderDir_; }
269 QDir textureDir() {
return textureDir_; }
270 QDir licenseDir() {
return licenseDir_; }
271 QDir scriptDir() {
return scriptDir_; }
272 QDir iconDir() {
return iconDir_; }
273 QDir translationsDir() {
return translationsDir_; }
274 QDir fontsDir() {
return fontsDir_; }
275 QDir helpDir() {
return helpDir_; }
276 QDir dataDir() {
return dataDir_; }
277 QDir currentDir() {
return currentDir_; }
278 QDir currentScriptDir() {
return currentScriptDir_; }
279 QDir currentTextureDir(){
return currentTextureDir_; }
281 QString applicationDirStr() {
return applicationDir_.absolutePath(); }
282 QString configDirStr() {
return configDir_.absolutePath(); }
283 QString pluginDirStr() {
return pluginDir_.absolutePath(); }
284 QString shaderDirStr() {
return shaderDir_.absolutePath(); }
285 QString textureDirStr() {
return textureDir_.absolutePath(); }
286 QString licenseDirStr() {
return licenseDir_.absolutePath(); }
287 QString scriptDirStr() {
return scriptDir_.absolutePath(); }
288 QString iconDirStr() {
return iconDir_.absolutePath(); }
289 QString translationsDirStr() {
return translationsDir_.absolutePath(); }
290 QString fontsDirStr() {
return fontsDir_.absolutePath(); }
291 QString helpDirStr() {
return helpDir_.absolutePath(); }
292 QString dataDirStr() {
return dataDir_.absolutePath(); }
293 QString currentDirStr() {
return currentDir_.absolutePath(); }
294 QString currentScriptDirStr() {
return currentScriptDir_.absolutePath(); }
295 QString currentTextureDirStr() {
return currentTextureDir_.absolutePath(); }
297 QStringList optionFiles() {
return optionFiles_; }
299 void optionFiles(QStringList _list) { optionFiles_ = _list; }
301 bool startup() {
return startup_; };
303 void finishedStartup() { startup_ =
false;};
305 QIcon& OpenFlipperIcon() {
307 if (OpenFlipperIcon_ == 0){
308 OpenFlipperIcon_ =
new QIcon( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_128x128x32.png");
309 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_48x48x32.png", QSize(48,48) );
310 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_32x32x32.png", QSize(32,32) );
311 OpenFlipperIcon_->addFile( iconDirStr() + dirSeparator() +
"OpenFlipper_Icon_16x16x32.png", QSize(16,16) );
314 return *OpenFlipperIcon_;
317 void currentDir(QDir _dir) {
321 bool currentDir(QString _dir) {
331 bool currentScriptDir(QString _dir) {
334 currentScriptDir_ = tmp;
340 bool currentTextureDir(QString _dir) {
343 currentTextureDir_ = tmp;
349 void deleteIniFile(
bool _delete) {
350 deleteIniFile_ = _delete;
353 bool deleteIniFile() {
354 return deleteIniFile_;
358 void nogui(
bool _nogui ) {
373 void stereo(
bool _stereo ) {
383 void coreProfile(
bool _enableCoreProfile,
bool _temporary ) {
386 profileOverride_ =
true;
387 coreProfile_ = _enableCoreProfile;
394 bool coreProfile( ) {
402 QPair<int,int> glVersion(){
410 return QPair<int, int>(major,minor);
415 void glVersion(
const QPair<int,int> & _version,
bool _temporary)
421 versionOverride_ =
true;
430 void samples(
int _samples,
bool _temporary) {
434 samplesOverride_ =
true;
449 void glStereo(
bool _glStereo,
bool _temporary ) {
452 requestedGLStereo = _glStereo;
457 glStereo_ = _glStereo;
458 overrideGLStereo_ =
true;
466 if(overrideGLStereo_)
473 bool glStereoRequested( ) {
474 return requestedGLStereo;
478 void stereoMode( StereoMode _mode ) {
488 void eyeDistance(
double _eye ) {
489 settings_->
setValue(
"Core/Stereo/EyeDistance",_eye);
493 double eyeDistance( )
495 return settings_->
value(
"Core/Stereo/EyeDistance",0.07f).toDouble();
499 void focalDistance(
float _focal )
501 settings_->
setValue(
"Core/Stereo/FocalDistance",_focal);
505 float focalDistance( )
507 return settings_->
value(
"Core/Stereo/FocalDistance",0.5f).toDouble();
511 void anaglyphLeftEyeColorMatrix( std::vector<float> _mat )
513 for (
int i = 0; i < 9; i++)
514 anaglyphLeftEyeColors_[i] = _mat[i];
518 std::vector<float> anaglyphLeftEyeColorMatrix( )
520 return anaglyphLeftEyeColors_;
524 void anaglyphRightEyeColorMatrix( std::vector<float> _mat )
526 for (
int i = 0; i < 9; i++)
527 anaglyphRightEyeColors_[i] = _mat[i];
531 std::vector<float> anaglyphRightEyeColorMatrix( )
533 return anaglyphRightEyeColors_;
537 void synchronization(
bool _synchronization ) {
538 synchronization_ = _synchronization;
542 bool synchronization( ) {
543 return synchronization_;
547 defaultDrawMode_[_viewer] = _mode;
551 return defaultDrawMode_[_viewer];
554 void defaultPerspectiveProjectionMode(
bool _mode,
int _viewer){
558 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
563 bool defaultPerspectiveProjectionMode(
int _viewer){
565 QString entry =
"Viewer" + QString::number(_viewer) +
"/perspectiveProjection";
577 std::cerr <<
"defaultProjectionMode: illegal viewer id: " << _viewer << std::endl;
584 void defaultViewingDirection(
int _mode,
int _viewer){
585 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
589 int defaultViewingDirection(
int _viewer){
591 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultViewingDirection";
603 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
607 return PluginFunctions::VIEW_FREE;
610 void defaultLockRotation(
bool _lock,
int _viewer ) {
611 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
615 bool defaultLockRotation(
int _viewer ) {
617 QString entry =
"Viewer" + QString::number(_viewer) +
"/defaultLockRotation";
629 std::cerr <<
"defaultViewingDirection: illegal viewer id: " << _viewer << std::endl;
637 void defaultViewerLayout(
int _layout ){
638 defaultViewerLayout_ = _layout;
641 int defaultViewerLayout(){
642 return defaultViewerLayout_;
645 void redrawDisabled(
bool disable ){
649 if ( redrawDisabled_ == 0 )
650 std::cerr <<
"Mismatch of redraw enable/disable!!" << std::endl;
655 bool redrawDisabled( ){
656 return (redrawDisabled_ > 0);
659 bool drawModesInContextMenu() {
660 return drawModesInContextMenu_;
663 void drawModesInContextMenu(
bool _show) {
664 drawModesInContextMenu_ = _show;
667 unsigned int examinerWidgets() {
675 void loggerState( LoggerState _state) {
684 if(coreProfile_ && state == LoggerState::InScene)
685 return LoggerState::Normal;
692 QString currentViewMode( ) {
693 return currentViewMode_;
697 void currentViewMode( QString _mode ) {
698 currentViewMode_ = _mode;
702 QString windowTitle( ) {
706 void windowTitle( QString _titel ) {
710 void defaultColor( QColor _color ) {
711 defaultColor_ = _color;
714 QColor defaultColor() {
715 return defaultColor_;
718 void randomDefaultColor(
bool _random) {
719 randomDefaultColor_ = _random;
722 bool randomDefaultColor() {
723 return randomDefaultColor_;
727 QString lastDataType(){
728 return lastDataType_;
732 void lastDataType(QString _type){
733 lastDataType_ = _type;
740 void scripting(
bool _status ) {
741 scripting_ = _status;
744 bool logToConsole( ) {
745 return logToConsole_;
748 void logToConsole(
bool _logToConsole ) {
749 logToConsole_ = _logToConsole;
756 void debug(
bool _debug ) {
760 bool backupEnabled( ) {
761 return enableBackup_;
764 void enableBackup(
bool _enableBackup ) {
765 enableBackup_ = _enableBackup;
768 void blockSceneGraphUpdates( ) {
769 ++sceneGraphUpdatesBlocked_;
772 void unblockSceneGraphUpdates() {
773 if ( sceneGraphUpdatesBlocked_ <= 0)
774 std::cerr <<
"Error: More unblocks than blocks! Ignoring this request" << std::endl;
776 --sceneGraphUpdatesBlocked_;
779 bool sceneGraphUpdatesBlocked( ) {
780 if ( sceneGraphUpdatesBlocked_ < 0)
781 std::cerr <<
"Error: updates blocked < 0 ... more unblocks than blocks" << std::endl;
783 return (sceneGraphUpdatesBlocked_ > 0);
786 bool savingSettings( ) {
787 return savingSettings_;
790 void savingSettings(
bool _savingSettings ) {
791 savingSettings_ = _savingSettings;
794 bool loadingRecentFile( ) {
795 return loadingRecentFile_;
798 void loadingRecentFile(
bool _loadingRecentFile ) {
799 loadingRecentFile_ = _loadingRecentFile;
810 void argc(
int* _argc ) {
814 void argv(
char*** _argv) {
818 bool remoteControl(){
819 return remoteControl_;
822 void remoteControl(
bool _remote){
823 remoteControl_ = _remote;
826 int remoteControlPort(){
827 return remoteControlPort_;
830 void remoteControlPort(
int _remotePort){
831 remoteControlPort_ = _remotePort;
834 void doSlotDebugging(
bool _debugging ) {
835 doSlotDebugging_ = _debugging;
838 bool doSlotDebugging( ) {
839 return doSlotDebugging_;
842 QString coreVersion() {
844 #define CORE_VERSION "1.0.0RC2" 846 return QString(CORE_VERSION);
849 static const char *
const CONFIG_DIR =
"." TOSTRING(PRODUCT_STRING);
851 bool initializeSettings() {
852 if (OpenFlipper::Options::settings_ ==
nullptr)
855 #if defined(__INTEL_COMPILER) 856 compilerInfo_ =
"Intel: " + QString(
TOSTRING(__INTEL_COMPILER)) +
"." + QString(
TOSTRING(__GNUC_MINOR__));
857 #if defined(__INTEL_COMPILER_BUILD_DATE) 858 compilerInfo_ +=
" BuildDate " + QString(
TOSTRING(__INTEL_COMPILER_BUILD_DATE));
860 #elif defined(__GNUC__) 861 compilerInfo_ =
"Gnu CC: " + QString(
TOSTRING(__GNUC__)) +
"." + QString(
TOSTRING(__GNUC_MINOR__));
862 #if defined(__GNUC_PATCHLEVEL__) 863 compilerInfo_ +=
"." + QString(
TOSTRING(__GNUC_PATCHLEVEL__));
865 #elif defined (_MSC_FULL_VER) 866 compilerInfo_ =
"MSVC: " + QString(
TOSTRING(_MSC_FULL_VER));
868 compilerInfo_ =
"Unknown Compiler";
875 #if defined(ARCH_DARWIN) 876 configDir_ = QDir::home();
878 if (!configDir_.cd(
"Library"))
879 configDir_.mkdir(
"Library");
881 if (!configDir_.cd(
"Application Support"))
882 configDir_.mkdir(
"Application Support");
884 if (!configDir_.cd(
"de.rwth-aachen.graphics.openflipper")) {
885 configDir_.mkdir(
"de.rwth-aachen.graphics.openflipper");
886 if (!configDir_.cd(
"de.rwth-aachen.graphics.openflipper")) {
887 std::cerr <<
"Unable to create config dir ~/Library/de.rwth-aachen.graphics.openflipper" << std::endl;
892 configDir_ = QDir::home();
893 if (!configDir_.cd(CONFIG_DIR)) {
894 std::cerr <<
"Creating config Dir ~/" << CONFIG_DIR << std::endl;;
895 configDir_.mkdir(CONFIG_DIR);
896 if (!configDir_.cd(CONFIG_DIR)) {
897 std::cerr <<
"Unable to create config dir ~/" << CONFIG_DIR << std::endl;
911 QSettings::setDefaultFormat(QSettings::IniFormat);
914 QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, configDir_.absolutePath());
917 settings_ =
new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope,
"VCI",
"OpenFlipper");
924 if (!configDir_.exists(
"Icons")) {
925 configDir_.mkdir(
"Icons");
926 std::cerr <<
"Creating Icon Cache Dir ~/" << CONFIG_DIR <<
"/Icons" << std::endl;
934 applicationDir_ = QCoreApplication::applicationDirPath();
937 applicationDir_.cd(OPENFLIPPER_APPDIR);
944 pluginDir_ = applicationDir_;
947 pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
949 dataDir_ = OpenFlipper::Options::applicationDir();
951 #ifdef OPENFLIPPER_DATADIR 952 dataDir_.cd(OPENFLIPPER_DATADIR);
954 dataDir_ = OpenFlipper::Options::applicationDir();
958 shaderDir_ = dataDir_;
959 shaderDir_.cd(
"Shaders");
963 textureDir_ = dataDir_;
964 textureDir_.cd(
"Textures");
967 scriptDir_ = dataDir_;
968 scriptDir_.cd(
"Scripts");
973 iconDir_.cd(
"Icons");
976 translationsDir_ = dataDir_;
977 translationsDir_.cd(
"Translations");
980 fontsDir_ = dataDir_;
981 fontsDir_.cd(
"Fonts");
984 licenseDir_ = dataDir_;
985 licenseDir_.cd(
"Licenses");
996 if (!settings_->contains(
"Core/Gui/glViewer/defaultBackgroundColor"))
997 settings_->setValue(
"Core/Gui/glViewer/defaultBackgroundColor", QColor(
"black"));
999 if (!settings_->contains(
"Core/Gui/glViewer/showControlWheels"))
1000 settings_->setValue(
"Core/Gui/glViewer/showControlWheels",
false);
1004 if (!settings_->contains(
"Core/Mouse/Wheel/ZoomFactor"))
1005 settings_->setValue(
"Core/Mouse/Wheel/ZoomFactor", 1.0);
1007 if (!settings_->contains(
"Core/Mouse/Wheel/ZoomFactorShift"))
1008 settings_->setValue(
"Core/Mouse/Wheel/ZoomFactorShift", 0.2);
1010 if (!settings_->contains(
"Core/Mouse/Wheel/Invert"))
1011 settings_->setValue(
"Core/Mouse/Wheel/Invert",
false);
1014 if (!settings_->contains(
"Core/Stereo/FocalLength"))
1015 settings_->setValue(
"Core/Stereo/FocalLength", 0.5);
1017 if (!settings_->contains(
"Core/Stereo/EyeDistance"))
1018 settings_->setValue(
"Core/Stereo/EyeDistance", 0.07);
1025 void closeSettings() {
1031 QString compilerInfo() {
1032 return compilerInfo_;
1042 if ( OpenFlipper::Options::settings_ !=
nullptr )
1043 return *OpenFlipper::Options::settings_;
1045 return emptySettings;
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
LoggerState
State of the logging widget.
static void setShaderDir(QString _dir)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
#define TOSTRING(x)
QSettings object containing all program settings of OpenFlipper.
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.