NodeGraphCanvas class
#include <Editor/Public/NodeGraphCanvas.h>
A node graph: the nodes and wires of a script, and how it is being looked at. Held by value, one per open graph. Build shows it in GG-UI (ui.Graph); edits made there are undoable with the graph's own history while it has the keyboard.
Public types
- struct Pin
- struct ScriptNode
- struct NodeLink
- enum class PinType: uint8_t { Exec, Float, Int, Bool, Vec3, Any }
- enum class PinDir: uint8_t { Input, Output }
- enum class NodeKind: uint8_t { Event_OnPrePhysics, Event_OnPhysicsStep, Event_OnPostPhysics, Event_OnUpdate, Event_OnSpawn, Event_OnDestroy, Sequence, Branch, GetProperty, SetProperty, Math_Add, Math_Subtract, Math_Multiply, Math_Divide, Math_Clamp, Math_Lerp, Vec3_Make, Vec3_Break, Vec3_Length, Vec3_Normalize, Vec3_Scale, GetPosition, SetPosition, GetVelocity, SetVelocity, ApplyImpulse, Const_Float, Const_Int, Const_Bool, GetDeltaTime, Compare, LogicalAnd, LogicalOr, LogicalNot, CheckAction, Math_Sqrt, Math_Abs, Math_Negate, Return_, LocalVar, FuncEntry, RawCode }
Public static functions
-
static auto PinTypeColor(PinType t) -> GGUI::
GGColor - static auto NodeKindTitle(NodeKind k) -> const char*
- static auto CanJoin(PinType from, PinType to) -> bool
- True if pins of these types may be joined.
Constructors, destructors, conversion operators
Public functions
- void AddDefaultEventNode()
- Seed the graph with a default OnUpdate event node.
- void Clear()
- Remove all nodes and links, reset view.
-
void Build(GGUI::
UI& ui, const NodeGraphFind& find, GGUI:: GGRevision& changed) - auto Step(bool bRedo) -> bool
- Undo (or redo) the last edit made through Build. False if there was none.
- void AddEventNode(NodeKind kind, float cx, float cy)
- void AddFuncEntryNode(const char* displayName, float cx, float cy)
- void AddActionNode(NodeKind kind, float cx, float cy)
- void AddNode(ScriptNode node)
- Add a pre-built node directly (used by the body parser).
- void AddExecLink(int srcNodeID, int srcPinID, int dstNodeID, int dstPinID)
- Wire an exec-out pin to an exec-in pin.
- void AddDataLink(int srcNodeID, int srcPinID, int dstNodeID, int dstPinID)
- Wire any two data pins.
- auto NewID() -> int
- auto FindNode(int id) -> ScriptNode*
- auto FindNode(int id) const -> const ScriptNode*
- auto FindPin(int nodeID, int pinID) const -> const Pin*
- auto NodeOfPin(int pinID) const -> const ScriptNode*
- The node owning pin
pinID, or null. - void Remember(uint64_t merge = 0)
- void Connect(int from, int to)
- Join out pin
fromto in pinto. An in pin takes one wire, so any other is replaced. - auto Insert(const std::vector<ScriptNode>& nodes, const std::vector<NodeLink>& links, float dx, float dy) -> std::vector<uint64_t>
- Copies of
nodesand the wires among them, moved by (dx, dy). Returns the copies' IDs.
Public variables
- std::vector<ScriptNode> Nodes
- std::vector<NodeLink> Links
-
GGUI::
GGGraphView View - Pan, zoom and selection, kept with the graph so each tab has its own.
Function documentation
void NodeGraphCanvas:: Build(GGUI:: UI& ui,
const NodeGraphFind& find,
GGUI:: GGRevision& changed)
Show the graph. Each edit finds it with find, is remembered for undo, then bumps changed, which the caller watches.
void NodeGraphCanvas:: Remember(uint64_t merge = 0)
Keep the graph as it is, for undo. A non-zero merge equal to the last one's adds to that step instead (typing on in one field).