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