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