Generic node-editor graph data structure, renderer, and serializer.
More...
#include <NodeGraphFramework.hpp>
|
| | NodeGraph () |
| | ~NodeGraph () |
| uint32_t | createNode (const std::string &title, const std::string &typeName, ImVec2 pos=ImVec2(100.0f, 100.0f)) |
| uint32_t | addInputPin (uint32_t nodeId, const std::string &name, const NodePinType &type) |
| uint32_t | addOutputPin (uint32_t nodeId, const std::string &name, const NodePinType &type) |
| void | addLink (uint32_t fromPinId, uint32_t toPinId) |
| void | removeLink (uint32_t linkId) |
| void | deleteNode (uint32_t nodeId) |
| void | clear () |
| Node * | findNode (uint32_t nodeId) |
| NodePin * | findPin (uint32_t pinId) |
| NodeLink * | findLink (uint32_t linkId) |
| NodeLink * | findLinkConnectingToInput (uint32_t inputPinId) |
| const std::vector< Node > & | getNodes () const |
| const std::vector< NodeLink > & | getLinks () const |
| uint32_t | getSelectedNodeId () const |
| void | setSelectedNodeId (uint32_t id) |
| uint32_t | getSelectedLinkId () const |
| void | setSelectedLinkId (uint32_t id) |
| void | setNodeHeaderColor (uint32_t nodeId, ImU32 color) |
| std::string | serialize () |
| bool | deserialize (const std::string &jsonStr) |
| void | draw (const char *editorId, const ImVec2 &canvasSize=ImVec2(0.0f, 0.0f), float detailPanelWidth=220.0f) |
| | Draw the node graph editor.
|
| void | registerNodeType (const std::string &category, const std::string &typeName, const std::string &title, std::function< void(uint32_t)> populateCallback, std::function< void(Node &)> customWidgetCallback=nullptr, std::function< void(Node &)> detailPanelCallback=nullptr) |
| const std::vector< NodeRegistryEntry > & | getRegisteredNodeTypes () const |
Generic node-editor graph data structure, renderer, and serializer.
Built-in features available to all graph editors:
- Pannable infinite grid canvas
- Bezier link drawing and drag-to-connect
- Right-click node creation menu (registered types + categories)
- Detail panel: right-side panel that shows detailPanelCallback of the selected node
◆ NodeGraph()
| Engine::NodeGraph::NodeGraph |
( |
| ) |
|
◆ ~NodeGraph()
| Engine::NodeGraph::~NodeGraph |
( |
| ) |
|
◆ addInputPin()
| uint32_t Engine::NodeGraph::addInputPin |
( |
uint32_t | nodeId, |
|
|
const std::string & | name, |
|
|
const NodePinType & | type ) |
◆ addLink()
| void Engine::NodeGraph::addLink |
( |
uint32_t | fromPinId, |
|
|
uint32_t | toPinId ) |
◆ addOutputPin()
| uint32_t Engine::NodeGraph::addOutputPin |
( |
uint32_t | nodeId, |
|
|
const std::string & | name, |
|
|
const NodePinType & | type ) |
◆ clear()
| void Engine::NodeGraph::clear |
( |
| ) |
|
◆ createNode()
| uint32_t Engine::NodeGraph::createNode |
( |
const std::string & | title, |
|
|
const std::string & | typeName, |
|
|
ImVec2 | pos = ImVec2(100.0f, 100.0f) ) |
◆ deleteNode()
| void Engine::NodeGraph::deleteNode |
( |
uint32_t | nodeId | ) |
|
◆ deserialize()
| bool Engine::NodeGraph::deserialize |
( |
const std::string & | jsonStr | ) |
|
◆ draw()
| void Engine::NodeGraph::draw |
( |
const char * | editorId, |
|
|
const ImVec2 & | canvasSize = ImVec2(0.0f, 0.0f), |
|
|
float | detailPanelWidth = 220.0f ) |
Draw the node graph editor.
- Parameters
-
| editorId | Unique ImGui ID string for this graph instance. |
| canvasSize | Total area (canvas + detail panel). 0 = fill available. |
| detailPanelWidth | Width of the built-in right-side detail panel. Pass 0.0f to disable the detail panel entirely. |
◆ drawCanvas()
| void Engine::NodeGraph::drawCanvas |
( |
const ImVec2 & | canvasSize | ) |
|
|
private |
◆ drawDetailPanel()
| void Engine::NodeGraph::drawDetailPanel |
( |
float | panelWidth | ) |
|
|
private |
◆ findLink()
| NodeLink * Engine::NodeGraph::findLink |
( |
uint32_t | linkId | ) |
|
◆ findLinkConnectingToInput()
| NodeLink * Engine::NodeGraph::findLinkConnectingToInput |
( |
uint32_t | inputPinId | ) |
|
◆ findNode()
| Node * Engine::NodeGraph::findNode |
( |
uint32_t | nodeId | ) |
|
◆ findPin()
| NodePin * Engine::NodeGraph::findPin |
( |
uint32_t | pinId | ) |
|
◆ generateId()
| uint32_t Engine::NodeGraph::generateId |
( |
| ) |
|
|
private |
◆ getLinks()
| const std::vector< NodeLink > & Engine::NodeGraph::getLinks |
( |
| ) |
const |
|
inline |
◆ getNodes()
| const std::vector< Node > & Engine::NodeGraph::getNodes |
( |
| ) |
const |
|
inline |
◆ getRegisteredNodeTypes()
| const std::vector< NodeRegistryEntry > & Engine::NodeGraph::getRegisteredNodeTypes |
( |
| ) |
const |
|
inline |
◆ getSelectedLinkId()
| uint32_t Engine::NodeGraph::getSelectedLinkId |
( |
| ) |
const |
|
inline |
◆ getSelectedNodeId()
| uint32_t Engine::NodeGraph::getSelectedNodeId |
( |
| ) |
const |
|
inline |
◆ registerNodeType()
| void Engine::NodeGraph::registerNodeType |
( |
const std::string & | category, |
|
|
const std::string & | typeName, |
|
|
const std::string & | title, |
|
|
std::function< void(uint32_t)> | populateCallback, |
|
|
std::function< void(Node &)> | customWidgetCallback = nullptr, |
|
|
std::function< void(Node &)> | detailPanelCallback = nullptr ) |
◆ removeLink()
| void Engine::NodeGraph::removeLink |
( |
uint32_t | linkId | ) |
|
◆ serialize()
| std::string Engine::NodeGraph::serialize |
( |
| ) |
|
◆ setNodeHeaderColor()
| void Engine::NodeGraph::setNodeHeaderColor |
( |
uint32_t | nodeId, |
|
|
ImU32 | color ) |
Convenience helper to change a node's header color after creation.
◆ setSelectedLinkId()
| void Engine::NodeGraph::setSelectedLinkId |
( |
uint32_t | id | ) |
|
|
inline |
◆ setSelectedNodeId()
| void Engine::NodeGraph::setSelectedNodeId |
( |
uint32_t | id | ) |
|
|
inline |
◆ m_draggingPinId
| uint32_t Engine::NodeGraph::m_draggingPinId = 0 |
|
private |
◆ m_links
| std::vector<NodeLink> Engine::NodeGraph::m_links |
|
private |
◆ m_nextId
| uint32_t Engine::NodeGraph::m_nextId = 1 |
|
private |
◆ m_nodes
| std::vector<Node> Engine::NodeGraph::m_nodes |
|
private |
◆ m_pan
| ImVec2 Engine::NodeGraph::m_pan { 0.0f, 0.0f } |
|
private |
◆ m_registeredTypes
◆ m_selectedLinkId
| uint32_t Engine::NodeGraph::m_selectedLinkId = 0 |
|
private |
◆ m_selectedNodeId
| uint32_t Engine::NodeGraph::m_selectedNodeId = 0 |
|
private |
◆ onCanvasAssetDropped
| std::function<void(const std::string& assetPath, const ImVec2& dropCanvasPos)> Engine::NodeGraph::onCanvasAssetDropped |
Fired when an asset path is dropped onto the canvas grid area.
◆ onDetailPanelAssetDropped
| std::function<void(const std::string& assetPath)> Engine::NodeGraph::onDetailPanelAssetDropped |
Fired when an asset path is dropped onto the detail panel area.
◆ onLinkCreated
| std::function<void(uint32_t fromPinId, uint32_t toPinId)> Engine::NodeGraph::onLinkCreated |
Fired after a link is successfully created.
◆ onLinkDeleted
| std::function<void(uint32_t fromPinId, uint32_t toPinId)> Engine::NodeGraph::onLinkDeleted |
Fired just before a link is destroyed (passes original pin IDs).
◆ onNodeCreated
| std::function<void(uint32_t nodeId, const std::string& typeName, const ImVec2& spawnPos)> Engine::NodeGraph::onNodeCreated |
Fired after a node is created from the canvas context menu.
◆ onNodeDeleted
| std::function<void(uint32_t nodeId)> Engine::NodeGraph::onNodeDeleted |
Fired after a node and all its links are destroyed.
◆ onNodeSelected
| std::function<void(uint32_t nodeId)> Engine::NodeGraph::onNodeSelected |
Fired when the user clicks / selects a node (nodeId = 0 means deselect).
The documentation for this class was generated from the following files: