OGS
MeshMapping2DDialog Class Reference

Detailed Description

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

Definition at line 22 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 19 of file MeshMapping2DDialog.cpp.

19 : 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}
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow

Member Function Documentation

◆ accept

void MeshMapping2DDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 56 of file MeshMapping2DDialog.cpp.

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

References OGSError::box().

◆ getIgnoreNoData()

bool MeshMapping2DDialog::getIgnoreNoData ( ) const
inline

Definition at line 33 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ getNewMeshName()

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

Definition at line 35 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ getNoDataReplacement()

double MeshMapping2DDialog::getNoDataReplacement ( ) const
inline

Definition at line 32 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ getRasterPath()

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

Definition at line 31 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ getStaticValue()

double MeshMapping2DDialog::getStaticValue ( ) const
inline

Definition at line 34 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ on_ignoreNoDataCheckbox_toggled

void MeshMapping2DDialog::on_ignoreNoDataCheckbox_toggled ( bool isChecked)
privateslot

Definition at line 29 of file MeshMapping2DDialog.cpp.

30{
31 this->noDataValueEdit->setEnabled(!isChecked);
32}

◆ on_rasterSelectButton_pressed

void MeshMapping2DDialog::on_rasterSelectButton_pressed ( )
privateslot

Definition at line 44 of file MeshMapping2DDialog.cpp.

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}

◆ on_rasterValueButton_toggled

void MeshMapping2DDialog::on_rasterValueButton_toggled ( bool isChecked)
privateslot

Definition at line 34 of file MeshMapping2DDialog.cpp.

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}

◆ reject

void MeshMapping2DDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 46 of file MeshMapping2DDialog.h.

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

◆ useRasterMapping()

bool MeshMapping2DDialog::useRasterMapping ( ) const
inline

Definition at line 29 of file MeshMapping2DDialog.h.

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

Referenced by MeshView::openMap2dMeshDialog().

◆ useStaticMapping()

bool MeshMapping2DDialog::useStaticMapping ( ) const
inline

Definition at line 30 of file MeshMapping2DDialog.h.

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

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