OGS
TranslateDataDialog Class Reference

Detailed Description

A dialog window for calling translation methods.

Definition at line 36 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 28 of file TranslateDataDialog.cpp.

31 : QDialog(parent), _mesh_model(mesh_model), _geo_models(geo_models)
32{
33 setupUi(this);
34 assert(_geo_models != nullptr);
35 assert(_mesh_model != nullptr);
36 auto const geoNames = _geo_models->getGeometryNames();
37
38 QStringList dataList;
39 for (auto const& name : geoNames)
40 {
41 dataList.append(QString::fromStdString(name));
42 }
43
44 for (int model_index = 0; model_index < _mesh_model->rowCount();
45 ++model_index)
46 {
47 auto const* mesh =
48 _mesh_model->getMesh(_mesh_model->index(model_index, 0));
49 dataList.append(QString::fromStdString(mesh->getName()));
50 }
51
52 if (dataList.empty())
53 {
54 this->selectDataButton->setDisabled(true);
55 this->deselectDataButton->setDisabled(true);
56 dataList.append("[No data available.]");
57 }
58
59 _allData.setStringList(dataList);
60 this->allDataView->setModel(&_allData);
61 this->selectedDataView->setModel(&_selData);
62}
std::vector< std::string > getGeometryNames() const
const MeshLib::Mesh * getMesh(const QModelIndex &idx) const
Returns the mesh with the given index.
Definition MeshModel.cpp:96
QStringListModel _allData
QStringListModel _selData
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 _allData, _geo_models, _mesh_model, _selData, GEOModels::getGeometryNames(), MeshModel::getMesh(), TreeModel::index(), and TreeModel::rowCount().

Member Function Documentation

◆ accept

void TranslateDataDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 106 of file TranslateDataDialog.cpp.

107{
108 if (this->_selData.rowCount() == 0)
109 {
110 OGSError::box("Please specify the input data.");
111 return;
112 }
113
114 QString const xinput = this->xlineEdit->text();
115 QString const yinput = this->ylineEdit->text();
116 QString const zinput = this->zlineEdit->text();
117
118 bool ok;
119 if (!xinput.toDouble(&ok) or !yinput.toDouble(&ok) or !zinput.toDouble(&ok))
120 {
121 INFO(
122 "If the x/y/z-input is 0, not specified or not a real number, it "
123 "is used as 0.");
124 }
125
126 Eigen::Vector3d const displacement{xinput.toDouble(), yinput.toDouble(),
127 zinput.toDouble()};
128
129 INFO("translate model ({:f}, {:f}, {:f}).",
130 displacement[0],
131 displacement[1],
132 displacement[2]);
133
134 std::vector<std::string> const selectedData =
136
137 auto const geoNames = _geo_models->getGeometryNames();
138
139 for (auto const& data_name : selectedData)
140 {
141 if (std::find(std::begin(geoNames), std::end(geoNames), data_name) !=
142 std::end(geoNames))
143 {
144 moveGeometry(displacement, data_name);
145 continue;
146 }
147 moveMesh(displacement, data_name);
148 }
149
150 this->done(QDialog::Accepted);
151}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
static void box(const QString &e)
Definition OGSError.cpp:23
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)
Definition Utils.cpp:15

References _geo_models, _selData, OGSError::box(), GEOModels::getGeometryNames(), 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 74 of file TranslateDataDialog.cpp.

76{
77 std::vector<GeoLib::Point*> const* point_vec =
79 if (point_vec == nullptr)
80 {
81 OGSError::box("The geometry is faulty.");
82 return;
83 }
84
85 MeshToolsLib::moveMeshNodes(point_vec->begin(), point_vec->end(),
86 displacement);
87
89}
const std::vector< GeoLib::Point * > * getPointVec(const std::string &name) const
void updateGeometry(const std::string &geo_name)
Definition GEOModels.cpp:40
void moveMeshNodes(Iterator begin, Iterator end, Eigen::Vector3d const &displacement)

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

Referenced by accept().

◆ moveMesh()

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

Definition at line 91 of file TranslateDataDialog.cpp.

93{
94 MeshLib::Mesh const* mesh(_mesh_model->getMesh(name));
95 if (mesh == nullptr)
96 {
97 OGSError::box("The mesh is faulty.");
98 return;
99 }
100
101 MeshToolsLib::moveMeshNodes(mesh->getNodes().begin(),
102 mesh->getNodes().end(), displacement);
103 _mesh_model->updateMesh(const_cast<MeshLib::Mesh*>(mesh));
104}
void updateMesh(MeshLib::Mesh *)
Updates the model/view for a mesh.

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

Referenced by accept().

◆ on_deselectDataButton_pressed()

void TranslateDataDialog::on_deselectDataButton_pressed ( )
private

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

Definition at line 69 of file TranslateDataDialog.cpp.

70{
71 Utils::moveSelectedItems(this->selectedDataView, _selData, _allData);
72}
void moveSelectedItems(QListView *sourceView, QStringListModel &sourceModel, QStringListModel &targetModel)
Definition Utils.cpp:23

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 64 of file TranslateDataDialog.cpp.

65{
66 Utils::moveSelectedItems(this->allDataView, _allData, _selData);
67}

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

◆ reject

void TranslateDataDialog::reject ( )
inlineoverrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 58 of file TranslateDataDialog.h.

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

Member Data Documentation

◆ _allData

QStringListModel TranslateDataDialog::_allData
private

◆ _geo_models

GEOModels* TranslateDataDialog::_geo_models
private

Definition at line 50 of file TranslateDataDialog.h.

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

◆ _mesh_model

MeshModel* TranslateDataDialog::_mesh_model
private

Definition at line 49 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: