2016-04-07 22:37:28 +02:00
|
|
|
#pragma once
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2016-01-03 19:45:47 +01:00
|
|
|
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
|
|
2016-04-20 23:18:10 +02:00
|
|
|
#include "PortType.hpp"
|
2016-03-29 08:45:30 +02:00
|
|
|
#include "NodeData.hpp"
|
2016-09-23 09:45:07 +02:00
|
|
|
#include "Serializable.hpp"
|
2017-04-22 06:01:42 -06:00
|
|
|
#include "NodeGeometry.hpp"
|
2017-04-24 11:18:54 +02:00
|
|
|
#include "NodeStyle.hpp"
|
2017-04-25 14:39:22 +02:00
|
|
|
#include "NodePainterDelegate.hpp"
|
2016-09-14 22:25:48 +02:00
|
|
|
#include "Export.hpp"
|
2018-05-02 08:54:58 -07:00
|
|
|
#include "memory.hpp"
|
2018-08-09 20:19:12 -06:00
|
|
|
#include "FlowSceneModel.hpp"
|
2016-09-14 22:25:48 +02:00
|
|
|
|
2017-01-30 10:31:43 +01:00
|
|
|
namespace QtNodes
|
|
|
|
|
{
|
|
|
|
|
|
2017-04-25 14:39:22 +02:00
|
|
|
class StyleCollection;
|
|
|
|
|
|
2016-09-14 22:25:48 +02:00
|
|
|
class NODE_EDITOR_PUBLIC NodeDataModel
|
2016-09-18 15:05:14 +02:00
|
|
|
: public QObject
|
2016-09-23 09:45:07 +02:00
|
|
|
, public Serializable
|
2015-12-23 14:47:08 +01:00
|
|
|
{
|
2016-08-21 17:41:34 +02:00
|
|
|
Q_OBJECT
|
2016-04-07 22:37:28 +02:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2017-04-25 14:39:22 +02:00
|
|
|
NodeDataModel();
|
2017-04-24 11:18:54 +02:00
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
virtual
|
2017-04-25 14:39:22 +02:00
|
|
|
~NodeDataModel() = default;
|
2016-01-03 19:45:47 +01:00
|
|
|
|
2016-09-23 09:45:07 +02:00
|
|
|
/// Caption is used in GUI
|
2016-09-18 15:05:14 +02:00
|
|
|
virtual QString
|
2016-09-23 09:45:07 +02:00
|
|
|
caption() const = 0;
|
|
|
|
|
|
|
|
|
|
/// It is possible to hide caption in GUI
|
|
|
|
|
virtual bool
|
|
|
|
|
captionVisible() const { return true; }
|
2016-11-22 22:01:28 +01:00
|
|
|
|
2017-01-12 23:10:03 +01:00
|
|
|
/// Port caption is used in GUI to label individual ports
|
|
|
|
|
virtual QString
|
2017-05-13 16:38:33 +02:00
|
|
|
portCaption(PortType, PortIndex) const { return QString(); }
|
2017-01-12 23:10:03 +01:00
|
|
|
|
|
|
|
|
/// It is possible to hide port caption in GUI
|
|
|
|
|
virtual bool
|
2017-05-13 16:38:33 +02:00
|
|
|
portCaptionVisible(PortType, PortIndex) const { return false; }
|
2017-01-12 23:10:03 +01:00
|
|
|
|
2016-11-25 02:14:51 +01:00
|
|
|
/// Name makes this model unique
|
|
|
|
|
virtual QString
|
|
|
|
|
name() const = 0;
|
|
|
|
|
|
2017-01-31 21:30:56 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
QJsonObject
|
2017-04-25 14:39:22 +02:00
|
|
|
save() const override;
|
2017-01-31 21:30:56 +01:00
|
|
|
|
2015-12-23 14:47:08 +01:00
|
|
|
public:
|
|
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
virtual
|
2018-08-22 22:36:34 +02:00
|
|
|
unsigned int
|
|
|
|
|
nPorts(PortType portType) const = 0;
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2016-08-06 22:48:37 +02:00
|
|
|
virtual
|
2018-08-22 22:36:34 +02:00
|
|
|
NodeDataType
|
|
|
|
|
dataType(PortType portType, PortIndex portIndex) const = 0;
|
2016-08-06 22:48:37 +02:00
|
|
|
|
2017-04-24 21:57:21 +02:00
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
ConnectionPolicy
|
|
|
|
|
portOutConnectionPolicy(PortIndex) const
|
|
|
|
|
{
|
|
|
|
|
return ConnectionPolicy::Many;
|
2017-04-22 13:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
2017-04-24 11:18:54 +02:00
|
|
|
NodeStyle const&
|
2017-04-25 14:39:22 +02:00
|
|
|
nodeStyle() const;
|
2017-04-24 11:18:54 +02:00
|
|
|
|
|
|
|
|
void
|
2017-04-25 14:39:22 +02:00
|
|
|
setNodeStyle(NodeStyle const& style);
|
2018-08-22 22:36:34 +02:00
|
|
|
|
2016-08-22 22:20:34 +02:00
|
|
|
public:
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2016-01-03 19:45:47 +01:00
|
|
|
/// Triggers the algorithm
|
2016-09-18 15:05:14 +02:00
|
|
|
virtual
|
|
|
|
|
void
|
|
|
|
|
setInData(std::shared_ptr<NodeData> nodeData,
|
|
|
|
|
PortIndex port) = 0;
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2016-08-22 22:20:34 +02:00
|
|
|
virtual
|
2016-09-18 15:05:14 +02:00
|
|
|
std::shared_ptr<NodeData>
|
|
|
|
|
outData(PortIndex port) = 0;
|
2016-08-22 22:20:34 +02:00
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
virtual
|
|
|
|
|
QWidget *
|
|
|
|
|
embeddedWidget() = 0;
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
bool
|
|
|
|
|
resizable() const { return false; }
|
2017-01-30 10:31:43 +01:00
|
|
|
|
2017-01-25 11:34:03 +01:00
|
|
|
virtual
|
|
|
|
|
NodeValidationState
|
|
|
|
|
validationState() const { return NodeValidationState::Valid; }
|
|
|
|
|
|
|
|
|
|
virtual
|
|
|
|
|
QString
|
|
|
|
|
validationMessage() const { return QString(""); }
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2017-04-22 06:01:42 -06:00
|
|
|
virtual
|
2018-08-22 22:36:34 +02:00
|
|
|
NodePainterDelegate*
|
|
|
|
|
painterDelegate() const { return nullptr; }
|
2017-04-22 06:01:42 -06:00
|
|
|
|
2016-01-03 19:45:47 +01:00
|
|
|
signals:
|
2015-12-23 14:47:08 +01:00
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
void
|
|
|
|
|
dataUpdated(PortIndex index);
|
2016-08-21 17:41:34 +02:00
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
void
|
|
|
|
|
dataInvalidated(PortIndex index);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
computingStarted();
|
2016-09-23 09:45:07 +02:00
|
|
|
|
2016-09-18 15:05:14 +02:00
|
|
|
void
|
|
|
|
|
computingFinished();
|
2017-04-24 11:18:54 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
NodeStyle _nodeStyle;
|
2015-12-23 14:47:08 +01:00
|
|
|
};
|
2017-01-30 10:31:43 +01:00
|
|
|
}
|