maxon.GraphModelInterface¶
Description¶
maxon.GraphModelInterface
has a single root node (see maxon.GraphModelInterface.GetRoot()
).- Root (maxon.NODE_KIND.NODE)
- N1 (maxon.NODE_KIND.NODE)
- N2 (maxon.NODE_KIND.NODE)
- Inputs (maxon.NODE_KIND.INPUTS)
- PortA (maxon.NODE_KIND.INPORT)
PortB (maxon.NODE_KIND.INPORT)
PortC (maxon.NODE_KIND.INPORT)
- Outputs (maxon.NODE_KIND.OUTPUTS)
PortD (maxon.NODE_KIND.OUTPORT)
- Inputs (maxon.NODE_KIND.INPUTS)
PortE (maxon.NODE_KIND.INPORT)g
- Outputs (maxon.NODE_KIND.OUTPUTS)
- PortF (maxon.NODE_KIND.OUTPORT)
PortG (maxon.NODE_KIND.OUTPORT)
- N3 (maxon.NODE_KIND.NODE)
- Inputs (maxon.NODE_KIND.INPUTS)
PortH (maxon.NODE_KIND.INPORT)
- Outputs (maxon.NODE_KIND.OUTPUTS)
PortI (maxon.NODE_KIND.OUTPORT)
maxon.GraphModelInterface
represents nodes and ports by the same class maxon.GraphNode
.maxon.GraphNode
, a value of type maxon.NODE_KIND
is returned by maxon.GraphNode.GetKind()
.maxon.NODE_KIND.NODE
stands for true nodes.maxon.NODE_KIND.INPUTS
/maxon.NODE_KIND.OUTPUTS
represent the lists of top-level input/output ports of a node.maxon.NODE_KIND.INPORT
/maxon.NODE_KIND.OUTPORT
represent input/output ports.
maxon.GraphModelInterface
to support arbitrary nestings.maxon.GraphConnection
.An output port of a node may have a connection to an input port of a sibling node (so both nodes must have the same direct parent).
An input port of a child node may have a connection from an input port of its direct parent node.
An output port of a child node may have a connection to an output port of its direct parent node.
An input port of a node may have a connection to an output port of that same node (so the connections just tunnels the value through the node).
maxon.InternedId
, typically this id is defined together with the type of the attribute
value by maxon.MAXON_ATTRIBUTE()
.Methods Signature¶
|
Adds an instance of the node given by the identifier nodeId as child of the root node to this graph. |
|
|
|
Applies the given change list to the node system of this manager. |
|
Begins a new transaction within which modifications can be made.
|
|
|
|
Returns a new graph model which is a copy of the subgraph given by the selection. |
Returns the change list to which this graph model currently logs its modifications.
|
|
|
Returns the
maxon.GraphAttribute which this graph model uses for the attribute identified by attr. |
|
Returns the
maxon.GraphAttributeInterface.FLAGS to use for the attribute identified by attr. |
Returns a time stamp of this graph which can be used to test for modifications.
|
|
|
Reports all modifications which have been made since the given stamp to receiver.
|
|
Returns the |
|
Returns the root node of this graph.
|
Returns the path of the root node of this graph.
|
|
Checks if this graph is read-only. |
|
|
|
|
Merges the other graph into this graph.
|
|
Removes all values for the given user state attribute attr from this graph (so from all of its nodes). |
Starts a new change list and returns the previous one.
|
|
|
Validates the graph.
|
Methods Definition¶
-
GraphModelInterface.
AddChild
(childId, nodeId, args=maxon.DataDictionary object at 0x1b1d6326420 with the data: DataDictionary{})¶ Adds an instance of the node given by the identifier nodeId as child of the root node to this graph.
If childId is empty, amaxon.UUID
will be chosen as identifier of the child, otherwise childId.In the latter case it is an error if this root node already has a child with that identifier.- Parameters
childId (Union[str,
maxon.Id
]) – Identifier for the child node (if empty, a UUID is chosen).nodeId (Union[str,
maxon.Id
]) – Identifier for the type of the node to add. How this is resolved to an actual node type is model-specific.args (
maxon.DataDictionary
) – Arguments to use for the node creation. The exact meaning is model-specific.
- Returns
A
maxon.GraphNode
referencing the added child.- Return type
-
GraphModelInterface.
AddPorts
()¶
-
GraphModelInterface.
Apply
(list, inverse)¶ Applies the given change list to the node system of this manager.
- Parameters
list (
maxon.ChangeList
) – Change list to apply.inverse (bool) – True if the inverse of the change list shall be applied (for an undo), False otherwise.
- Returns
A new change list which contains those changes of list which couldn’t be applied, for example the change of an attribute value at a node which doesn’t exist in the node system.
- Return type
maxon.ChangeList
-
GraphModelInterface.
BeginTransaction
(userData=None)¶ - Begins a new transaction within which modifications can be made.This is mandatory in order to modify the graph, modifications outside of transactions are not allowed (with the exception of changing user state attributes).If there already is an active transaction, this will create a nested transaction.Otherwise a non-nested transaction starts, only then the observable
Warning
It’s mandatory to use the with statement as unclosed Transaction could lead to a freeze.
# This will start a new transaction and RollBack the transaction once the scope is left with graph.BeginTransaction() as transaction: # Do some modification like connecting two ports graph.Connect() # This will commit and perform the change to the graph transaction.Commit() # transaction is not anymore accessible and it has been Rolled out to the previous Commit.
- Parameters
userData (
maxon.DataDictionary
) –User data to pass to the observers ofGraphModelInterface.ObservableTransactionStarted()
.Because nested transactions don’t trigger the observable, the user data of them is ignored.- Returns
A
maxon.GraphTransaction
object to commit or rollback the transaction at a later point of time.- Return type
-
GraphModelInterface.
BeginTransactionImpl
()¶
-
GraphModelInterface.
CommitImpl
(userData, nesting, validate=True)¶
-
GraphModelInterface.
CreateCopyOfSelection
(selection)¶ Returns a new graph model which is a copy of the subgraph given by the selection.
- Parameters
selection (list[
maxon.GraphNode
]) – A selection of nodes. Nodes which aren’t direct children of this graph are ignored.- Returns
A copy of the subgraph given by the selection.
- Return type
-
GraphModelInterface.
GetChangeList
()¶ - Returns the change list to which this graph model currently logs its modifications.A newly created graph model doesn’t automatically create a change list, so to start logging you need to call
GraphModelInterface.StartNewChangeList()
once.The change list can be used to undo or redo the changes or even to apply them to a different graph, seeGraphModelInterface.Apply()
.- Returns
Current change list, may be a null reference.
- Return type
maxon.ChangeList
-
GraphModelInterface.
GetGraphAttribute
(attr)¶ - Returns the
maxon.GraphAttribute
which this graph model uses for the attribute identified by attr.The model may return a null reference if it doesn’t provide amaxon.GraphAttribute
for attr.This doesn’t mean that the attribute is unsupported, it just means that there is no need for special handling of the attribute (which would require amaxon.GraphAttribute
).- Parameters
attr (
maxon.InternedId
) – The identifier of the attribute- Returns
The corresponding
maxon.GraphAttribute
, or a null reference if the graph model has nomaxon.GraphAttribute
for attr.- Return type
-
GraphModelInterface.
GetGraphAttributeFlags
(attr)¶ - Returns the
maxon.GraphAttributeInterface.FLAGS
to use for the attribute identified by attr.This allows the graph model to override the default flags of the attribute, for example to mark an attribute as meta attribute.- Parameters
attr (
maxon.InternedId
) – The identifier of the attribute.- Returns
The flags which this graph model uses for the attribute.
- Return type
-
GraphModelInterface.
GetModificationStamp
()¶ - Returns a time stamp of this graph which can be used to test for modifications.Each transaction or change of user state increments the stamp.The time stamp is also needed for
GraphModelInterface.GetModificationsSince()
andGraphNode.GetAttributeModificationsSince()
to get all modifications which have happened since then.- Returns
Modification time stamp of the graph.
- Return type
maxon.TimeStamp
-
GraphModelInterface.
GetModificationsSince
(stamp, receiver=None, filtered=True)¶ - Reports all modifications which have been made since the given stamp to receiver.If receiver is None only flags will be returned.
- Parameters
stamp (
maxon.Timestamp
) – A reference time stamp. Only modifications newer than this stamp are reported.receiver (Union[None, list, Callable[[
maxon.GraphNode
,maxon.GraphModelInterface.MODIFIED
], bool]) – Modifications are reported to this receiver.
- Returns
Combination of flags to indicate the kinds of changes that have happened.
-
GraphModelInterface.
GetNode
(path, filtered=True)¶ Returns the
maxon.GraphNode
corresponding to path.Note
If no such node exists in the graph, an empty node is returned.
- Parameters
path (
maxon.NodePath
) –A node path.This has to be an absolute path, so if the current graph is view of a nested part of an enclosing graph.The path has to be the full path starting at the root of the enclosing graph.filtered –
With the default value of True the filter settings (if any) of this graph will be used.When False this is disabled, then you’ll get a validmaxon.GraphNode
even for paths which don’t belong to this graph, but e.g. to nested graphs which are hidden by the filter settings.
- Return type
- Returns
- The
maxon.GraphNode
corresponding to the path.This is empty when there is no such node in the graph.
-
GraphModelInterface.
GetRoot
()¶ - Returns the root node of this graph.The whole graph can be traversed starting from the root node.
- Return type
- Returns
The root node of this graph.
-
GraphModelInterface.
GetRootPath
()¶ - Returns the path of the root node of this graph.Usually this is an empty path, but a graph model may be a view of a nested part of an enclosing graph.In the latter case the path points to the root node of the nested part.
- Return type
- Returns
The path of the root node of this graph.
-
GraphModelInterface.
GetTransactionCount
()¶
-
GraphModelInterface.
GetUserState
()¶
-
GraphModelInterface.
IsConnectable
()¶
-
GraphModelInterface.
IsReadOnly
()¶ Checks if this graph is read-only.
Note
You can’t modify read-only graphs.
- Return type
bool
- Returns
True if this graph is read-only otherwise False.
-
GraphModelInterface.
IsRoot
()¶
-
GraphModelInterface.
Merge
(other)¶ - Merges the other graph into this graph.Top-level nodes and ports are added into this graph using new unique identifiers to prevent naming conflicts.The mapping from the original identifiers of other to the new ones is returned.
- Parameters
other (
maxon.GraphModelRef
) – Another graph to merge into this graph.- Returns
The mapping from original identifiers of other to the identifiers used for the merge: | - first entry contains the mapping of top-level nodes. | - second entry contains the mapping of top-level input ports. | - third entry contains the mapping of top-level output ports.
- Return type
tuple[
maxon.HashMap
[maxon.InternedId
,maxon.InternedId
]]
-
GraphModelInterface.
RemovePorts
()¶
-
GraphModelInterface.
ResetUserState
(attr)¶ Removes all values for the given user state attribute attr from this graph (so from all of its nodes).
- Parameters
attr (
maxon.InternedId
) – A user state attribute
-
GraphModelInterface.
StartNewChangeList
()¶ - Starts a new change list and returns the previous one.Afterwards this manager will log all modifications to the newly created change list.The new change list can be obtained with
GraphModelInterface.GetChangeList()
or as the result of the next call toGraphModelInterface.StartNewChangeList()
.The returned change list contains all modifications which have been made since the previous call toGraphModelInterface.StartNewChangeList()
.You can pass it toGraphModelInterface.Apply()
to undo or redo the changes.- Returns
Change list which contains the modifications since the previous call to GraphModelInterface.StartNewChangeList.
- Return type
maxon.ChangeList
-
GraphModelInterface.
Validate
()¶ - Validates the graph.
Note
This is an implementation-specific operation and should be invoked when a batch of changes has been applied to the graph and the graph should be brought into a valid state again.For example, the implementation of
maxon.GraphModelInterface
for nodes may update the type of an output port of a polymorphic node based on the types of the input ports.