-
Notifications
You must be signed in to change notification settings - Fork 4
/
openglwidget.h
120 lines (88 loc) · 3.51 KB
/
openglwidget.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
/*#--------------------------------------------------------------*
#
# openGL Widget
# for dominant colors in 3D color spaces
#
# by AbsurdePhoton - www.absurdephoton.fr
#
# v2.3 - 2023/03/10
# - Lights
# - Mouse control :
# . zoom with wheel
# . rotate view on x/y axes with left mouse button
# . rotate view on z axis with CTRL + left mouse button
# . move view on x/y axes with right mouse button
# . sphere size with CTRL + wheel
#
# * QT signals sent when zoomed, moved, rotated, sphere size
#
# * Public access to zoom, position and rotation
#
# * Draw values in color spaces
#
#--------------------------------------------------------------*/
#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H
#include <QOpenGLWidget>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
#include "opencv2/opencv.hpp"
#include "palette.h"
class openGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
explicit openGLWidget(QWidget *parent = 0);
~openGLWidget();
struct_palette palettes[5000]; // 5000 is very large !
int nb_palettes; // number of colors in palette
int sphere_size; // size factor for spheres
double xRot, yRot, zRot; // rotation values
int xShift, yShift; // position values
double zoom3D; // zoom coefficient
bool axesEnabled; // draw 3D origin axes
bool lightEnabled; // light
bool qualityEnabled; // antialiasing
QImage capture3D; // image of captured 3D scene
std::string color_space; // color space to plot
float size3d;
void Capture(); // take a snapshot of rendered 3D scene
void ConvertPaletteFromRGB(); // from a RGB value, convert all palette to all color spaces
void ConvertPaletteFromLAB(); // from a CIE L*a*b* value, convert all palette to all color spaces
void DrawSpherePlus(const int &ndiv, const float &radius, const float &x, float y, float z, float r, float g, float b, const bool circle, const bool visible); // draw a sphere with a white circle if colorChosen equal (r,g,b)
protected:
void initializeGL(); // launched when the widget is initialized
void paintGL(); // 3D rendering
void resizeGL(int width, int height); // called when the widget is resized
void mousePressEvent(QMouseEvent *event); // save initial mouse position for move and rotate
void mouseMoveEvent(QMouseEvent *event); // move and rotate view with mouse buttons
void wheelEvent(QWheelEvent *event); // zoom
public slots:
void SetXRotation(int angle); // rotate view
void SetYRotation(int angle);
void SetZRotation(int angle);
void SetAngleXMinus();
void SetAngleXPlus();
void SetAngleYMinus();
void SetAngleYPlus();
void SetAngleZMinus();
void SetAngleZPlus();
void SetXShift(int value); // move view
void SetYShift(int value);
void SetShiftUp();
void SetShiftDown();
void SetShiftLeft();
void SetShiftRight();
void SetSphereSize(int size); // factor to increase or decrease sphere size
signals:
void xRotationChanged(int angle); // rotation signals
void yRotationChanged(int angle);
void zRotationChanged(int angle);
void xShiftChanged(int dec); // move signals
void yShiftChanged(int dec);
void zoomChanged(double zoom); // zoom signal
void sphereSizeChanged(int size); // zoom signal
private:
QPoint lastPos; // save mouse position
};
#endif // OPENGLWIDGET_H