GraphNodeDelegateRouter#

class omni.kit.widget.graph.GraphNodeDelegateRouter#

Bases: AbstractGraphNodeDelegate

The delegate that keeps multiple delegates and pick them depending on the routing conditions.

It’s possible to add the routing conditions with `add_route`, and conditions could be a type or a lambda expression.

The latest added routing is stronger than previously added. Routing added without conditions is the default.

We use type routing to make the specific kind of nodes unique, and also we can use the lambda function to make the particular state of nodes unique (ex. full/collapsed).

It’s possible to use type and lambda routing at the same time.

Usage examples:

delegate.add_route(TextureDelegate(), type=”Texture2d”) delegate.add_route(CollapsedDelegate(), expressipon=is_collapsed)

Methods

__init__()

Initializes the GraphNodeDelegateRouter with an empty routing table.

add_route(delegate[, type, expression])

Adds a delegate with an optional type and/or expression to the routing table.

connection(model, source, target[, foreground])

Creates a graphical connection between two ports.

destroy()

Destroys all delegates in the routing table.

get_node_layout(model, node_desc)

Determines the layout for a given node.

node_background(model, node_desc)

Creates widgets for the background of a node.

node_footer(model, node_desc)

Creates widgets for the bottom of a node.

node_header(model, node_desc)

Creates widgets for the top of a node.

node_header_input(model, node_desc)

Creates the left part of the node header to be used as input when the node is collapsed.

node_header_output(model, node_desc)

Creates the right part of the node header to be used as output when the node is collapsed.

port(model, node_desc, port_desc)

Creates the middle part of a port.

port_input(model, node_desc, port_desc)

Creates the left part of a port to be used as input.

port_output(model, node_desc, port_desc)

Creates the right part of a port to be used as output.

__init__()#

Initializes the GraphNodeDelegateRouter with an empty routing table.

add_route(
delegate: AbstractGraphNodeDelegate,
type=None,
expression=None,
)#

Adds a delegate with an optional type and/or expression to the routing table.

Parameters:
  • delegate (AbstractGraphNodeDelegate) – The delegate to be added.

  • type (str, optional) – The type of the delegate. Defaults to None.

  • expression (callable, optional) – A lambda expression to evaluate for routing. Defaults to None.

connection(
model,
source: GraphConnectionDescription,
target: GraphConnectionDescription,
foreground: bool = False,
)#

Creates a graphical connection between two ports.

Parameters:
  • model – The data model associated with the graph.

  • source (GraphConnectionDescription) – The source port description.

  • target (GraphConnectionDescription) – The target port description.

  • foreground (bool, optional) – If True, draw the connection in the foreground. Defaults to False.

Returns:

The created connection widget.

destroy()#

Destroys all delegates in the routing table.

get_node_layout(
model,
node_desc: GraphNodeDescription,
)#

Determines the layout for a given node.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The layout for the node.

node_background(
model,
node_desc: GraphNodeDescription,
)#

Creates widgets for the background of a node.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The widgets for the node’s background.

Creates widgets for the bottom of a node.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The widgets for the node’s footer.

node_header(
model,
node_desc: GraphNodeDescription,
)#

Creates widgets for the top of a node.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The widgets for the node’s header.

node_header_input(
model,
node_desc: GraphNodeDescription,
)#

Creates the left part of the node header to be used as input when the node is collapsed.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The widgets for the node’s header input.

node_header_output(
model,
node_desc: GraphNodeDescription,
)#

Creates the right part of the node header to be used as output when the node is collapsed.

Parameters:
  • model – The data model associated with the graph.

  • node_desc (GraphNodeDescription) – The description of the node.

Returns:

The widgets for the node’s header output.

port(
model,
node_desc: GraphNodeDescription,
port_desc: GraphPortDescription,
)#

Creates the middle part of a port.

Parameters:
Returns:

The widget for the port.

port_input(
model,
node_desc: GraphNodeDescription,
port_desc: GraphPortDescription,
)#

Creates the left part of a port to be used as input.

Parameters:
Returns:

The widget for the port input.

port_output(
model,
node_desc: GraphNodeDescription,
port_desc: GraphPortDescription,
)#

Creates the right part of a port to be used as output.

Parameters:
Returns:

The widget for the port output.