OGS
TranslateDataDialog Class Reference

Detailed Description

A dialog window for calling translation methods.

Definition at line 26 of file TranslateDataDialog.h.

#include <TranslateDataDialog.h>

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

Signals

void meshAdded (MeshLib::Mesh const *mesh)

Public Member Functions

 TranslateDataDialog (MeshModel *mesh_model, GEOModels *geo_models, 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 moveGeometry (Eigen::Vector3d const &displacement, std::string const &name)
void moveMesh (Eigen::Vector3d const &displacement, std::string const &name)
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
GEOModels_geo_models
QStringListModel _allData
QStringListModel _selData

Constructor & Destructor Documentation

◆ TranslateDataDialog()

TranslateDataDialog::TranslateDataDialog ( MeshModel * mesh_model,
GEOModels * geo_models,
QDialog * parent = nullptr )
explicit

Definition at line 18 of file TranslateDataDialog.cpp.

21 : QDialog(parent), _mesh_model(mesh_model), _geo_models(geo_models)
22{
23 setupUi(this);
24 assert(_geo_models != nullptr);
25 assert(_mesh_model != nullptr);
26 auto const geoNames = _geo_models->getGeometryNames();
27
28 QStringList dataList;
29 for (auto const& name : geoNames)
30 {
31 dataList.append(QString::fromStdString(name));
32 }
33
34 for (int model_index = 0; model_index < _mesh_model->rowCount();
35 ++model_index)
36 {
37 auto const* mesh =
38 _mesh_model->getMesh(_mesh_model->index(model_index, 0));
39 dataList.append(QString::fromStdString(mesh->getName()));
40 }
41
42 if (dataList.empty())
43 {
44 this->selectDataButton->setDisabled(true);
45 this->deselectDataButton->setDisabled(true);
46 dataList.append("[No data available.]");
47 }
48
49 _allData.setStringList(dataList);
50 this->allDataView->setModel(&_allData);
51 this->selectedDataView->setModel(&_selData);
52}
QStringListModel _allData
QStringListModel _selData

References _allData, _geo_models, _mesh_model, and _selData.

Member Function Documentation

◆ accept

void TranslateDataDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 96 of file TranslateDataDialog.cpp.

97{
98 if (this->_selData.rowCount() == 0)
99 {
100 OGSError::box("Please specify the input data.");
101 return;
102 }
103
104 QString const xinput = this->xlineEdit->text();
105 QString const yinput = this->ylineEdit->text();
106 QString const zinput = this->zlineEdit->text();
107
108 bool ok;
109 if (!xinput.toDouble(&ok) or !yinput.toDouble(&ok) or !zinput.toDouble(&ok))
110 {
111 INFO(
112 "If the x/y/z-input is 0, not specified or not a real number, it "
113 "is used as 0.");
114 }
115
116 Eigen::Vector3d const displacement{xinput.toDouble(), yinput.toDouble(),
117 zinput.toDouble()};
118
119 INFO("translate model ({:f}, {:f}, {:f}).",
120 displacement[0],
121 displacement[1],
122 displacement[2]);
123
124 std::vector<std::string> const selectedData =
126
127 auto const geoNames = _geo_models->getGeometryNames();
128
129 for (auto const& data_name : selectedData)
130 {
131 if (std::find(std::begin(geoNames), std::end(geoNames), data_name) !=
132 std::end(geoNames))
133 {
134 moveGeometry(displacement, data_name);
135 continue;
136 }
137 moveMesh(displacement, data_name);
138 }
139
140 this->done(QDialog::Accepted);
141}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
static void box(const QString &e)
Definition OGSError.cpp:13
void moveGeometry(Eigen::Vector3d const &displacement, std::string const &name)
void moveMesh(Eigen::Vector3d const &displacement, std::string const &name)
std::vector< std::string > getSelectedObjects(QStringList const &list)

References _geo_models, _selData, OGSError::box(), Utils::getSelectedObjects(), INFO(), moveGeometry(), and moveMesh().

◆ meshAdded

void TranslateDataDialog::meshAdded ( MeshLib::Mesh const * mesh)
signal

◆ moveGeometry()

void TranslateDataDialog::moveGeometry ( Eigen::Vector3d const & displacement,
std::string const & name )
private

Definition at line 64 of file TranslateDataDialog.cpp.

66{
67 std::vector<GeoLib::Point*> const* point_vec =
68 _geo_models->getPointVec(name);
69 if (point_vec == nullptr)
70 {
71 OGSError::box("The geometry is faulty.");
72 return;
73 }
74
75 MeshToolsLib::moveMeshNodes(point_vec->begin(), point_vec->end(),
76 displacement);
77
78 _geo_models->updateGeometry(name);
79}
void moveMeshNodes(Iterator begin, Iterator end, Eigen::Vector3d const &displacement)

References _geo_models, OGSError::box(), and MeshToolsLib::moveMeshNodes().

Referenced by accept().

◆ moveMesh()

void TranslateDataDialog::moveMesh ( Eigen::Vector3d const & displacement,
std::string const & name )
private

Definition at line 81 of file TranslateDataDialog.cpp.

83{
84 MeshLib::Mesh const* mesh(_mesh_model->getMesh(name));
85 if (mesh == nullptr)
86 {
87 OGSError::box("The mesh is faulty.");
88 return;
89 }
90
91 MeshToolsLib::moveMeshNodes(mesh->getNodes().begin(),
92 mesh->getNodes().end(), displacement);
93 _mesh_model->updateMesh(const_cast<MeshLib::Mesh*>(mesh));
94}

References _mesh_model, OGSError::box(), MeshLib::Mesh::getNodes(), and MeshToolsLib::moveMeshNodes().

Referenced by accept().

◆ on_deselectDataButton_pressed()

void TranslateDataDialog::on_deselectDataButton_pressed ( )
private

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

Definition at line 59 of file TranslateDataDialog.cpp.

60{
61 Utils::moveSelectedItems(this->selectedDataView, _selData, _allData);
62}
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)

References _allData, _selData, and Utils::moveSelectedItems().

◆ on_selectDataButton_pressed()

void TranslateDataDialog::on_selectDataButton_pressed ( )
private

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

Definition at line 54 of file TranslateDataDialog.cpp.

55{
56 Utils::moveSelectedItems(this->allDataView, _allData, _selData);
57}

References _allData, _selData, and Utils::moveSelectedItems().

◆ reject

void TranslateDataDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 48 of file TranslateDataDialog.h.

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

Member Data Documentation

◆ _allData

QStringListModel TranslateDataDialog::_allData
private

◆ _geo_models

GEOModels* TranslateDataDialog::_geo_models
private

Definition at line 40 of file TranslateDataDialog.h.

Referenced by TranslateDataDialog(), accept(), and moveGeometry().

◆ _mesh_model

MeshModel* TranslateDataDialog::_mesh_model
private

Definition at line 39 of file TranslateDataDialog.h.

Referenced by TranslateDataDialog(), and moveMesh().

◆ _selData

QStringListModel TranslateDataDialog::_selData
private

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