123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #ifndef FLOWGRAPHMODEL_H
- #define FLOWGRAPHMODEL_H
- #include <QJsonObject>
- #include <QPointF>
- #include <QSize>
- #include <QtNodes/AbstractGraphModel>
- #include <QtNodes/ConnectionIdUtils>
- #include <QtNodes/StyleCollection>
- using ConnectionId = QtNodes::ConnectionId;
- using ConnectionPolicy = QtNodes::ConnectionPolicy;
- using NodeFlag = QtNodes::NodeFlag;
- using NodeId = QtNodes::NodeId;
- using NodeRole = QtNodes::NodeRole;
- using PortIndex = QtNodes::PortIndex;
- using PortRole = QtNodes::PortRole;
- using PortType = QtNodes::PortType;
- using StyleCollection = QtNodes::StyleCollection;
- using QtNodes::InvalidNodeId;
- class FlowGraphModel : public QtNodes::AbstractGraphModel
- {
- Q_OBJECT
- public:
- struct NodeGeometryData
- {
- QSize size;
- QPointF pos;
- };
- public:
- FlowGraphModel();
- ~FlowGraphModel() override;
- std::unordered_set<NodeId> allNodeIds() const override;
- std::unordered_set<ConnectionId> allConnectionIds(NodeId const nodeId) const override;
- std::unordered_set<ConnectionId> connections(NodeId nodeId, PortType portType, PortIndex portIndex) const override;
- bool connectionExists(ConnectionId const connectionId) const override;
- NodeId addNode(QString const nodeType = QString()) override;
-
- bool connectionPossible(ConnectionId const connectionId) const override;
- void addConnection(ConnectionId const connectionId) override;
- bool nodeExists(NodeId const nodeId) const override;
- QVariant nodeData(NodeId nodeId, NodeRole role) const override;
- bool setNodeData(NodeId nodeId, NodeRole role, QVariant value) override;
- QVariant portData(NodeId nodeId, PortType portType, PortIndex portIndex, PortRole role) const override;
- bool setPortData(NodeId nodeId, PortType portType, PortIndex portIndex, QVariant const &value,
- PortRole role = PortRole::Data) override;
- bool deleteConnection(ConnectionId const connectionId) override;
- bool deleteNode(NodeId const nodeId) override;
- QJsonObject saveNode(NodeId const) const override;
-
-
- void loadNode(QJsonObject const &nodeJson) override;
- NodeId newNodeId() override { return _nextNodeId++; }
- private:
- std::unordered_set<NodeId> _nodeIds;
-
-
-
-
-
-
-
- std::unordered_set<ConnectionId> _connectivity;
- mutable std::unordered_map<NodeId, NodeGeometryData> _nodeGeometryData;
-
- unsigned int _nextNodeId;
- };
- #endif
|