OGS
RasterDataToMeshDialog.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#include "
RasterDataToMeshDialog.h
"
5
6
#include <QFileDialog>
7
#include <QSettings>
8
9
#include "
Base/OGSError.h
"
10
#include "
Base/StrictDoubleValidator.h
"
11
12
RasterDataToMeshDialog::RasterDataToMeshDialog
(std::string
const
& mesh_name,
13
QDialog* parent)
14
: QDialog(parent)
15
{
16
setupUi(
this
);
17
18
this->meshNameEdit->setText(QString::fromStdString(mesh_name) +
"_Raster"
);
19
auto
* no_data_validator =
new
StrictDoubleValidator
(
this
);
20
this->noDataValueEdit->setValidator(no_data_validator);
21
}
22
23
void
RasterDataToMeshDialog::on_rasterSelectButton_pressed
()
24
{
25
QSettings settings;
26
QString filename = QFileDialog::getOpenFileName(
27
this
,
"Select raster file to open"
,
28
settings.value(
"lastOpenedRasterFileDirectory"
).toString(),
29
"ASCII raster files (*.asc);;All files (* *.*)"
);
30
this->rasterPathEdit->setText(filename);
31
QFileInfo fi(filename);
32
settings.setValue(
"lastOpenedRasterFileDirectory"
, fi.absolutePath());
33
}
34
35
void
RasterDataToMeshDialog::accept
()
36
{
37
if
(this->rasterPathEdit->text().isEmpty())
38
{
39
OGSError::box
(
"Please specify path to raster file."
);
40
return
;
41
}
42
else
if
(this->arrayNameEdit->text().isEmpty())
43
{
44
OGSError::box
(
"Please specify a name for the new array."
);
45
return
;
46
}
47
else
if
(this->noDataValueEdit->text().isEmpty())
48
{
49
OGSError::box
(
"Please specify No Data value."
);
50
return
;
51
}
52
else
if
(this->meshNameEdit->text().isEmpty())
53
{
54
OGSError::box
(
"Please specify name of new mesh."
);
55
return
;
56
}
57
58
this->done(QDialog::Accepted);
59
}
OGSError.h
RasterDataToMeshDialog.h
StrictDoubleValidator.h
OGSError::box
static void box(const QString &e)
Definition
OGSError.cpp:13
RasterDataToMeshDialog::accept
void accept() override
Definition
RasterDataToMeshDialog.cpp:35
RasterDataToMeshDialog::RasterDataToMeshDialog
RasterDataToMeshDialog(std::string const &mesh_name, QDialog *parent=nullptr)
Definition
RasterDataToMeshDialog.cpp:12
RasterDataToMeshDialog::on_rasterSelectButton_pressed
void on_rasterSelectButton_pressed()
Definition
RasterDataToMeshDialog.cpp:23
StrictDoubleValidator
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow
Definition
StrictDoubleValidator.h:13
Applications
DataExplorer
DataView
RasterDataToMeshDialog.cpp
Generated by
1.14.0