OGS
LineEditDialog Class Reference

Detailed Description

A dialog window for manipulation of polylines. Currently included functionality is the concatenation of polylines as well as creating polygons or surfaces from polylines.

Definition at line 18 of file LineEditDialog.h.

#include <LineEditDialog.h>

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

Signals

void connectPolylines (const std::string &, std::vector< std::size_t >, double, std::string, bool, bool)
void triangulateSurface (const GeoLib::Polyline)

Public Member Functions

 LineEditDialog (const GeoLib::PolylineVec &ply_vec, QDialog *parent=nullptr)
 ~LineEditDialog () override

Private Slots

void on_selectPlyButton_pressed ()
 Instructions when polylines are selected.
void on_deselectPlyButton_pressed ()
 Instructions when polylines are deselected.
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

std::vector< std::size_t > getSelectedIndeces (QStringList list)

Private Attributes

QStringListModel * _allPly
QStringListModel * _selPly
std::string _geoName

Constructor & Destructor Documentation

◆ LineEditDialog()

LineEditDialog::LineEditDialog ( const GeoLib::PolylineVec & ply_vec,
QDialog * parent = nullptr )
explicit

Definition at line 11 of file LineEditDialog.cpp.

13 : QDialog(parent),
14 _allPly(new QStringListModel),
15 _selPly(new QStringListModel),
16 _geoName(ply_vec.getName())
17{
18 setupUi(this);
19
20 this->proximityEdit->setValidator(new QDoubleValidator(0, 100, 8, this));
21
22 std::size_t nPly(ply_vec.size());
23 QStringList list;
24 for (std::size_t i = 0; i < nPly; i++)
25 {
26 std::string ply_name;
27 ply_vec.getNameOfElementByID(i, ply_name);
28 list.append("Line " + QString::number(i) + " " +
29 QString::fromStdString(ply_name));
30 }
31 _allPly->setStringList(list);
32
33 this->allPlyView->setModel(_allPly);
34 this->selectedPlyView->setModel(_selPly);
35}
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
std::string getName() const
Definition TemplateVec.h:71
std::size_t size() const
Definition TemplateVec.h:88
QStringListModel * _selPly
std::string _geoName
QStringListModel * _allPly

References _allPly, _geoName, _selPly, getName(), GeoLib::TemplateVec< T >::getNameOfElementByID(), and GeoLib::TemplateVec< T >::size().

◆ ~LineEditDialog()

LineEditDialog::~LineEditDialog ( )
override

Definition at line 37 of file LineEditDialog.cpp.

38{
39 delete _allPly;
40 delete _selPly;
41}

References _allPly, and _selPly.

Member Function Documentation

◆ accept

void LineEditDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 73 of file LineEditDialog.cpp.

74{
75 std::vector<std::size_t> selectedIndeces =
76 this->getSelectedIndeces(_selPly->stringList());
77
78 if (!selectedIndeces.empty())
79 {
80 std::string prox_string = this->proximityEdit->text().toStdString();
81 double prox =
82 (prox_string.empty()) ? 0.0 : strtod(prox_string.c_str(), nullptr);
83 std::string ply_name = (plyNameEdit->text().toStdString().empty())
84 ? ""
85 : plyNameEdit->text().toStdString();
87 selectedIndeces,
88 prox,
89 ply_name,
90 this->closePlyCheckBox->isChecked(),
91 this->createSfcCheckBox->isChecked());
92 this->done(QDialog::Accepted);
93 }
94 else
95 {
96 OGSError::box("No polylines selected", "Error");
97 }
98}
void connectPolylines(const std::string &, std::vector< std::size_t >, double, std::string, bool, bool)
std::vector< std::size_t > getSelectedIndeces(QStringList list)
static void box(const QString &e)
Definition OGSError.cpp:13

References _geoName, _selPly, OGSError::box(), connectPolylines(), and getSelectedIndeces().

◆ connectPolylines

void LineEditDialog::connectPolylines ( const std::string & ,
std::vector< std::size_t > ,
double ,
std::string ,
bool ,
bool  )
signal

Referenced by accept().

◆ getSelectedIndeces()

std::vector< std::size_t > LineEditDialog::getSelectedIndeces ( QStringList list)
private

Definition at line 105 of file LineEditDialog.cpp.

106{
107 std::vector<std::size_t> indexList;
108 for (auto& index : list)
109 {
110 QString s = index.mid(5, index.indexOf(" ") - 5);
111 indexList.push_back(s.toInt());
112 }
113 return indexList;
114}

Referenced by accept().

◆ on_deselectPlyButton_pressed

void LineEditDialog::on_deselectPlyButton_pressed ( )
privateslot

Instructions when polylines are deselected.

Definition at line 58 of file LineEditDialog.cpp.

59{
60 QModelIndexList selected =
61 this->selectedPlyView->selectionModel()->selectedIndexes();
62 QStringList list = _allPly->stringList();
63
64 for (auto& index : selected)
65 {
66 list.append(index.data().toString());
67
68 _selPly->removeRow(index.row());
69 }
70 _allPly->setStringList(list);
71}

References _allPly, and _selPly.

◆ on_selectPlyButton_pressed

void LineEditDialog::on_selectPlyButton_pressed ( )
privateslot

Instructions when polylines are selected.

Definition at line 43 of file LineEditDialog.cpp.

44{
45 QModelIndexList selected =
46 this->allPlyView->selectionModel()->selectedIndexes();
47 QStringList list = _selPly->stringList();
48
49 for (auto& index : selected)
50 {
51 list.append(index.data().toString());
52
53 _allPly->removeRow(index.row());
54 }
55 _selPly->setStringList(list);
56}

References _allPly, and _selPly.

◆ reject

void LineEditDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 100 of file LineEditDialog.cpp.

101{
102 this->done(QDialog::Rejected);
103}

◆ triangulateSurface

void LineEditDialog::triangulateSurface ( const GeoLib::Polyline )
signal

Member Data Documentation

◆ _allPly

QStringListModel* LineEditDialog::_allPly
private

◆ _geoName

std::string LineEditDialog::_geoName
private

Definition at line 32 of file LineEditDialog.h.

Referenced by LineEditDialog(), and accept().

◆ _selPly

QStringListModel* LineEditDialog::_selPly
private

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