-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglframe.cpp
More file actions
executable file
·104 lines (84 loc) · 2.32 KB
/
glframe.cpp
File metadata and controls
executable file
·104 lines (84 loc) · 2.32 KB
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
#include <QResizeEvent>
#include "glframe.h"
#include <iostream>
#include <vector>
using namespace std;
GLFrame::GLFrame (QWidget *parent) :
QGLWidget (parent),
RenderThread (this)
{
setFocusPolicy (Qt::StrongFocus);
setAutoBufferSwap (false);
Ctrl_or_Meta_key_pressed = false;
Alt_key_pressed = false;
}
GLFrame::~GLFrame() {}
void GLFrame::initRenderThread (void)
{
doneCurrent();
RenderThread.start();
}
void GLFrame::resumeRenderThread (void)
{
RenderThread.resume();
}
void GLFrame::stopRenderThread (void)
{
RenderThread.stop();
RenderThread.wait();
}
void GLFrame::pauseRenderThread (void)
{
RenderThread.stop();
}
void GLFrame::delegateSetPointCloud (PointCloud *point_cloud)
{
RenderThread.setPointCloud (point_cloud);
}
void GLFrame::DelegateCameraPyramidAddition (cv::Mat_<double> &camera_matrix, int rows, int cols)
{
RenderThread.addCameraPyramid (camera_matrix, rows, cols);
}
////////////////
void GLFrame::resizeEvent (QResizeEvent *event)
{
RenderThread.resizeViewport (event->size());
}
void GLFrame::paintEvent (QPaintEvent *)
{
// Do nothing. Let the thread do the heavy lifting.
}
void GLFrame::closeEvent (QCloseEvent *event)
{
stopRenderThread();
QGLWidget::closeEvent (event);
}
void GLFrame::wheelEvent (QWheelEvent *event)
{
if (this->getCtrlMetaFlag() == true)
{
RenderThread.updateCameraDistanceFromCenter (event->delta());
}
}
void GLFrame::focusInEvent (QFocusEvent *event)
{
cout << "focus In" << endl;
this->resumeRenderThread ();
}
void GLFrame::focusOutEvent (QFocusEvent *event)
{
cout << "focus Out" << endl;
this->pauseRenderThread ();
}
void GLFrame::keyPressEvent (QKeyEvent *event)
{
if (event->key() == Qt::Key_Control or event->key() == Qt::Key_Meta) {Ctrl_or_Meta_key_pressed = true;}
if (event->key() == Qt::Key_Alt) {Alt_key_pressed = true;}
}
void GLFrame::keyReleaseEvent (QKeyEvent *event)
{
if (event->key() == Qt::Key_Control or event->key() == Qt::Key_Meta) {Ctrl_or_Meta_key_pressed = false;}
if (event->key() == Qt::Key_Alt) {Alt_key_pressed = false;}
}
bool GLFrame::getCtrlMetaFlag () {return Ctrl_or_Meta_key_pressed;}
bool GLFrame::getAltFlag () {return Alt_key_pressed;}