forked from paceholder/nodeeditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberDisplayDataModel.cpp
More file actions
73 lines (56 loc) · 1.34 KB
/
NumberDisplayDataModel.cpp
File metadata and controls
73 lines (56 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "NumberDisplayDataModel.hpp"
#include <QtWidgets/QLabel>
NumberDisplayDataModel::NumberDisplayDataModel()
: _label{nullptr}
{
this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::NoStatus);
}
unsigned int NumberDisplayDataModel::nPorts(PortType portType) const
{
unsigned int result = 1;
switch (portType) {
case PortType::In:
result = 1;
break;
case PortType::Out:
result = 0;
default:
break;
}
return result;
}
NodeDataType NumberDisplayDataModel::dataType(PortType, PortIndex) const
{
return DecimalData().type();
}
std::shared_ptr<NodeData> NumberDisplayDataModel::outData(PortIndex)
{
std::shared_ptr<NodeData> ptr;
return ptr;
}
void NumberDisplayDataModel::setInData(std::shared_ptr<NodeData> data, PortIndex portIndex)
{
_numberData = std::dynamic_pointer_cast<DecimalData>(data);
if (!_label)
return;
if (_numberData) {
_label->setText(_numberData->numberAsText());
} else {
_label->clear();
}
_label->adjustSize();
}
QWidget *NumberDisplayDataModel::embeddedWidget()
{
if (!_label) {
_label = new QLabel();
_label->setMargin(3);
}
return _label;
}
double NumberDisplayDataModel::number() const
{
if (_numberData)
return _numberData->number();
return 0.0;
}