-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainview.h
63 lines (49 loc) · 1.79 KB
/
mainview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef MAINVIEW_H
#define MAINVIEW_H
#include <QMouseEvent>
#include <QOpenGLDebugLogger>
#include <QOpenGLFunctions_4_1_Core>
#include <QOpenGLShaderProgram>
#include <QOpenGLWidget>
#include "mainwindow.h"
#include "mesh/mesh.h"
#include "renderers/meshrenderer.h"
/**
* @brief The MainView class represents the main view of the UI. It handles and
* orchestrates the different renderers.
*/
class MainView : public QOpenGLWidget, protected QOpenGLFunctions_4_1_Core {
Q_OBJECT
public:
MainView(QWidget* Parent = nullptr);
~MainView() override;
void updateMatrices();
void updateUniforms();
void updateBuffers(Mesh& currentMesh);
protected:
void initializeGL() override;
void resizeGL(int newWidth, int newHeight) override;
void paintGL() override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
private:
QVector2D toNormalizedScreenCoordinates(float x, float y);
QVector3D toNormalizedDeviceCoordinates(int mouse_x, int mouse_y);
QVector3D extractCameraPos();
void findClosestHalfEdge(const QVector3D& p);
QOpenGLDebugLogger debugLogger;
// for mouse interactions:
float scale;
QVector3D oldVec;
QQuaternion rotationQuaternion;
bool dragging;
MeshRenderer meshRenderer;
Settings settings;
// we make mainwindow a friend so it can access settings
friend class MainWindow ;
private slots:
void onMessageLogged(QOpenGLDebugMessage Message);
};
#endif // MAINVIEW_H