74 lines
1.4 KiB
C++
74 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "geometryengine.h"
|
|
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QMatrix4x4>
|
|
#include <QQuaternion>
|
|
#include <QVector2D>
|
|
#include <QBasicTimer>
|
|
#include <QOpenGLShaderProgram>
|
|
|
|
|
|
class GeometryEngine;
|
|
|
|
class OglViewerWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit OglViewerWidget(QWidget *parent = 0);
|
|
~OglViewerWidget();
|
|
|
|
signals:
|
|
void loadFile(QString);
|
|
|
|
private:
|
|
struct {
|
|
bool left = false;
|
|
bool right = false;
|
|
QVector2D position;
|
|
} m_mouse;
|
|
|
|
struct {
|
|
bool x = true;
|
|
bool y = true;
|
|
bool z = true;
|
|
} m_rotDirections;
|
|
|
|
QOpenGLShaderProgram m_program;
|
|
GeometryEngine *m_dataEngine;
|
|
|
|
QMatrix4x4 m_projection;
|
|
QVector3D m_translation;
|
|
QQuaternion m_rotation;
|
|
|
|
bool m_wireframe = false;
|
|
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
|
void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
|
|
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
|
|
void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE;
|
|
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void initializeGL() Q_DECL_OVERRIDE;
|
|
void resizeGL(int w, int h) Q_DECL_OVERRIDE;
|
|
void paintGL() Q_DECL_OVERRIDE;
|
|
|
|
private:
|
|
void initShaders();
|
|
void setConnections();
|
|
|
|
private slots:
|
|
void resetView();
|
|
|
|
public slots:
|
|
void changeDirection(int direction);
|
|
void toggleWireframe();
|
|
};
|
|
|