OGS
AddFaultsToVoxelGridDialog Class Reference

Detailed Description

Definition at line 29 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 29 of file AddFaultsToVoxelGridDialog.cpp.

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

References _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 79 of file AddFaultsToVoxelGridDialog.cpp.

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

References _mesh_model, _selFaults, MeshModel::addMesh(), OGSError::box(), MeshModel::getMesh(), 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 74 of file AddFaultsToVoxelGridDialog.cpp.

75{
76 Utils::moveSelectedItems(this->selectedFaults, _selFaults, _meshes2D);
77}
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)
Definition Utils.cpp:23

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 69 of file AddFaultsToVoxelGridDialog.cpp.

70{
72}

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

◆ reject

void AddFaultsToVoxelGridDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 48 of file AddFaultsToVoxelGridDialog.h.

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

Member Data Documentation

◆ _mesh_model

MeshModel& AddFaultsToVoxelGridDialog::_mesh_model
private

Definition at line 39 of file AddFaultsToVoxelGridDialog.h.

Referenced by accept().

◆ _meshes2D

QStringListModel AddFaultsToVoxelGridDialog::_meshes2D
private

◆ _selFaults

QStringListModel AddFaultsToVoxelGridDialog::_selFaults
private

◆ _voxelGrids

QStringListModel AddFaultsToVoxelGridDialog::_voxelGrids
private

Definition at line 40 of file AddFaultsToVoxelGridDialog.h.

Referenced by AddFaultsToVoxelGridDialog().


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