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 29 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. More...
 
void on_deselectPlyButton_pressed ()
 Instructions when polylines are deselected. More...
 
void accept () override
 Instructions if the OK-Button has been pressed. More...
 
void reject () override
 Instructions if the Cancel-Button has been pressed. More...
 

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 22 of file LineEditDialog.cpp.

24  : QDialog(parent),
25  _allPly(new QStringListModel),
26  _selPly(new QStringListModel),
27  _geoName(ply_vec.getName())
28 {
29  setupUi(this);
30 
31  this->proximityEdit->setValidator(new QDoubleValidator(0, 100, 8, this));
32 
33  std::size_t nPly(ply_vec.size());
34  QStringList list;
35  for (std::size_t i = 0; i < nPly; i++)
36  {
37  std::string ply_name;
38  ply_vec.getNameOfElementByID(i, ply_name);
39  list.append("Line " + QString::number(i) + " " +
40  QString::fromStdString(ply_name));
41  }
42  _allPly->setStringList(list);
43 
44  this->allPlyView->setModel(_allPly);
45  this->selectedPlyView->setModel(_selPly);
46 }
bool getNameOfElementByID(std::size_t id, std::string &element_name) const
Definition: TemplateVec.h:153
std::string getName() const
Definition: TemplateVec.h:95
std::size_t size() const
Definition: TemplateVec.h:106
QStringListModel * _selPly
std::string _geoName
QStringListModel * _allPly

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

◆ ~LineEditDialog()

LineEditDialog::~LineEditDialog ( )
override

Definition at line 48 of file LineEditDialog.cpp.

49 {
50  delete _allPly;
51  delete _selPly;
52 }

References _allPly, and _selPly.

Member Function Documentation

◆ accept

void LineEditDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 84 of file LineEditDialog.cpp.

85 {
86  std::vector<std::size_t> selectedIndeces =
87  this->getSelectedIndeces(_selPly->stringList());
88 
89  if (!selectedIndeces.empty())
90  {
91  std::string prox_string = this->proximityEdit->text().toStdString();
92  double prox =
93  (prox_string.empty()) ? 0.0 : strtod(prox_string.c_str(), nullptr);
94  std::string ply_name = (plyNameEdit->text().toStdString().empty())
95  ? ""
96  : plyNameEdit->text().toStdString();
98  selectedIndeces,
99  prox,
100  ply_name,
101  this->closePlyCheckBox->isChecked(),
102  this->createSfcCheckBox->isChecked());
103  this->done(QDialog::Accepted);
104  }
105  else
106  {
107  OGSError::box("No polylines selected", "Error");
108  }
109 }
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:23

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 116 of file LineEditDialog.cpp.

117 {
118  std::vector<std::size_t> indexList;
119  for (auto& index : list)
120  {
121  QString s = index.mid(5, index.indexOf(" ") - 5);
122  indexList.push_back(s.toInt());
123  }
124  return indexList;
125 }

Referenced by accept().

◆ on_deselectPlyButton_pressed

void LineEditDialog::on_deselectPlyButton_pressed ( )
privateslot

Instructions when polylines are deselected.

Definition at line 69 of file LineEditDialog.cpp.

70 {
71  QModelIndexList selected =
72  this->selectedPlyView->selectionModel()->selectedIndexes();
73  QStringList list = _allPly->stringList();
74 
75  for (auto& index : selected)
76  {
77  list.append(index.data().toString());
78 
79  _selPly->removeRow(index.row());
80  }
81  _allPly->setStringList(list);
82 }

References _allPly, and _selPly.

◆ on_selectPlyButton_pressed

void LineEditDialog::on_selectPlyButton_pressed ( )
privateslot

Instructions when polylines are selected.

Definition at line 54 of file LineEditDialog.cpp.

55 {
56  QModelIndexList selected =
57  this->allPlyView->selectionModel()->selectedIndexes();
58  QStringList list = _selPly->stringList();
59 
60  for (auto& index : selected)
61  {
62  list.append(index.data().toString());
63 
64  _allPly->removeRow(index.row());
65  }
66  _selPly->setStringList(list);
67 }

References _allPly, and _selPly.

◆ reject

void LineEditDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 111 of file LineEditDialog.cpp.

112 {
113  this->done(QDialog::Rejected);
114 }

◆ 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 43 of file LineEditDialog.h.

Referenced by accept().

◆ _selPly

QStringListModel* LineEditDialog::_selPly
private

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