OGS
MeshMapping2DDialog Class Reference

Detailed Description

A dialog window for mapping a 2d mesh based on a raster file.

Definition at line 15 of file MeshMapping2DDialog.h.

#include <MeshMapping2DDialog.h>

Inheritance diagram for MeshMapping2DDialog:
[legend]
Collaboration diagram for MeshMapping2DDialog:
[legend]

Public Member Functions

 MeshMapping2DDialog (QDialog *parent=nullptr)
bool useRasterMapping () const
bool useStaticMapping () const
std::string getRasterPath () const
double getNoDataReplacement () const
bool getIgnoreNoData () const
double getStaticValue () const
std::string getNewMeshName () const

Private Slots

void on_ignoreNoDataCheckbox_toggled (bool isChecked)
void on_rasterValueButton_toggled (bool isChecked)
void on_rasterSelectButton_pressed ()
void accept () override
 Instructions if the OK-Button has been pressed.
void reject () override
 Instructions if the Cancel-Button has been pressed.

Constructor & Destructor Documentation

◆ MeshMapping2DDialog()

MeshMapping2DDialog::MeshMapping2DDialog ( QDialog * parent = nullptr)
explicit

Definition at line 12 of file MeshMapping2DDialog.cpp.

12 : 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}

Member Function Documentation

◆ accept

void MeshMapping2DDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 49 of file MeshMapping2DDialog.cpp.

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}
static void box(const QString &e)
Definition OGSError.cpp:13

References OGSError::box().

◆ getIgnoreNoData()

bool MeshMapping2DDialog::getIgnoreNoData ( ) const
inline

Definition at line 26 of file MeshMapping2DDialog.h.

26{ return this->ignoreNoDataCheckbox->isChecked(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ getNewMeshName()

std::string MeshMapping2DDialog::getNewMeshName ( ) const
inline

Definition at line 28 of file MeshMapping2DDialog.h.

28{ return this->newNameEdit->text().toStdString(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ getNoDataReplacement()

double MeshMapping2DDialog::getNoDataReplacement ( ) const
inline

Definition at line 25 of file MeshMapping2DDialog.h.

25{ return this->noDataValueEdit->text().toDouble(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ getRasterPath()

std::string MeshMapping2DDialog::getRasterPath ( ) const
inline

Definition at line 24 of file MeshMapping2DDialog.h.

24{ return this->rasterPathEdit->text().toStdString(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ getStaticValue()

double MeshMapping2DDialog::getStaticValue ( ) const
inline

Definition at line 27 of file MeshMapping2DDialog.h.

27{ return this->staticValueEdit->text().toDouble(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ on_ignoreNoDataCheckbox_toggled

void MeshMapping2DDialog::on_ignoreNoDataCheckbox_toggled ( bool isChecked)
privateslot

Definition at line 22 of file MeshMapping2DDialog.cpp.

23{
24 this->noDataValueEdit->setEnabled(!isChecked);
25}

◆ on_rasterSelectButton_pressed

void MeshMapping2DDialog::on_rasterSelectButton_pressed ( )
privateslot

Definition at line 37 of file MeshMapping2DDialog.cpp.

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}

◆ on_rasterValueButton_toggled

void MeshMapping2DDialog::on_rasterValueButton_toggled ( bool isChecked)
privateslot

Definition at line 27 of file MeshMapping2DDialog.cpp.

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}

◆ reject

void MeshMapping2DDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 39 of file MeshMapping2DDialog.h.

39{ this->done(QDialog::Rejected); }

◆ useRasterMapping()

bool MeshMapping2DDialog::useRasterMapping ( ) const
inline

Definition at line 22 of file MeshMapping2DDialog.h.

22{ return this->rasterValueButton->isChecked(); }

Referenced by MeshView::openMap2dMeshDialog().

◆ useStaticMapping()

bool MeshMapping2DDialog::useStaticMapping ( ) const
inline

Definition at line 23 of file MeshMapping2DDialog.h.

23{ return this->staticValueButton->isChecked(); }

The documentation for this class was generated from the following files: