-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
executable file
·240 lines (205 loc) · 9.89 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/*
* qZeb3D - calculating 3D-point-clouds from Georawfiles/Georohdaten of german ZEB
* Copyright (C) 2016 Christoph Jung
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
graph(new Q3DScatter()){
//load settings
if(!this->controller.loadSettings()) {
QMessageBox::information(this, "", "cannot find settings");
}
//setup all windows/dialogs
ui->setupUi(this);
//adjust the labelling of all buttons
this->ui->pushButton_import->setText(this->controller.getMessage("import"));
this->ui->pushButton_import->setToolTip(this->controller.getMessage("import"));
this->ui->actionImport->setText(this->controller.getMessage("import"));
this->ui->actionImport->setToolTip(this->controller.getMessage("import"));
this->ui->pushButton_importexport->setText(this->controller.getMessage("importexport"));
this->ui->pushButton_importexport->setToolTip(this->controller.getMessage("importexport"));
this->ui->pushButton_export->setText(this->controller.getMessage("export"));
this->ui->pushButton_export->setToolTip(this->controller.getMessage("export"));
this->ui->actionExport->setText(this->controller.getMessage("export"));
this->ui->actionExport->setToolTip(this->controller.getMessage("export"));
this->ui->actionInfo->setToolTip(this->controller.getMessage("information"));
this->ui->menuLanguage->setTitle(this->controller.getMessage("lang"));
this->ui->menuFile->setTitle(this->controller.getMessage("file"));
this->initViewer();
}
MainWindow::~MainWindow() {
delete ui;
}
void MainWindow::on_pushButton_import_clicked() {
QString filename = this->importData();
if(filename != "") {
//display the pointcloud
this->displayZebTrack(this->controller.getDataName(filename, "zeb"));
}
}
QString MainWindow::importData() {
//open FileDialog
QString filename = QFileDialog::getOpenFileName(
this,
this->controller.getMessage("openfile"),
this->controller.getSetting("importpath"),
this->controller.getMessage("allfiles") + " (*.*);;" + controller.getMessage("zebfiles") + " (*.xml)");
if(filename.isEmpty()) {
QMessageBox::information(this, this->controller.getMessage("information"), this->controller.getMessage("nofileselected"));
} else {
//store the selected path in settings
this->controller.setSetting("importpath", QFileInfo(filename).dir().absolutePath());
int result = this->controller.importSingleTrack(filename, this->ui->textEdit);
switch (result) {
case -1:
QMessageBox::information(this, this->controller.getMessage("information"), controller.getMessage("cannotfindtp3"));
break;
case -2:
QMessageBox::warning(this, this->controller.getMessage("problem"), controller.getMessage("cannotfind1a1b"));
break;
case -3:
QMessageBox::warning(this, this->controller.getMessage("problem"), controller.getMessage("cannotimporttp1a"));
break;
case -4:
QMessageBox::warning(this, this->controller.getMessage("problem"), controller.getMessage("cannotimporttp1b"));
break;
case -5:
QMessageBox::information(this, this->controller.getMessage("information"), controller.getMessage("cannotimporttp3"));
break;
default:
break;
}
//add the imported track to the gui/tree widget, if import was successfull
if(result == 0 || result == -1 || result == -5) {
//create root element
QTreeWidgetItem *item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, this->controller.getDataName(filename, "zeb"));
//ui->treeWidget->addTopLevelItem(item);
//create element for TP1a
QTreeWidgetItem *item1a = new QTreeWidgetItem();
item1a->setText(0, "TP1a");
item->addChild(item1a);
//create element for TP1b
QTreeWidgetItem *item1b = new QTreeWidgetItem();
item1b->setText(0, "TP1b");
item->addChild(item1b);
//create element for TP3
if(result == 0) {
QTreeWidgetItem *item3 = new QTreeWidgetItem();
item3->setText(0, "TP3");
item->addChild(item3);
}
//create a pointcloud from the given zeb-track
controller.convertZebToPointCloud(controller.getDataName(filename, "zeb"), ui->progressBar, 5, this->ui->textEdit);
return filename;
} else {
this->ui->textEdit->insertPlainText(
QDateTime::currentDateTime().toString() +
" - " + this->controller.getMessage("notabletocalcualtepointcloud") + "\n");
return "";
}
}
}
void MainWindow::displayZebTrack(QString trackNumber) {
//init data-objects
this->graphProxy = new QScatterDataProxy();
this->graphSeries = new QScatter3DSeries(this->graphProxy);
this->graphSeries->setItemLabelFormat(QStringLiteral("@xTitle: @xLabel @yTitle: @yLabel @zTitle: @zLabel"));
this->graphSeries->setMeshSmooth(true);
this->graph->addSeries(graphSeries);
//populate the data-array
QScatterDataArray *dataArray = new QScatterDataArray;
this->controller.loadPointCloudDataArray(trackNumber, dataArray);
//set data-array into proxy
this->graphProxy->resetArray(dataArray);
this->graph->show();
}
void MainWindow::initViewer() {
this->container = QWidget::createWindowContainer(graph);
this->ui->verticalLayout->addWidget(this->container);
if (!graph->hasContext()) {
QMessageBox::warning(this, this->controller.getMessage("information"), this->controller.getMessage("opengl"));
}
this->graph->activeTheme()->setType(Q3DTheme::Theme(0));
QFont font = this->graph->activeTheme()->font();
font.setPointSize(40.0f);
this->graph->activeTheme()->setFont(font);
this->graph->setShadowQuality(QAbstract3DGraph::ShadowQualitySoftLow);
this->graph->scene()->activeCamera()->setCameraPreset(Q3DCamera::CameraPresetFront);
// Configure the axes according to the data
this->graph->axisX()->setTitle(QStringLiteral("Latitude"));
this->graph->axisY()->setTitle(QStringLiteral("Height"));
this->graph->axisZ()->setTitle(QStringLiteral("Longitude"));
this->graph->axisX()->setAutoAdjustRange(true);
this->graph->axisY()->setAutoAdjustRange(true);
this->graph->axisZ()->setAutoAdjustRange(true);
}
void MainWindow::on_pushButton_export_clicked() {
this->exportData(this->ui->treeWidget->selectedItems().at(0)->text(0));
}
void MainWindow::exportData(QString track) {
QString filename = QFileDialog::getSaveFileName(
this,
this->controller.getMessage("exportfile"),
this->controller.getSetting("exportpath"),
this->controller.getMessage("allfiles") + " (*.*);;" +
this->controller.getMessage("zebfiles") + " (*.xml)");
if(filename.isEmpty()) {
QMessageBox::information(this, this->controller.getMessage("information"), this->controller.getMessage("notrackselected"));
} else {
//store the selected path in settings
this->controller.setSetting("exportpath", QFileInfo(filename).dir().absolutePath());
//start export
this->controller.exportPointCloud(filename, track, this->ui->progressBar, this->ui->textEdit);
}
}
void MainWindow::on_actionImport_triggered() {
this->on_pushButton_import_clicked();
}
void MainWindow::on_actionExport_triggered() {
this->on_pushButton_export_clicked();
}
void MainWindow::on_actionEnglish_triggered() {
this->controller.setSetting("language", "en");
QMessageBox::information(this, this->controller.getMessage("information"), "please restart the software to change the language");
}
void MainWindow::on_actionFrench_triggered() {
this->controller.setSetting("language", "fr");
QMessageBox::information(this, this->controller.getMessage("information"), "veuillez redémarrer le logiciel pour changer la langue");
}
void MainWindow::on_actionGerman_triggered() {
this->controller.setSetting("language", "de");
QMessageBox::information(this, this->controller.getMessage("information"), "bitte das Programm neustarten, um die Sprache zu wechseln");
}
void MainWindow::on_actionPolish_triggered() {
this->controller.setSetting("language", "pl");
QMessageBox::information(this, this->controller.getMessage("information"), "proszę zrestartuj oprogramowanie, aby zmienić język");
}
void MainWindow::on_actionInfo_triggered() {
QMessageBox::about(this, "",
this->controller.getSetting("appname") + "\n" +
"Version: " + this->controller.getSetting("appversion") + "\n" +
"written by: " + this->controller.getSetting("appauthor") + "\n" +
"GitHub: " + this->controller.getSetting("appgithub"));
}
void MainWindow::on_pushButton_importexport_clicked() {
QString filename = this->importData();
this->exportData(this->controller.getDataName(filename, "zeb"));
}