OGS
LinearEditDialog.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "LinearEditDialog.h"
5
7 const std::vector<std::size_t>& dis_nodes,
8 const std::vector<double>& dis_values,
9 QDialog* parent)
10 : QDialog(parent), _line(line)
11{
12 setupUi(this);
13 setupDialog(dis_nodes, dis_values);
14}
15
16void LinearEditDialog::setupDialog(const std::vector<std::size_t>& dis_nodes,
17 const std::vector<double>& dis_values)
18{
19 std::size_t nPoints(_line.getNumberOfPoints());
20 this->tableWidget->setRowCount(nPoints);
21 QList<QString> indexlist;
22
23 for (std::size_t i = 0; i < nPoints; i++)
24 {
25 indexlist.push_back(QString::number(i));
26 QTableWidgetItem* newItem = new QTableWidgetItem("");
27 tableWidget->setItem(i, 0, newItem);
28 }
29 QStringList vHeaders(indexlist);
30 tableWidget->setVerticalHeaderLabels(vHeaders);
31
32 std::size_t nValues(dis_values.size());
33 for (std::size_t i = 0; i < nValues; i++)
34 {
35 tableWidget->item(static_cast<int>(dis_nodes[i]), 0)
36 ->setText(QString::number(dis_values[i]));
37 }
38}
39
41
43{
44 if (index > 0) // elevation
45 {
46 std::size_t nRows = tableWidget->rowCount();
47 for (std::size_t i = 0; i < nRows; i++)
48 {
49 tableWidget->item(i, 0)->setText(
50 QString::number((*_line.getPoint(i))[2]));
51 }
52 }
53}
54
56{
57 std::vector<std::pair<std::size_t, double>> linear_values;
58
59 std::size_t nRows = tableWidget->rowCount();
60 for (std::size_t i = 0; i < nRows; i++)
61 {
62 QString row_text(tableWidget->item(i, 0)->text());
63 if (row_text.length() > 0)
64 {
65 linear_values.emplace_back(i, row_text.toDouble());
66 }
67 }
68
69 emit transmitDisValues(linear_values);
70 this->done(QDialog::Accepted);
71}
72
74{
75 this->done(QDialog::Rejected);
76}
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:29
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 > >)