-
-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathglwidget.h
138 lines (111 loc) · 3.2 KB
/
glwidget.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// This file is a part of "grblControl" application.
// Copyright 2015 Hayrullin Denis Ravilevich
#ifndef GLWIDGET_H
#define GLWIDGET_H
#ifndef GLES
#include <QGLWidget>
#else
#include <QOpenGLWidget>
#endif
#include <QTimer>
#include <QTime>
#include "shaderdrawable.h"
#ifdef GLES
class GLWidget : public QOpenGLWidget
#else
class GLWidget : public QGLWidget
#endif
{
Q_OBJECT
public:
explicit GLWidget(QWidget *parent = 0);
~GLWidget();
void addDrawable(ShaderDrawable *drawable);
void updateExtremes(ShaderDrawable *drawable);
void fitDrawable(ShaderDrawable *drawable = NULL);
bool antialiasing() const;
void setAntialiasing(bool antialiasing);
QTime spendTime() const;
void setSpendTime(const QTime &spendTime);
QTime estimatedTime() const;
void setEstimatedTime(const QTime &estimatedTime);
double lineWidth() const;
void setLineWidth(double lineWidth);
void setIsometricView();
void setTopView();
void setFrontView();
void setLeftView();
int fps();
void setFps(int fps);
QString parserStatus() const;
void setParserStatus(const QString &parserStatus);
QString bufferState() const;
void setBufferState(const QString &bufferState);
bool zBuffer() const;
void setZBuffer(bool zBuffer);
bool updatesEnabled() const;
void setUpdatesEnabled(bool updatesEnabled);
bool msaa() const;
void setMsaa(bool msaa);
QColor colorBackground() const;
void setColorBackground(const QColor &colorBackground);
QColor colorText() const;
void setColorText(const QColor &colorText);
signals:
void rotationChanged();
void resized();
public slots:
private slots:
void onFramesTimer();
void viewAnimation();
private:
double m_xRot, m_yRot, m_xLastRot, m_yLastRot;
double m_xPan, m_yPan, m_xLastPan, m_yLastPan;
double m_xLookAt, m_yLookAt, m_zLookAt;
QPoint m_lastPos;
double m_zoom;
double m_distance;
double m_xMin, m_xMax, m_yMin, m_yMax, m_zMin, m_zMax, m_xSize, m_ySize, m_zSize;
double m_lineWidth;
bool m_antialiasing;
bool m_msaa;
bool m_zBuffer;
int m_frames = 0;
int m_fps = 0;
int m_targetFps;
int m_animationFrame;
QTime m_spendTime;
QTime m_estimatedTime;
QBasicTimer m_timerAnimation;
double m_xRotTarget, m_yRotTarget;
double m_xRotStored, m_yRotStored;
bool m_animateView;
QString m_parserStatus;
QString m_bufferState;
bool m_updatesEnabled;
double normalizeAngle(double angle);
double calculateVolume(QVector3D size);
void beginViewAnimation();
void stopViewAnimation();
QList<ShaderDrawable*> m_shaderDrawables;
QOpenGLShaderProgram *m_shaderProgram;
QMatrix4x4 m_projectionMatrix;
QMatrix4x4 m_viewMatrix;
QColor m_colorBackground;
QColor m_colorText;
protected:
void initializeGL();
void resizeGL(int width, int height);
void updateProjection();
void updateView();
#ifdef GLES
void paintGL();
#else
void paintEvent(QPaintEvent *pe);
#endif
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *we);
void timerEvent(QTimerEvent *);
};
#endif // GLWIDGET_H