2016-08-21 19:20:29 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtWidgets/QLabel>
|
|
|
|
|
|
|
|
|
|
#include <nodes/NodeDataModel>
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2017-01-30 10:31:43 +01:00
|
|
|
using QtNodes::PortType;
|
|
|
|
|
using QtNodes::PortIndex;
|
|
|
|
|
using QtNodes::NodeData;
|
|
|
|
|
using QtNodes::NodeDataType;
|
|
|
|
|
using QtNodes::NodeDataModel;
|
|
|
|
|
using QtNodes::NodeValidationState;
|
|
|
|
|
|
2016-08-21 19:20:29 +02:00
|
|
|
/// The model dictates the number of inputs and outputs for the Node.
|
|
|
|
|
/// In this example it has no logic.
|
|
|
|
|
class NumberDisplayDataModel : public NodeDataModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
NumberDisplayDataModel();
|
|
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
virtual
|
|
|
|
|
~NumberDisplayDataModel() {}
|
2016-08-21 19:20:29 +02:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
|
caption() const override
|
2017-01-30 18:03:50 +01:00
|
|
|
{ return QStringLiteral("Result"); }
|
2016-09-23 09:45:07 +02:00
|
|
|
|
2016-09-26 16:48:04 +02:00
|
|
|
bool
|
|
|
|
|
captionVisible() const override
|
|
|
|
|
{ return false; }
|
|
|
|
|
|
2016-11-22 22:01:28 +01:00
|
|
|
QString
|
|
|
|
|
name() const override
|
2017-01-30 18:03:50 +01:00
|
|
|
{ return QStringLiteral("Result"); }
|
2016-08-22 22:20:34 +02:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
public:
|
2016-08-21 19:20:29 +02:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
unsigned int
|
|
|
|
|
nPorts(PortType portType) const override;
|
2016-08-21 19:20:29 +02:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
NodeDataType
|
|
|
|
|
dataType(PortType portType,
|
|
|
|
|
PortIndex portIndex) const override;
|
2016-08-21 19:20:29 +02:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
std::shared_ptr<NodeData>
|
|
|
|
|
outData(PortIndex port) override;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
setInData(std::shared_ptr<NodeData> data, int) override;
|
|
|
|
|
|
|
|
|
|
QWidget *
|
|
|
|
|
embeddedWidget() override { return _label; }
|
2016-08-21 19:20:29 +02:00
|
|
|
|
2017-01-31 21:30:56 +01:00
|
|
|
NodeValidationState
|
2017-01-25 11:34:03 +01:00
|
|
|
validationState() const override;
|
|
|
|
|
|
2017-01-31 21:30:56 +01:00
|
|
|
QString
|
2017-01-25 11:34:03 +01:00
|
|
|
validationMessage() const override;
|
|
|
|
|
|
2016-08-21 19:20:29 +02:00
|
|
|
private:
|
|
|
|
|
|
2017-01-25 11:34:03 +01:00
|
|
|
NodeValidationState modelValidationState = NodeValidationState::Warning;
|
2017-01-30 18:03:50 +01:00
|
|
|
QString modelValidationError = QStringLiteral("Missing or incorrect inputs");
|
2017-01-25 11:34:03 +01:00
|
|
|
|
2016-08-21 19:20:29 +02:00
|
|
|
QLabel * _label;
|
|
|
|
|
};
|