Commit b8906443 authored by Jan Möbius's avatar Jan Möbius
Browse files
parents cd161990 5875bf0c
......@@ -51,11 +51,7 @@
#define VIEWMODEINTERFACE_HH
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QMenuBar>
#include <QStringList>
......
......@@ -67,11 +67,6 @@
#include <ACG/QtWidgets/QtFileDialog.hh>
// -------------------- Qt
#if QT_VERSION >= 0x050000
#else
#undef QT_NO_OPENGL
#include <QGLFormat>
#endif
#include "OpenFlipper/BasePlugin/KeyInterface.hh"
#include "OpenFlipper/BasePlugin/MouseInterface.hh"
......@@ -93,6 +88,8 @@
#include <OpenFlipper/widgets/messageBox/StaysOnTopMessageBox.hh>
#include <OpenFlipper/common/PluginStorage.hh>
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH 800
......@@ -241,7 +238,7 @@ Core::init() {
Qt::AlignBottom | Qt::AlignLeft , Qt::white);
}
coreWidget_ = new CoreWidget(viewModes_ , plugins_, coreSlots_);
coreWidget_ = new CoreWidget(viewModes_ , coreSlots_);
spinBoxEventFilter_.registerScrollArea(coreWidget_->getToolboxScrollArea());
spinBoxEventFilter_.registerScrollArea(coreWidget_->getToolboxArea());
......@@ -723,6 +720,12 @@ Core::~Core()
//-----------------------------------------------------------------------------
std::vector<PluginInfo>& Core::plugins() {
return PluginStorage::plugins();
};
//-----------------------------------------------------------------------------
void
Core::slotMouseEventIdentify( QMouseEvent* _event )
{
......@@ -1174,8 +1177,8 @@ void Core::slotExit() {
clearAll();
// Notify plugins of imminent exit.
for ( uint i = 0 ; i < plugins_.size() ; ++i ){
BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugins_[i].plugin);
for ( uint i = 0 ; i < plugins().size() ; ++i ){
BaseInterface* basePlugin = qobject_cast< BaseInterface * >(plugins()[i].plugin);
// Dont call exit if we cannot get the Plugin
if ( basePlugin )
......@@ -1183,7 +1186,7 @@ void Core::slotExit() {
}
// Delete Plugins to actually call their destructor
for(PluginInfo p : plugins_)
for(PluginInfo p : plugins())
delete p.plugin;
// close the log file to ensure everything is writeen correctly
......@@ -1305,9 +1308,9 @@ void Core::slotSetSlotDescription(QString _slotName, QString _slotDescrip
//find plugin
PluginInfo* pluginInfo = 0;
for (uint i=0; i < plugins_.size(); i++)
if (plugins_[i].plugin == sender())
pluginInfo = &plugins_[i];
for (uint i=0; i < plugins().size(); i++)
if (plugins()[i].plugin == sender())
pluginInfo = &plugins()[i];
if (pluginInfo == 0){
emit log(LOGERR, tr("Unable to set slot-description. Plugin not found!"));
......@@ -1383,9 +1386,9 @@ void Core::slotGetDescription(QString _function, QString& _fnDescript
//find plugin
PluginInfo* pluginInfo = 0;
for (uint i=0; i < plugins_.size(); i++)
if (plugins_[i].rpcName == pluginName)
pluginInfo = &plugins_[i];
for (uint i=0; i < plugins().size(); i++)
if (plugins()[i].rpcName == pluginName)
pluginInfo = &plugins()[i];
if (pluginInfo == 0){
emit log(LOGERR, tr("Unable to get slot-description. Plugin not found!"));
......@@ -1529,12 +1532,12 @@ void Core::writeVersionNumbers(QString _filename){
ini.add_entry( "Core" , "VersionLinux" , OpenFlipper::Options::coreVersion() );
//add pluginVersions
for (uint i=0; i < plugins_.size(); i++){
for (uint i=0; i < plugins().size(); i++){
if ( OpenFlipper::Options::isWindows() )
ini.add_entry( plugins_[i].name , "VersionWindows" , plugins_[i].version );
ini.add_entry( plugins()[i].name , "VersionWindows" , plugins()[i].version );
else
ini.add_entry( plugins_[i].name , "VersionLinux" , plugins_[i].version );
ini.add_entry( plugins()[i].name , "VersionLinux" , plugins()[i].version );
}
ini.disconnect();
......
......@@ -121,7 +121,6 @@
#include <OpenFlipper/threads/JobInfo.hh>
#include <OpenFlipper/common/FileTypes.hh>
#include <OpenFlipper/common/InformationPlugins.hh>
#include "SpinBoxEventFilter.hh"
......@@ -1214,17 +1213,19 @@ private slots:
//===========================================================================
public :
const std::vector<PluginInfo> plugins() const {return plugins_; };
std::vector<PluginInfo>& plugins();
private:
/// List of all loaded plugins_
std::vector<PluginInfo> plugins_;
/// Index of Plugins toolbox widget
int toolboxindex_;
/// Load all plugins from default plugin directory and from INI-File
void loadPlugins();
/// Print all info collected about plugin during loading
void printPluginLoadLog(const QString& errors,const QString& warnings);
private slots:
/// Show Plugins Dialog
void slotShowPlugins();
......@@ -1250,10 +1251,8 @@ private slots:
signals:
void genericMetadataDeserialized(QString key, QString value);
void objectMetadataDeserialized(QString object_name, QString value);
#if QT_VERSION >= 0x050000
void objectMetadataDeserializedJson(
QString object_name, QJsonDocument value);
#endif
private slots:
void slotMetadataDeserialized( const QVector<QPair<QString, QString> > &data);
......
......@@ -467,11 +467,11 @@ void connectPlugins( Core* c, const std::vector<PluginInfo>& plugins_, QString _
}
void Core::slotCrossPluginConnect( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot) {
connectPlugins(this, plugins_, _pluginName1, _signal, _pluginName2, _slot, false);
connectPlugins(this, plugins(), _pluginName1, _signal, _pluginName2, _slot, false);
}
void Core::slotCrossPluginConnectQueued( QString _pluginName1, const char* _signal, QString _pluginName2, const char* _slot) {
connectPlugins(this, plugins_, _pluginName1, _signal, _pluginName2, _slot, true);
connectPlugins(this, plugins(), _pluginName1, _signal, _pluginName2, _slot, true);
}
//========================================================================================
......@@ -533,7 +533,6 @@ void Core::slotMetadataDeserialized(
const QStringRef value = obj_metadata.midRef(cursor, next - cursor);
emit objectMetadataDeserialized(current_object_name, value.toString());
#if QT_VERSION >= 0x050000
QJsonParseError json_error;
QJsonDocument json_doc =
QJsonDocument::fromJson(value.toUtf8(), &json_error);
......@@ -541,7 +540,6 @@ void Core::slotMetadataDeserialized(
emit objectMetadataDeserializedJson(
current_object_name, json_doc);
}
#endif
cursor = next + re_end.matchedLength();
state = STATE_SEARCH_BEGIN;
break;
......
......@@ -85,6 +85,8 @@ class PluginInfo{
version(""),
path(""),
rpcName(""),
errors(""),
warnings(""),
optionsWidget(0),
buildIn(true),
status(FAILED)
......@@ -108,6 +110,8 @@ class PluginInfo{
version(_i.version),
path(_i.path),
rpcName(_i.rpcName),
errors(_i.errors),
warnings(_i.warnings),
rpcFunctions(_i.rpcFunctions),
slotInfos(_i.slotInfos),
keys(_i.keys),
......@@ -141,6 +145,12 @@ class PluginInfo{
/// Clean rpc name of the plugin
QString rpcName;
/// Store errors encountered during plugin loading
QString errors;
/// Store warnings encountered during plugin loading
QString warnings;
/// List of exported rpc slots
QStringList rpcFunctions;
......
This diff is collapsed.
......@@ -68,8 +68,8 @@
void Core::slotPluginExists( QString _pluginName , bool& _exists ) {
for ( int i = 0 ; i < (int)plugins_.size(); ++i ) {
if ( plugins_[i].rpcName == _pluginName ) {
for ( int i = 0 ; i < (int)plugins().size(); ++i ) {
if ( plugins()[i].rpcName == _pluginName ) {
_exists = true;
return;
}
......@@ -82,8 +82,8 @@ void Core::slotFunctionExists( QString _pluginName , QString _functionName , boo
//Find plugin
int plugin = -1;
for ( int i = 0 ; i < (int)plugins_.size(); ++i ) {
if ( plugins_[i].rpcName == _pluginName ) {
for ( int i = 0 ; i < (int)plugins().size(); ++i ) {
if ( plugins()[i].rpcName == _pluginName ) {
plugin = i;
break;
}
......@@ -94,15 +94,15 @@ void Core::slotFunctionExists( QString _pluginName , QString _functionName , boo
return;
}
_exists = plugins_[plugin].rpcFunctions.contains(_functionName);
_exists = plugins()[plugin].rpcFunctions.contains(_functionName);
}
void Core::slotCall( QString _pluginName , QString _functionName , bool& _success ) {
//Find plugin
int plugin = -1;
for ( int i = 0 ; i < (int)plugins_.size(); ++i ) {
if ( plugins_[i].rpcName == _pluginName ) {
for ( int i = 0 ; i < (int)plugins().size(); ++i ) {
if ( plugins()[i].rpcName == _pluginName ) {
plugin = i;
break;
}
......@@ -114,7 +114,7 @@ void Core::slotCall( QString _pluginName , QString _functionName , bool& _succes
return;
}
if ( !plugins_[plugin].rpcFunctions.contains(_functionName) ) {
if ( !plugins()[plugin].rpcFunctions.contains(_functionName) ) {
_success = false;
emit log(LOGERR, tr("Unable to call function from Plugin : ") + _pluginName);
emit log(LOGERR, tr("Function ") + _functionName + tr(" not found!"));
......
......@@ -52,6 +52,9 @@
//#include <ObjectTypes/Light/Light.hh>
#include <OpenFlipper/common/FileTypes.hh>
/// Save Settings (slot is called from CoreWidget's File-Menu)
void Core::saveSettings(){
......
......@@ -231,13 +231,13 @@ void Core::setToolBoxSide(QString _side) {
//-----------------------------------------------------------------------------
QWidget *Core::getToolbox(QString _pluginName, QString _toolboxName) {
std::vector<PluginInfo>::const_iterator pluginIt = plugins_.end();
for (std::vector<PluginInfo>::const_iterator it = plugins_.begin(), it_end = plugins_.end(); it != it_end; ++it) {
std::vector<PluginInfo>::const_iterator pluginIt = plugins().end();
for (std::vector<PluginInfo>::const_iterator it = plugins().begin(), it_end = plugins().end(); it != it_end; ++it) {
if (it->name == _pluginName) {
pluginIt = it;
}
}
if (pluginIt == plugins_.end()) return 0;
if (pluginIt == plugins().end()) return 0;
for (std::vector<std::pair<QString , QWidget*> >::const_iterator it = pluginIt->toolboxWidgets.begin(), it_end = pluginIt->toolboxWidgets.end();
it != it_end; ++it) {
......@@ -266,8 +266,8 @@ void Core::addToolbox(QString _name ,QWidget* _widget, QIcon* _icon,
int id = -1;
// Find the plugin which added this Toolbox
for ( uint i = 0 ; i < plugins_.size(); ++i ) {
if ( plugins_[i].plugin == sender() ) {
for ( uint i = 0 ; i < plugins().size(); ++i ) {
if ( plugins()[i].plugin == sender() ) {
id = i;
break;
}
......@@ -275,8 +275,8 @@ void Core::addToolbox(QString _name ,QWidget* _widget, QIcon* _icon,
// Find the scripting plugin because we assign this toolBox to it as we did not find the original sender
if ( id == -1 ) {
for ( uint i = 0 ; i < plugins_.size(); ++i ) {
if ( plugins_[i].name == "Scripting" ) {
for ( uint i = 0 ; i < plugins().size(); ++i ) {
if ( plugins()[i].name == "Scripting" ) {
id = i;
break;
}
......@@ -290,9 +290,9 @@ void Core::addToolbox(QString _name ,QWidget* _widget, QIcon* _icon,
}
spinBoxEventFilter_.hookUpToWidgetTree(_widget);
plugins_[id].toolboxWidgets.push_back( std::pair< QString,QWidget* >( _name , _widget) );
plugins_[id].toolboxIcons.push_back( _icon );
plugins_[id].headerAreaWidgets.push_back( std::pair< QString,QWidget* >( _name , _headerAreaWidget) );
plugins()[id].toolboxWidgets.push_back( std::pair< QString,QWidget* >( _name , _widget) );
plugins()[id].toolboxIcons.push_back( _icon );
plugins()[id].headerAreaWidgets.push_back( std::pair< QString,QWidget* >( _name , _headerAreaWidget) );
// add widget name to viewMode 'all'
if ( !viewModes_[0]->visibleToolboxes.contains(_name) ){
......
......@@ -144,6 +144,7 @@ if (WIN32)
-DUSEACG
-DPLUGINLIBDLL
-DUSEPLUGINLIBDLL
-DFREEGLUT_LIB_PRAGMAS=0
)
endif ()
......@@ -359,7 +360,16 @@ elseif(WIN32)
file (GLOB qtplugin_dirs RELATIVE "${QT_PLUGINS_DIR}" "${QT_PLUGINS_DIR}/*" )
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Build/QtPlugins" )
foreach (qtplugin ${qtplugin_dirs})
file(COPY "${QT_PLUGINS_DIR}/${qtplugin}" DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/")
# Exclude PDB files if we build release mode
if ( CMAKE_BUILD_TYPE MATCHES "Debug" )
file(COPY "${QT_PLUGINS_DIR}/${qtplugin}"
DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/" )
else()
file(COPY "${QT_PLUGINS_DIR}/${qtplugin}"
DESTINATION "${CMAKE_BINARY_DIR}/Build/QtPlugins/"
PATTERN "*.pdb" EXCLUDE )
endif()
endforeach ()
endif( APPLE )
......
......@@ -19,6 +19,7 @@
- <b>ACG</b>
- Clamp shininess in Materialnode (caused GL Errors)
- Better Material support in Materialnode (emissive and refractive materials)
- Use ShaderGenerator for picking shaders
- <b>Plugins</b>
- File-OBJ
- Read emissive and refractive materials
......
......@@ -10,6 +10,13 @@
* --no-splash : Disable splash screen\n
* --disable-stereo : Disable Stereo Mode\n
*
* OpenGL Options:\n
* -profile < compat | core > : request Compatibility or %Core context ( Default = %Core )\n
* -glVersion <int.int> : request specified OpenGL version (Default = 3.2)\n
* -samples <int> : request MSAA with <int> samples (Default = 16)\n
* -glStereo <true | false> : request creation of stereo buffers
* \note The OpenGL command line parameters override stored settings temporarily. To permanently store an OpenGL setting, use the options dialog.
*
* Log options:\n
* --log-to-console ( -c ) : Write logger window contents to console\n
* \note On Window Systems, using the --log-to-console option causes the creation of a console if OpenFlipper was started without one.
......
......@@ -49,11 +49,7 @@
#include <QApplication>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QtWidgets>
#include <QFile>
#include <QMessageBox>
......
......@@ -48,12 +48,7 @@
\*===========================================================================*/
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QtWidgets>
#include <QMessageBox>
......
......@@ -97,6 +97,9 @@
crashFile.open(crashName.toLatin1(),std::ios::out | std::ios::app);
crashFile << szText;
crashFile.close();
// Write crash dump to console as well
StackWalker::OnOutput(szText);
}
};
#endif
......@@ -350,9 +353,17 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
QCommandLineOption coreProfileOption("core-profile",QCoreApplication::translate("main", "OpenGL Core Profile Mode"));
parser.addOption(coreProfileOption);
QCommandLineOption profileOption("profile",QCoreApplication::translate("main","Request OpenGL context profile <profile> with profile set as compat or core"),QCoreApplication::translate("main","<compat | core >"));
profileOption.setDefaultValue("compat");
QCommandLineOption glVersionOption("glVersion",QCoreApplication::translate("main","Request OpenGL version <major>.<minor> "),QCoreApplication::translate("main","< 1.0 | 1.1 | ... | 4.6 >"));
parser.addOption(glVersionOption);
QCommandLineOption samplesOption("samples",QCoreApplication::translate("main","Overwrite multisampling sample count"),QCoreApplication::translate("main","< 0 | 1 | 2 | ... | 16 >"));
parser.addOption(samplesOption);
QCommandLineOption glStereoOption("glStereo",QCoreApplication::translate("main","Overwrite OpenGL Stereo setting"),QCoreApplication::translate("main","< true | false >"));
parser.addOption(glStereoOption);
QCommandLineOption profileOption("profile",QCoreApplication::translate("main","Request OpenGL context profile <profile> with profile set as compat or core"),QCoreApplication::translate("main","< compat | core >"));
parser.addOption(profileOption);
const QCommandLineOption helpOption = parser.addHelpOption();
const QCommandLineOption versionOption = parser.addVersionOption();
......@@ -415,25 +426,196 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
std::cerr << "Got port option : " << port.toStdString() << std::endl;
OpenFlipper::Options::remoteControl(port.toInt());
}
if(parser.isSet("samples"))
OpenFlipper::Options::samples(parser.value("samples").toInt(),true);
if(parser.isSet("glVersion"))
{
QStringList values = parser.value("glVersion").split(".");
QPair<int,int> version(
values[0].toInt(),
values[1].toInt());
OpenFlipper::Options::glVersion(version,true);
}
if(parser.isSet("glStereo"))
OpenFlipper::Options::glStereo(parser.value("glStereo")=="true");
if(parser.value(profileOption)=="core")
{
OpenFlipper::Options::coreProfile(true);
OpenFlipper::Options::coreProfile(true, true);
}
else
{
if(parser.value(profileOption)=="compat")
{
OpenFlipper::Options::coreProfile(false);
OpenFlipper::Options::coreProfile(false, true);
}
}
if(parser.isSet(coreProfileOption)) {
OpenFlipper::Options::coreProfile(true);
OpenFlipper::Options::coreProfile(true, true);
}
return CommandLineOk;
}
namespace
{
// Print human-readable GL profile strings
std::string profileToString(QSurfaceFormat::OpenGLContextProfile _profile)
{
if(_profile == QSurfaceFormat::CompatibilityProfile)
return "CompatibilityProfile";
if(_profile == QSurfaceFormat::CoreProfile)
return "CoreProfile";
if(_profile == QSurfaceFormat::NoProfile)
return "NoProfile";
return "[Unknown]";
}
// Check whether a specific context request can be fulfilled
// Can also return the format of the actually created context
bool verifySpecificContextFormat(QSurfaceFormat format, QSurfaceFormat* resultingFormat = nullptr)
{
// All created surfaces try to obey the given format
QSurfaceFormat::setDefaultFormat(format);
// We need a temporary qApp to create a surface and test the current context
int tempArgC = 0;
QApplication tempApp(tempArgC, nullptr);
QOffscreenSurface *surface = new QOffscreenSurface();
surface->create();
auto shareContext = QOpenGLContext::globalShareContext();
if(!shareContext)
{
std::cerr << "Error: Apparently no GL context was created!" << std::endl;
return false;
}
// Make the globally shared OpenGLContext current
shareContext->makeCurrent(surface);
// The opengl surface properties that have actually been applied
// (does not necessarily match the requested properties)
auto resultFormat = QOpenGLContext::globalShareContext()->format();
// Return the format of the actually created context (may be identical to the requested one)
if(resultingFormat != nullptr)
*resultingFormat = resultFormat;
auto curVersion = resultFormat.version();
// Human-readable name of requested profile
auto reqProfileString = profileToString(format.profile());
// Human-readable name of current profile
auto curProfileString = profileToString(resultFormat.profile());
// Check whether the actually applied OpenGL context profile matches the requested one
// and the current GL version is at least the requested one (but may be higher)
// If not, print some error to the console
if(curVersion.first < format.version().first ||
((curVersion.first == format.version().first) && (curVersion.second < format.version().second)) ||
format.profile() != resultFormat.profile())
{
std::cout << "[OpenGL context] Requested: "
<< format.version().first << "." << format.version().second << " (" << reqProfileString << ")"
<< ", Actually created: "
<< curVersion.first << "." << curVersion.second << " (" << curProfileString << ")"
<< std::endl;
return false;
}
std::cout << "[OpenGL context] Successfully created OpenGL context with version " << curVersion.first << "."
<< curVersion.second << " (" << curProfileString << ")." << std::endl;
return true;
}
// Create a QSurfaceFormat from the most important properties like version and profile
QSurfaceFormat createFormat(QSurfaceFormat::OpenGLContextProfile _profile, int _glMajor, int _glMinor, int _multisamplingSamples, bool _stereo, bool _debugContext)
{
QSurfaceFormat format;
format.setVersion(_glMajor, _glMinor);
format.setProfile(_profile);
format.setSamples(_multisamplingSamples);
format.setStereo(_stereo);
if(_profile != QSurfaceFormat::CoreProfile)
format.setOption(QSurfaceFormat::DeprecatedFunctions);
if (_debugContext)
format.setOption(format.options() | QSurfaceFormat::DebugContext);
return format;
}
// This method tries to find the best possible OpenGL context format in the following order:
// 1. The profile/format requested via the settings
// 2. A 4.4 compatibility context (should contain all relevant GL functions)
// 3. A 3.2 core context (best choice e.g. on MacOS)
// 4. Return whatever context was applied instead of the requested ones
QSurfaceFormat getContextFormat()
{
auto reqProfile = OpenFlipper::Options::coreProfile() ? QSurfaceFormat::CoreProfile : QSurfaceFormat::CompatibilityProfile;
QPair<int,int> reqVersion = OpenFlipper::Options::glVersion();
auto reqSamples = OpenFlipper::Options::samples();
auto reqStereo = OpenFlipper::Options::glStereo();
bool debugContext = OpenFlipper::Options::debug();
/*
// Debug: test all (possible and impossible) OpenGL versions and profiles and exit
for(int majo = 1; majo < 5; ++majo)
for(int mino = 0; mino < 10; ++mino)
{
std::cout << "========== " << majo << "." << mino << " ==========="<<std::endl;
verifySpecificContextFormat(createFormat(QSurfaceFormat::CoreProfile, majo, mino, reqSamples, reqStereo, debugContext));
verifySpecificContextFormat(createFormat(QSurfaceFormat::CompatibilityProfile, majo, mino, reqSamples, reqStereo, debugContext));
verifySpecificContextFormat(createFormat(QSurfaceFormat::NoProfile, majo, mino, reqSamples, reqStereo, debugContext));
std::cout << "================================" << std::endl;
std::cout << std::endl;
}
exit(0);
*/
QSurfaceFormat resultFormat;
std::cout << "[OpenGL context] Trying to create a " << reqVersion.first << "." << reqVersion.second << " " << profileToString(reqProfile) << " context (default from settings)..." << std::endl;
bool success = verifySpecificContextFormat(createFormat(reqProfile, reqVersion.first, reqVersion.second, reqSamples, reqStereo, debugContext), &resultFormat);
// If that did not work...
if(!success)
{
std::cout << "[OpenGL context] Trying to create a 4.4 compat context..." << std::endl;
success = verifySpecificContextFormat(createFormat(QSurfaceFormat::CompatibilityProfile, 4, 4, reqSamples, reqStereo, debugContext), &resultFormat);