Kemena3D
Loading...
Searching...
No Matches
kemena::kScriptGraph Struct Reference

The complete editable node graph for one script. More...

#include <kscriptgraph.h>

Public Member Functions

int newId ()
 Returns the next graph-unique id and advances the counter.
kScriptGraphNodefindNode (int id)
 Finds a node by id, or nullptr.
const kScriptGraphNodefindNode (int id) const
 Const overload: finds a node by id, or nullptr.
const kScriptGraphLinkincomingLink (int nodeId, int pinId) const
 Returns the link feeding an input pin, or nullptr.
const kScriptGraphLinkoutgoingLink (int nodeId, int pinId) const
 Returns the first link leaving an output pin, or nullptr.
bool isPinConnected (int nodeId, int pinId) const
 True if any link touches the given pin.
void removeLinksByNode (int nodeId)
 Removes every link attached to a node.
void removeLinksByPin (int nodeId, int pinId)
 Removes every link attached to a specific pin.
void removeNode (int nodeId)
 Removes a node and all of its links.
kScriptGraphNode makeNode (kScriptNodeType type, float x, float y)
 Builds a fully-pinned node of the given type at (x, y).
kJson toJson () const
 Serialises the whole graph to JSON.
void fromJson (const kJson &j)
 Restores a graph from JSON produced by toJson().

Public Attributes

kString uuid
 Stable script-asset UUID.
kString name
 Display name.
std::vector< kScriptGraphNodenodes
 All nodes in the graph.
std::vector< kScriptGraphLinklinks
 All wires between pins.
std::vector< kScriptGraphVarvariables
 Graph-scope variables.
int nextId = 1
 Monotonic id source.
bool dirty = false
 Unsaved-changes flag (editor only).

Detailed Description

The complete editable node graph for one script.

Member Function Documentation

◆ findNode() [1/2]

kScriptGraphNode * kemena::kScriptGraph::findNode ( int id)

Finds a node by id, or nullptr.

Parameters
idGraph-unique node id to look up.
Returns
Pointer to the matching node, or nullptr if none.

◆ findNode() [2/2]

const kScriptGraphNode * kemena::kScriptGraph::findNode ( int id) const

Const overload: finds a node by id, or nullptr.

Parameters
idGraph-unique node id to look up.
Returns
Pointer to the matching node, or nullptr if none.

◆ fromJson()

void kemena::kScriptGraph::fromJson ( const kJson & j)

Restores a graph from JSON produced by toJson().

Parameters
jJSON object previously emitted by toJson().

◆ incomingLink()

const kScriptGraphLink * kemena::kScriptGraph::incomingLink ( int nodeId,
int pinId ) const

Returns the link feeding an input pin, or nullptr.

Parameters
nodeIdDestination node id.
pinIdDestination input pin id.
Returns
The incoming link, or nullptr if the pin is unconnected.

◆ isPinConnected()

bool kemena::kScriptGraph::isPinConnected ( int nodeId,
int pinId ) const

True if any link touches the given pin.

Parameters
nodeIdOwning node id.
pinIdPin id to test.
Returns
True when at least one link references the pin.

◆ makeNode()

kScriptGraphNode kemena::kScriptGraph::makeNode ( kScriptNodeType type,
float x,
float y )

Builds a fully-pinned node of the given type at (x, y).

Pin ids are drawn from newId(); the node id is assigned too.

Parameters
typeNode kind to construct.
xInitial canvas X position.
yInitial canvas Y position.
Returns
The newly built node (not yet added to nodes).

◆ newId()

int kemena::kScriptGraph::newId ( )
inline

Returns the next graph-unique id and advances the counter.

Returns
A fresh id never previously handed out by this graph.

◆ outgoingLink()

const kScriptGraphLink * kemena::kScriptGraph::outgoingLink ( int nodeId,
int pinId ) const

Returns the first link leaving an output pin, or nullptr.

Parameters
nodeIdSource node id.
pinIdSource output pin id.
Returns
The first outgoing link, or nullptr if none.

◆ removeLinksByNode()

void kemena::kScriptGraph::removeLinksByNode ( int nodeId)

Removes every link attached to a node.

Parameters
nodeIdNode whose links are removed.

◆ removeLinksByPin()

void kemena::kScriptGraph::removeLinksByPin ( int nodeId,
int pinId )

Removes every link attached to a specific pin.

Parameters
nodeIdOwning node id.
pinIdPin whose links are removed.

◆ removeNode()

void kemena::kScriptGraph::removeNode ( int nodeId)

Removes a node and all of its links.

Parameters
nodeIdNode to delete.

◆ toJson()

kJson kemena::kScriptGraph::toJson ( ) const

Serialises the whole graph to JSON.

Returns
A JSON object holding nodes, links, variables and metadata.

Member Data Documentation

◆ dirty

bool kemena::kScriptGraph::dirty = false

Unsaved-changes flag (editor only).

◆ links

std::vector<kScriptGraphLink> kemena::kScriptGraph::links

All wires between pins.

◆ name

kString kemena::kScriptGraph::name

Display name.

◆ nextId

int kemena::kScriptGraph::nextId = 1

Monotonic id source.

◆ nodes

std::vector<kScriptGraphNode> kemena::kScriptGraph::nodes

All nodes in the graph.

◆ uuid

kString kemena::kScriptGraph::uuid

Stable script-asset UUID.

◆ variables

std::vector<kScriptGraphVar> kemena::kScriptGraph::variables

Graph-scope variables.


The documentation for this struct was generated from the following file: