OGS
CondFromRasterDialog Class Reference

Detailed Description

A dialog window for creating DIRECT boundary conditions from raster files.

Definition at line 29 of file CondFromRasterDialog.h.

#include <CondFromRasterDialog.h>

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

Signals

void directNodesWritten (std::string)
 
void transmitDisValues (std::vector< std::pair< std::size_t, double > >)
 

Public Member Functions

 CondFromRasterDialog (std::vector< MeshLib::Mesh * > msh_vec, QDialog *parent=nullptr)
 
 ~CondFromRasterDialog () override
 

Private Slots

void on_integrateButton_toggled (bool isSelected)
 
void on_selectButton_pressed ()
 
void accept () override
 Instructions if the OK-Button has been pressed.
 
void reject () override
 Instructions if the Cancel-Button has been pressed.
 

Private Attributes

const std::vector< MeshLib::Mesh * > _msh_vec
 
StrictDoubleValidator_scale_validator
 

Constructor & Destructor Documentation

◆ CondFromRasterDialog()

CondFromRasterDialog::CondFromRasterDialog ( std::vector< MeshLib::Mesh * > msh_vec,
QDialog * parent = nullptr )
explicit

Definition at line 26 of file CondFromRasterDialog.cpp.

28 : QDialog(parent), _msh_vec(std::move(msh_vec))
29{
30 setupUi(this);
31
32 this->scalingEdit->setEnabled(false);
33 _scale_validator = new StrictDoubleValidator(-1e+10, 1e+20, 5);
34 this->scalingEdit->setText("1.0");
35 this->scalingEdit->setValidator(_scale_validator);
36
37 for (auto mesh : _msh_vec)
38 {
39 this->meshBox->addItem(QString::fromStdString(mesh->getName()));
40 }
41
42 this->directButton->setChecked(true);
43}
StrictDoubleValidator * _scale_validator
const std::vector< MeshLib::Mesh * > _msh_vec
A validator for an input field which only accepts decimals. Source code adapted from StackOverflow

References _msh_vec, and _scale_validator.

◆ ~CondFromRasterDialog()

CondFromRasterDialog::~CondFromRasterDialog ( )
override

Definition at line 45 of file CondFromRasterDialog.cpp.

46{
47 delete _scale_validator;
48}

References _scale_validator.

Member Function Documentation

◆ accept

void CondFromRasterDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 72 of file CondFromRasterDialog.cpp.

73{
74 std::string mesh_name(this->meshBox->currentText().toStdString());
75 std::string raster_name(this->rasterEdit->text().toStdString());
76 double scaling_factor = this->scalingEdit->text().toDouble();
77 std::vector<std::pair<std::size_t, double>> direct_values;
78
79 if (mesh_name.empty())
80 {
81 OGSError::box("No mesh selected.");
82 return;
83 }
84 if (raster_name.empty())
85 {
86 OGSError::box("No raster selected.");
87 return;
88 }
89
90 MeshLib::Mesh* mesh(nullptr);
91 for (auto mesh_ : _msh_vec)
92 {
93 if (mesh_->getName() == mesh_name)
94 {
95 mesh = mesh_;
96 break;
97 }
98 }
99
100 if (this->directButton->isChecked())
101 {
103 direct_values = dcg.directToSurfaceNodes(*mesh, raster_name);
104 // dcg.writeToFile(direct_node_name);
105 }
106 else
107 {
108 if (scaling_factor <= 0)
109 {
110 OGSError::box("No valid scaling factor given.");
111 return;
112 }
113 auto* new_mesh = const_cast<MeshLib::Mesh*>(mesh);
115 direct_values = dcg.directWithSurfaceIntegration(*new_mesh, raster_name,
116 scaling_factor);
117
118 // dcg.writeToFile(direct_node_name);
119 }
120 // emit directNodesWritten(direct_node_name);
121 emit transmitDisValues(direct_values);
122 this->done(QDialog::Accepted);
123}
void transmitDisValues(std::vector< std::pair< std::size_t, double > >)
const std::vector< std::pair< std::size_t, double > > & directToSurfaceNodes(const MeshLib::Mesh &mesh, const std::string &filename)
const std::vector< std::pair< std::size_t, double > > & directWithSurfaceIntegration(MeshLib::Mesh &mesh, const std::string &filename, double scaling)
static void box(const QString &e)
Definition OGSError.cpp:23

References _msh_vec, OGSError::box(), DirectConditionGenerator::directToSurfaceNodes(), DirectConditionGenerator::directWithSurfaceIntegration(), and transmitDisValues().

◆ directNodesWritten

void CondFromRasterDialog::directNodesWritten ( std::string )
signal

◆ on_integrateButton_toggled

void CondFromRasterDialog::on_integrateButton_toggled ( bool isSelected)
privateslot

Definition at line 130 of file CondFromRasterDialog.cpp.

131{
132 this->scalingEdit->setEnabled(isSelected);
133}

◆ on_selectButton_pressed

void CondFromRasterDialog::on_selectButton_pressed ( )
privateslot

Definition at line 50 of file CondFromRasterDialog.cpp.

51{
52 QSettings settings;
53#ifdef GEOTIFF_FOUND
54 QString geotiffExtension(" *.tif");
55#else
56 QString geotiffExtension("");
57#endif
58 QString fileName = QFileDialog::getOpenFileName(
59 this, "Select raster file",
60 settings.value("lastOpenedRasterFileDirectory").toString(),
61 QString("Raster files (*.asc *.grd);;").arg(geotiffExtension));
62
63 if (!fileName.isEmpty())
64 {
65 this->rasterEdit->setText(fileName);
66
67 QFileInfo fi(fileName);
68 settings.setValue("lastOpenedRasterFileDirectory", fi.absolutePath());
69 }
70}

◆ reject

void CondFromRasterDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 125 of file CondFromRasterDialog.cpp.

126{
127 this->done(QDialog::Rejected);
128}

◆ transmitDisValues

void CondFromRasterDialog::transmitDisValues ( std::vector< std::pair< std::size_t, double > > )
signal

Referenced by accept().

Member Data Documentation

◆ _msh_vec

const std::vector<MeshLib::Mesh*> CondFromRasterDialog::_msh_vec
private

Definition at line 39 of file CondFromRasterDialog.h.

Referenced by CondFromRasterDialog(), and accept().

◆ _scale_validator

StrictDoubleValidator* CondFromRasterDialog::_scale_validator
private

Definition at line 40 of file CondFromRasterDialog.h.

Referenced by CondFromRasterDialog(), and ~CondFromRasterDialog().


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