...
 
Commits (21)
......@@ -98,6 +98,20 @@
//== IMPLEMENTATION ==========================================================
namespace {
void recreateContext()
{
#ifdef WIN32
QOpenGLContext* ctx = QOpenGLContext::currentContext();
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
ctx->setFormat(format);
ctx->create();
QOffscreenSurface* surface = new QOffscreenSurface();
ctx->makeCurrent(surface);
#endif
}
}
/** \brief Constuctor for the Core Widget ( This is stage 1 , call init for stage 2)
*
* Initialization is working the following way:\n
......@@ -653,6 +667,7 @@ Core::init() {
coreWidget_->splitter_->restoreState (windowStates.value("Core/LogSplitter").toByteArray ());
coreWidget_->show();
recreateContext();
applyOptions();
......@@ -671,6 +686,8 @@ Core::init() {
} else {
coreWidget_->show();
recreateContext();
applyOptions();
}
......
......@@ -125,6 +125,12 @@ void connect_console()
if (check) {
std::cerr << "Error reopening stderr" << std::endl;
}
std::cout.clear();
std::cerr.clear();
std::cin.clear();
std::wcout.clear();
std::wcerr.clear();
std::wcin.clear();
}
void attachConsole()
......@@ -428,22 +434,43 @@ int main(int argc, char **argv)
OpenFlipper::Options::argc(&argc);
OpenFlipper::Options::argv(&argv);
// Ugly command line parse to check if we run in batch mode or not.
// Qt parser needs either QApplication or QCoreApplication to work.
// But we need that option to decide which one to choose so ...
for (int i = 1; i < argc; i++) {
QString option = QString(argv[i]);
if (option.contains("batch") || option.contains("-b") ||
option.contains("--batch")) {
std::cerr << "Batch Mode started" << std::endl;
OpenFlipper::Options::nogui(true);
}
// Set organization and application names
QCoreApplication::setOrganizationName("rwth-aachen.de");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
QCoreApplication::setApplicationVersion(OpenFlipper::Options::coreVersion());
}
// initialize a core application to check for commandline parameters
QCoreApplication* coreApp = new QCoreApplication(argc, argv);
OpenFlipper::Options::initializeSettings();
QCommandLineParser parser;
QString errorMessage;
// parse command line options
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
// only one application is allowed so delete the core application
// once cmdline parsing is done
delete coreApp;
#ifdef WIN32
//attach a console if necessary
attachConsole();
......@@ -463,11 +490,10 @@ int main(int argc, char **argv)
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif
QApplication::setColorSpec( QApplication::CustomColor );
QApplication app(argc,argv);
#if QT_VERSION >= 0x050500
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
QSurfaceFormat format;
format.setVersion(4, 4);
......@@ -482,6 +508,7 @@ int main(int argc, char **argv)
QSurfaceFormat::setDefaultFormat(format);
QApplication app(argc, argv);
QScreen *screen = app.primaryScreen();
QOffscreenSurface *surface = new QOffscreenSurface();
......@@ -494,11 +521,6 @@ int main(int argc, char **argv)
#endif
// Set organization and application names
QCoreApplication::setOrganizationName("rwth-aachen.de");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
QCoreApplication::setApplicationVersion(OpenFlipper::Options::coreVersion());
if ( !QGLFormat::hasOpenGL() ) {
std::cerr << "This system has no OpenGL support.\n";
return -1;
......@@ -511,25 +533,6 @@ int main(int argc, char **argv)
// create core ( this also reads the ini files )
Core * w = new Core( );
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
delete w;
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
QString tLang = OpenFlipperSettings().value("Core/Language/Translation","en_US").toString();
if (tLang == "locale")
......@@ -537,20 +540,11 @@ int main(int argc, char **argv)
// Install translator for qt internals
QTranslator qtTranslator;
// std::cerr << "Loading qt translations from: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath).toStdString() << std::endl;
// if ( qtTranslator.load("qt_" + tLang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) )
// std::cerr << "Loaded" << std::endl;
// std::cerr << "Loading qt translations from: " << QLibraryInfo::location(QLibraryInfo::TranslationsPath).toStdString() << std::endl;
qtTranslator.load("qt_" + tLang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
// std::cerr << "Loaded" << std::endl;
app.installTranslator(&qtTranslator);
// install translator for Core Application
QString translationDir = OpenFlipper::Options::translationsDirStr() + QDir::separator();
// std::cerr << "Loading own translations from: " << QString(translationDir + " (" + tLang + ")").toStdString() << std::endl;
QDir dir(translationDir);
dir.setFilter(QDir::Files);
......@@ -562,12 +556,12 @@ int main(int argc, char **argv)
if ( fileInfo.baseName().contains(tLang) ){
QTranslator* myAppTranslator = new QTranslator();
if ( myAppTranslator->load( fileInfo.filePath() ) ){
// std::cerr << "Loaded " << fileInfo.fileName().toStdString() << std::endl;
if ( myAppTranslator->load( fileInfo.filePath() ) )
{
app.installTranslator(myAppTranslator);
} else {
delete myAppTranslator;
} else
{
delete myAppTranslator;
}
}
}
......@@ -591,49 +585,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc,argv);
// Set organization and application names
QCoreApplication::setOrganizationName("rwth-aachen.de");
QCoreApplication::setApplicationName(TOSTRING(PRODUCT_STRING));
QCoreApplication::setApplicationVersion(OpenFlipper::Options::coreVersion());
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
// create widget ( this also reads the ini files )
Core * w = new Core( );
switch (parseCommandLine(parser, &errorMessage)) {
case CommandLineOk:
break;
case CommandLineError:
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(parser.helpText()), stderr);
delete w;
return 1;
case CommandLineVersionRequested:
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
qPrintable(QCoreApplication::applicationVersion()));
return 0;
case CommandLineHelpRequested:
parser.showHelp();
Q_UNREACHABLE();
}
// After setting all Options from command line, build the real gui
w->init();
......
......@@ -414,6 +414,7 @@ set (PREFOUND_PACKAGES "${LOADED_PACKAGES}" CACHE INTERNAL "List of packages tha
# ========================================================================
add_subdirectory (OpenFlipper/CoreApp)
GROUP_PROJECT(${OPENFLIPPER_PRODUCT_STRING} ${OPENFLIPPER_PRODUCT_STRING})
# ========================================================================
......
......@@ -752,174 +752,177 @@ QString coreVersion() {
static const char * const CONFIG_DIR = "." TOSTRING(PRODUCT_STRING);
bool initializeSettings() {
#if defined(__INTEL_COMPILER)
compilerInfo_ = "Intel: " + QString( TOSTRING(__INTEL_COMPILER) ) + "." + QString( TOSTRING(__GNUC_MINOR__) ) ;
#if defined(__INTEL_COMPILER_BUILD_DATE)
compilerInfo_ += " BuildDate " + QString( TOSTRING(__INTEL_COMPILER_BUILD_DATE) );
#endif
#elif defined(__GNUC__)
compilerInfo_ = "Gnu CC: " + QString( TOSTRING(__GNUC__) ) + "." + QString( TOSTRING(__GNUC_MINOR__) ) ;
#if defined(__GNUC_PATCHLEVEL__)
compilerInfo_ += "." + QString( TOSTRING(__GNUC_PATCHLEVEL__) );
#endif
#elif defined (_MSC_FULL_VER)
compilerInfo_ = "MSVC: " + QString( TOSTRING(_MSC_FULL_VER) );
#else
compilerInfo_ = "Unknown Compiler";
#endif
//==================================================================================================
// Get the Main config dir in the home directory and possibly create it
//==================================================================================================
#if defined(ARCH_DARWIN)
configDir_ = QDir::home();
if ( ! configDir_.cd("Library") )
configDir_.mkdir("Library");
if ( ! configDir_.cd("Application Support") )
configDir_.mkdir("Application Support");
if ( ! configDir_.cd("de.rwth-aachen.graphics.openflipper") ) {
configDir_.mkdir("de.rwth-aachen.graphics.openflipper");
if ( ! configDir_.cd("de.rwth-aachen.graphics.openflipper") ) {
std::cerr << "Unable to create config dir ~/Library/de.rwth-aachen.graphics.openflipper" << std::endl;
return false;
}
}
#else
configDir_ = QDir::home();
if ( ! configDir_.cd(CONFIG_DIR) ) {
std::cerr << "Creating config Dir ~/" << CONFIG_DIR << std::endl;;
configDir_.mkdir(CONFIG_DIR);
if ( ! configDir_.cd(CONFIG_DIR) ) {
std::cerr << "Unable to create config dir ~/" << CONFIG_DIR << std::endl;
return false;
}
}
if (OpenFlipper::Options::settings_ == nullptr)
{
#endif
#if defined(__INTEL_COMPILER)
compilerInfo_ = "Intel: " + QString(TOSTRING(__INTEL_COMPILER)) + "." + QString(TOSTRING(__GNUC_MINOR__));
#if defined(__INTEL_COMPILER_BUILD_DATE)
compilerInfo_ += " BuildDate " + QString(TOSTRING(__INTEL_COMPILER_BUILD_DATE));
#endif
#elif defined(__GNUC__)
compilerInfo_ = "Gnu CC: " + QString(TOSTRING(__GNUC__)) + "." + QString(TOSTRING(__GNUC_MINOR__));
#if defined(__GNUC_PATCHLEVEL__)
compilerInfo_ += "." + QString(TOSTRING(__GNUC_PATCHLEVEL__));
#endif
#elif defined (_MSC_FULL_VER)
compilerInfo_ = "MSVC: " + QString(TOSTRING(_MSC_FULL_VER));
#else
compilerInfo_ = "Unknown Compiler";
#endif
//==================================================================================================
// Setup settings.
//==================================================================================================
// This has to be done as early as possible to set the program options right
// Force ini format on all platforms
QSettings::setDefaultFormat ( QSettings::IniFormat );
// Force settings to be stored in the OpenFlipper config directory
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope , configDir_.absolutePath() );
// Finally attach the settings object.
settings_ = new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope, "ACG", "OpenFlipper");
//==================================================================================================
// Get the Main config dir in the home directory and possibly create it
//==================================================================================================
#if defined(ARCH_DARWIN)
configDir_ = QDir::home();
//==================================================================================================
// Now create special directories in th OpenFlipper config dir
//==================================================================================================
// Create a personal Icon cache dir to save for example user added icons
if ( ! configDir_.exists("Icons") ){
configDir_.mkdir("Icons");
std::cerr << "Creating Icon Cache Dir ~/" << CONFIG_DIR << "/Icons" << std::endl;
}
//==================================================================================================
// Setup main application dir
//==================================================================================================
if (!configDir_.cd("Library"))
configDir_.mkdir("Library");
// Remember the main application directory (assumed to be one above executable Path)
applicationDir_ = QCoreApplication::applicationDirPath();
if (!configDir_.cd("Application Support"))
configDir_.mkdir("Application Support");
// When using cmake, we get the absolute path to the Application directory via a define
applicationDir_.cd(OPENFLIPPER_APPDIR);
//==================================================================================================
// Setup directory containing plugins
//==================================================================================================
// start at application directory
pluginDir_ = applicationDir_;
// cmake style: Path is directly given from define!
pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
dataDir_ = OpenFlipper::Options::applicationDir();
#ifdef OPENFLIPPER_DATADIR
dataDir_.cd(OPENFLIPPER_DATADIR);
#else
dataDir_ = OpenFlipper::Options::applicationDir();
#endif
// Set the Path to the Shaders
shaderDir_ = dataDir_;
shaderDir_.cd("Shaders");
ACG::ShaderProgGenerator::setShaderDir(OpenFlipper::Options::shaderDirStr());
// Set the Path to the textures
textureDir_ = dataDir_;
textureDir_.cd("Textures");
if (!configDir_.cd("de.rwth-aachen.graphics.openflipper")) {
configDir_.mkdir("de.rwth-aachen.graphics.openflipper");
if (!configDir_.cd("de.rwth-aachen.graphics.openflipper")) {
std::cerr << "Unable to create config dir ~/Library/de.rwth-aachen.graphics.openflipper" << std::endl;
return false;
}
}
#else
configDir_ = QDir::home();
if (!configDir_.cd(CONFIG_DIR)) {
std::cerr << "Creating config Dir ~/" << CONFIG_DIR << std::endl;;
configDir_.mkdir(CONFIG_DIR);
if (!configDir_.cd(CONFIG_DIR)) {
std::cerr << "Unable to create config dir ~/" << CONFIG_DIR << std::endl;
return false;
}
}
// Set the Path to the Scripts
scriptDir_ = dataDir_;
scriptDir_.cd("Scripts");
// Set the Path to the Icons
iconDir_ = dataDir_;
iconDir_.cd("Icons");
// Set the Path to the translations
translationsDir_ = dataDir_;
translationsDir_.cd("Translations");
// Set the Path to the Fonts
fontsDir_ = dataDir_;
fontsDir_.cd("Fonts");
// Set the Path to the License files
licenseDir_ = dataDir_;
licenseDir_.cd("Licenses");
// Set the Path to the Help
helpDir_ = dataDir_;
helpDir_.cd("Help");
//==================================================================================================
// Initialize with default values if not already set
//==================================================================================================
#endif
// User Interface Settings
if ( ! settings_->contains("Core/Gui/glViewer/defaultBackgroundColor") )
settings_->setValue("Core/Gui/glViewer/defaultBackgroundColor",QColor("black"));
if ( ! settings_->contains("Core/Gui/glViewer/showControlWheels") )
settings_->setValue("Core/Gui/glViewer/showControlWheels",false);
// Mouse Controls
if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactor") )
settings_->setValue("Core/Mouse/Wheel/ZoomFactor",1.0);
if ( ! settings_->contains("Core/Mouse/Wheel/ZoomFactorShift") )
settings_->setValue("Core/Mouse/Wheel/ZoomFactorShift",0.2);
if ( ! settings_->contains("Core/Mouse/Wheel/Invert") )
settings_->setValue("Core/Mouse/Wheel/Invert",false);
// General Stereo Settings
if ( ! settings_->contains("Core/Stereo/FocalLength") )
settings_->setValue("Core/Stereo/FocalLength",0.5);
if ( ! settings_->contains("Core/Stereo/EyeDistance") )
settings_->setValue("Core/Stereo/EyeDistance",0.07);
return true;
//==================================================================================================
// Setup settings.
//==================================================================================================
// This has to be done as early as possible to set the program options right
// Force ini format on all platforms
QSettings::setDefaultFormat(QSettings::IniFormat);
// Force settings to be stored in the OpenFlipper config directory
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, configDir_.absolutePath());
// Finally attach the settings object.
settings_ = new OpenFlipperQSettings(QSettings::IniFormat, QSettings::UserScope, "ACG", "OpenFlipper");
//==================================================================================================
// Now create special directories in th OpenFlipper config dir
//==================================================================================================
// Create a personal Icon cache dir to save for example user added icons
if (!configDir_.exists("Icons")) {
configDir_.mkdir("Icons");
std::cerr << "Creating Icon Cache Dir ~/" << CONFIG_DIR << "/Icons" << std::endl;
}
//==================================================================================================
// Setup main application dir
//==================================================================================================
// Remember the main application directory (assumed to be one above executable Path)
applicationDir_ = QCoreApplication::applicationDirPath();
// When using cmake, we get the absolute path to the Application directory via a define
applicationDir_.cd(OPENFLIPPER_APPDIR);
//==================================================================================================
// Setup directory containing plugins
//==================================================================================================
// start at application directory
pluginDir_ = applicationDir_;
// cmake style: Path is directly given from define!
pluginDir_.cd(OPENFLIPPER_PLUGINDIR);
dataDir_ = OpenFlipper::Options::applicationDir();
#ifdef OPENFLIPPER_DATADIR
dataDir_.cd(OPENFLIPPER_DATADIR);
#else
dataDir_ = OpenFlipper::Options::applicationDir();
#endif
// Set the Path to the Shaders
shaderDir_ = dataDir_;
shaderDir_.cd("Shaders");
ACG::ShaderProgGenerator::setShaderDir(OpenFlipper::Options::shaderDirStr());
// Set the Path to the textures
textureDir_ = dataDir_;
textureDir_.cd("Textures");
// Set the Path to the Scripts
scriptDir_ = dataDir_;
scriptDir_.cd("Scripts");
// Set the Path to the Icons
iconDir_ = dataDir_;
iconDir_.cd("Icons");
// Set the Path to the translations
translationsDir_ = dataDir_;
translationsDir_.cd("Translations");
// Set the Path to the Fonts
fontsDir_ = dataDir_;
fontsDir_.cd("Fonts");
// Set the Path to the License files
licenseDir_ = dataDir_;
licenseDir_.cd("Licenses");
// Set the Path to the Help
helpDir_ = dataDir_;
helpDir_.cd("Help");
//==================================================================================================
// Initialize with default values if not already set
//==================================================================================================
// User Interface Settings
if (!settings_->contains("Core/Gui/glViewer/defaultBackgroundColor"))
settings_->setValue("Core/Gui/glViewer/defaultBackgroundColor", QColor("black"));
if (!settings_->contains("Core/Gui/glViewer/showControlWheels"))
settings_->setValue("Core/Gui/glViewer/showControlWheels", false);
// Mouse Controls
if (!settings_->contains("Core/Mouse/Wheel/ZoomFactor"))
settings_->setValue("Core/Mouse/Wheel/ZoomFactor", 1.0);
if (!settings_->contains("Core/Mouse/Wheel/ZoomFactorShift"))
settings_->setValue("Core/Mouse/Wheel/ZoomFactorShift", 0.2);
if (!settings_->contains("Core/Mouse/Wheel/Invert"))
settings_->setValue("Core/Mouse/Wheel/Invert", false);
// General Stereo Settings
if (!settings_->contains("Core/Stereo/FocalLength"))
settings_->setValue("Core/Stereo/FocalLength", 0.5);
if (!settings_->contains("Core/Stereo/EyeDistance"))
settings_->setValue("Core/Stereo/EyeDistance", 0.07);
return true;
}
return true;
}
void closeSettings() {
......@@ -939,7 +942,7 @@ OpenFlipperQSettings& OpenFlipperSettings() {
// Empty standard settings object if the right settings are not available!
static OpenFlipperQSettings emptySettings;
if ( OpenFlipper::Options::settings_ )
if ( OpenFlipper::Options::settings_ != nullptr )
return *OpenFlipper::Options::settings_;
else
return emptySettings;
......
......@@ -223,7 +223,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
format.setStencil(true);
format.setSampleBuffers(true);
#endif
OFGLFormat::setDefaultFormat(format);
// Construct GL context & widget
baseLayout_ = new QtMultiViewLayout;
......@@ -244,7 +243,6 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
if ( ! test->format().stereo() ) {
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format.setStereo(false);
OFGLFormat::setDefaultFormat(format);
}/* else {
std::cerr << "Stereo found ok" << std::endl;
}*/
......
......@@ -102,7 +102,7 @@ void glViewer::startGLDebugLogger()
if (glDebugLogger_->initialize())
{
connect(glDebugLogger_, SIGNAL(messageLogged(QOpenGLDebugMessage)), this, SLOT(processGLDebugMessage(QOpenGLDebugMessage)));
glDebugLogger_->startLogging();
glDebugLogger_->startLogging(QOpenGLDebugLogger::SynchronousLogging);
}
}
#endif
......