made node edge changes undoable

This commit is contained in:
itsmattkc
2019-07-17 00:14:49 -04:00
parent a78cc3950a
commit 39256fd6f9
15 changed files with 318 additions and 12 deletions
+26 -3
View File
@@ -113,9 +113,7 @@ bool NodeParam::AreDataTypesCompatible(const DataType &output_type, const QList<
NodeEdgePtr NodeParam::ConnectEdge(NodeOutput *output, NodeInput *input)
{
// If the input can only accept one input (the default) and has one already, disconnect it
if (!input->edges_.isEmpty() && !input->can_accept_multiple_inputs()) {
DisconnectEdge(input->edges_.first());
}
FreeSpaceForEdgeFromInput(input);
// Make sure it's not a duplicate of an edge that already exists
foreach (NodeEdgePtr existing, input->edges()) {
@@ -146,6 +144,31 @@ void NodeParam::DisconnectEdge(NodeEdgePtr edge)
emit output->EdgeRemoved(edge);
}
void NodeParam::DisconnectEdge(NodeOutput *output, NodeInput *input)
{
for (int i=0;i<output->edges_.size();i++) {
NodeEdgePtr edge = output->edges_.at(i);
if (edge->input() == input) {
DisconnectEdge(edge);
break;
}
}
}
NodeEdgePtr NodeParam::FreeSpaceForEdgeFromInput(NodeInput *input)
{
// If the input can only accept one input (the default) and has one already, disconnect it
if (!input->edges_.isEmpty() && !input->can_accept_multiple_inputs()) {
NodeEdgePtr edge = input->edges_.first();
DisconnectEdge(edge);
return edge;
}
return nullptr;
}
QString NodeParam::GetDefaultDataTypeName(const DataType& type)
{
switch (type) {