OGS
MergeGeometriesDialog Class Reference

Detailed Description

A dialog window for setting preferences for GMSH.

Definition at line 30 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 23 of file MergeGeometriesDialog.cpp.

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

References _allGeo, _geo_objects, _selGeo, GeoLib::GEOObjects::getGeometryNames(), GeoLib::GEOObjects::getStationVectorNames(), and GeoLib::GEOObjects::isUniquePointVecName().

◆ ~MergeGeometriesDialog()

MergeGeometriesDialog::~MergeGeometriesDialog ( )
override

Definition at line 67 of file MergeGeometriesDialog.cpp.

68{
69 delete _allGeo;
70 delete _selGeo;
71}

References _allGeo, and _selGeo.

Member Function Documentation

◆ accept

void MergeGeometriesDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 103 of file MergeGeometriesDialog.cpp.

104{
105 if (_selGeo->stringList().size() > 1)
106 {
107 this->done(QDialog::Accepted);
108 }
109 else
110 {
112 "At least two geometries need\n to be selected for merging.");
113 }
114}
static void box(const QString &e)
Definition OGSError.cpp:23

References _selGeo, and OGSError::box().

◆ getGeometryName()

std::string MergeGeometriesDialog::getGeometryName ( ) const

Returns the name of the new merged geometry.

Definition at line 130 of file MergeGeometriesDialog.cpp.

131{
132 return this->newGeoNameEdit->text().toStdString();
133}

Referenced by MainWindow::showMergeGeometriesDialog().

◆ getSelectedGeometries()

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

Returns a vector of selected geometries.

Definition at line 121 of file MergeGeometriesDialog.cpp.

122{
123 std::vector<std::string> indexList;
124 QStringList const& list(_selGeo->stringList());
125 std::transform(list.begin(), list.end(), std::back_inserter(indexList),
126 [](auto const& index) { return index.toStdString(); });
127 return indexList;
128}

References _selGeo.

Referenced by MainWindow::showMergeGeometriesDialog().

◆ on_deselectGeoButton_pressed

void MergeGeometriesDialog::on_deselectGeoButton_pressed ( )
privateslot

Definition at line 88 of file MergeGeometriesDialog.cpp.

89{
90 QModelIndexList selected =
91 this->selectedGeoView->selectionModel()->selectedIndexes();
92 QStringList list = _allGeo->stringList();
93
94 for (auto& index : selected)
95 {
96 list.append(index.data().toString());
97
98 _selGeo->removeRow(index.row());
99 }
100 _allGeo->setStringList(list);
101}

References _allGeo, and _selGeo.

◆ on_selectGeoButton_pressed

void MergeGeometriesDialog::on_selectGeoButton_pressed ( )
privateslot

Definition at line 73 of file MergeGeometriesDialog.cpp.

74{
75 QModelIndexList selected =
76 this->allGeoView->selectionModel()->selectedIndexes();
77 QStringList list = _selGeo->stringList();
78
79 for (auto& index : selected)
80 {
81 list.append(index.data().toString());
82
83 _allGeo->removeRow(index.row());
84 }
85 _selGeo->setStringList(list);
86}

References _allGeo, and _selGeo.

◆ reject

void MergeGeometriesDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 116 of file MergeGeometriesDialog.cpp.

117{
118 this->done(QDialog::Rejected);
119}

Member Data Documentation

◆ _allGeo

QStringListModel* MergeGeometriesDialog::_allGeo
private

◆ _geo_objects

GeoLib::GEOObjects& MergeGeometriesDialog::_geo_objects
private

Definition at line 46 of file MergeGeometriesDialog.h.

Referenced by MergeGeometriesDialog().

◆ _selGeo

QStringListModel* MergeGeometriesDialog::_selGeo
private

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