-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGLMainWidget.cpp
More file actions
79 lines (67 loc) · 1.38 KB
/
Copy pathGLMainWidget.cpp
File metadata and controls
79 lines (67 loc) · 1.38 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
#include"GLMainWidget.h"
#include"RoamingScenceManager.h"
#include<QMouseEvent>
#include<QWheelEvent>
#include<QDebug>
#include <QLabel.h>
GLMainWidget::GLMainWidget(QWidget *parent) :
QGLWidget(parent)
{
this->setFocusPolicy(Qt::StrongFocus);
manager=new RoamingScenceManager();
}
GLMainWidget::~GLMainWidget()
{
delete manager;
}
void GLMainWidget::setTxtName(QString filename)
{
QByteArray ba = filename.toLocal8Bit();
char *c_str = ba.data();
//char* ch;
//QByteArray ba = filename.toLatin1();
//ch = ba.data();
manager->loadPointCloudPLY(c_str);
}
void GLMainWidget::initializeGL()
{
manager->init();
}
void GLMainWidget::resizeGL(int w, int h)
{
glViewport(0,-(w-h)/2,w,w);
}
void GLMainWidget::paintGL()
{
manager->render();
}
void GLMainWidget::mousePressEvent(QMouseEvent *e)
{
manager->getInitPos(e->x(),e->y());
}
void GLMainWidget::mouseMoveEvent(QMouseEvent *e)
{
if(e->buttons()&Qt::MiddleButton)
{
if(e->modifiers()==Qt::CTRL)
{
manager->executeTranslateOperation(e->x(),e->y());
}
else
{
manager->executeRotateOperation(e->x(),e->y());
}
}
updateGL();
}
void GLMainWidget::wheelEvent(QWheelEvent *e)
{
if(e->delta()>=0)
{
manager->executeScaleOperation(-0.1);
}else
{
manager->executeScaleOperation(0.1);
}
updateGL();
}