| 636 | } |
| 637 | |
| 638 | void |
| 639 | NodeGraph::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 | |
| 686 | QPointF |
| 687 | NodeGraph::getRootPos() const |
no test coverage detected