MCPcopy Create free account
hub / github.com/MrKepzie/Natron / copyNodesAndCreateInGroup

Method copyNodesAndCreateInGroup

Gui/NodeGraph45.cpp:638–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

636}
637
638void
639NodeGraph::copyNodesAndCreateInGroup(const NodesGuiList& nodes,
640 const boost::shared_ptr<NodeCollection>& group,
641 std::list<std::pair<std::string, NodeGuiPtr > >& createdNodes)
642{
643 {
644 CreatingNodeTreeFlag_RAII createNodeTree( getGui()->getApp() );
645 NodeClipBoard clipboard;
646 _imp->copyNodesInternal(nodes, clipboard);
647
648 std::map<std::string, std::string> oldNewScriptNamesMapping;
649 std::list<boost::shared_ptr<NodeSerialization> >::const_iterator itOther = clipboard.nodes.begin();
650 for (std::list<boost::shared_ptr<NodeGuiSerialization> >::const_iterator it = clipboard.nodesUI.begin();
651 it != clipboard.nodesUI.end(); ++it, ++itOther) {
652 NodeGuiPtr node = _imp->pasteNode( *itOther, *it, QPointF(0, 0), group, std::string(), false, &oldNewScriptNamesMapping);
653 assert(node);
654 if (node) {
655 oldNewScriptNamesMapping[(*itOther)->getNodeScriptName()] = node->getNode()->getScriptName();
656 createdNodes.push_back( std::make_pair( (*itOther)->getNodeScriptName(), node ) );
657 }
658 }
659 assert( clipboard.nodes.size() == createdNodes.size() );
660 if ( clipboard.nodes.size() != createdNodes.size() ) {
661 return;
662 }
663
664 ///Now that all nodes have been duplicated, try to restore nodes connections
665 _imp->restoreConnections(clipboard.nodes, createdNodes, oldNewScriptNamesMapping);
666
667 //Restore links once all children are created for alias knobs/expressions
668 NodesList allNodes;
669 group->getActiveNodes(&allNodes);
670 // If the group is a Group node, append to all nodes reachable through links
671 NodeGroup* isGroupNode = dynamic_cast<NodeGroup*>(group.get());
672 if (isGroupNode) {
673 allNodes.push_back(isGroupNode->getNode());
674 }
675
676 std::list<boost::shared_ptr<NodeSerialization> >::const_iterator itSerialization = clipboard.nodes.begin();
677 for (std::list<std::pair<std::string, NodeGuiPtr > > ::iterator it = createdNodes.begin(); it != createdNodes.end(); ++it, ++itSerialization) {
678 it->second->getNode()->restoreKnobsLinks(**itSerialization, allNodes, oldNewScriptNamesMapping);
679 }
680
681 }
682
683 getGui()->getApp()->getProject()->forceComputeInputDependentDataOnAllTrees();
684}
685
686QPointF
687NodeGraph::getRootPos() const

Callers 1

redoMethod · 0.80

Calls 15

getGuiFunction · 0.85
QPointFClass · 0.85
copyNodesInternalMethod · 0.80
pasteNodeMethod · 0.80
restoreConnectionsMethod · 0.80
getActiveNodesMethod · 0.80
restoreKnobsLinksMethod · 0.80
getProjectMethod · 0.80
getAppMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected