OGS
VtkAlgorithmPropertyVectorEdit.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// ** INCLUDES **
6
7#include <QDoubleValidator>
8#include <QHBoxLayout>
9#include <QIntValidator>
10#include <QLineEdit>
11#include <QSize>
12#include <utility>
13
15
17 const QList<QString> contents,
18 QString name,
19 QVariant::Type type,
20 VtkAlgorithmProperties* algProps,
21 QWidget* parent /*= 0*/)
22 : QWidget(parent), _name(std::move(name)), _algProps(algProps), _type(type)
23{
24 auto* layout = new QHBoxLayout;
25 layout->setSpacing(3);
26 layout->setContentsMargins(0, 0, 0, 0);
27
28 foreach (QString content, contents)
29 {
30 auto* lineEdit = new QLineEdit(content, this);
31 layout->addWidget(lineEdit);
32
33 switch (_type)
34 {
35 case QVariant::Double:
36 lineEdit->setValidator(new QDoubleValidator(this));
37 break;
38
39 case QVariant::Int:
40 lineEdit->setValidator(new QIntValidator(this));
41 break;
42
43 default:
44 break;
45 }
46
47 connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(setNewValue()));
48 }
49
50 this->setLayout(layout);
51 this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
52}
53
55
57{
58 QLayout* layout = this->layout();
59 QList<QVariant> list;
60 for (int i = 0; i < layout->count(); ++i)
61 {
62 auto* lineEdit = static_cast<QLineEdit*>(layout->itemAt(i)->widget());
63 list.push_back(QVariant(lineEdit->text()));
64 }
65
66 _algProps->SetUserVectorProperty(_name, list);
67
68 emit editingFinished();
69}
Contains properties for the visualization of objects as VtkVisPipelineItems.
void editingFinished()
Is emitted when text of one the line edits changed.
void setNewValue()
This slots is automatically called when the checkbox state changed.
VtkAlgorithmPropertyVectorEdit(const QList< QString > contents, QString name, QVariant::Type type, VtkAlgorithmProperties *algProps, QWidget *parent=nullptr)
Constructor.
~VtkAlgorithmPropertyVectorEdit() override