started qt6 migration
This commit is contained in:
@@ -30,7 +30,7 @@ endif ()
|
||||
target_link_libraries (QtViewer
|
||||
OpenMeshCore
|
||||
OpenMeshTools
|
||||
Qt5::OpenGL
|
||||
${QT_TARGET}::OpenGL
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()). */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user