OGS
LinearEditDialog.cpp
Go to the documentation of this file.
1
15#include "LinearEditDialog.h"
16
18 const std::vector<std::size_t>& dis_nodes,
19 const std::vector<double>& dis_values,
20 QDialog* parent)
21 : QDialog(parent), _line(line)
22{
23 setupUi(this);
24 setupDialog(dis_nodes, dis_values);
25}
26
27void LinearEditDialog::setupDialog(const std::vector<std::size_t>& dis_nodes,
28 const std::vector<double>& dis_values)
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}
50
52
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}
65
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}
83
85{
86 this->done(QDialog::Rejected);
87}
Definition of the LinearEditDialog class.
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:40
std::size_t getNumberOfPoints() const
Definition Polyline.cpp:109
const Point * getPoint(std::size_t i) const
returns the i-th point contained in the polyline
Definition Polyline.cpp:179
void reject() override
Instructions if the Cancel-Button has been pressed.
const GeoLib::Polyline _line
~LinearEditDialog() override
void on_comboBox_currentIndexChanged(int index)
void setupDialog(const std::vector< std::size_t > &dis_nodes, const std::vector< double > &dis_values)
void accept() override
Instructions if the OK-Button has been pressed.
LinearEditDialog(const GeoLib::Polyline &line, const std::vector< std::size_t > &dis_nodes, const std::vector< double > &dis_values, QDialog *parent=nullptr)
void transmitDisValues(std::vector< std::pair< std::size_t, double > >)