MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / pasteNodesInternal

Method pasteNodesInternal

Gui/NodeGraphPrivate10.cpp:52–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50
51
52NATRON_NAMESPACE_ENTER
53
54
55void
56NodeGraphPrivate::pasteNodesInternal(const NodeClipBoard & clipboard,
57 const QPointF& scenePos,
58 bool useUndoCommand,
59 std::list<std::pair<std::string, NodeGuiPtr> > *newNodes)
60{
61 if ( !clipboard.isEmpty() ) {
62 double xmax = std::numeric_limits<int>::min();
63 double xmin = std::numeric_limits<int>::max();
64 double ymin = std::numeric_limits<int>::max();
65 double ymax = std::numeric_limits<int>::min();
66
67 for (std::list<NodeGuiSerializationPtr>::const_iterator it = clipboard.nodesUI.begin();
68 it != clipboard.nodesUI.end(); ++it) {
69 double x = (*it)->getX();
70 double y = (*it)->getY();
71 double w, h;
72 (*it)->getSize(&w, &h);
73 if ( (x + w) > xmax ) {
74 xmax = x;
75 }
76 if (x < xmin) {
77 xmin = x;
78 }
79 if ( (y + h) > ymax ) {
80 ymax = y;
81 }
82 if (y < ymin) {
83 ymin = y;
84 }
85 }
86
87
88 QPointF offset( scenePos.x() - ( (xmin + xmax) / 2. ), scenePos.y() - ( (ymin + ymax) / 2. ) );
89
90 assert( clipboard.nodes.size() == clipboard.nodesUI.size() );
91
92 NodesGuiList newNodesList;
93 std::list<std::pair<NodeSerializationPtr, NodePtr> > newNodesMap;
94
95 ///The script-name of the copy node is different than the one of the original one
96 ///We store the mapping so we can restore node links correctly
97 std::map<std::string, std::string> oldNewScriptNamesMapping;
98 {
99 CreatingNodeTreeFlag_RAII createNodeTree( _publicInterface->getGui()->getApp() );
100 const std::list<NodeSerializationPtr>& internalNodesClipBoard = clipboard.nodes;
101 std::list<NodeSerializationPtr>::const_iterator itOther = internalNodesClipBoard.begin();
102 for (std::list<NodeGuiSerializationPtr>::const_iterator it = clipboard.nodesUI.begin();
103 it != clipboard.nodesUI.end(); ++it, ++itOther) {
104 const std::string& oldScriptName = (*itOther)->getNodeScriptName();
105 NodeGuiPtr node = pasteNode( *itOther, *it, offset, group.lock(), std::string(), false, &oldNewScriptNamesMapping);
106
107 if (!node) {
108 continue;
109 }

Callers 3

pasteCliboardMethod · 0.80
pasteNodeClipBoardsMethod · 0.80

Calls 15

maxFunction · 0.85
getProjectMethod · 0.80
storeKnobsLinksMethod · 0.80
restoreKnobsLinksMethod · 0.80
getEffectInstanceMethod · 0.80
forceComputePreviewMethod · 0.80
isEmptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected