OGS
RasterDataToMeshDialog.cpp
Go to the documentation of this file.
1 
11 #include "RasterDataToMeshDialog.h"
12 
13 #include <QFileDialog>
14 #include <QSettings>
15 
16 #include "Base/OGSError.h"
18 
20  QDialog* parent)
21  : QDialog(parent)
22 {
23  setupUi(this);
24 
25  this->meshNameEdit->setText(QString::fromStdString(mesh_name) + "_Raster");
26  auto* no_data_validator = new StrictDoubleValidator(this);
27  this->noDataValueEdit->setValidator(no_data_validator);
28 }
29 
31 {
32  QSettings settings;
33  QString filename = QFileDialog::getOpenFileName(
34  this, "Select raster file to open",
35  settings.value("lastOpenedRasterFileDirectory").toString(),
36  "ASCII raster files (*.asc);;All files (* *.*)");
37  this->rasterPathEdit->setText(filename);
38  QFileInfo fi(filename);
39  settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath());
40 }
41 
43 {
44  if (this->rasterPathEdit->text().isEmpty())
45  {
46  OGSError::box("Please specify path to raster file.");
47  return;
48  }
49  else if (this->arrayNameEdit->text().isEmpty())
50  {
51  OGSError::box("Please specify a name for the new array.");
52  return;
53  }
54  else if (this->noDataValueEdit->text().isEmpty())
55  {
56  OGSError::box("Please specify No Data value.");
57  return;
58  }
59  else if (this->meshNameEdit->text().isEmpty())
60  {
61  OGSError::box("Please specify name of new mesh.");
62  return;
63  }
64 
65  this->done(QDialog::Accepted);
66 }
Definition of the OGSError class.
Implementation of the StrictDoubleValidator class.
static void box(const QString &e)
Definition: OGSError.cpp:23
RasterDataToMeshDialog(std::string const &mesh_name, QDialog *parent=nullptr)
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow