-
Notifications
You must be signed in to change notification settings - Fork 13
/
openglscene.h
122 lines (100 loc) · 3.25 KB
/
openglscene.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
/*
*
* Copyright (C) 2015 Miroslav Krajicek (https://github.com/kaajo).
* All Rights Reserved.
*
* This file is part of WebCamCap.
*
* WebCamCap is free software: you can redistribute it and/or modify
* it under the terms of the GNU LGPL version 3 as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebCamCap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU LGPL version 3
* along with WebCamCap. If not, see <http://www.gnu.org/licenses/lgpl-3.0.txt>.
*
*/
#ifndef OPENGLSCENE_H
#define OPENGLSCENE_H
#include "webcamcapgui_global.h"
#include "frame.h"
#include "camerasettings.h"
#include <QColor>
#include <QVector>
#include <QVector2D>
#include <QVector3D>
#include <QOpenGLWidget>
#include <GL/glu.h>
#include <memory>
/**
* @author Miroslav Krajicek
* @brief The OpenGlScene class is widget for drawing #Frame or whole #Animation . It should be singleton.
*/
class WEBCAMCAPGUISHARED_EXPORT OpenGlScene : public QOpenGLWidget
{
static OpenGlScene *m_scene;
QVector3D m_roomDims = QVector3D(100,100,100);
QVector<std::shared_ptr<CameraSettings>> m_camSettings;
QVector<QPair<int,int>> m_Topology;
//paint props
QVector<QColor> m_randomColors;
bool m_drawJoints = true;
bool m_drawLines = true;
QPoint m_camRot = QPoint(0,0);
float m_zoom = 1.0;
//mouse tracking
bool m_leftButton = false;
bool m_rightButton = false;
QPoint m_lastMousePos, m_currentMousePos;
Frame m_actualFrame;
//some glu mess
GLUquadricObj *m_sphereQuadric = gluNewQuadric();
GLUquadricObj *m_cubeQuadric = gluNewQuadric();
public:
/**
* @brief OpenGlScene default constructor
* @param parent
*/
explicit OpenGlScene(QWidget *parent = 0);
/**
* @brief For bottom rectangle, #OpenGlScene needs to know size of #IVirtualRoom.
* @param m_roomDims Room dimensions
*/
void setRoomDimensions(QVector3D m_roomDims);
/**
* @brief For camera position preview, #OpenGlScene needs to know position
* and direction vector of every #ICamera in the virtual scene.
* @param settings All #CameraSettings in #IVirtualRoom
*/
void setCamerasSettings(QVector<std::shared_ptr<CameraSettings>> settings);
/**
* @brief Static function for using #OpenGlScene as singleton.
* @return Singleton
*/
static OpenGlScene *getInstance();
public slots:
/**
* @brief SLOT which sets actual frame to scene. #OpenGlScene draws every #Line and #Marker in \a frame
* @param frame
*/
void setFrame(Frame frame);
private:
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
void paintScene();
void paintCameras();
void paintTopology();
void paintFrame();
void mousePressEvent(QMouseEvent * event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void drawLine(const Line &line) const;
void generateRandomColors(int count);
};
#endif // OPENGLSCENE_H