added IDs to parameters for serialization
This commit is contained in:
@@ -24,19 +24,19 @@
|
||||
|
||||
Block::Block()
|
||||
{
|
||||
previous_input_ = new NodeInput();
|
||||
previous_input_ = new NodeInput("prev_block");
|
||||
previous_input_->add_data_input(NodeParam::kBlock);
|
||||
AddParameter(previous_input_);
|
||||
|
||||
block_output_ = new NodeOutput();
|
||||
block_output_ = new NodeOutput("block_out");
|
||||
block_output_->set_data_type(NodeParam::kBlock);
|
||||
AddParameter(block_output_);
|
||||
|
||||
next_input_ = new NodeInput();
|
||||
next_input_ = new NodeInput("next_block");
|
||||
next_input_->add_data_input(NodeParam::kBlock);
|
||||
AddParameter(next_input_);
|
||||
|
||||
texture_output_ = new NodeOutput();
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
texture_output_->set_data_type(NodeParam::kTexture);
|
||||
AddParameter(texture_output_);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
ClipBlock::ClipBlock()
|
||||
{
|
||||
texture_input_ = new NodeInput();
|
||||
texture_input_ = new NodeInput("tex_in");
|
||||
texture_input_->add_data_input(NodeInput::kTexture);
|
||||
AddParameter(texture_input_);
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
SolidGenerator::SolidGenerator() :
|
||||
texture_(nullptr)
|
||||
{
|
||||
color_input_ = new NodeInput();
|
||||
color_input_ = new NodeInput("color_in");
|
||||
color_input_->add_data_input(NodeParam::kColor);
|
||||
AddParameter(color_input_);
|
||||
|
||||
texture_output_ = new NodeOutput();
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
texture_output_->set_data_type(NodeOutput::kTexture);
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
+2
-1
@@ -22,7 +22,8 @@
|
||||
|
||||
#include "output.h"
|
||||
|
||||
NodeInput::NodeInput() :
|
||||
NodeInput::NodeInput(const QString& id) :
|
||||
NodeParam(id),
|
||||
keyframing_(false),
|
||||
can_accept_multiple_inputs_(false)
|
||||
{
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class NodeInput : public NodeParam
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
NodeInput();
|
||||
NodeInput(const QString &id);
|
||||
|
||||
/**
|
||||
* @brief Returns kInput
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
MediaInput::MediaInput() :
|
||||
decoder_(nullptr)
|
||||
{
|
||||
footage_input_ = new NodeInput();
|
||||
footage_input_ = new NodeInput("footage_in");
|
||||
footage_input_->add_data_input(NodeInput::kFootage);
|
||||
AddParameter(footage_input_);
|
||||
|
||||
texture_output_ = new NodeOutput();
|
||||
texture_output_ = new NodeOutput("tex_out");
|
||||
texture_output_->set_data_type(NodeOutput::kTexture);
|
||||
AddParameter(texture_output_);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,9 @@ void Node::Release()
|
||||
|
||||
void Node::AddParameter(NodeParam *param)
|
||||
{
|
||||
// Ensure no other param with this ID has been added to this Node (since that defeats the purpose)
|
||||
Q_ASSERT(!HasParamWithID(param->id()));
|
||||
|
||||
param->setParent(this);
|
||||
|
||||
connect(param, SIGNAL(EdgeAdded(NodeEdgePtr)), this, SIGNAL(EdgeAdded(NodeEdgePtr)));
|
||||
@@ -120,3 +123,18 @@ QVariant Node::PtrToValue(void *ptr)
|
||||
{
|
||||
return reinterpret_cast<quintptr>(ptr);
|
||||
}
|
||||
|
||||
bool Node::HasParamWithID(const QString &id)
|
||||
{
|
||||
QList<NodeParam*> params = parameters();
|
||||
|
||||
foreach (NodeParam* p, params)
|
||||
{
|
||||
if (p->id() == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,6 +179,12 @@ signals:
|
||||
* The edge that was removed
|
||||
*/
|
||||
void EdgeRemoved(NodeEdgePtr edge);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Return whether a parameter with ID `id` has already been added to this Node
|
||||
*/
|
||||
bool HasParamWithID(const QString& id);
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
NodeOutput::NodeOutput()
|
||||
NodeOutput::NodeOutput(const QString &id) :
|
||||
NodeParam(id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NodeParam::Type NodeOutput::type()
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ public:
|
||||
/**
|
||||
* @brief NodeOutput Constructor
|
||||
*/
|
||||
NodeOutput();
|
||||
NodeOutput(const QString& id);
|
||||
|
||||
/**
|
||||
* @brief Returns kOutput
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
ViewerOutput::ViewerOutput() :
|
||||
attached_viewer_(nullptr)
|
||||
{
|
||||
texture_input_ = new NodeInput();
|
||||
texture_input_ = new NodeInput("tex_out");
|
||||
texture_input_->add_data_input(NodeInput::kTexture);
|
||||
AddParameter(texture_input_);
|
||||
}
|
||||
|
||||
+8
-1
@@ -26,8 +26,15 @@
|
||||
#include "node/input.h"
|
||||
#include "node/output.h"
|
||||
|
||||
NodeParam::NodeParam()
|
||||
NodeParam::NodeParam(const QString &id) :
|
||||
id_(id)
|
||||
{
|
||||
Q_ASSERT(!id_.isEmpty());
|
||||
}
|
||||
|
||||
const QString NodeParam::id()
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
const QString &NodeParam::name()
|
||||
|
||||
+11
-1
@@ -72,7 +72,12 @@ public:
|
||||
/**
|
||||
* @brief NodeParam Constructor
|
||||
*/
|
||||
NodeParam();
|
||||
NodeParam(const QString& id);
|
||||
|
||||
/**
|
||||
* @brief Return ID of this parameter
|
||||
*/
|
||||
const QString id();
|
||||
|
||||
/**
|
||||
* @brief The type of node paramter this is
|
||||
@@ -220,6 +225,11 @@ private:
|
||||
*/
|
||||
QString name_;
|
||||
|
||||
/**
|
||||
* @brief Internal ID string
|
||||
*/
|
||||
QString id_;
|
||||
|
||||
};
|
||||
|
||||
#endif // NODEPARAM_H
|
||||
|
||||
Reference in New Issue
Block a user