MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / copyUiNode

Method copyUiNode

source/MaterialXGraphEditor/Graph.cpp:1537–1580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1535}
1536
1537void Graph::copyUiNode(UiNodePtr node)
1538{
1539 UiNodePtr copyNode = std::make_shared<UiNode>(mx::EMPTY_STRING, int(_state.nextUiId + 1));
1540 ++_state.nextUiId;
1541 if (node->getNodeGraph())
1542 {
1543 _graphDoc->addNodeGraph();
1544 std::string nodeGraphName = _graphDoc->getNodeGraphs().back()->getName();
1545 copyNode->setNodeGraph(_graphDoc->getNodeGraphs().back());
1546 copyNode->setName(nodeGraphName);
1547 copyNodeGraph(node, copyNode);
1548 }
1549 else if (node->getElement())
1550 {
1551 std::string newName = _state.graphElem->createValidChildName(node->getName());
1552 if (node->getNode())
1553 {
1554 mx::NodePtr mxNode;
1555 mxNode = _state.graphElem->addNodeInstance(node->getNode()->getNodeDef());
1556 mxNode->copyContentFrom(node->getNode());
1557 mxNode->setName(newName);
1558 copyNode->setNode(mxNode);
1559 }
1560 else if (node->getInput())
1561 {
1562 mx::InputPtr mxInput;
1563 mxInput = _state.graphElem->addInput(newName);
1564 mxInput->copyContentFrom(node->getInput());
1565 copyNode->setInput(mxInput);
1566 }
1567 else if (node->getOutput())
1568 {
1569 mx::OutputPtr mxOutput;
1570 mxOutput = _state.graphElem->addOutput(newName);
1571 mxOutput->copyContentFrom(node->getOutput());
1572 mxOutput->setName(newName);
1573 copyNode->setOutput(mxOutput);
1574 }
1575 copyNode->getElement()->setName(newName);
1576 copyNode->setName(newName);
1577 }
1578 _copiedNodes[node] = copyNode;
1579 setUiNodeInfo(copyNode, node->getType(), node->getCategory());
1580}
1581
1582void Graph::copyNodeGraph(UiNodePtr origGraph, UiNodePtr copyGraph)
1583{

Callers

nothing calls this directly

Calls 15

getNodeGraphMethod · 0.80
setNodeGraphMethod · 0.80
copyContentFromMethod · 0.80
setNodeMethod · 0.80
addInputMethod · 0.80
setInputMethod · 0.80
addOutputMethod · 0.80
setOutputMethod · 0.80
getCategoryMethod · 0.80
getNameMethod · 0.45
setNameMethod · 0.45
getElementMethod · 0.45

Tested by

no test coverage detected