-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathopenglwindow.cpp
92 lines (77 loc) · 2.65 KB
/
openglwindow.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
#include "openglwindow.h"
#include "ui_openglwindow.h"
// 引入GDAL头文件
#include "ogrsf_frmts.h"
float *gdalDemo();
OpenGLWindow::OpenGLWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::OpenGLWindow) {
ui->setupUi(this);
RenderLayer::windowUi = this->ui;
RenderLayer::window = this;
}
OpenGLWindow::~OpenGLWindow() { delete ui; }
void OpenGLWindow::on_pushButton_clicked() {
QString curPath = QDir::currentPath(); //获取系统当前目录
QString dlgTitle = "Open a File"; //对话框标题
QString filter =
"Shape File(*.shp);;Program File(*.h *.cpp);;txt "
"File(*.txt);;All File(*.*)"; //文件过滤器
QString aFileName =
QFileDialog::getOpenFileName(this, dlgTitle, curPath, filter);
qDebug() << "Chosen File Path: " << aFileName;
// C++中不存在对象为null,对象一定是对应内存空间的。
// Java中的对象为空,对应C++中指针为空,即不指向任何对象。
if (aFileName.isEmpty()) {
qDebug() << "Cancel File Choose";
return;
}
RenderLayer *layer = new RenderLayer(aFileName.toStdString().data());
ui->openGLWidget->layers.append(layer);
ui->openGLWidget->boundary = &(layer->boundaryQ);
ui->openGLWidget->update();
}
void OpenGLWindow::displaySelection() {
ui->textEdit->setWindowFlag(Qt::Window);
ui->textEdit->show();
QString str;
for (RenderLayer *layer : ui->openGLWidget->layers) {
str += layer->queryString;
str += "\n";
}
ui->textEdit->setText(str);
}
void OpenGLWindow::on_checkBox_toggled(bool checked) {
ui->openGLWidget->displaySpeed = ui->lineEdit_3->text().toFloat();
ui->openGLWidget->displayMode = checked;
}
void OpenGLWindow::on_checkBox_2_toggled(bool checked) {
ui->openGLWidget->gameMode = checked;
}
void OpenGLWindow::on_checkBox_3_toggled(bool checked) {
ui->openGLWidget->rotate(checked);
ui->openGLWidget->rotateHeight = ui->lineEdit->text().toFloat();
}
void OpenGLWindow::on_pushButton_2_clicked() {
for (RenderLayer *layer : ui->openGLWidget->layers) {
layer->calculateDensity(ui->lineEdit_4->text().toFloat(),
ui->lineEdit_5->text().toFloat());
}
}
void OpenGLWindow::on_pushButton_3_clicked() {
for (RenderLayer *layer : ui->openGLWidget->layers) {
if (layer->geoType == 0) {
layer->layerHeight = ui->lineEdit_2->text().toFloat();
}
}
}
void OpenGLWindow::on_pushButton_4_clicked() {
for (RenderLayer *layer : ui->openGLWidget->layers) {
delete layer;
}
ui->openGLWidget->layers.clear();
}
void OpenGLWindow::on_checkBox_4_toggled(bool checked) {
for (RenderLayer *layer : ui->openGLWidget->layers) {
layer->concreteSelect = checked;
}
}