OGS
AddFaultsToVoxelGridDialog Class Reference

Detailed Description

Definition at line 19 of file AddFaultsToVoxelGridDialog.h.

#include <AddFaultsToVoxelGridDialog.h>

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

Public Member Functions

 AddFaultsToVoxelGridDialog (MeshModel &mesh_model, QDialog *parent=nullptr)

Private Slots

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

Private Member Functions

void on_selectDataButton_pressed ()
 Instructions if the ">>-button" has been pressed.
void on_deselectDataButton_pressed ()
 Instructions if the "<<-button" has been pressed.

Private Attributes

MeshModel_mesh_model
QStringListModel _voxelGrids
QStringListModel _meshes2D
QStringListModel _selFaults

Constructor & Destructor Documentation

◆ AddFaultsToVoxelGridDialog()

AddFaultsToVoxelGridDialog::AddFaultsToVoxelGridDialog ( MeshModel & mesh_model,
QDialog * parent = nullptr )
explicit

Definition at line 19 of file AddFaultsToVoxelGridDialog.cpp.

21 : QDialog(parent), _mesh_model(mesh_model)
22{
23 setupUi(this);
24 QStringList voxelGridList;
25 QStringList faultsList;
26
27 for (int model_index = 0; model_index < mesh_model.rowCount();
28 ++model_index)
29 {
30 auto const* mesh = mesh_model.getMesh(mesh_model.index(model_index, 0));
31 assert(mesh);
33 *mesh))
34 {
35 voxelGridList.append(QString::fromStdString(mesh->getName()));
36 }
37 if (mesh->getDimension() == 2)
38 {
39 faultsList.append(QString::fromStdString(mesh->getName()));
40 }
41 }
42 if (voxelGridList.empty())
43 {
44 voxelGridList.append(no_voxel_str);
45 }
46
47 if (faultsList.empty())
48 {
49 faultsList.append("[No 2D faults available.]");
50 }
51
52 _voxelGrids.setStringList(voxelGridList);
53 _meshes2D.setStringList(faultsList);
54 this->voxelGridListBox->addItems(_voxelGrids.stringList());
55 this->all2Dmeshes->setModel(&_meshes2D);
56 this->selectedFaults->setModel(&_selFaults);
57}
QString no_voxel_str
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
Definition MeshModel.cpp:85
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition TreeModel.cpp:93
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Definition TreeModel.cpp:39

References _mesh_model, _meshes2D, _selFaults, _voxelGrids, MeshModel::getMesh(), TreeModel::index(), MeshToolsLib::MeshGenerator::AddFaultToVoxelGrid::isVoxelGrid(), no_voxel_str, and TreeModel::rowCount().

Member Function Documentation

◆ accept

void AddFaultsToVoxelGridDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 69 of file AddFaultsToVoxelGridDialog.cpp.

70{
71 using namespace MeshToolsLib::MeshGenerator;
72 if (this->voxelGridListBox->currentText() == no_voxel_str)
73 {
74 OGSError::box("Please specify the input voxel grid.");
75 return;
76 }
77
78 auto* input_voxelgrid = _mesh_model.getMesh(
79 this->voxelGridListBox->currentText().toStdString());
80 assert(input_voxelgrid);
81 std::unique_ptr<MeshLib::Mesh> voxelgrid(
82 new MeshLib::Mesh(*input_voxelgrid));
83 assert(voxelgrid);
84
85 auto const* mat_ids = MeshLib::materialIDs(*voxelgrid);
86
87 if (mat_ids == nullptr)
88 {
89 OGSError::box("Input mesh has no material IDs");
90 return;
91 }
92
93 std::vector<std::string> const selected_faults =
95
96 if (this->_selFaults.rowCount() == 0)
97 {
98 OGSError::box("Please specify the fault(s) to be added to the mesh.");
99 return;
100 }
101
102 auto max_mat_id = std::max_element(mat_ids->cbegin(), mat_ids->cend());
103 assert(max_mat_id);
104 auto fault_id = *max_mat_id;
105 for (auto const& fault_name : selected_faults)
106 {
107 fault_id++;
108 auto const* fault = _mesh_model.getMesh(fault_name);
109 if (AddFaultToVoxelGrid::addFaultToVoxelGrid(voxelgrid.get(), fault,
110 fault_id))
111 {
112 INFO("The fault '{}' was added.", fault_name);
113 continue;
114 }
115 OGSError::box("The fault " + QString::fromStdString(fault_name) +
116 " could not be added.");
117 }
118
119 _mesh_model.addMesh(voxelgrid.release());
120 this->done(QDialog::Accepted);
121}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
static void box(const QString &e)
Definition OGSError.cpp:13
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:258
std::vector< std::string > getSelectedObjects(QStringList const &list)

References _mesh_model, _selFaults, MeshToolsLib::MeshGenerator::AddFaultToVoxelGrid::addFaultToVoxelGrid(), OGSError::box(), Utils::getSelectedObjects(), INFO(), MeshLib::materialIDs(), and no_voxel_str.

◆ on_deselectDataButton_pressed()

void AddFaultsToVoxelGridDialog::on_deselectDataButton_pressed ( )
private

Instructions if the "<<-button" has been pressed.

Definition at line 64 of file AddFaultsToVoxelGridDialog.cpp.

65{
66 Utils::moveSelectedItems(this->selectedFaults, _selFaults, _meshes2D);
67}
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)

References _meshes2D, _selFaults, and Utils::moveSelectedItems().

◆ on_selectDataButton_pressed()

void AddFaultsToVoxelGridDialog::on_selectDataButton_pressed ( )
private

Instructions if the ">>-button" has been pressed.

Definition at line 59 of file AddFaultsToVoxelGridDialog.cpp.

60{
62}

References _meshes2D, _selFaults, and Utils::moveSelectedItems().

◆ reject

void AddFaultsToVoxelGridDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 38 of file AddFaultsToVoxelGridDialog.h.

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

Member Data Documentation

◆ _mesh_model

MeshModel& AddFaultsToVoxelGridDialog::_mesh_model
private

Definition at line 29 of file AddFaultsToVoxelGridDialog.h.

Referenced by AddFaultsToVoxelGridDialog(), and accept().

◆ _meshes2D

QStringListModel AddFaultsToVoxelGridDialog::_meshes2D
private

◆ _selFaults

QStringListModel AddFaultsToVoxelGridDialog::_selFaults
private

◆ _voxelGrids

QStringListModel AddFaultsToVoxelGridDialog::_voxelGrids
private

Definition at line 30 of file AddFaultsToVoxelGridDialog.h.

Referenced by AddFaultsToVoxelGridDialog().


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