![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Main document class for a node graph. More...
#include <GraphDocument.h>
Collaboration diagram for Olympe::NodeGraph::GraphDocument:Public Member Functions | |
| GraphDocument () | |
| ~GraphDocument () | |
| NodeId | CreateNode (const std::string &nodeType, Vector2 pos) |
| Create a new node in the graph. | |
| bool | DeleteNode (NodeId id) |
| Delete a node from the graph. | |
| bool | UpdateNodePosition (NodeId id, Vector2 newPos) |
| Update node position. | |
| bool | UpdateNodeParameters (NodeId id, const std::map< std::string, std::string > ¶ms) |
| Update node parameters. | |
| NodeData * | GetNode (NodeId id) |
| Get a node by ID. | |
| const NodeData * | GetNode (NodeId id) const |
| bool | UpdateNode (NodeId nodeId, const NodeData &newData) |
| Update an existing node's data. | |
| LinkId | ConnectPins (PinId fromPin, PinId toPin) |
| Connect two pins with a link. | |
| bool | DisconnectLink (LinkId id) |
| Disconnect a link. | |
| LinkData * | GetLink (LinkId id) |
| Get a link by ID. | |
| const LinkData * | GetLink (LinkId id) const |
| bool | ValidateGraph (std::string &errorMessage) const |
| Validate the graph structure. | |
| bool | HasCycles () const |
| Check if the graph has cycles. | |
| json | ToJson () const |
| Convert graph to JSON format (v2 schema) | |
| bool | AutoLayout (const AutoLayoutConfig &config) |
| Automatically layout nodes in a hierarchical arrangement. | |
| const std::vector< NodeData > & | GetNodes () const |
| const std::vector< LinkData > & | GetLinks () const |
| std::vector< NodeData > & | GetNodesRef () |
| std::vector< LinkData > & | GetLinksRef () |
| bool | IsDirty () const |
| void | SetDirty (bool dirty) |
| NodeAnnotationsManager & | GetNodeAnnotations () |
| Get node annotations manager (non-const) | |
| const NodeAnnotationsManager & | GetNodeAnnotations () const |
| Get node annotations manager (const) | |
| BlackboardSystem & | GetBlackboard () |
| Get blackboard system (non-const) | |
| const BlackboardSystem & | GetBlackboard () const |
| Get blackboard system (const) | |
Static Public Member Functions | |
| static GraphDocument | FromJson (const json &j) |
| Create graph from JSON. | |
Public Attributes | |
| std::string | type |
| std::string | graphKind |
| NodeId | rootNodeId |
| json | metadata |
| EditorState | editorState |
Private Member Functions | |
| bool | HasCyclesHelper (NodeId nodeId, std::vector< NodeId > &visited, std::vector< NodeId > &recursionStack) const |
| float | AutoLayoutNode (NodeId nodeId, const AutoLayoutConfig &config, float startX, float startY, int depth, std::map< NodeId, bool > &visited) |
| Helper to recursively layout a node and its children. | |
Private Attributes | |
| std::vector< NodeData > | m_nodes |
| std::vector< LinkData > | m_links |
| uint32_t | m_nextNodeId = 1 |
| uint32_t | m_nextLinkId = 1 |
| bool | m_isDirty = false |
| NodeAnnotationsManager | m_nodeAnnotations |
| BlackboardSystem | m_blackboard |
Main document class for a node graph.
Definition at line 30 of file GraphDocument.h.
| Olympe::NodeGraph::GraphDocument::GraphDocument | ( | ) |
Definition at line 21 of file GraphDocument.cpp.
References metadata.
| Olympe::NodeGraph::GraphDocument::~GraphDocument | ( | ) |
Definition at line 31 of file GraphDocument.cpp.
| bool Olympe::NodeGraph::GraphDocument::AutoLayout | ( | const AutoLayoutConfig & | config | ) |
Automatically layout nodes in a hierarchical arrangement.
| config | Layout configuration (direction, spacing, etc.) |
Definition at line 591 of file GraphDocument.cpp.
References AutoLayoutNode(), GetComponentTypeID_Static(), GetNode(), m_isDirty, m_nodes, rootNodeId, SYSTEM_LOG, and Olympe::NodeGraph::NodeId::value.
Here is the call graph for this function:
|
private |
Helper to recursively layout a node and its children.
| nodeId | Node to layout |
| config | Layout configuration |
| startX | Starting X position |
| startY | Starting Y position |
| depth | Current depth in tree (0 = root) |
| visited | Map to track visited nodes (cycle detection) |
Definition at line 637 of file GraphDocument.cpp.
References AutoLayoutNode(), GetComponentTypeID_Static(), GetNode(), SYSTEM_LOG, UpdateNodePosition(), Olympe::NodeGraph::NodeId::value, and Olympe::Vector2.
Referenced by AutoLayout(), and AutoLayoutNode().
Here is the call graph for this function:
Here is the caller graph for this function:Connect two pins with a link.
| fromPin | Source pin |
| toPin | Target pin |
Definition at line 156 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), Olympe::NodeGraph::LinkData::id, m_isDirty, m_links, m_nextLinkId, and Olympe::NodeGraph::LinkId::value.
Referenced by Olympe::NodeGraph::ConnectPinsCommand::Execute().
Here is the call graph for this function:
Here is the caller graph for this function:Create a new node in the graph.
| nodeType | Type of the node (e.g., "BT_Selector", "BT_Action") |
| pos | Position of the node |
Definition at line 39 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), Olympe::NodeGraph::NodeData::id, m_isDirty, m_nextNodeId, m_nodes, and Olympe::NodeGraph::NodeId::value.
Referenced by Olympe::NodeGraph::CreateNodeCommand::Execute(), Test15_SaveLoadIntegration(), Test6_ValidateGraph(), and Test7_SaveLoadRoundtrip().
Here is the call graph for this function:
Here is the caller graph for this function:Delete a node from the graph.
| id | ID of the node to delete |
Definition at line 53 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), m_isDirty, m_links, and m_nodes.
Referenced by Olympe::NodeGraph::DeleteNodeCommand::Execute(), and Olympe::NodeGraph::CreateNodeCommand::Undo().
Here is the call graph for this function:
Here is the caller graph for this function:Disconnect a link.
| id | Link ID |
Definition at line 169 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), m_isDirty, and m_links.
Referenced by Olympe::NodeGraph::ConnectPinsCommand::Undo().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Create graph from JSON.
| j | JSON object |
Definition at line 420 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), JsonHelper::GetFloat(), JsonHelper::GetString(), JsonHelper::GetUInt(), Olympe::NodeGraph::NodeData::id, Olympe::NodeGraph::LinkData::id, type, Olympe::NodeGraph::NodeId::value, and Olympe::NodeGraph::LinkId::value.
Referenced by Olympe::NodeGraph::GraphMigrator::LoadWithMigration().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Get blackboard system (non-const)
Definition at line 198 of file GraphDocument.h.
References m_blackboard.
|
inline |
Get blackboard system (const)
Definition at line 203 of file GraphDocument.h.
References m_blackboard.
Get a link by ID.
| id | Link ID |
Definition at line 184 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), and m_links.
Here is the call graph for this function:Definition at line 194 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), and m_links.
Here is the call graph for this function:Definition at line 169 of file GraphDocument.h.
References m_links.
Referenced by Olympe::NodeGraph::DeleteNodeCommand::Execute(), and Olympe::AI::AIEditorGUI::RenderConnections().
Here is the caller graph for this function:
|
inline |
Definition at line 172 of file GraphDocument.h.
References m_links.
Get a node by ID.
| id | Node ID |
Definition at line 104 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), and m_nodes.
Referenced by AutoLayout(), AutoLayoutNode(), Olympe::NodeGraph::DeleteNodeCommand::Execute(), HasCyclesHelper(), UpdateNodeParameters(), UpdateNodePosition(), and ValidateGraph().
Here is the call graph for this function:
Here is the caller graph for this function:Definition at line 114 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), and m_nodes.
Here is the call graph for this function:
|
inline |
Get node annotations manager (non-const)
Definition at line 184 of file GraphDocument.h.
References m_nodeAnnotations.
|
inline |
Get node annotations manager (const)
Definition at line 189 of file GraphDocument.h.
References m_nodeAnnotations.
Definition at line 168 of file GraphDocument.h.
References m_nodes.
Referenced by Olympe::AI::AIEditorGUI::MenuAction_SelectAll(), and Olympe::AI::AIEditorGUI::RenderNodeGraphCanvas().
Here is the caller graph for this function:
|
inline |
Definition at line 171 of file GraphDocument.h.
References m_nodes.
Referenced by Olympe::NodeGraph::DeleteNodeCommand::Undo().
Here is the caller graph for this function:| bool Olympe::NodeGraph::GraphDocument::HasCycles | ( | ) | const |
Check if the graph has cycles.
Definition at line 251 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), HasCyclesHelper(), and m_nodes.
Referenced by ValidateGraph().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 271 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), GetNode(), and HasCyclesHelper().
Referenced by HasCycles(), and HasCyclesHelper().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 174 of file GraphDocument.h.
References m_isDirty.
Definition at line 175 of file GraphDocument.h.
References GetComponentTypeID_Static(), and m_isDirty.
Here is the call graph for this function:| json Olympe::NodeGraph::GraphDocument::ToJson | ( | ) | const |
Convert graph to JSON format (v2 schema)
Definition at line 316 of file GraphDocument.cpp.
References editorState, GetComponentTypeID_Static(), graphKind, Olympe::NodeGraph::EditorState::layoutDirection, m_blackboard, m_links, m_nodeAnnotations, m_nodes, metadata, rootNodeId, Olympe::NodeGraph::EditorState::scrollOffset, Olympe::NodeGraph::EditorState::selectedNodes, Olympe::NodeGraph::BlackboardSystem::ToJson(), Olympe::NodeGraph::NodeAnnotationsManager::ToJson(), type, Olympe::NodeGraph::NodeId::value, and Olympe::NodeGraph::EditorState::zoom.
Here is the call graph for this function:Update an existing node's data.
| nodeId | The node to update |
| newData | New node data (position, type, parameters) |
Definition at line 124 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), m_nodes, SYSTEM_LOG, and Olympe::NodeGraph::NodeId::value.
Here is the call graph for this function:| bool Olympe::NodeGraph::GraphDocument::UpdateNodeParameters | ( | NodeId | id, |
| const std::map< std::string, std::string > & | params | ||
| ) |
Update node parameters.
| id | Node ID |
| params | New parameters |
Definition at line 92 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), GetNode(), and m_isDirty.
Here is the call graph for this function:Update node position.
| id | Node ID |
| newPos | New position |
Definition at line 80 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), GetNode(), and m_isDirty.
Referenced by AutoLayoutNode(), Olympe::NodeGraph::MoveNodeCommand::Execute(), and Olympe::NodeGraph::MoveNodeCommand::Undo().
Here is the call graph for this function:
Here is the caller graph for this function:| bool Olympe::NodeGraph::GraphDocument::ValidateGraph | ( | std::string & | errorMessage | ) | const |
Validate the graph structure.
| errorMessage | Output error message if validation fails |
Definition at line 208 of file GraphDocument.cpp.
References GetComponentTypeID_Static(), GetNode(), HasCycles(), m_nodes, rootNodeId, and Olympe::NodeGraph::NodeId::value.
Referenced by Test8_ValidateGraph().
Here is the call graph for this function:
Here is the caller graph for this function:| EditorState Olympe::NodeGraph::GraphDocument::editorState |
Definition at line 43 of file GraphDocument.h.
Referenced by ToJson().
| std::string Olympe::NodeGraph::GraphDocument::graphKind |
Definition at line 40 of file GraphDocument.h.
Referenced by ToJson().
|
private |
Definition at line 218 of file GraphDocument.h.
Referenced by GetBlackboard(), GetBlackboard(), and ToJson().
Definition at line 212 of file GraphDocument.h.
Referenced by AutoLayout(), ConnectPins(), CreateNode(), DeleteNode(), DisconnectLink(), IsDirty(), SetDirty(), UpdateNodeParameters(), and UpdateNodePosition().
|
private |
Definition at line 208 of file GraphDocument.h.
Referenced by ConnectPins(), DeleteNode(), DisconnectLink(), GetLink(), GetLink(), GetLinks(), GetLinksRef(), and ToJson().
|
private |
Definition at line 211 of file GraphDocument.h.
Referenced by ConnectPins().
|
private |
Definition at line 210 of file GraphDocument.h.
Referenced by CreateNode().
|
private |
Definition at line 215 of file GraphDocument.h.
Referenced by GetNodeAnnotations(), GetNodeAnnotations(), and ToJson().
|
private |
Definition at line 207 of file GraphDocument.h.
Referenced by AutoLayout(), CreateNode(), DeleteNode(), GetNode(), GetNode(), GetNodes(), GetNodesRef(), HasCycles(), ToJson(), UpdateNode(), and ValidateGraph().
| json Olympe::NodeGraph::GraphDocument::metadata |
Definition at line 42 of file GraphDocument.h.
Referenced by GraphDocument(), and ToJson().
| NodeId Olympe::NodeGraph::GraphDocument::rootNodeId |
Definition at line 41 of file GraphDocument.h.
Referenced by AutoLayout(), ToJson(), and ValidateGraph().
| std::string Olympe::NodeGraph::GraphDocument::type |
Definition at line 39 of file GraphDocument.h.
Referenced by FromJson(), Test1_CreateGraphDocument(), Test3_ValidationValidRoot(), Test4_Serialization(), Test4_ValidationMultipleRoots(), Test5_ValidationCycle(), Test6_CompilationSimpleBT(), Test7_CompilationInvalidNodeType(), Test8_ValidationChildrenCount(), and ToJson().