-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
119 lines (101 loc) · 3.58 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "iostream"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QLabel>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this);
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(3, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
glwidget = this->findChild<MyGLWidget *>("glwidget");
glwidget->setFormat(format);
xSlider = createVerticalSlider();
ySlider = createVerticalSlider();
zSlider = createVerticalSlider();
ui->horizontalLayout->addWidget(xSlider);
ui->horizontalLayout->addWidget(ySlider);
ui->horizontalLayout->addWidget(zSlider);
connect(xSlider, &QSlider::valueChanged, glwidget, &MyGLWidget::setXRotation);
connect(glwidget, &MyGLWidget::xRotationChanged, xSlider, &QSlider::setValue);
connect(ySlider, &QSlider::valueChanged, glwidget, &MyGLWidget::setYRotation);
connect(glwidget, &MyGLWidget::yRotationChanged, ySlider, &QSlider::setValue);
connect(zSlider, &QSlider::valueChanged, glwidget, &MyGLWidget::setZRotation);
connect(glwidget, &MyGLWidget::zRotationChanged, zSlider, &QSlider::setValue);
ui->cellLength->setVisible(false);
ui->curve->setVisible(false);
statusLabel = new QLabel();
ui->statusBar->addWidget(statusLabel);
connect(glwidget, &MyGLWidget::celllengthChange, this, &MainWindow::setCell);
connect(glwidget, &MyGLWidget::curvChange, this, &MainWindow::setCurv);
connect(glwidget, &MyGLWidget::showCurrentStatus, this,
&MainWindow::setStatusMessage);
}
MainWindow::~MainWindow() { delete ui; }
void MainWindow::on_openfile_triggered() {
QString modelFilePath = QFileDialog::getOpenFileName(
this, tr("选择模型文件"), "./", tr("点云模型 (*.xyz)"));
std::cout << modelFilePath.toStdString() << std::endl;
glwidget->setPointCloud(modelFilePath.toStdString());
glwidget->setDisplayPercent(100);
ui->cellLength->setVisible(false);
ui->curve->setVisible(false);
}
void MainWindow::on_curvSimplify_triggered() {
currentSimplify = curva;
ui->curve->setVisible(true);
glwidget->curvSimplify(ui->curve->value());
}
QSlider *MainWindow::createVerticalSlider() {
QSlider *slider = new QSlider(Qt::Vertical);
slider->setRange(0, 360 * 16);
slider->setSingleStep(16);
slider->setPageStep(15 * 16);
slider->setTickInterval(15 * 16);
slider->setTickPosition(QSlider::TicksRight);
return slider;
}
void MainWindow::on_curve_valueChanged(double arg1) {
glwidget->setDisplayPercent(arg1);
}
void MainWindow::setCell(double val) {
ui->cellLength->setVisible(true);
ui->cellLength->setValue(val);
}
void MainWindow::setCurv(float val) {
ui->curve->setVisible(true);
ui->curve->setValue(val);
}
void MainWindow::on_cellLength_valueChanged(double arg1) {
switch (currentSimplify) {
case curva:
glwidget->curvSimplify(arg1);
break;
case average:
glwidget->averageSimplify(arg1);
break;
case averagedbscan:
glwidget->averageSimplifyDBSCAN(arg1);
break;
}
}
void MainWindow::setStatusMessage(const QString &mess, int timeout) {
statusLabel->setText(mess);
}
void MainWindow::on_action_triggered() {
currentSimplify = average;
ui->cellLength->setVisible(true);
ui->curve->setVisible(false);
glwidget->setDisplayPercent(100);
glwidget->averageSimplify(ui->cellLength->value());
}
void MainWindow::on_action_2_triggered() {
currentSimplify = averagedbscan;
ui->cellLength->setVisible(true);
ui->curve->setVisible(false);
glwidget->setDisplayPercent(100);
glwidget->averageSimplifyDBSCAN(ui->cellLength->value());
}