OGS
MeshMapping2DDialog.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
5
6#include <QFileDialog>
7#include <QSettings>
8
9#include "Base/OGSError.h"
11
12MeshMapping2DDialog::MeshMapping2DDialog(QDialog* parent) : QDialog(parent)
13{
14 setupUi(this);
15
16 auto* no_data_validator = new StrictDoubleValidator(this);
17 this->noDataValueEdit->setValidator(no_data_validator);
18 auto* static_value_validator = new StrictDoubleValidator(this);
19 this->staticValueEdit->setValidator(static_value_validator);
20}
21
23{
24 this->noDataValueEdit->setEnabled(!isChecked);
25}
26
28{
29 this->rasterPathEdit->setEnabled(isChecked);
30 this->ignoreNoDataCheckbox->setEnabled(isChecked);
31 this->noDataValueEdit->setEnabled(isChecked &&
32 !this->ignoreNoDataCheckbox->isChecked());
33 this->rasterSelectButton->setEnabled(isChecked);
34 this->staticValueEdit->setEnabled(!isChecked);
35}
36
38{
39 QSettings settings;
40 QString filename = QFileDialog::getOpenFileName(
41 this, "Select raster file to open",
42 settings.value("lastOpenedRasterFileDirectory").toString(),
43 "ASCII raster files (*.asc *.grd *.xyz);;All files (* *.*)");
44 this->rasterPathEdit->setText(filename);
45 QFileInfo fi(filename);
46 settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath());
47}
48
50{
51 if (this->rasterValueButton->isChecked() &&
52 this->rasterPathEdit->text().isEmpty())
53 {
54 OGSError::box("Please specify path to raster file.");
55 return;
56 }
57 if (this->rasterValueButton->isChecked() &&
58 !this->ignoreNoDataCheckbox->isChecked() &&
59 this->noDataValueEdit->text().isEmpty())
60 {
61 OGSError::box("Please specify No Data value.");
62 return;
63 }
64 if (this->staticValueButton->isChecked() &&
65 this->staticValueEdit->text().isEmpty())
66 {
67 OGSError::box("Please specify value for mapping.");
68 return;
69 }
70 if (this->newNameEdit->text().isEmpty())
71 {
72 OGSError::box("Please specify a name for the resulting mesh.");
73 return;
74 }
75 if (this->noDataValueEdit->text().isEmpty())
76 {
77 this->noDataValueEdit->setText("0.0");
78 }
79
80 this->done(QDialog::Accepted);
81}
void on_rasterValueButton_toggled(bool isChecked)
void on_ignoreNoDataCheckbox_toggled(bool isChecked)
void accept() override
Instructions if the OK-Button has been pressed.
MeshMapping2DDialog(QDialog *parent=nullptr)
static void box(const QString &e)
Definition OGSError.cpp:13
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow