| 646 | } |
| 647 | |
| 648 | void |
| 649 | NodeGraph::copyNodesAndCreateInGroup(const NodesGuiList& nodes, |
| 650 | const NodeCollectionPtr& group, |
| 651 | std::list<std::pair<std::string, NodeGuiPtr> >& createdNodes) |
| 652 | { |
| 653 | { |
| 654 | CreatingNodeTreeFlag_RAII createNodeTree( getGui()->getApp() ); |
| 655 | NodeClipBoard clipboard; |
| 656 | _imp->copyNodesInternal(nodes, clipboard); |
| 657 | |
| 658 | std::map<std::string, std::string> oldNewScriptNamesMapping; |
| 659 | std::list<NodeSerializationPtr>::const_iterator itOther = clipboard.nodes.begin(); |
| 660 | for (std::list<NodeGuiSerializationPtr>::const_iterator it = clipboard.nodesUI.begin(); |
| 661 | it != clipboard.nodesUI.end(); ++it, ++itOther) { |
| 662 | NodeGuiPtr node = _imp->pasteNode( *itOther, *it, QPointF(0, 0), group, std::string(), false, &oldNewScriptNamesMapping); |
| 663 | assert(node); |
| 664 | if (node) { |
| 665 | oldNewScriptNamesMapping[(*itOther)->getNodeScriptName()] = node->getNode()->getScriptName(); |
| 666 | createdNodes.push_back( std::make_pair( (*itOther)->getNodeScriptName(), node ) ); |
| 667 | } |
| 668 | } |
| 669 | assert( clipboard.nodes.size() == createdNodes.size() ); |
| 670 | if ( clipboard.nodes.size() != createdNodes.size() ) { |
| 671 | return; |
| 672 | } |
| 673 | |
| 674 | ///Now that all nodes have been duplicated, try to restore nodes connections |
| 675 | _imp->restoreConnections(clipboard.nodes, createdNodes, oldNewScriptNamesMapping); |
| 676 | |
| 677 | //Restore links once all children are created for alias knobs/expressions |
| 678 | NodesList allNodes; |
| 679 | getGui()->getApp()->getProject()->getActiveNodesExpandGroups(&allNodes); |
| 680 | |
| 681 | std::list<NodeSerializationPtr>::const_iterator itSerialization = clipboard.nodes.begin(); |
| 682 | for (std::list<std::pair<std::string, NodeGuiPtr> > ::iterator it = createdNodes.begin(); it != createdNodes.end(); ++it, ++itSerialization) { |
| 683 | it->second->getNode()->storeKnobsLinks(**itSerialization, oldNewScriptNamesMapping); |
| 684 | it->second->getNode()->restoreKnobsLinks(allNodes, oldNewScriptNamesMapping, true); // may not fail |
| 685 | } |
| 686 | |
| 687 | } |
| 688 | |
| 689 | getGui()->getApp()->getProject()->forceComputeInputDependentDataOnAllTrees(); |
| 690 | } |
| 691 | |
| 692 | QPointF |
| 693 | NodeGraph::getRootPos() const |
no test coverage detected