IsolationGraphModel

class omni.kit.widget.graph.IsolationGraphModel(model: GraphModel, root)

Bases: object

A model class to isolate and manage a sub-graph within a larger graph model.

This class provides functionality to create and manage a sub-graph within a larger graph model. It allows for the isolation of a section of a graph model, enabling operations such as adding, editing, and connecting nodes and ports within this isolated section, without affecting the rest of the graph model.

Parameters
  • model (GraphModel) – The graph model from which the sub-graph is isolated.

  • root – The root node of the sub-graph to be isolated.

Methods

__init__(model, root)

Initializes the IsolationGraphModel.

add_input_or_output(position[, is_input])

Adds an input or output node to the isolation graph.

can_connect(source, target)

Checks if a connection between the source and target can be made.

clear_caches()

Clears the internal caches of the model.

destroy()

Destroys the model, clearing all internal data and subscriptions.

position_begin_edit(item)

Begins the edit operation for the position of an item.

position_end_edit(item)

Ends the edit operation for the position of an item.

subscribe_item_changed(fn)

Subscribes to item changed events.

subscribe_node_changed(fn)

Subscribes to node changed events.

subscribe_selection_changed(fn)

Subscribes to selection changed events.

Attributes

nodes

It's only called to get the nodes from the top level

selection

Gets the current selection.

__init__(model: GraphModel, root)

Initializes the IsolationGraphModel.

class EmptyPort(parent: Union[InputNode, OutputNode])

Bases: object

Is used by the model for an empty port

static get_type_name() str

The string type that goes the source model abd view

class InputNode(model: GraphModel, source)

Bases: object

Is used by the model for the input node. This node represents input ports of the compound node and it’s placed to the subnetwork of the compound.

static get_type_name() str

The string type that goes the source model and view

property ports: Optional[List[Any]]

The list of ports of this node. It only has input ports from the compound node.

class MagicWrapperMeta(name, bases, dct)

Bases: type

Python always looks in the class (and parent classes) __dict__ for magic methods and __getattr__ doesn’t work, but since we want to override them, we need to use this trick with proxy property.

It makes the class looking like the source object.

See https://stackoverflow.com/questions/9057669 for details.

class OutputNode(model: GraphModel, source)

Bases: object

Is used by the model for the ouput node. This node represents output ports of the comound node and it’s placed to the subnetwork of the compound.

static get_type_name() str

The string type that goes the source model and view

property ports: Optional[List[Any]]

The list of ports of this node. It only has output ports from the compound node.

add_input_or_output(position: Tuple[float], is_input: bool = True)

Adds an input or output node to the isolation graph.

Parameters
  • position (Tuple[float]) – The position where the node should be added.

  • is_input (bool, optional) – Whether the node is an input node. Defaults to True.

can_connect(source: Any, target: Any)

Checks if a connection between the source and target can be made.

Parameters
  • source (Any) – The source of the connection.

  • target (Any) – The target of the connection.

Returns

True if the connection is possible, False otherwise.

Return type

bool

clear_caches()

Clears the internal caches of the model.

destroy()

Destroys the model, clearing all internal data and subscriptions.

position_begin_edit(item: Any)

Begins the edit operation for the position of an item.

Parameters

item (Any) – The item whose position is being edited.

position_end_edit(item: Any)

Ends the edit operation for the position of an item.

Parameters

item (Any) – The item whose position edit operation is being ended.

subscribe_item_changed(fn)

Subscribes to item changed events.

Parameters

fn (Callable) – The function to be called when an item changes.

Returns

An object that will automatically unsubscribe when destroyed.

Return type

_EventSubscription

subscribe_node_changed(fn)

Subscribes to node changed events.

Parameters

fn (Callable) – The function to be called when a node changes.

Returns

An object that will automatically unsubscribe when destroyed.

Return type

_EventSubscription

subscribe_selection_changed(fn)

Subscribes to selection changed events.

Parameters

fn (Callable) – The function to be called when the selection changes.

Returns

An object that will automatically unsubscribe when destroyed.

Return type

_EventSubscription

property nodes

It’s only called to get the nodes from the top level

Returns

A list of nodes at the top level, if any.

Return type

Optional[List[Any]]

property selection: Optional[List[Any]]

Gets the current selection.

Returns

The currently selected items.

Return type

Optional[List[Any]]