started qt6 migration

This commit is contained in:
Johannes Lenzen
2021-04-26 10:03:03 +02:00
parent c6833ff28a
commit 6d344047fa
15 changed files with 90 additions and 42 deletions

View File

@@ -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)

View File

@@ -29,7 +29,7 @@ endif ()
target_link_libraries (DecimaterGui
OpenMeshCore
OpenMeshTools
Qt5::OpenGL
${QT_TARGET}::OpenGL
${OPENGL_LIBRARIES}
)

View File

@@ -50,6 +50,7 @@
#include <OpenMesh/Tools/Utils/getopt.h>
#include <qapplication.h>
#include <qmessagebox.h>
#include <QOpenGLContext>
#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;

View File

@@ -28,7 +28,7 @@ endif ()
target_link_libraries ( ProgViewer
OpenMeshCore
OpenMeshTools
Qt5::OpenGL
${QT_TARGET}::OpenGL
${OPENGL_LIBRARIES}
)

View File

@@ -51,15 +51,20 @@
#include <OpenMesh/Apps/ProgViewer/ProgViewerWidget.hh>
#include <QString>
#include <QApplication>
#include <QGLWidget>
#if QT_VERSION_MAJOR > 5
#include <QOpenGLContext>
#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;
}

View File

@@ -30,7 +30,7 @@ endif ()
target_link_libraries (QtViewer
OpenMeshCore
OpenMeshTools
Qt5::OpenGL
${QT_TARGET}::OpenGL
${OPENGL_LIBRARIES}
)

View File

@@ -233,7 +233,7 @@ bool MeshViewerWidgetT<M>::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);

View File

@@ -60,6 +60,7 @@
#include <QImage>
#include <QDateTime>
#include <QMouseEvent>
#include <QActionGroup>
// --------------------
#include <OpenMesh/Apps/QtViewer/QGLViewerWidget.hh>
#include <OpenMesh/Tools/Utils/Timer.hh>
@@ -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();

View File

@@ -47,14 +47,15 @@
//== INCLUDES =================================================================
#include <OpenMesh/Core/Geometry/VectorT.hh>
#include <QGLWidget>
#include <string>
#include <vector>
#include <map>
#if QT_VERSION_MAJOR < 6
#include <QGLWidget>
#else
#include <QtOpenGLWidgets/QOpenGLWidget>
#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()). */

View File

@@ -44,12 +44,16 @@
#endif
#include <iostream>
#include <fstream>
#include <QApplication>
#include <QMessageBox>
#include <QMainWindow>
#include <QMenuBar>
#include <QFileDialog>
#if QT_VERSION_MAJOR > 5
#include <QOpenGLContext>
#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;

View File

@@ -28,7 +28,7 @@ endif ()
target_link_libraries (SubdividerGui
OpenMeshCore
OpenMeshTools
Qt5::OpenGL
${QT_TARGET}::OpenGL
${OPENGL_LIBRARIES}
)

View File

@@ -51,13 +51,20 @@
#include <QApplication>
#include <QMessageBox>
#include "SubdivideWidget.hh"
#if QT_VERSION_MAJOR > 5
#include <QOpenGLContext>
#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;

View File

@@ -25,6 +25,6 @@ endif ()
target_link_libraries (Synthesizer
OpenMeshCore
OpenMeshTools
Qt5::OpenGL
${QT_TARGET}::OpenGL
${OPENGL_LIBRARIES}
)

View File

@@ -49,6 +49,9 @@
#include <QString>
#include <QApplication>
#if QT_VERSION_MAJOR > 5
#include <QOpenGLContext>
#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;
}