Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Olympe::NodeGraph Class Reference

#include <NodeGraphManager.h>

+ Collaboration diagram for Olympe::NodeGraph:

Public Member Functions

 NodeGraph ()
 
 ~NodeGraph ()=default
 
int CreateNode (NodeType type, float x, float y, const std::string &name="")
 
bool DeleteNode (int nodeId)
 
GraphNodeGetNode (int nodeId)
 
const GraphNodeGetNode (int nodeId) const
 
std::vector< GraphNode * > GetAllNodes ()
 
std::vector< const GraphNode * > GetAllNodes () const
 
bool LinkNodes (int parentId, int childId)
 
bool UnlinkNodes (int parentId, int childId)
 
std::vector< GraphLinkGetAllLinks () const
 
bool SetNodeParameter (int nodeId, const std::string &paramName, const std::string &value)
 
std::string GetNodeParameter (int nodeId, const std::string &paramName) const
 
nlohmann::json ToJson () const
 
bool ValidateGraph (std::string &errorMsg) const
 
void Clear ()
 
int GetNextNodeId () const
 
void CalculateNodePositionsHierarchical ()
 
bool IsDirty () const
 
void MarkDirty ()
 
void ClearDirty ()
 
const std::string & GetFilepath () const
 
void SetFilepath (const std::string &filepath)
 
bool HasFilepath () const
 

Static Public Member Functions

static NodeGraph FromJson (const nlohmann::json &j)
 

Public Attributes

std::string name
 
std::string type
 
int rootNodeId = -1
 
EditorMetadata editorMetadata
 

Private Member Functions

int FindNodeIndex (int nodeId) const
 

Private Attributes

std::vector< GraphNodem_Nodes
 
int m_NextNodeId = 1
 
bool m_IsDirty = false
 
std::string m_Filepath
 

Detailed Description

Definition at line 123 of file NodeGraphManager.h.

Constructor & Destructor Documentation

◆ NodeGraph()

Olympe::NodeGraph::NodeGraph ( )

Definition at line 24 of file NodeGraphManager.cpp.

◆ ~NodeGraph()

Olympe::NodeGraph::~NodeGraph ( )
default

Member Function Documentation

◆ CalculateNodePositionsHierarchical()

void Olympe::NodeGraph::CalculateNodePositionsHierarchical ( )

Definition at line 476 of file NodeGraphManager.cpp.

References FindNodeIndex(), GetComponentTypeID_Static(), m_Nodes, rootNodeId, and visited.

+ Here is the call graph for this function:

◆ Clear()

void Olympe::NodeGraph::Clear ( )

Definition at line 459 of file NodeGraphManager.cpp.

References m_NextNodeId, m_Nodes, and rootNodeId.

◆ ClearDirty()

void Olympe::NodeGraph::ClearDirty ( )
inline

Definition at line 169 of file NodeGraphManager.h.

References m_IsDirty.

◆ CreateNode()

int Olympe::NodeGraph::CreateNode ( NodeType  type,
float  x,
float  y,
const std::string &  name = "" 
)

Definition at line 32 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), Olympe::GraphNode::id, m_NextNodeId, m_Nodes, MarkDirty(), and Olympe::NodeTypeToString().

+ Here is the call graph for this function:

◆ DeleteNode()

bool Olympe::NodeGraph::DeleteNode ( int  nodeId)

Definition at line 49 of file NodeGraphManager.cpp.

References FindNodeIndex(), GetComponentTypeID_Static(), m_Nodes, and MarkDirty().

Referenced by Olympe::CreateNodeCommand::Undo(), and Olympe::DuplicateNodeCommand::Undo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindNodeIndex()

int Olympe::NodeGraph::FindNodeIndex ( int  nodeId) const
private

Definition at line 466 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_Nodes.

Referenced by CalculateNodePositionsHierarchical(), DeleteNode(), GetNode(), and GetNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FromJson()

NodeGraph Olympe::NodeGraph::FromJson ( const nlohmann::json j)
static

◆ GetAllLinks()

std::vector< GraphLink > Olympe::NodeGraph::GetAllLinks ( ) const

Definition at line 166 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_Nodes.

+ Here is the call graph for this function:

◆ GetAllNodes() [1/2]

std::vector< GraphNode * > Olympe::NodeGraph::GetAllNodes ( )

Definition at line 93 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_Nodes.

Referenced by Olympe::NodeGraphPanel::RenderContextMenu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAllNodes() [2/2]

std::vector< const GraphNode * > Olympe::NodeGraph::GetAllNodes ( ) const

Definition at line 101 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_Nodes.

+ Here is the call graph for this function:

◆ GetFilepath()

const std::string & Olympe::NodeGraph::GetFilepath ( ) const
inline

Definition at line 172 of file NodeGraphManager.h.

References m_Filepath.

◆ GetNextNodeId()

int Olympe::NodeGraph::GetNextNodeId ( ) const
inline

Definition at line 161 of file NodeGraphManager.h.

References m_NextNodeId.

◆ GetNode() [1/2]

GraphNode * Olympe::NodeGraph::GetNode ( int  nodeId)

Definition at line 77 of file NodeGraphManager.cpp.

References FindNodeIndex(), GetComponentTypeID_Static(), and m_Nodes.

Referenced by GetNodeParameter(), LinkNodes(), SetNodeParameter(), UnlinkNodes(), and ValidateGraph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNode() [2/2]

const GraphNode * Olympe::NodeGraph::GetNode ( int  nodeId) const

Definition at line 85 of file NodeGraphManager.cpp.

References FindNodeIndex(), GetComponentTypeID_Static(), and m_Nodes.

+ Here is the call graph for this function:

◆ GetNodeParameter()

std::string Olympe::NodeGraph::GetNodeParameter ( int  nodeId,
const std::string &  paramName 
) const

Definition at line 199 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and GetNode().

+ Here is the call graph for this function:

◆ HasFilepath()

bool Olympe::NodeGraph::HasFilepath ( ) const
inline

Definition at line 174 of file NodeGraphManager.h.

References m_Filepath.

Referenced by Olympe::NodeGraphPanel::Render().

+ Here is the caller graph for this function:

◆ IsDirty()

bool Olympe::NodeGraph::IsDirty ( ) const
inline

Definition at line 167 of file NodeGraphManager.h.

References m_IsDirty.

◆ LinkNodes()

bool Olympe::NodeGraph::LinkNodes ( int  parentId,
int  childId 
)

Definition at line 109 of file NodeGraphManager.cpp.

References Olympe::BT_Decorator, Olympe::GraphNode::childIds, Olympe::GraphNode::decoratorChildId, GetNode(), MarkDirty(), and Olympe::GraphNode::type.

Referenced by Olympe::LinkNodesCommand::Execute(), and Olympe::UnlinkNodesCommand::Undo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MarkDirty()

void Olympe::NodeGraph::MarkDirty ( )
inline

Definition at line 168 of file NodeGraphManager.h.

References m_IsDirty.

Referenced by CreateNode(), DeleteNode(), LinkNodes(), SetNodeParameter(), and UnlinkNodes().

+ Here is the caller graph for this function:

◆ SetFilepath()

void Olympe::NodeGraph::SetFilepath ( const std::string &  filepath)
inline

Definition at line 173 of file NodeGraphManager.h.

References m_Filepath.

◆ SetNodeParameter()

bool Olympe::NodeGraph::SetNodeParameter ( int  nodeId,
const std::string &  paramName,
const std::string &  value 
)

Definition at line 188 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), GetNode(), and MarkDirty().

Referenced by Olympe::SetParameterCommand::Execute(), and Olympe::SetParameterCommand::Undo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToJson()

nlohmann::json Olympe::NodeGraph::ToJson ( ) const

◆ UnlinkNodes()

bool Olympe::NodeGraph::UnlinkNodes ( int  parentId,
int  childId 
)

Definition at line 135 of file NodeGraphManager.cpp.

References Olympe::GraphNode::childIds, Olympe::GraphNode::decoratorChildId, GetComponentTypeID_Static(), GetNode(), and MarkDirty().

Referenced by Olympe::UnlinkNodesCommand::Execute(), and Olympe::LinkNodesCommand::Undo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ValidateGraph()

bool Olympe::NodeGraph::ValidateGraph ( std::string &  errorMsg) const

Definition at line 434 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), GetNode(), and m_Nodes.

+ Here is the call graph for this function:

Member Data Documentation

◆ editorMetadata

EditorMetadata Olympe::NodeGraph::editorMetadata

Definition at line 133 of file NodeGraphManager.h.

Referenced by ToJson().

◆ m_Filepath

std::string Olympe::NodeGraph::m_Filepath
private

Definition at line 180 of file NodeGraphManager.h.

Referenced by GetFilepath(), HasFilepath(), and SetFilepath().

◆ m_IsDirty

bool Olympe::NodeGraph::m_IsDirty = false
private

Definition at line 179 of file NodeGraphManager.h.

Referenced by ClearDirty(), IsDirty(), and MarkDirty().

◆ m_NextNodeId

int Olympe::NodeGraph::m_NextNodeId = 1
private

Definition at line 178 of file NodeGraphManager.h.

Referenced by Clear(), CreateNode(), and GetNextNodeId().

◆ m_Nodes

std::vector<GraphNode> Olympe::NodeGraph::m_Nodes
private

◆ name

std::string Olympe::NodeGraph::name

Definition at line 130 of file NodeGraphManager.h.

Referenced by FromJson(), and ToJson().

◆ rootNodeId

int Olympe::NodeGraph::rootNodeId = -1

Definition at line 132 of file NodeGraphManager.h.

Referenced by CalculateNodePositionsHierarchical(), Clear(), and ToJson().

◆ type

std::string Olympe::NodeGraph::type

Definition at line 131 of file NodeGraphManager.h.

Referenced by ToJson().


The documentation for this class was generated from the following files: