OGS
MergeGeometriesDialog Class Reference

Detailed Description

A dialog window for setting preferences for GMSH.

Definition at line 19 of file MergeGeometriesDialog.h.

#include <MergeGeometriesDialog.h>

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

Public Member Functions

 MergeGeometriesDialog (GeoLib::GEOObjects &geoObjects, QDialog *parent=nullptr)
 ~MergeGeometriesDialog () override
std::vector< std::string > getSelectedGeometries () const
 Returns a vector of selected geometries.
std::string getGeometryName () const
 Returns the name of the new merged geometry.

Private Slots

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

Private Attributes

GeoLib::GEOObjects_geo_objects
QStringListModel * _allGeo
QStringListModel * _selGeo

Constructor & Destructor Documentation

◆ MergeGeometriesDialog()

MergeGeometriesDialog::MergeGeometriesDialog ( GeoLib::GEOObjects & geoObjects,
QDialog * parent = nullptr )
explicit

Definition at line 12 of file MergeGeometriesDialog.cpp.

14 : QDialog(parent),
15 _geo_objects(geoObjects),
16 _allGeo(new QStringListModel),
17 _selGeo(new QStringListModel)
18{
19 setupUi(this);
20
21 auto const geoNames = _geo_objects.getGeometryNames();
22
23 // get station names
24 std::vector<std::string> geo_station_names;
25 _geo_objects.getStationVectorNames(geo_station_names);
26
27 // merge method does currently not merge stations, converter function needed
28 // first
29 // geoNames.reserve(geo_station_names.size());
30 // std::copy(geo_station_names.begin(), geo_station_names.end(),
31 // std::back_inserter(geoNames));
32
33 std::size_t nGeoObjects(geoNames.size());
34
35 QStringList list;
36 for (unsigned i = 0; i < nGeoObjects; ++i)
37 {
38 list.append(QString::fromStdString(geoNames[i]));
39 }
40
41 if (list.empty())
42 {
43 this->selectGeoButton->setDisabled(true);
44 this->deselectGeoButton->setDisabled(true);
45 list.append("(No geometry available.)");
46 }
47 _allGeo->setStringList(list);
48 this->allGeoView->setModel(_allGeo);
49 this->selectedGeoView->setModel(_selGeo);
50
51 std::string new_geo_name("MergedGeometry");
52 _geo_objects.isUniquePointVecName(new_geo_name);
53 this->newGeoNameEdit->setText(QString::fromStdString(new_geo_name));
54}
GeoLib::GEOObjects & _geo_objects

References _allGeo, _geo_objects, and _selGeo.

◆ ~MergeGeometriesDialog()

MergeGeometriesDialog::~MergeGeometriesDialog ( )
override

Definition at line 56 of file MergeGeometriesDialog.cpp.

57{
58 delete _allGeo;
59 delete _selGeo;
60}

References _allGeo, and _selGeo.

Member Function Documentation

◆ accept

void MergeGeometriesDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 92 of file MergeGeometriesDialog.cpp.

93{
94 if (_selGeo->stringList().size() > 1)
95 {
96 this->done(QDialog::Accepted);
97 }
98 else
99 {
101 "At least two geometries need\n to be selected for merging.");
102 }
103}
static void box(const QString &e)
Definition OGSError.cpp:13

References _selGeo, and OGSError::box().

◆ getGeometryName()

std::string MergeGeometriesDialog::getGeometryName ( ) const

Returns the name of the new merged geometry.

Definition at line 119 of file MergeGeometriesDialog.cpp.

120{
121 return this->newGeoNameEdit->text().toStdString();
122}

Referenced by MainWindow::showMergeGeometriesDialog().

◆ getSelectedGeometries()

std::vector< std::string > MergeGeometriesDialog::getSelectedGeometries ( ) const

Returns a vector of selected geometries.

Definition at line 110 of file MergeGeometriesDialog.cpp.

111{
112 std::vector<std::string> indexList;
113 QStringList const& list(_selGeo->stringList());
114 std::transform(list.begin(), list.end(), std::back_inserter(indexList),
115 [](auto const& index) { return index.toStdString(); });
116 return indexList;
117}

References _selGeo.

Referenced by MainWindow::showMergeGeometriesDialog().

◆ on_deselectGeoButton_pressed

void MergeGeometriesDialog::on_deselectGeoButton_pressed ( )
privateslot

Definition at line 77 of file MergeGeometriesDialog.cpp.

78{
79 QModelIndexList selected =
80 this->selectedGeoView->selectionModel()->selectedIndexes();
81 QStringList list = _allGeo->stringList();
82
83 for (auto& index : selected)
84 {
85 list.append(index.data().toString());
86
87 _selGeo->removeRow(index.row());
88 }
89 _allGeo->setStringList(list);
90}

References _allGeo, and _selGeo.

◆ on_selectGeoButton_pressed

void MergeGeometriesDialog::on_selectGeoButton_pressed ( )
privateslot

Definition at line 62 of file MergeGeometriesDialog.cpp.

63{
64 QModelIndexList selected =
65 this->allGeoView->selectionModel()->selectedIndexes();
66 QStringList list = _selGeo->stringList();
67
68 for (auto& index : selected)
69 {
70 list.append(index.data().toString());
71
72 _allGeo->removeRow(index.row());
73 }
74 _selGeo->setStringList(list);
75}

References _allGeo, and _selGeo.

◆ reject

void MergeGeometriesDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 105 of file MergeGeometriesDialog.cpp.

106{
107 this->done(QDialog::Rejected);
108}

Member Data Documentation

◆ _allGeo

QStringListModel* MergeGeometriesDialog::_allGeo
private

◆ _geo_objects

GeoLib::GEOObjects& MergeGeometriesDialog::_geo_objects
private

Definition at line 35 of file MergeGeometriesDialog.h.

Referenced by MergeGeometriesDialog().

◆ _selGeo

QStringListModel* MergeGeometriesDialog::_selGeo
private

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