add mode for copying values only and not connections
Sometimes we'll be copying nodes without wanting to copy their connections, since we'll want to connect them to equivalent copies rather than connecting them to the same nodes the originals were connected to. We now have an extra parameter to distinguish such operations.
This commit is contained in:
+2
-2
@@ -280,7 +280,7 @@ void NodeInput::set_maximum(const QVariant &max)
|
||||
has_maximum_ = true;
|
||||
}
|
||||
|
||||
void NodeInput::CopyValues(NodeInput *source, NodeInput *dest)
|
||||
void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_connections)
|
||||
{
|
||||
// Copy values
|
||||
dest->keyframes_ = source->keyframes_;
|
||||
@@ -289,7 +289,7 @@ void NodeInput::CopyValues(NodeInput *source, NodeInput *dest)
|
||||
dest->set_is_keyframing(source->is_keyframing());
|
||||
|
||||
// Copy connections
|
||||
if (source->get_connected_output() != nullptr) {
|
||||
if (include_connections && source->get_connected_output() != nullptr) {
|
||||
ConnectEdge(source->get_connected_output(), dest);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public:
|
||||
/**
|
||||
* @brief Copy all values including keyframe information and connections from another NodeInput
|
||||
*/
|
||||
static void CopyValues(NodeInput* source, NodeInput* dest);
|
||||
static void CopyValues(NodeInput* source, NodeInput* dest, bool include_connections = true);
|
||||
|
||||
signals:
|
||||
void ValueChanged(const rational& start, const rational& end);
|
||||
|
||||
+34
-2
@@ -152,7 +152,7 @@ bool Node::IsProcessingLocked()
|
||||
}
|
||||
}
|
||||
|
||||
void Node::CopyInputs(Node *source, Node *destination)
|
||||
void Node::CopyInputs(Node *source, Node *destination, bool include_connections)
|
||||
{
|
||||
Q_ASSERT(source->id() == destination->id());
|
||||
|
||||
@@ -166,7 +166,39 @@ void Node::CopyInputs(Node *source, Node *destination)
|
||||
if (src->dependent()) {
|
||||
NodeInput* dst = static_cast<NodeInput*>(dst_param.at(i));
|
||||
|
||||
NodeInput::CopyValues(src, dst);
|
||||
NodeInput::CopyValues(src, dst, include_connections);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Node::DuplicateConnectionsBetweenLists(const QList<Node *> &source, const QList<Node *> &destination)
|
||||
{
|
||||
Q_ASSERT(source.size() == destination.size());
|
||||
|
||||
for (int i=0;i<source.size();i++) {
|
||||
Node* source_node = source.at(i);
|
||||
Node* dest_node = destination.at(i);
|
||||
|
||||
for (int j=0;j<source_node->params_.size();j++) {
|
||||
NodeParam* source_param = source_node->params_.at(j);
|
||||
|
||||
if (source_param->type() == NodeInput::kInput && source_param->IsConnected()) {
|
||||
NodeInput* source_input = static_cast<NodeInput*>(source_param);
|
||||
NodeInput* dest_input = static_cast<NodeInput*>(dest_node->params_.at(j));
|
||||
|
||||
// Get this input's connected outputs
|
||||
NodeOutput* connected_output = source_input->get_connected_output();
|
||||
Node* connected_node = connected_output->parent();
|
||||
|
||||
// Find index of connected output in source list
|
||||
int connection_index = source.indexOf(connected_node);
|
||||
|
||||
// Find equivalent in destination list
|
||||
Node* dest_output_node = destination.at(connection_index);
|
||||
NodeOutput* dest_output = static_cast<NodeOutput*>(dest_output_node->params_.at(connected_output->index()));
|
||||
|
||||
NodeParam::ConnectEdge(dest_output, dest_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -214,7 +214,12 @@ public:
|
||||
*
|
||||
* Nodes must be of the same types (i.e. have the same ID)
|
||||
*/
|
||||
static void CopyInputs(Node* source, Node* destination);
|
||||
static void CopyInputs(Node* source, Node* destination, bool include_connections = true);
|
||||
|
||||
/**
|
||||
* @brief For a list of copies nodes, this function will duplicate all the connections in the source list to the destination list
|
||||
*/
|
||||
static void DuplicateConnectionsBetweenLists(const QList<Node*>& source, const QList<Node *> &destination);
|
||||
|
||||
/**
|
||||
* @brief Return whether this Node can be deleted or not
|
||||
|
||||
Reference in New Issue
Block a user