From 6d344047fa3368dd83efcbc46a6da1e1b9c3663d Mon Sep 17 00:00:00 2001 From: Johannes Lenzen Date: Mon, 26 Apr 2021 10:03:03 +0200 Subject: [PATCH] started qt6 migration --- cmake-library | 2 +- src/OpenMesh/Apps/CMakeLists.txt | 20 ++++++------- .../Decimating/DecimaterGui/CMakeLists.txt | 2 +- .../Apps/Decimating/decimaterviewer.cc | 7 ++++- src/OpenMesh/Apps/ProgViewer/CMakeLists.txt | 2 +- src/OpenMesh/Apps/ProgViewer/progviewer.cc | 9 ++++-- src/OpenMesh/Apps/QtViewer/CMakeLists.txt | 2 +- .../Apps/QtViewer/MeshViewerWidgetT_impl.hh | 2 +- src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc | 30 +++++++++++-------- src/OpenMesh/Apps/QtViewer/QGLViewerWidget.hh | 28 +++++++++++------ src/OpenMesh/Apps/QtViewer/meshviewer.cc | 10 ++++++- .../Subdivider/SubdividerGui/CMakeLists.txt | 2 +- src/OpenMesh/Apps/Subdivider/qtsubdivider.cc | 7 +++++ .../VDProgMesh/Synthesizer/CMakeLists.txt | 2 +- .../VDProgMesh/Synthesizer/vdpmsynthesizer.cc | 7 +++++ 15 files changed, 90 insertions(+), 42 deletions(-) diff --git a/cmake-library b/cmake-library index ab9edd27..fb435484 160000 --- a/cmake-library +++ b/cmake-library @@ -1 +1 @@ -Subproject commit ab9edd278c64b3a387f4d8eb39eb2c2a091d6481 +Subproject commit fb4354848171b77a4f42966167bcd3071a878b3e diff --git a/src/OpenMesh/Apps/CMakeLists.txt b/src/OpenMesh/Apps/CMakeLists.txt index 2e17ab99..47468239 100644 --- a/src/OpenMesh/Apps/CMakeLists.txt +++ b/src/OpenMesh/Apps/CMakeLists.txt @@ -41,14 +41,14 @@ if ( BUILD_APPS ) find_package (OpenGL) # For the apps, we need qt and opengl to build them - if (NOT QT5_FOUND) - set(QT5_REQUIRED_PACKAGES - Qt5Core - Qt5Widgets - Qt5OpenGL - Qt5Gui + if (NOT QT_FOUND) + set(QT_REQUIRED_PACKAGES + Core + Widgets + OpenGL + Gui ) - vci_qt5 () + vci_qt () set(CMAKE_AUTOMOC ON) endif() @@ -57,7 +57,7 @@ if ( BUILD_APPS ) endif() # check for OpenGL as our required dependencies - if (( QT5_FOUND ) AND OPENGL_FOUND AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" ) + if (( QT_FOUND ) AND OPENGL_FOUND AND NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" ) add_subdirectory (Decimating/DecimaterGui) add_subdirectory (QtViewer) @@ -95,8 +95,8 @@ if ( BUILD_APPS ) else () # QT ,Opengl or glut not found - if (NOT QT5_FOUND) - message ("QT5 not found! Skipping some apps.") + if (NOT QT_FOUND) + message ("QT not found! Skipping some apps.") endif () if (NOT OPENGL_FOUND) diff --git a/src/OpenMesh/Apps/Decimating/DecimaterGui/CMakeLists.txt b/src/OpenMesh/Apps/Decimating/DecimaterGui/CMakeLists.txt index 8baa357e..303a325a 100644 --- a/src/OpenMesh/Apps/Decimating/DecimaterGui/CMakeLists.txt +++ b/src/OpenMesh/Apps/Decimating/DecimaterGui/CMakeLists.txt @@ -29,7 +29,7 @@ endif () target_link_libraries (DecimaterGui OpenMeshCore OpenMeshTools - Qt5::OpenGL + ${QT_TARGET}::OpenGL ${OPENGL_LIBRARIES} ) diff --git a/src/OpenMesh/Apps/Decimating/decimaterviewer.cc b/src/OpenMesh/Apps/Decimating/decimaterviewer.cc index da5a22db..13cfed8c 100644 --- a/src/OpenMesh/Apps/Decimating/decimaterviewer.cc +++ b/src/OpenMesh/Apps/Decimating/decimaterviewer.cc @@ -50,6 +50,7 @@ #include #include #include +#include #include "DecimaterViewerWidget.hh" @@ -64,8 +65,12 @@ int main(int argc, char **argv) // OpenGL check QApplication app(argc,argv); - + +#if QT_VERSION_MAJOR < 6 if ( !QGLFormat::hasOpenGL() ) { +#else + if ( QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL ) { +#endif QString msg = "System has no OpenGL support!"; QMessageBox::critical( nullptr, "OpenGL", msg + argv[1] ); return -1; diff --git a/src/OpenMesh/Apps/ProgViewer/CMakeLists.txt b/src/OpenMesh/Apps/ProgViewer/CMakeLists.txt index c0adbdff..95b69568 100644 --- a/src/OpenMesh/Apps/ProgViewer/CMakeLists.txt +++ b/src/OpenMesh/Apps/ProgViewer/CMakeLists.txt @@ -28,7 +28,7 @@ endif () target_link_libraries ( ProgViewer OpenMeshCore OpenMeshTools - Qt5::OpenGL + ${QT_TARGET}::OpenGL ${OPENGL_LIBRARIES} ) diff --git a/src/OpenMesh/Apps/ProgViewer/progviewer.cc b/src/OpenMesh/Apps/ProgViewer/progviewer.cc index 4ce5de6b..d09e8c1f 100644 --- a/src/OpenMesh/Apps/ProgViewer/progviewer.cc +++ b/src/OpenMesh/Apps/ProgViewer/progviewer.cc @@ -51,15 +51,20 @@ #include #include #include -#include - +#if QT_VERSION_MAJOR > 5 +#include +#endif int main(int argc, char **argv) { // OpenGL check QApplication app(argc,argv); +#if QT_VERSION_MAJOR < 6 if ( !QGLFormat::hasOpenGL() ) { +#else + if ( QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL ) { +#endif std::cerr << "This system has no OpenGL support.\n"; return -1; } diff --git a/src/OpenMesh/Apps/QtViewer/CMakeLists.txt b/src/OpenMesh/Apps/QtViewer/CMakeLists.txt index aa704908..4c14e5a5 100644 --- a/src/OpenMesh/Apps/QtViewer/CMakeLists.txt +++ b/src/OpenMesh/Apps/QtViewer/CMakeLists.txt @@ -30,7 +30,7 @@ endif () target_link_libraries (QtViewer OpenMeshCore OpenMeshTools - Qt5::OpenGL + ${QT_TARGET}::OpenGL ${OPENGL_LIBRARIES} ) diff --git a/src/OpenMesh/Apps/QtViewer/MeshViewerWidgetT_impl.hh b/src/OpenMesh/Apps/QtViewer/MeshViewerWidgetT_impl.hh index e796f7ce..339e3ac4 100644 --- a/src/OpenMesh/Apps/QtViewer/MeshViewerWidgetT_impl.hh +++ b/src/OpenMesh/Apps/QtViewer/MeshViewerWidgetT_impl.hh @@ -233,7 +233,7 @@ bool MeshViewerWidgetT::set_texture( QImage& _texsrc ) _texsrc = _texsrc.scaled( tex_w, tex_h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); } - QImage texture( QGLWidget::convertToGLFormat ( _texsrc ) ); + QImage texture = _texsrc.convertToFormat(QImage::Format_ARGB32).rgbSwapped(); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); diff --git a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc index ec2ce252..bf1f6973 100644 --- a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc +++ b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.cc @@ -60,6 +60,7 @@ #include #include #include +#include // -------------------- #include #include @@ -68,6 +69,10 @@ # define M_PI 3.1415926535897932 #endif +#if QT_VERSION_MAJOR > 5 +#define swapBuffers() +#endif + const double TRACKBALL_RADIUS = 0.6; @@ -81,21 +86,22 @@ std::string QGLViewerWidget::nomode_ = ""; //---------------------------------------------------------------------------- -QGLViewerWidget::QGLViewerWidget( QWidget* _parent ) - : QGLWidget( _parent ) +#if QT_VERSION_MAJOR < 6 +QGLViewerWidget::QGLViewerWidget( QWidget* _parent ) : QGLWidget( _parent ) +#else +QGLViewerWidget::QGLViewerWidget( QWidget* _parent ) : QOpenGLWidget( _parent ) +#endif { init(); } -//---------------------------------------------------------------------------- +//--------------------------------------------------------------------------- -QGLViewerWidget:: -QGLViewerWidget( QGLFormat& _fmt, QWidget* _parent ) - : QGLWidget( _fmt, _parent ) -{ - init(); +#if QT_VERSION_MAJOR > 5 +void QGLViewerWidget::updateGL() { + update(); } - +#endif //---------------------------------------------------------------------------- @@ -330,7 +336,7 @@ QGLViewerWidget::mouseMoveEvent( QMouseEvent* _event ) // move in z direction - if ( (_event->buttons() == (LeftButton+MidButton)) || + if ( (_event->buttons() == (LeftButton|MiddleButton)) || (_event->buttons() == LeftButton && _event->modifiers() == ControlModifier)) { float value_y = radius_ * dy * 3.0 / h; @@ -339,7 +345,7 @@ QGLViewerWidget::mouseMoveEvent( QMouseEvent* _event ) // move in x,y direction - else if ( (_event->buttons() == MidButton) || + else if ( (_event->buttons() == MiddleButton) || (_event->buttons() == LeftButton && _event->modifiers() == AltModifier) ) { float z = - (modelview_matrix_[ 2]*center_[0] + @@ -417,7 +423,7 @@ void QGLViewerWidget::wheelEvent(QWheelEvent* _event) { // Use the mouse wheel to zoom in/out - float d = -(float)_event->delta() / 120.0 * 0.2 * radius_; + float d = -(float)( _event->angleDelta().y() / 120.0 * 0.2 * radius_ ); translate(Vec3f(0.0, 0.0, d)); updateGL(); _event->accept(); diff --git a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.hh b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.hh index 44bf295a..ddef0faa 100644 --- a/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.hh +++ b/src/OpenMesh/Apps/QtViewer/QGLViewerWidget.hh @@ -47,14 +47,15 @@ //== INCLUDES ================================================================= - - #include -#include #include #include #include - +#if QT_VERSION_MAJOR < 6 + #include +#else + #include +#endif //== FORWARD DECLARATIONS ===================================================== @@ -64,21 +65,25 @@ class QAction; //== CLASS DEFINITION ========================================================= - +#if QT_VERSION_MAJOR < 6 class QGLViewerWidget : public QGLWidget +#else +class QGLViewerWidget : public QOpenGLWidget +#endif { - Q_OBJECT + public: + #if QT_VERSION_MAJOR < 6 typedef QGLWidget Super; + #else + typedef QOpenGLWidget Super; + #endif // Default constructor. explicit QGLViewerWidget( QWidget* _parent=0 ); - // - QGLViewerWidget( QGLFormat& _fmt, QWidget* _parent=0 ); - // Destructor. virtual ~QGLViewerWidget(); @@ -88,6 +93,11 @@ private: public: +#if QT_VERSION_MAJOR > 5 + /* Updates the gui - used to provide backwards compability */ + void updateGL(); +#endif + /* Sets the center and size of the whole scene. The _center is used as fixpoint for rotations and for adjusting the camera/viewer (see view_all()). */ diff --git a/src/OpenMesh/Apps/QtViewer/meshviewer.cc b/src/OpenMesh/Apps/QtViewer/meshviewer.cc index fdb5c144..8593bc8a 100644 --- a/src/OpenMesh/Apps/QtViewer/meshviewer.cc +++ b/src/OpenMesh/Apps/QtViewer/meshviewer.cc @@ -44,12 +44,16 @@ #endif #include + #include #include #include #include #include #include +#if QT_VERSION_MAJOR > 5 +#include +#endif #include "MeshViewerWidget.hh" @@ -62,7 +66,11 @@ int main(int argc, char **argv) // OpenGL check QApplication app(argc,argv); - if ( !QGLFormat::hasOpenGL() ) { +#if QT_VERSION_MAJOR < 6 + if ( !QGLFormat::hasOpenGL() ) { +#else + if ( QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL ) { +#endif QString msg = "System has no OpenGL support!"; QMessageBox::critical( nullptr, QString("OpenGL"), msg + QString(argv[1]) ); return -1; diff --git a/src/OpenMesh/Apps/Subdivider/SubdividerGui/CMakeLists.txt b/src/OpenMesh/Apps/Subdivider/SubdividerGui/CMakeLists.txt index 81e87499..57145ea5 100644 --- a/src/OpenMesh/Apps/Subdivider/SubdividerGui/CMakeLists.txt +++ b/src/OpenMesh/Apps/Subdivider/SubdividerGui/CMakeLists.txt @@ -28,7 +28,7 @@ endif () target_link_libraries (SubdividerGui OpenMeshCore OpenMeshTools - Qt5::OpenGL + ${QT_TARGET}::OpenGL ${OPENGL_LIBRARIES} ) diff --git a/src/OpenMesh/Apps/Subdivider/qtsubdivider.cc b/src/OpenMesh/Apps/Subdivider/qtsubdivider.cc index 9421653b..b6674d63 100644 --- a/src/OpenMesh/Apps/Subdivider/qtsubdivider.cc +++ b/src/OpenMesh/Apps/Subdivider/qtsubdivider.cc @@ -51,13 +51,20 @@ #include #include #include "SubdivideWidget.hh" +#if QT_VERSION_MAJOR > 5 +#include +#endif int main(int argc, char **argv) { // OpenGL check QApplication app(argc,argv); +#if QT_VERSION_MAJOR < 6 if ( !QGLFormat::hasOpenGL() ) { +#else + if ( QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL ) { +#endif QString msg = "System has no OpenGL support!"; QMessageBox::critical( nullptr, "OpenGL", msg + argv[1], QMessageBox::Ok ); return -1; diff --git a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/CMakeLists.txt b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/CMakeLists.txt index c39d3459..68f731e5 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/CMakeLists.txt +++ b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/CMakeLists.txt @@ -25,6 +25,6 @@ endif () target_link_libraries (Synthesizer OpenMeshCore OpenMeshTools - Qt5::OpenGL + ${QT_TARGET}::OpenGL ${OPENGL_LIBRARIES} ) diff --git a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/vdpmsynthesizer.cc b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/vdpmsynthesizer.cc index a46e8a19..f122fa4a 100644 --- a/src/OpenMesh/Apps/VDProgMesh/Synthesizer/vdpmsynthesizer.cc +++ b/src/OpenMesh/Apps/VDProgMesh/Synthesizer/vdpmsynthesizer.cc @@ -49,6 +49,9 @@ #include #include +#if QT_VERSION_MAJOR > 5 +#include +#endif #include "VDPMSynthesizerViewerWidget.hh" @@ -58,7 +61,11 @@ int main(int argc, char **argv) QApplication app(argc,argv); +#if QT_VERSION_MAJOR < 6 if ( !QGLFormat::hasOpenGL() ) { +#else + if ( QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL ) { +#endif std::cerr << "This system has no OpenGL support.\n"; return 1; }