sequence is now a node graph
This commit is contained in:
+25
-2
@@ -1,6 +1,29 @@
|
||||
#include "node.h"
|
||||
|
||||
Node::Node(NodeGraph *graph)
|
||||
{
|
||||
#include "nodegraph.h"
|
||||
|
||||
Node::Node(NodeGraph *graph) :
|
||||
QObject(graph)
|
||||
{
|
||||
}
|
||||
|
||||
void Node::AddParameter(NodeIO *param)
|
||||
{
|
||||
param->setParent(this);
|
||||
parameters_.append(param);
|
||||
}
|
||||
|
||||
int Node::IndexOfParameter(NodeIO *param)
|
||||
{
|
||||
return parameters_.indexOf(param);
|
||||
}
|
||||
|
||||
NodeIO *Node::Parameter(int i)
|
||||
{
|
||||
return parameters_.at(i);
|
||||
}
|
||||
|
||||
int Node::ParameterCount()
|
||||
{
|
||||
return parameters_.size();
|
||||
}
|
||||
|
||||
+10
-5
@@ -3,18 +3,23 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "nodes/nodeio.h"
|
||||
|
||||
class NodeGraph;
|
||||
|
||||
class Node;
|
||||
using NodePtr = std::shared_ptr<Node>;
|
||||
|
||||
class Node
|
||||
class Node : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Node(NodeGraph* parent);
|
||||
|
||||
void AddParameter(NodeIO* row);
|
||||
int IndexOfParameter(NodeIO* row);
|
||||
NodeIO* Parameter(int i);
|
||||
int ParameterCount();
|
||||
|
||||
private:
|
||||
NodeGraph* parent_;
|
||||
QVector<NodeIO*> parameters_;
|
||||
};
|
||||
|
||||
#endif // NODE_H
|
||||
|
||||
+12
-6
@@ -1,20 +1,26 @@
|
||||
#include "nodegraph.h"
|
||||
|
||||
#include <QChildEvent>
|
||||
#include <QDebug>
|
||||
|
||||
NodeGraph::NodeGraph() :
|
||||
output_node_(nullptr)
|
||||
NodeGraph::NodeGraph()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NodeGraph::AddNode(NodePtr node)
|
||||
void NodeGraph::childEvent(QChildEvent *event)
|
||||
{
|
||||
nodes_.append(node);
|
||||
emit NodeGraphChanged();
|
||||
if (event->type() == QEvent::ChildAdded || event->type() == QEvent::ChildRemoved) {
|
||||
emit NodeGraphChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeGraph::SetOutputNode(Node *node)
|
||||
{
|
||||
output_node_ = node;
|
||||
}
|
||||
|
||||
Node *NodeGraph::OutputNode()
|
||||
{
|
||||
return output_node_.get();
|
||||
return output_node_;
|
||||
}
|
||||
|
||||
+5
-13
@@ -12,15 +12,6 @@ class NodeGraph : public QObject
|
||||
public:
|
||||
NodeGraph();
|
||||
|
||||
/**
|
||||
* @brief Add a node to this graph
|
||||
*
|
||||
* The graph takes ownership of the node.
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
void AddNode(NodePtr node);
|
||||
|
||||
/**
|
||||
* @brief Process the graph
|
||||
*
|
||||
@@ -43,7 +34,7 @@ public:
|
||||
*
|
||||
* The node to set as the output node. The graph takes ownership of the node and the user cannot delete it.
|
||||
*/
|
||||
void SetOutputNode(NodePtr node);
|
||||
void SetOutputNode(Node* node);
|
||||
|
||||
/**
|
||||
* @brief Returns the currently set output node
|
||||
@@ -53,10 +44,11 @@ public:
|
||||
signals:
|
||||
void NodeGraphChanged();
|
||||
|
||||
private:
|
||||
NodePtr output_node_;
|
||||
protected:
|
||||
virtual void childEvent(QChildEvent *event) override;
|
||||
|
||||
QVector<NodePtr> nodes_;
|
||||
private:
|
||||
Node* output_node_;
|
||||
};
|
||||
|
||||
#endif // NODEGRAPH_H
|
||||
|
||||
Reference in New Issue
Block a user