7#include <QDoubleValidator>
8#include <QElapsedTimer>
13#include <QIntValidator>
16#include <QRadioButton>
45 this->gridLayoutLayerMapping->addWidget(
46 new QLabel(
"Please specify the number of layers to add:",
this), 0, 0);
47 this->gridLayoutLayerMapping->addWidget(
_layerEdit, 0, 1);
48 this->gridLayoutLayerMapping->addWidget(
_nextButton, 0, 2);
68 OGSError::box(
"Add the number of layers to add (at least 1)");
76 QRadioButton* selectButton1(
78 QRadioButton* selectButton2(
81 _radiobuttonLayout->addWidget(selectButton1);
82 _radiobuttonLayout->addWidget(selectButton2);
86 connect(selectButton2, SIGNAL(pressed()),
this, SLOT(
createStatic()));
93 const QString selectText =
94 (
_n_layers > 0) ?
"Please specify a raster file for mapping each layer:"
95 :
"Please specify raster file for surface mapping:";
108 text =
"Layer" + QString::number(
_n_layers) +
"-Bottom";
112 text =
"Layer" + QString::number(i + 1) +
"-Top";
114 auto* edit(
new QLineEdit(
this));
115 QPushButton* button(
new QPushButton(
"...",
_layerBox));
117 this->
_edits.push_back(edit);
119 connect(button, SIGNAL(clicked()),
this, SLOT(
getFileName()));
127 this->gridLayoutLayerMapping->addWidget(
_layerBox, 4, 0, 1, 3);
139 this->
_layerBox->setTitle(
"Please specify a thickness or each layer");
141 for (
unsigned i = 0; i < this->
_n_layers; ++i)
143 QString text(
"Layer" + QString::number(i) +
"-Thickness");
144 QLineEdit* staticLayerEdit =
new QLineEdit(
"10",
this);
145 staticLayerEdit->setValidator(
new QDoubleValidator(staticLayerEdit));
146 _edits.push_back(staticLayerEdit);
152 this->gridLayoutLayerMapping->addWidget(
_layerBox, 4, 0, 1, 3);
158 auto* meshToolSelectionBox(
new QGroupBox(
this));
159 meshToolSelectionBox->setTitle(
"Output element type");
160 auto* meshToolSelectionLayout(
new QGridLayout(meshToolSelectionBox));
161 _ogsMeshButton =
new QRadioButton(
"Prisms", meshToolSelectionBox);
162 QRadioButton* tetgenMeshButton =
163 new QRadioButton(
"Tetrahedra", meshToolSelectionBox);
164 tetgenMeshButton->setFixedWidth(150);
165 auto* minThicknessLabel =
new QLabel(meshToolSelectionBox);
166 minThicknessLabel->setText(
"Minimum thickness of layers:");
169 auto* min_thickness_validator =
175 meshToolSelectionLayout->addWidget(tetgenMeshButton, 0, 1);
176 meshToolSelectionLayout->addWidget(minThicknessLabel, 1, 0);
178 meshToolSelectionBox->setLayout(meshToolSelectionLayout);
181 gridLayoutLayerMapping->addWidget(meshToolSelectionBox, 5, 0, 1, 3);
186 const unsigned nLayers =
_layerEdit->text().toInt();
190 QElapsedTimer myTimer0;
195 if (minimum_thickness <= 0)
197 minimum_thickness = std::numeric_limits<float>::epsilon();
199 std::vector<std::string> raster_paths;
200 for (
int i = nLayers; i >= 0; --i)
202 raster_paths.push_back(this->
_edits[i]->text().toStdString());
208 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
209 return mapper.
getMesh(
"SubsurfaceMesh").release();
214 std::vector<float> layer_thickness;
215 for (
unsigned i = 0; i < nLayers; ++i)
217 layer_thickness.push_back(this->
_edits[i]->text().toFloat());
219 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
227 QString filename = QFileDialog::getSaveFileName(
228 this,
"Write TetGen input file to",
229 settings.value(
"lastOpenedTetgenFileDirectory").toString(),
230 "TetGen Geometry (*.smesh)");
231 if (filename.isEmpty())
236 const unsigned nLayers =
_layerEdit->text().toInt();
238 QElapsedTimer myTimer0;
244 if (minimum_thickness <= 0)
246 minimum_thickness = std::numeric_limits<float>::epsilon();
248 std::vector<std::string> raster_paths;
249 for (
int i = nLayers; i >= 0; --i)
251 raster_paths.push_back(this->
_edits[i]->text().toStdString());
258 tg_mesh = lv.
getMesh(
"SubsurfaceMesh").release();
271 std::vector<float> layer_thickness;
272 for (
unsigned i = 0; i < nLayers; ++i)
274 layer_thickness.push_back(this->
_edits[i]->text().toFloat());
277 *
_msh, layer_thickness);
278 std::vector<MeshLib::Node> tg_attr;
283 INFO(
"Mesh construction time: {:d} ms.", myTimer0.elapsed());
290 if (this->
_edits.isEmpty())
293 "Please specify the number and\n type of layers and press 'Next'");
297 bool all_paths_set(
true);
300 if (
_edits[0]->text().isEmpty())
302 all_paths_set =
false;
308 for (
int i = start_idx; i <
_edits.size(); ++i)
310 if (
_edits[i]->text().isEmpty())
312 all_paths_set =
false;
319 OGSError::box(
"Please specify raster files for all layers.");
342 this->done(QDialog::Accepted);
347 this->done(QDialog::Rejected);
352 auto* button =
dynamic_cast<QPushButton*
>(this->sender());
354 QString filename = QFileDialog::getOpenFileName(
355 this,
"Select raster file to open",
356 settings.value(
"lastOpenedRasterFileDirectory").toString(),
357 "ASCII raster files (*.asc *.grd *.xyz);;All files (* *.*)");
359 QFileInfo fi(filename);
360 settings.setValue(
"lastOpenedRasterFileDirectory", fi.absolutePath());
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
static bool writeTetGenSmesh(const std::string &file_name, const GeoLib::GEOObjects &geo_objects, const std::string &geo_name, const std::vector< GeoLib::Point > &attribute_points)
virtual bool createLayers(MeshLib::Mesh const &mesh, std::vector< GeoLib::Raster const * > const &rasters, double minimum_thickness, double noDataReplacementValue=0.0) final
std::unique_ptr< MeshLib::Mesh > getMesh(std::string const &mesh_name) const
Returns a mesh of the subsurface representation.
Creates a volume geometry from 2D mesh layers based on raster data.
std::vector< MeshLib::Node > getAttributePoints() const
MeshLayerEditDialog(const MeshLib::Mesh *mesh, QDialog *parent=nullptr)
~MeshLayerEditDialog() override
void mshEditFinished(MeshLib::Mesh *)
QRadioButton * _ogsMeshButton
MeshLib::Mesh * createPrismMesh()
QMap< QPushButton *, QLineEdit * > _fileButtonMap
QPushButton * _nextButton
void reject() override
Instructions if the Cancel-Button has been pressed.
MeshLib::Mesh * createTetMesh()
QGridLayout * _layerSelectionLayout
QVector< QLineEdit * > _edits
void accept() override
Instructions if the OK-Button has been pressed.
void createMeshToolSelection()
const MeshLib::Mesh * _msh
QLineEdit * _minThicknessEdit
QLineEdit * _noDataReplacementEdit
QGroupBox * _radioButtonBox
static void box(const QString &e)
std::optional< std::vector< GeoLib::Raster const * > > readRasters(std::vector< std::string > const &raster_paths)