Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
DeleteNodeCommand.cpp
Go to the documentation of this file.
1/**
2 * @file DeleteNodeCommand.cpp
3 * @brief Implementation of DeleteNodeCommand
4 * @author Olympe Engine
5 * @date 2026-02-18
6 */
7
8#include "DeleteNodeCommand.h"
9
10namespace Olympe {
11namespace NodeGraph {
12
14 : m_graph(graph)
15 , m_nodeId(nodeId)
16 , m_wasExecuted(false)
17{
18}
19
21{
22 if (m_graph == nullptr)
23 return;
24
25 // Save node data before deleting
27 if (node != nullptr)
28 {
30
31 // Save connected links
32 m_savedLinks.clear();
33 for (const auto& link : m_graph->GetLinks())
34 {
35 // For now, save all links (we'd need to check pin ownership)
36 m_savedLinks.push_back(link);
37 }
38
40 m_wasExecuted = true;
41 }
42}
43
45{
46 if (m_graph == nullptr || !m_wasExecuted)
47 return;
48
49 // Restore the node
50 m_graph->GetNodesRef().push_back(m_savedNode);
51
52 // Restore links if needed
53 // (This is simplified; in practice we'd need better link management)
54}
55
57{
58 return "Delete Node";
59}
60
61} // namespace NodeGraph
62} // namespace Olympe
Command for deleting a node.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::string GetDescription() const override
Get description of the command.
DeleteNodeCommand(GraphDocument *graph, NodeId nodeId)
void Undo() override
Undo the command.
void Execute() override
Execute the command.
Main document class for a node graph.
bool DeleteNode(NodeId id)
Delete a node from the graph.
const std::vector< LinkData > & GetLinks() const
std::vector< NodeData > & GetNodesRef()
NodeData * GetNode(NodeId id)
Get a node by ID.
< Provides AssetID and INVALID_ASSET_ID