NodesGraphModelInterface Manual

Table of Contents

About

maxon::nodes::NodesGraphModelInterface is an implementation of maxon::GraphModelInterface and presents the node system (NodeSystemInterface Manual) as a graph model.

Note
If possible, one should work with the more generic maxon::GraphModelInterface, see GraphModelInterface Manual.

Access

The maxon::nodes::NodesGraphModelRef is obtained from the NodeMaterial:

See NodeMaterial Manual.

// This example obtains the NodesGraphModelRef from the given NodeMaterial.
// access node space
const maxon::Id nodeSpaceID = GetActiveNodeSpaceId();
if (nodeMaterial->HasSpace(nodeSpaceID) == false)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
const maxon::nodes::NodesGraphModelRef& graph = nodeMaterial->GetGraph(nodeSpaceID) iferr_return;
maxon::Id GetActiveNodeSpaceId()
Definition: apibaseid.h:243
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define iferr_return
Definition: resultbase.h:1524

Use

The node graph model gives access to the stored node system:

See NodeSystemInterface Manual.

// This example obtains the NodeSystem from the given NodeMaterial.
const maxon::nodes::NodesGraphModelRef& graph = nodeMaterial->GetGraph(nodeSpaceID) iferr_return;
const maxon::nodes::NodeSystem& system = graph.GetNodeSystem();
Definition: nodesystem.h:944

A new nodes graph can be created with the class maxon::nodes::NodesGraphModelClass().

// This example creates a new NodesGraphModelRef.
maxon::AssetRepositoryRef repository = maxon::AssetInterface::GetBuiltinRepository();
maxon::nodes::MutableRoot root = maxon::nodes::CoreNodesNodeSystemClass().CreateNodeSystem(repository) iferr_return;
const auto nodesGraphModelClass = maxon::nodes::NodesGraphModelClass();
maxon::nodes::NodesGraphModelRef nodesGraphModel = nodesGraphModelClass.Create() iferr_return;
nodesGraphModel.Init(sys, repository, filter, true) iferr_return;
static MAXON_METHOD const AssetRepositoryRef & GetBuiltinRepository()
Definition: nodesystem.h:2395
Result< NodeSystem > EndModification(Opt< ChangeList & > list={}, NodeSystem::FINALIZE_FLAGS finalize=NodeSystem::FINALIZE_FLAGS::CLEANUP)
@ NONE
Don't do any finalizations at all.
@ INCLUDE_INNER
Includes inner nodes in the view.
@ INCLUDE_HIDDEN
Includes hidden nodes in the view.
static const NO_VALUE_TYPE NO_VALUE
Definition: optional.h:17

A view on a node graph is a new node graph that presents only a subset of the original node graph.

A node system can contain multiple children under the root node:

// This example obtains a node graph from a node material and inserts a new node.
// get graph
const maxon::nodes::NodesGraphModelRef& nodeGraph = nodeMaterial->GetGraph(nodeSpaceID) iferr_return;
if (nodeGraph.IsReadOnly())
return maxon::IllegalStateError(MAXON_SOURCE_LOCATION);
// start a new change list if we want to apply the changes also to a different graph
nodeGraph.StartNewChangeList() iferr_return;
// start transaction
maxon::GraphTransaction transaction = nodeGraph.BeginTransaction() iferr_return;
// prepare for adding a new node
const maxon::Id nodeAssetId { "net.maxonexample.noderenderer.usernode" };
const maxon::AssetRepositoryRef& repository = maxon::AssetInterface::GetBuiltinRepository();
maxon::nodes::NodeTemplate nodeTemplate = maxon::nodes::NodesLib::LoadTemplate(repository, nodeAssetId) iferr_return;
// add new node
// leave the 'childId' parameter empty to create a UUID
maxon::GraphNode userGraphNode = nodeGraph.AddChild(maxon::Id(), nodeTemplate) iferr_return;
// set node name
userGraphNode.SetValue(maxon::NODE::BASE::NAME, "My user node"_s) iferr_return;
// commit transaction
transaction.Commit() iferr_return;
// this change list contains the latest changes
const maxon::ChangeList& list = nodeGraph.GetChangeList();
Result< Bool > SetValue(const InternedId &attr, ForwardingDataPtr &&value, Bool checkAndInvalidate=true) const
Definition: graph.h:1741
Definition: graph.h:2014
Definition: graph.h:1011
Result< void > Commit(const DataDictionary &userData=GetPtrSizedZeroRef< DataDictionary >(), Bool validate=true)
static MAXON_METHOD Result< NodeTemplate > LoadTemplate(const AssetRepositoryRef &repo, const Id &assetId)
PyWideStringList * list
Definition: initconfig.h:447

Nodes can be organized in group nodes:

Nodes are based on assets from the asset repository:

A maxon::nodes::NodeSystemManagerInterface manages a node system and its views: