MCPcopy Create free account
hub / github.com/BobbyAnguelov/Esoterica / PasteNodes

Method PasteNodes

Code/EngineTools/NodeGraph/NodeGraph_View.cpp:1454–1617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1452 {
1453 auto pFlowGraph = GetFlowGraph();
1454
1455 xml_node copiedConnectionsNode = dataNode.append_child( s_copiedConnectionsNodeName );
1456
1457 for ( auto const& connection : pFlowGraph->m_connections )
1458 {
1459 auto SearchPredicate = [] ( BaseNode const* pNode, UUID const& nodeID ) { return pNode->GetID() == nodeID; };
1460 bool const wasFromNodeCopied = VectorContains( nodesToCopy, connection.m_fromNodeID, SearchPredicate );
1461 bool const wasToNodeCopied = VectorContains( nodesToCopy, connection.m_toNodeID, SearchPredicate );
1462 if ( wasFromNodeCopied && wasToNodeCopied )
1463 {
1464 Serialization::WriteType( typeRegistry, &connection, copiedConnectionsNode );
1465 }
1466 }
1467 }
1468
1469 //-------------------------------------------------------------------------
1470
1471 String xmlStr;
1472 Serialization::WriteXmlToString( copiedData, xmlStr );
1473 ImGui::SetClipboardText( xmlStr.c_str() );
1474 }
1475
1476 void GraphView::PasteNodes( TypeSystem::TypeRegistry const& typeRegistry, ImVec2 const& canvasPastePosition )
1477 {
1478 EE_ASSERT( m_pGraph != nullptr );
1479
1480 if ( m_isReadOnly )
1481 {
1482 return;
1483 }
1484
1485 // Get pasted data
1486 //-------------------------------------------------------------------------
1487
1488 char const* pClipboardText = ImGui::GetClipboardText();
1489 if ( pClipboardText == nullptr )
1490 {
1491 return;
1492 }
1493
1494 xml_document document;
1495 if ( !Serialization::ReadXmlFromString( pClipboardText, document ) )
1496 {
1497 return;
1498 }
1499
1500 xml_node copiedDataNode = document.child( s_graphCopiedDataNodeName );
1501 if ( copiedDataNode.empty() )
1502 {
1503 return;
1504 }
1505
1506 // Deserialize pasted nodes and regenerated IDs
1507 //-------------------------------------------------------------------------
1508
1509 Log log( LogCategory::Tools, "Node Graph - Paste Node" );
1510 xml_node copiedNodesNode = copiedDataNode.child( s_copiedNodesNodeName );
1511 TInlineVector<xml_node, 10> graphNodeNodes;

Callers

nothing calls this directly

Calls 15

ReadXmlFromStringFunction · 0.85
GetAllChildNodesFunction · 0.85
DeleteFunction · 0.85
IsViewingFlowGraphFunction · 0.85
GetFlowGraphFunction · 0.85
childMethod · 0.80
RenameMethod · 0.80
SetPositionMethod · 0.80
NotifyNodesPastedMethod · 0.80
TryCreateAndReadTypeFunction · 0.50
Float2Function · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected