loom
42 строки · 858.0 Байт
1#include "MathOperationDataModel.hpp"
2
3#include "DecimalData.hpp"
4
5unsigned int MathOperationDataModel::nPorts(PortType portType) const
6{
7unsigned int result;
8
9if (portType == PortType::In)
10result = 2;
11else
12result = 1;
13
14return result;
15}
16
17NodeDataType MathOperationDataModel::dataType(PortType, PortIndex) const
18{
19return DecimalData().type();
20}
21
22std::shared_ptr<NodeData> MathOperationDataModel::outData(PortIndex)
23{
24return std::static_pointer_cast<NodeData>(_result);
25}
26
27void MathOperationDataModel::setInData(std::shared_ptr<NodeData> data, PortIndex portIndex)
28{
29auto numberData = std::dynamic_pointer_cast<DecimalData>(data);
30
31if (!data) {
32Q_EMIT dataInvalidated(0);
33}
34
35if (portIndex == 0) {
36_number1 = numberData;
37} else {
38_number2 = numberData;
39}
40
41compute();
42}
43