Factorize more code into Polyhedron_demo.cpp

At the same time, fix that warning from Qt5:
> Attribute Qt::AA_UseDesktopOpenGL must be set before QCoreApplication is created.
This commit is contained in:
Laurent Rineau 2019-07-05 15:38:58 +02:00
parent c5566d3d77
commit 75d76c6d72
4 changed files with 30 additions and 46 deletions

View File

@ -10,20 +10,9 @@
*/
int main(int argc, char **argv)
{
QSurfaceFormat fmt;
fmt.setVersion(4, 3);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
QStringList keywords;
keywords << "Classification";
Polyhedron_demo app(argc, argv,
Polyhedron_demo app(argc, argv,
"Classification demo",
"CGAL Classification Demo",
keywords);
//We set the locale to avoid any trouble with VTK
std::setlocale(LC_ALL, "C");
QStringList() << "Classification");
return app.try_exec();
}

View File

@ -10,20 +10,9 @@
*/
int main(int argc, char **argv)
{
QSurfaceFormat fmt;
fmt.setVersion(4, 3);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
QStringList keywords;
keywords << "Mesh_3";
Polyhedron_demo app(argc, argv,
Polyhedron_demo app(argc, argv,
"Mesh_3 demo",
"CGAL Mesh_3 Demo",
keywords);
//We set the locale to avoid any trouble with VTK
std::setlocale(LC_ALL, "C");
QStringList() << "Mesh_3");
return app.try_exec();
}

View File

@ -1,8 +1,4 @@
#include "Polyhedron_demo.h"
#include <clocale>
#include <CGAL/Qt/resources.h>
#include <QSurfaceFormat>
/*!
* \brief Defines the entry point of the demo.
@ -10,17 +6,8 @@
*/
int main(int argc, char **argv)
{
QSurfaceFormat fmt;
fmt.setVersion(4, 3);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
Polyhedron_demo app(argc, argv,
Polyhedron_demo app(argc, argv,
"Polyhedron_3 demo",
"CGAL Polyhedron Demo");
//We set the locale to avoid any trouble with VTK
std::setlocale(LC_ALL, "C");
return app.try_exec();
}

View File

@ -8,6 +8,7 @@
#include <QCommandLineOption>
#include <QSurfaceFormat>
#include <QOpenGLContext>
#include <clocale>
struct Polyhedron_demo_impl {
@ -17,11 +18,34 @@ struct Polyhedron_demo_impl {
Polyhedron_demo_impl() : catch_exceptions(true) {}
}; // end struct Polyhedron_demo_impl
int& code_to_call_before_creation_of_QCoreApplication(int& i) {
QSurfaceFormat fmt;
fmt.setVersion(4, 3);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
//We set the locale to avoid any trouble with VTK
std::setlocale(LC_ALL, "C");
return i;
}
Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
QString application_name,
QString main_window_title,
QStringList input_keywords)
: QApplication(argc, argv)
: QApplication(code_to_call_before_creation_of_QCoreApplication(argc),
// This trick in the previous line ensure that code
// is called before the creation of the QApplication
// object.
argv)
, d_ptr_is_initialized(false)
, d_ptr(new Polyhedron_demo_impl)
{
@ -30,11 +54,6 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
std::cout.precision(17);
std::clog.precision(17);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
this->setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
// Import resources from libCGAL (Qt5).
CGAL_QT_INIT_RESOURCES;