-
Notifications
You must be signed in to change notification settings - Fork 2
/
myglwidget.h
91 lines (78 loc) · 2.57 KB
/
myglwidget.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
#ifndef MYGLWIDGET_H
#define MYGLWIDGET_H
#include <QtOpenGLWidgets/QOpenGLWidget>
#include <QMatrix4x4>
#include <QOpenGLFunctions>
class MyGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
explicit MyGLWidget(QWidget *parent = 0);
void setVoxels(int16_t*** voxels, short int numCubes);
void repaint_function();
QVector<int> countVoxelColors(); // Функція для підрахунку кількості вокселей кожного кольору
void exportVRML(const QString& filename, const std::vector<std::array<GLubyte, 4>>& colors);
std::vector<std::array<GLubyte, 4>> generateDistinctColors();
void calculateSurfaceArea();
~MyGLWidget();
int cubeSize = 1;
signals:
protected:
struct Voxel;
void initializeGL();
void paintGL();
void resizeGL(int width, int height);
void paintSphere(float radius, int numStacks, int numSlices);
void drawCube(float cubeSize, GLenum type = GL_QUADS);
void drawCube(short cubeSize, Voxel v);
QSize minimumSizeHint() const;
QSize sizeHint() const;
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void calculateScene();
public slots:
// slots for xyz-rotation slider
void setXRotation(int angle);
void setYRotation(int angle);
void setZRotation(int angle);
void setNumCubes(int numCubes);
void setNumColors(int numColors);
void setDistanceFactor(int factor);
void setDelayAnimation(int delayAnimation);
void update_function();
//void explodeCubes(int value);
//void setColorDistanceFactor(float factor);
void updateGLWidget(int16_t*** voxels, short int numCubes);
signals:
// signaling rotation from mouse movement
void xRotationChanged(int angle);
void yRotationChanged(int angle);
void zRotationChanged(int angle);
private:
QTimer* timer;
protected:
int xRot;
int yRot;
int zRot;
int delayAnimation;
float distance;
QPoint lastPos;
QMatrix4x4 m_projection;
float distanceFactor = 0;
//float colordistanceFactor;
int16_t*** voxels;
short int numCubes;
int numColors;
std::vector<std::array<GLubyte, 4>> colors;
std::vector<float> directionFactors;
struct Voxel
{
GLshort x, y, z;
GLubyte r, g, b, a; // Color attributes
GLbyte nx, ny, nz; // Normal attributes
};
std::vector<Voxel> voxelScene;
bool plotWireFrame = false;
};
#endif // MYGLWIDGET_H