OGS
LinearEditDialog Class Reference

Detailed Description

A dialog window for creating linear boundary conditions on polylines.

Definition at line 25 of file LinearEditDialog.h.

#include <LinearEditDialog.h>

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

Signals

void transmitDisValues (std::vector< std::pair< std::size_t, double > >)
 

Public Member Functions

 LinearEditDialog (const GeoLib::Polyline &line, const std::vector< std::size_t > &dis_nodes, const std::vector< double > &dis_values, QDialog *parent=nullptr)
 
 ~LinearEditDialog () override
 

Private Slots

void on_comboBox_currentIndexChanged (int index)
 
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 setupDialog (const std::vector< std::size_t > &dis_nodes, const std::vector< double > &dis_values)
 

Private Attributes

const GeoLib::Polyline _line
 

Constructor & Destructor Documentation

◆ LinearEditDialog()

LinearEditDialog::LinearEditDialog ( const GeoLib::Polyline & line,
const std::vector< std::size_t > & dis_nodes,
const std::vector< double > & dis_values,
QDialog * parent = nullptr )

Definition at line 17 of file LinearEditDialog.cpp.

21 : QDialog(parent), _line(line)
22{
23 setupUi(this);
24 setupDialog(dis_nodes, dis_values);
25}
const GeoLib::Polyline _line
void setupDialog(const std::vector< std::size_t > &dis_nodes, const std::vector< double > &dis_values)

References setupDialog().

◆ ~LinearEditDialog()

LinearEditDialog::~LinearEditDialog ( )
overridedefault

Member Function Documentation

◆ accept

void LinearEditDialog::accept ( )
overrideprivateslot

Instructions if the OK-Button has been pressed.

Definition at line 66 of file LinearEditDialog.cpp.

67{
68 std::vector<std::pair<std::size_t, double>> linear_values;
69
70 std::size_t nRows = tableWidget->rowCount();
71 for (std::size_t i = 0; i < nRows; i++)
72 {
73 QString row_text(tableWidget->item(i, 0)->text());
74 if (row_text.length() > 0)
75 {
76 linear_values.emplace_back(i, row_text.toDouble());
77 }
78 }
79
80 emit transmitDisValues(linear_values);
81 this->done(QDialog::Accepted);
82}
void transmitDisValues(std::vector< std::pair< std::size_t, double > >)

References transmitDisValues().

◆ on_comboBox_currentIndexChanged

void LinearEditDialog::on_comboBox_currentIndexChanged ( int index)
privateslot

Definition at line 53 of file LinearEditDialog.cpp.

54{
55 if (index > 0) // elevation
56 {
57 std::size_t nRows = tableWidget->rowCount();
58 for (std::size_t i = 0; i < nRows; i++)
59 {
60 tableWidget->item(i, 0)->setText(
61 QString::number((*_line.getPoint(i))[2]));
62 }
63 }
64}
const Point * getPoint(std::size_t i) const
returns the i-th point contained in the polyline
Definition Polyline.cpp:179

References _line, and GeoLib::Polyline::getPoint().

◆ reject

void LinearEditDialog::reject ( )
overrideprivateslot

Instructions if the Cancel-Button has been pressed.

Definition at line 84 of file LinearEditDialog.cpp.

85{
86 this->done(QDialog::Rejected);
87}

◆ setupDialog()

void LinearEditDialog::setupDialog ( const std::vector< std::size_t > & dis_nodes,
const std::vector< double > & dis_values )
private

Definition at line 27 of file LinearEditDialog.cpp.

29{
30 std::size_t nPoints(_line.getNumberOfPoints());
31 this->tableWidget->setRowCount(nPoints);
32 QList<QString> indexlist;
33
34 for (std::size_t i = 0; i < nPoints; i++)
35 {
36 indexlist.push_back(QString::number(i));
37 QTableWidgetItem* newItem = new QTableWidgetItem("");
38 tableWidget->setItem(i, 0, newItem);
39 }
40 QStringList vHeaders(indexlist);
41 tableWidget->setVerticalHeaderLabels(vHeaders);
42
43 std::size_t nValues(dis_values.size());
44 for (std::size_t i = 0; i < nValues; i++)
45 {
46 tableWidget->item(static_cast<int>(dis_nodes[i]), 0)
47 ->setText(QString::number(dis_values[i]));
48 }
49}
std::size_t getNumberOfPoints() const
Definition Polyline.cpp:109

References _line, and GeoLib::Polyline::getNumberOfPoints().

Referenced by LinearEditDialog().

◆ transmitDisValues

void LinearEditDialog::transmitDisValues ( std::vector< std::pair< std::size_t, double > > )
signal

Referenced by accept().

Member Data Documentation

◆ _line

const GeoLib::Polyline LinearEditDialog::_line
private

Definition at line 39 of file LinearEditDialog.h.

Referenced by on_comboBox_currentIndexChanged(), and setupDialog().


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