![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
Adapts the BTNodeGraphManager + NodeGraphPanel to IGraphRenderer. More...
#include <BehaviorTreeRenderer.h>
Inheritance diagram for Olympe::BehaviorTreeRenderer:
Collaboration diagram for Olympe::BehaviorTreeRenderer:Classes | |
| struct | CanvasState |
Public Member Functions | |
| BehaviorTreeRenderer (NodeGraphPanel &panel) | |
| ~BehaviorTreeRenderer () | |
| void | Render () override |
| Renders the graph canvas into the current ImGui child window. | |
| bool | Load (const std::string &path) override |
| Loads a graph from a file on disk. | |
| bool | Save (const std::string &path) override |
| Saves the current graph state to disk. | |
| bool | IsDirty () const override |
| Returns true when the graph has unsaved changes. | |
| std::string | GetGraphType () const override |
| Returns the graph type string, e.g. | |
| std::string | GetCurrentPath () const override |
| Returns the last path successfully loaded/saved, or empty string. | |
| bool | CreateNew (const std::string &name="Untitled BehaviorTree") |
| Create a new empty BehaviorTree graph and set it active. | |
| void | OnRunGraphClicked () |
| Run graph simulation via BehaviorTreeGraphAdapter + GraphExecutionSimulator Converts BT to graph format, executes, formats trace, and displays in ExecutionTestPanel. | |
Public Member Functions inherited from Olympe::IGraphRenderer | |
| virtual | ~IGraphRenderer () |
Private Member Functions | |
| void | RenderLayoutWithTabs () |
| void | RenderRightPanelTabs () |
| void | AcceptNodeDrop (const std::string &nodeType, float screenX, float screenY) |
| Handle drop of node type at screen position. | |
| void | HandleKeyboardShortcuts () |
| Handle keyboard shortcuts for copy/paste/duplicate operations Ctrl+C: Copy selected node Ctrl+V: Paste nodes from clipboard Ctrl+D: Duplicate selected node. | |
| void | SaveCanvasState () override |
| Save the current canvas viewport state (pan, zoom, etc.) Called when tab is deactivated. | |
| void | RestoreCanvasState () override |
| Restore previously saved canvas viewport state Called when tab is reactivated. | |
| std::string | GetCanvasStateJSON () const override |
| Get canvas state as JSON string for persistence. | |
| void | SetCanvasStateJSON (const std::string &json) override |
| Restore canvas state from JSON string. | |
Private Attributes | |
| NodeGraphPanel & | m_panel |
| Shared panel reference (not owned) | |
| std::unique_ptr< AI::BTNodePalette > | m_palette |
| BTNodePalette for drag-drop. | |
| BTNodePropertyPanel | m_propertyPanel |
| Property editor for node properties. | |
| int | m_graphId |
| ID in BTNodeGraphManager; -1 if not loaded. | |
| std::string | m_filePath |
| Path that was loaded. | |
| float | m_canvasPanelWidth = 0.75f |
| Split ratio: 75% canvas, 25% right panel. | |
| int | m_rightPanelTabSelection = 0 |
| 0 = Palette, 1 = Properties | |
| ImVec2 | m_canvasScreenPos = ImVec2(0, 0) |
| Screen position of canvas for drag-drop coordinate transformation. | |
| std::unique_ptr< ExecutionTestPanel > | m_executionTestPanel |
| REUSED: Simulation results panel. | |
| std::unique_ptr< GraphExecutionTracer > | m_lastTracer |
| Last simulation trace for results display. | |
| struct Olympe::BehaviorTreeRenderer::CanvasState | m_savedCanvasState |
Adapts the BTNodeGraphManager + NodeGraphPanel to IGraphRenderer.
Phase 2 Enhancement: Now includes split-panel layout with:
Each instance manages a single BT graph ID in BTNodeGraphManager. When Render() is called, this renderer sets that graph as the active one and delegates to a shared NodeGraphPanel reference for drawing.
Definition at line 44 of file BehaviorTreeRenderer.h.
|
explicit |
| panel | Reference to the shared NodeGraphPanel owned by the editor GUI. The renderer does NOT take ownership. |
Definition at line 28 of file BehaviorTreeRenderer.cpp.
References Olympe::BTNodePropertyPanel::Initialize(), m_executionTestPanel, m_lastTracer, m_palette, and m_propertyPanel.
Here is the call graph for this function:| Olympe::BehaviorTreeRenderer::~BehaviorTreeRenderer | ( | ) |
Definition at line 48 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::CloseGraph(), Olympe::NodeGraphManager::Get(), and m_graphId.
Here is the call graph for this function:
|
private |
Handle drop of node type at screen position.
| nodeType | BT node type name |
| screenX | Absolute screen X coordinate |
| screenY | Absolute screen Y coordinate |
Definition at line 283 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), Olympe::NodeGraphManager::GetGraph(), m_canvasScreenPos, m_graphId, Olympe::StringToNodeType(), and SYSTEM_LOG.
Referenced by RenderLayoutWithTabs().
Here is the call graph for this function:
Here is the caller graph for this function:| bool Olympe::BehaviorTreeRenderer::CreateNew | ( | const std::string & | name = "Untitled BehaviorTree" | ) |
Create a new empty BehaviorTree graph and set it active.
| name | Name for the new graph |
Definition at line 57 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::CloseGraph(), Olympe::NodeGraphManager::CreateGraph(), Olympe::NodeGraphManager::Get(), m_filePath, m_graphId, Olympe::NodeGraphManager::SetActiveGraph(), and SYSTEM_LOG.
Here is the call graph for this function:
|
overrideprivatevirtual |
Get canvas state as JSON string for persistence.
Reimplemented from Olympe::IGraphRenderer.
Definition at line 547 of file BehaviorTreeRenderer.cpp.
|
overridevirtual |
Returns the last path successfully loaded/saved, or empty string.
Implements Olympe::IGraphRenderer.
Definition at line 278 of file BehaviorTreeRenderer.cpp.
References m_filePath.
|
overridevirtual |
Returns the graph type string, e.g.
"VisualScript", "BehaviorTree".
Implements Olympe::IGraphRenderer.
Definition at line 273 of file BehaviorTreeRenderer.cpp.
|
private |
Handle keyboard shortcuts for copy/paste/duplicate operations Ctrl+C: Copy selected node Ctrl+V: Paste nodes from clipboard Ctrl+D: Duplicate selected node.
Definition at line 333 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), Olympe::NodeGraphManager::GetGraph(), m_graphId, m_panel, Olympe::NodeGraphPanel::m_SelectedNodeId, and SYSTEM_LOG.
Referenced by RenderLayoutWithTabs().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Returns true when the graph has unsaved changes.
Implements Olympe::IGraphRenderer.
Definition at line 264 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), Olympe::NodeGraphManager::GetGraph(), Olympe::NodeGraph::IsDirty(), and m_graphId.
Here is the call graph for this function:Loads a graph from a file on disk.
| path | Absolute or relative path to the .ats / .json file. |
Implements Olympe::IGraphRenderer.
Definition at line 222 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::CloseGraph(), Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), Olympe::NodeGraphManager::LoadGraph(), m_filePath, m_graphId, Olympe::NodeGraphManager::SetActiveGraph(), and SYSTEM_LOG.
Here is the call graph for this function:| void Olympe::BehaviorTreeRenderer::OnRunGraphClicked | ( | ) |
Run graph simulation via BehaviorTreeGraphAdapter + GraphExecutionSimulator Converts BT to graph format, executes, formats trace, and displays in ExecutionTestPanel.
Called by "Run Graph" toolbar button.
Definition at line 391 of file BehaviorTreeRenderer.cpp.
References Action, Olympe::BT_Action, Olympe::BT_Condition, Olympe::BT_Decorator, Olympe::BT_Inverter, Olympe::BT_OnEvent, Olympe::BT_Repeater, Olympe::BT_Root, Olympe::BT_Selector, Olympe::BT_Sequence, Olympe::BT_UntilFailure, Olympe::BT_UntilSuccess, Condition, Olympe::BehaviorTreeExecutor::ExecuteTree(), Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), Olympe::NodeGraphManager::GetGraph(), BTNode::id, BehaviorTreeAsset::id, Inverter, m_executionTestPanel, m_graphId, Olympe::NodeGraph::name, OnEvent, Repeater, Root, Selector, Sequence, Success, and SYSTEM_LOG.
Referenced by RenderLayoutWithTabs().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Renders the graph canvas into the current ImGui child window.
Implements Olympe::IGraphRenderer.
Definition at line 81 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::Get(), DataManager::Get(), m_executionTestPanel, m_graphId, DataManager::RenderFilePickerModal(), RenderLayoutWithTabs(), and Olympe::NodeGraphManager::SetActiveGraph().
Here is the call graph for this function:
|
private |
Definition at line 99 of file BehaviorTreeRenderer.cpp.
References AcceptNodeDrop(), GetComponentTypeID_Static(), HandleKeyboardShortcuts(), m_canvasPanelWidth, m_canvasScreenPos, m_panel, Olympe::NodeGraphPanel::m_SuppressGraphTabs, OnRunGraphClicked(), Olympe::NodeGraphPanel::RenderContent(), and RenderRightPanelTabs().
Referenced by Render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 182 of file BehaviorTreeRenderer.cpp.
References Olympe::BTNodePropertyPanel::ClearSelection(), GetComponentTypeID_Static(), Olympe::BTNodePropertyPanel::HasSelectedNode(), m_graphId, m_palette, m_panel, m_propertyPanel, Olympe::BTNodePropertyPanel::m_selectedNodeId, Olympe::NodeGraphPanel::m_SelectedNodeId, Olympe::BTNodePropertyPanel::Render(), and Olympe::BTNodePropertyPanel::SetSelectedNode().
Referenced by RenderLayoutWithTabs().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overrideprivatevirtual |
Restore previously saved canvas viewport state Called when tab is reactivated.
Ensures smooth tab switching without losing layout.
Reimplemented from Olympe::IGraphRenderer.
Definition at line 541 of file BehaviorTreeRenderer.cpp.
References Olympe::BehaviorTreeRenderer::CanvasState::canvasOffset, m_canvasScreenPos, and m_savedCanvasState.
Saves the current graph state to disk.
| path | Destination path. If empty, save to the path passed to Load(). |
Implements Olympe::IGraphRenderer.
Definition at line 249 of file BehaviorTreeRenderer.cpp.
References Olympe::NodeGraphManager::Get(), GetComponentTypeID_Static(), m_filePath, m_graphId, and Olympe::NodeGraphManager::SaveGraph().
Here is the call graph for this function:
|
overrideprivatevirtual |
Save the current canvas viewport state (pan, zoom, etc.) Called when tab is deactivated.
Used to preserve viewport when switching between multiple tabs.
Reimplemented from Olympe::IGraphRenderer.
Definition at line 534 of file BehaviorTreeRenderer.cpp.
References Olympe::BehaviorTreeRenderer::CanvasState::canvasOffset, m_canvasScreenPos, and m_savedCanvasState.
|
overrideprivatevirtual |
Restore canvas state from JSON string.
| json | JSON representation of saved canvas state |
Reimplemented from Olympe::IGraphRenderer.
Definition at line 553 of file BehaviorTreeRenderer.cpp.
References GetComponentTypeID_Static().
Here is the call graph for this function:Split ratio: 75% canvas, 25% right panel.
Definition at line 81 of file BehaviorTreeRenderer.h.
Referenced by RenderLayoutWithTabs().
Screen position of canvas for drag-drop coordinate transformation.
Definition at line 83 of file BehaviorTreeRenderer.h.
Referenced by AcceptNodeDrop(), RenderLayoutWithTabs(), RestoreCanvasState(), and SaveCanvasState().
|
private |
REUSED: Simulation results panel.
Definition at line 84 of file BehaviorTreeRenderer.h.
Referenced by BehaviorTreeRenderer(), OnRunGraphClicked(), and Render().
|
private |
Path that was loaded.
Definition at line 80 of file BehaviorTreeRenderer.h.
Referenced by CreateNew(), GetCurrentPath(), Load(), and Save().
|
private |
ID in BTNodeGraphManager; -1 if not loaded.
Definition at line 79 of file BehaviorTreeRenderer.h.
Referenced by AcceptNodeDrop(), CreateNew(), HandleKeyboardShortcuts(), IsDirty(), Load(), OnRunGraphClicked(), Render(), RenderRightPanelTabs(), Save(), and ~BehaviorTreeRenderer().
|
private |
Last simulation trace for results display.
Definition at line 85 of file BehaviorTreeRenderer.h.
Referenced by BehaviorTreeRenderer().
|
private |
BTNodePalette for drag-drop.
Definition at line 77 of file BehaviorTreeRenderer.h.
Referenced by BehaviorTreeRenderer(), and RenderRightPanelTabs().
|
private |
Shared panel reference (not owned)
Definition at line 76 of file BehaviorTreeRenderer.h.
Referenced by HandleKeyboardShortcuts(), RenderLayoutWithTabs(), and RenderRightPanelTabs().
|
private |
Property editor for node properties.
Definition at line 78 of file BehaviorTreeRenderer.h.
Referenced by BehaviorTreeRenderer(), and RenderRightPanelTabs().
|
private |
0 = Palette, 1 = Properties
Definition at line 82 of file BehaviorTreeRenderer.h.
|
private |
Referenced by RestoreCanvasState(), and SaveCanvasState().