GraphModelHelper Class Reference

#include <graph_helper.h>

Static Public Member Functions

static MAXON_METHOD Result< void > GetDirectPredecessors (const GraphNode &node, NODE_KIND filter, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > GetAllPredecessors (const GraphNode &node, NODE_KIND filter, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > GetDirectSuccessors (const GraphNode &node, NODE_KIND filter, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > GetAllSuccessors (const GraphNode &node, NODE_KIND filter, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > MuteConnection (const GraphNode &srcNode, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > MuteAllConnections (const GraphNode &node, PORT_DIR direction)
 
static MAXON_METHOD Result< void > UnmuteConnection (const GraphNode &srcNode, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > UnmuteAllConnections (const GraphNode &node, PORT_DIR direction)
 
static MAXON_METHOD Result< void > RemoveAllConnections (const GraphNode &node)
 
static MAXON_METHOD Result< void > RemoveConnection (const GraphNode &srcPort, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > SelectConnection (const GraphNode &srcPort, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > DeselectConnection (const GraphNode &srcPort, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > GetSelectedConnections (const GraphModelRef &graphModel, const ValueReceiver< const GraphNode &, const GraphNode &, const Wires & > &callback)
 
static MAXON_METHOD Result< void > SelectNode (const GraphNode &node)
 
static MAXON_METHOD Result< void > DeselectNode (const GraphNode &node)
 
static MAXON_METHOD Result< void > ListAllNodes (const GraphModelRef &graphModel, const DataDictionary &matchingData, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Bool IsConnectionSelected (const GraphNode &srcPort, const GraphNode &dstPort)
 
static MAXON_METHOD Result< void > GetSelectedNodes (const GraphModelRef &graphModel, NODE_KIND kind, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > DeselectAll (const GraphModelRef &graphModel, NODE_KIND kind)
 
static MAXON_METHOD Bool IsConnected (const GraphNode &srcNode, const GraphNode &dstPort)
 
static MAXON_METHOD Bool IsNodeSelected (const GraphNode &node)
 
static MAXON_METHOD Result< void > FindNodesByName (const GraphModelRef &graphModel, const String &nodeName, NODE_KIND kind, PORT_DIR direction, Bool exactName, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > FindNodesById (const GraphModelRef &graphModel, const Id &nodeId, NODE_KIND kind, PORT_DIR direction, Bool exactId, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< void > FindNodesByAssetId (const GraphModelRef &graphModel, const Id &assetId, Bool exactId, const ValueReceiver< const GraphNode & > &callback)
 
static MAXON_METHOD Result< GraphNodeCreateOutputPort (const GraphNode &dstNode, const CString &portId, const String &portName=String("Output"))
 
static MAXON_METHOD Result< GraphNodeCreateInputPort (const GraphNode &dstNode, const CString &portId, const String &portName=String("Input"))
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (GraphModelHelper, MAXON_REFERENCE_STATIC, "net.maxon.graph.interface.graphmodelhelper")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( GraphModelHelper  ,
MAXON_REFERENCE_STATIC  ,
"net.maxon.graph.interface.graphmodelhelper"   
)
private

◆ GetDirectPredecessors()

static MAXON_METHOD Result<void> GetDirectPredecessors ( const GraphNode node,
NODE_KIND  filter,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves the first level of nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the inputs.

Parameters
[in]nodeThe starting point to retrieve the direct predecessors. A node or a port can be used. If a port is used, an input port must be used.
[in]filterThe NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.
[out]callbackThe callback that will receive all connected nodes.

◆ GetAllPredecessors()

static MAXON_METHOD Result<void> GetAllPredecessors ( const GraphNode node,
NODE_KIND  filter,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves all nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the inputs.

Parameters
[in]nodeThe starting point to retrieve all the predecessor. A node or a port can be used. If a port is used, an input port must be used.
[in]filterThe NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.
[out]callbackThe callback that will receive all connected nodes.

◆ GetDirectSuccessors()

static MAXON_METHOD Result<void> GetDirectSuccessors ( const GraphNode node,
NODE_KIND  filter,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves the first level of nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the outputs.

Parameters
[in]nodeThe starting point to retrieve the direct successors. A node or a port can be used. If a port is used, an output port must be used.
[in]filterThe NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.
[out]callbackThe callback that will receive all connected nodes.

◆ GetAllSuccessors()

static MAXON_METHOD Result<void> GetAllSuccessors ( const GraphNode node,
NODE_KIND  filter,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves all nodes or ports connected to the passed port or node. This will only retrieve nodes or ports that are connected to the outputs.

Parameters
[in]nodeThe starting point to retrieve all the successors. A node or a port can be used. If a port is used, an output port must be used.
[in]filterThe NODE_KIND that will be included. The function search for all possible nodes or ports and will include them or not based on this filter.
[out]callbackThe callback that will receive all connected nodes.

◆ MuteConnection()

static MAXON_METHOD Result<void> MuteConnection ( const GraphNode srcNode,
const GraphNode dstPort 
)
static

Mutes the connection between a node or port and another port. If a true node is passed, and the port is connected to one or several input port, all the connections will be muted between the port and the node. For example, a constant port is connected to several input port of another node.

Parameters
[in]srcNodeThe node to mute the connection with.
[in]dstPortThe other port the connection must be muted.

◆ MuteAllConnections()

static MAXON_METHOD Result<void> MuteAllConnections ( const GraphNode node,
PORT_DIR  direction 
)
static

Mutes all incoming or outgoing connections of a node depending on the specified direction

Parameters
[in]nodeThe true node to mute all the connections.
[in]directionThe direction where all connection will be muted.

◆ UnmuteConnection()

static MAXON_METHOD Result<void> UnmuteConnection ( const GraphNode srcNode,
const GraphNode dstPort 
)
static

Unmutes the connection between a node or port and another port. If a true node is passed, depending of the port passed direction, every output or every input will be unmuted.

Parameters
[in]srcNodeThe node to unmute the connection with.
[in]dstPortThe other port that the connection must be Unmuted.

◆ UnmuteAllConnections()

static MAXON_METHOD Result<void> UnmuteAllConnections ( const GraphNode node,
PORT_DIR  direction 
)
static

Unmutes all the connections in one direction.

Parameters
[in]nodeThe node to unmute the connection.
[in]directionThe direction where all connection will be Unmuted.

◆ RemoveAllConnections()

static MAXON_METHOD Result<void> RemoveAllConnections ( const GraphNode node)
static

Removes all the connection a true node have. The node should be a true node. To remove connection for a port, use maxon::GraphNodeFunctions::RemoveConnections()

Parameters
[in]nodeThe node to remove all the connections to.

◆ RemoveConnection()

static MAXON_METHOD Result<void> RemoveConnection ( const GraphNode srcPort,
const GraphNode dstPort 
)
static

Removes the connections between two ports.

Parameters
[in]srcPortThe source's port.
[in]dstPortThe destination's port.

◆ SelectConnection()

static MAXON_METHOD Result<void> SelectConnection ( const GraphNode srcPort,
const GraphNode dstPort 
)
static

Selects the connection between two ports.

Parameters
[in]srcPortThe connection's source port.
[in]dstPortThe connection's destination port.

◆ DeselectConnection()

static MAXON_METHOD Result<void> DeselectConnection ( const GraphNode srcPort,
const GraphNode dstPort 
)
static

Deselects the connection between two ports. A connection hold a Wire object. There is at most one connection between two port, but this connection is composed by 8 wires.

Parameters
[in]srcPortThe connection's source port.
[in]dstPortThe connection's destination port.

◆ GetSelectedConnections()

static MAXON_METHOD Result<void> GetSelectedConnections ( const GraphModelRef &  graphModel,
const ValueReceiver< const GraphNode &, const GraphNode &, const Wires & > &  callback 
)
static

Retrieves all the selected connections on the graph. A connection hold a Wire object. There is none or only one connection between two ports, and this connection is composed by multiple wires.

Parameters
[in]graphModelThe GraphModelRef to retrieve the GraphNode from the path.
[out]callbackThis callback will receive the source and destination ports and the wires itself.

◆ SelectNode()

static MAXON_METHOD Result<void> SelectNode ( const GraphNode node)
static

Selects a node or a port.

Parameters
[in]nodeThe node or the port that have to be selected.

◆ DeselectNode()

static MAXON_METHOD Result<void> DeselectNode ( const GraphNode node)
static

Deselects a node or a port.

Parameters
[in]nodeThe node or the port that have to be Deselected.

◆ ListAllNodes()

static MAXON_METHOD Result<void> ListAllNodes ( const GraphModelRef &  graphModel,
const DataDictionary &  matchingData,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves all nodes having their stored data equals the ones in the passed DataDictionary. The passed DataDictionary can have one or multiple data defined. The function will compare all the value inside the DataDictionary, if they all match, the node will be returned.

// Retrieve all nodes with a defined name
DataDictionary nodeProperties;
nodeProperties.Set(NODE::BASE::NAME, groupName) iferr_return;
GraphModelHelper::ListAllNodes(nodeGraph, nodeProperties, [](const GraphNode& child)
{
ApplicationOuput("node that have this name @", child);
return true;
static MAXON_METHOD Result< void > ListAllNodes(const GraphModelRef &graphModel, const DataDictionary &matchingData, const ValueReceiver< const GraphNode & > &callback)
#define iferr_return
Definition: resultbase.h:1519
Parameters
[in]graphModelThe GraphModelRef to list the node.
[in]matchingDataThe Dictionary filled with the data we want to compare the GraphNode with.
[out]callbackThis callback will receive all nodes founded that have the same data values than those passed within the Dictionary

◆ IsConnectionSelected()

static MAXON_METHOD Bool IsConnectionSelected ( const GraphNode srcPort,
const GraphNode dstPort 
)
static

Checks if a connection between two port is selected. A connection hold a Wire object. There is at most one connection between two port, but this connection is composed by 8 wires. If a GraphNode is passed instead a NodePath, the GraphNode will be converted to NodePath.

Parameters
[in]srcPortThe connection's source port.
[in]dstPortThe connection's destination port.
Returns
true if the connection is selected, otherwise false..

◆ GetSelectedNodes()

static MAXON_METHOD Result<void> GetSelectedNodes ( const GraphModelRef &  graphModel,
NODE_KIND  kind,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Retrieves all selected ports and/or true node on the graph depending on the NODE_KIND passed as argument.

Parameters
[in]graphModelThe GraphModelRef to retrieve the selected elements.
[in]kindThe GraphNode kind to check.
[out]callbackThis callback will receive all selected ports and/or true node.

◆ DeselectAll()

static MAXON_METHOD Result<void> DeselectAll ( const GraphModelRef &  graphModel,
NODE_KIND  kind 
)
static

Deselect all true nodes and ports based on the NODE_KIND passed as parameter.

Parameters
[in]graphModelThe GraphModelRef to deselect elements.
[in]kindThe GraphNode's kind that will be deselected.

◆ IsConnected()

static MAXON_METHOD Bool IsConnected ( const GraphNode srcNode,
const GraphNode dstPort 
)
static

Checks if this node or port is connected to another port. If a true node is passed, every port on the node will be tested. If a port is passed, only the passed port will be tested.

Parameters
[in]srcNodeThe node to check the connection with.
[in]dstPortThe port to check the connection with.
Returns
true if ports are connected, otherwise false..

◆ IsNodeSelected()

static MAXON_METHOD Bool IsNodeSelected ( const GraphNode node)
static

Returns if the node or the port is selected or not.

Parameters
[in]nodeThe Node or the Port to check.
Returns
true if the node or the port is selected, otherwise false..

◆ FindNodesByName()

static MAXON_METHOD Result<void> FindNodesByName ( const GraphModelRef &  graphModel,
const String nodeName,
NODE_KIND  kind,
PORT_DIR  direction,
Bool  exactName,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Find all GraphNode (true nodes or ports) that have the same name as the passed argument. This function will return several nodes/port if they share the same name.

Warning
Name of true nodes or port can change depending on the language of Cinema4D. Search based on name should be avoided as mush as possible, unless you are sure the name will not be different on any setup.
Parameters
[in]graphModelThe GraphModelRef to search for the nodes.
[in]nodeNameThe name of the true node or the port to look for.
[in]kindFilter that will be applied to the kind of GraphNode we are looking for. By default, All type (true node/ports)
[in]directionFilter the GraphNode by direction. Input or Output. By default INPUT.
[in]exactNameSet true if the exact name should be search. If this is set to false, check if the passed name is contained in the GraphNode's name.
[out]callbackThis callback will receive all ports and/or true node that have the same name.

◆ FindNodesById()

static MAXON_METHOD Result<void> FindNodesById ( const GraphModelRef &  graphModel,
const Id nodeId,
NODE_KIND  kind,
PORT_DIR  direction,
Bool  exactId,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Find all GraphNode (true nodes or ports) that have the same id as the passed argument. This function will return several nodes/port if they share the same id.

Parameters
[in]graphModelThe GraphModelRef to search for the nodes.
[in]nodeIdThe id of the true node or the port to look for.
[in]kindFilter that will be applied to the kind of GraphNode we are looking for. By default, All type (true node/ports)
[in]directionFilter the GraphNode by direction. Input or Output. By default INPUT.
[in]exactIdSet true if the exact id should be search. If this is set to false, check if the passed id is contained in the GraphNode's id.
[out]callbackThis callback will receive all ports and/or true node that have the same name.

◆ FindNodesByAssetId()

static MAXON_METHOD Result<void> FindNodesByAssetId ( const GraphModelRef &  graphModel,
const Id assetId,
Bool  exactId,
const ValueReceiver< const GraphNode & > &  callback 
)
static

Find all true nodes that have the same AssetId as the passed argument. Only nodes have assetId. This function will return several nodes if they share the same assetId.

Parameters
[in]graphModelThe GraphModelRef to search for the nodes.
[in]assetIdThe AssetId of the true node or the port to look for. This have the form of a reversed domain string. e.g "net.maxon.asset.utility.color"
[in]exactIdSet true if the exact id should be search. If this is set to false, check if the passed id is contained in the node assetID.
[out]callbackThis callback will receive all ports and/or true node that have the same name.

◆ CreateOutputPort()

static MAXON_METHOD Result<GraphNode> CreateOutputPort ( const GraphNode dstNode,
const CString portId,
const String portName = String("Output") 
)
static

Creates and returns a new OutputPort. The port will be identify by the passed id and will be rename with the passed string. This new port can only be created on the root or any group node.

Parameters
[in]dstNodeThe node where to create the output port.
[in]portIdThe id of the port that need to be created.
[in]portNameThe name of the port that need to be created.
Returns
The created port.

◆ CreateInputPort()

static MAXON_METHOD Result<GraphNode> CreateInputPort ( const GraphNode dstNode,
const CString portId,
const String portName = String("Input") 
)
static

Creates and returns a new InputPort. The port will be identify by the passed id and will be rename with the passed string. This new port can only be created on the root or any group node.

Parameters
[in]dstNodeThe node where to create the input port.
[in]portIdThe id of the port that need to be created.
[in]portNameThe name of the port that need to be created.
Returns
The created port.