Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AIEditorClipboard.h
Go to the documentation of this file.
1/**
2 * @file AIEditorClipboard.h
3 * @brief Clipboard system for AI Editor (Cut/Copy/Paste)
4 * @author Olympe Engine
5 * @date 2026-02-19
6 *
7 * @details
8 * Provides clipboard functionality for copying, cutting, and pasting
9 * nodes with their connections preserved. Uses singleton pattern for
10 * global clipboard access.
11 */
12
13#pragma once
14
15#include "../../NodeGraphCore/NodeGraphCore.h"
16#include "../../NodeGraphCore/GraphDocument.h"
17#include "../../vector.h"
18#include <vector>
19#include <map>
20#include <string>
21
22namespace Olympe {
23namespace AI {
24
25// Pin ID Convention Constants
26// These match the convention used in AIEditorNodeRenderer.cpp
27constexpr uint32_t PIN_ID_MULTIPLIER = 1000; ///< Multiplier for pin IDs from node IDs
28constexpr uint32_t PIN_ID_INPUT_OFFSET = 0; ///< Offset for input pin: nodeId * 1000 + 0
29constexpr uint32_t PIN_ID_OUTPUT_OFFSET = 1; ///< Offset for output pin: nodeId * 1000 + 1
30
31/**
32 * @struct ClipboardNode
33 * @brief Represents a node in the clipboard
34 */
36 std::string type; ///< Node type (e.g., "BT_Selector")
37 std::string name; ///< Node display name
38 Vector position; ///< Position relative to first node
39 std::map<std::string, std::string> parameters; ///< Node parameters
40 uint32_t originalId = 0; ///< Original node ID (for link reconstruction)
41};
42
43/**
44 * @struct ClipboardLink
45 * @brief Represents a connection between nodes in the clipboard
46 */
48 uint32_t parentOriginalId = 0; ///< Parent node's original ID
49 uint32_t childOriginalId = 0; ///< Child node's original ID
50};
51
52/**
53 * @class AIEditorClipboard
54 * @brief Singleton clipboard manager for AI Editor
55 *
56 * @details
57 * Provides Cut/Copy/Paste functionality for nodes in the AI Editor.
58 * Preserves node connections and maintains relative positions when pasting.
59 */
61public:
62 /**
63 * @brief Get singleton instance
64 * @return Reference to the clipboard instance
65 */
66 static AIEditorClipboard& Get();
67
68 /**
69 * @brief Copy selected nodes to clipboard
70 * @param nodeIds List of selected node IDs
71 * @param doc Source graph document
72 */
73 void Copy(const std::vector<NodeGraph::NodeId>& nodeIds, NodeGraph::GraphDocument* doc);
74
75 /**
76 * @brief Cut selected nodes (copy + delete)
77 * @param nodeIds List of selected node IDs
78 * @param doc Source graph document
79 */
80 void Cut(const std::vector<NodeGraph::NodeId>& nodeIds, NodeGraph::GraphDocument* doc);
81
82 /**
83 * @brief Paste clipboard nodes into active graph
84 * @param doc Target graph document
85 * @param pasteOffset Offset from original position
86 * @return List of new node IDs
87 */
88 std::vector<NodeGraph::NodeId> Paste(NodeGraph::GraphDocument* doc, Vector pasteOffset);
89
90 /**
91 * @brief Check if clipboard has data
92 * @return true if clipboard contains nodes
93 */
94 bool IsEmpty() const;
95
96 /**
97 * @brief Clear clipboard
98 */
99 void Clear();
100
101 /**
102 * @brief Get number of nodes in clipboard
103 * @return Number of nodes
104 */
105 size_t GetNodeCount() const { return m_nodes.size(); }
106
107private:
108 AIEditorClipboard() = default;
110
111 // Prevent copying
114
115 std::vector<ClipboardNode> m_nodes; ///< Copied nodes
116 std::vector<ClipboardLink> m_links; ///< Copied links
117};
118
119} // namespace AI
120} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton clipboard manager for AI Editor.
AIEditorClipboard & operator=(const AIEditorClipboard &)=delete
void Cut(const std::vector< NodeGraph::NodeId > &nodeIds, NodeGraph::GraphDocument *doc)
Cut selected nodes (copy + delete)
static AIEditorClipboard & Get()
Get singleton instance.
AIEditorClipboard(const AIEditorClipboard &)=delete
size_t GetNodeCount() const
Get number of nodes in clipboard.
void Copy(const std::vector< NodeGraph::NodeId > &nodeIds, NodeGraph::GraphDocument *doc)
Copy selected nodes to clipboard.
std::vector< NodeGraph::NodeId > Paste(NodeGraph::GraphDocument *doc, Vector pasteOffset)
Paste clipboard nodes into active graph.
bool IsEmpty() const
Check if clipboard has data.
std::vector< ClipboardNode > m_nodes
Copied nodes.
std::vector< ClipboardLink > m_links
Copied links.
Main document class for a node graph.
constexpr uint32_t PIN_ID_INPUT_OFFSET
Offset for input pin: nodeId * 1000 + 0.
constexpr uint32_t PIN_ID_OUTPUT_OFFSET
Offset for output pin: nodeId * 1000 + 1.
constexpr uint32_t PIN_ID_MULTIPLIER
Multiplier for pin IDs from node IDs.
< Provides AssetID and INVALID_ASSET_ID
Represents a node in the clipboard.
uint32_t originalId
Original node ID (for link reconstruction)
std::string name
Node display name.
Vector position
Position relative to first node.
std::string type
Node type (e.g., "BT_Selector")
std::map< std::string, std::string > parameters
Node parameters.