LayerModel#
- class omni.kit.widget.layers.LayerModel(usd_context, layer_settings=None)#
Bases:
AbstractItemModelClass representing the Layer Model.
Methods
__init__(usd_context[, layer_settings])Initialize.
Add a dirtiness listener.
Add a muteness scope listener.
Add a stage attachment listener.
can_item_have_children(item)Check if an item can have children.
destroy()Destroys the LayerModel instance.
drop(target_item, source[, drop_location])Reimplemented from AbstractItemModel.
drop_accepted(target_item, source[, ...])Reimplemented from AbstractItemModel.
filter_by_text(filter_name_text)Specify the filter string that is used to reduce the model.
find_all_specs(paths)Return the list of all the parent nodes and the node representing the given path.
Flatten all layers if there is not layer locked.
Returns a list of all dirty layer identifiers.
get_drag_mime_data(item)Returns Multipurpose Internet Mail Extensions (MIME) data for be able to drop this item somewhere.
get_item_children(item)Get the children of an item, reimplemented from AbstractItemModel.
get_item_value_model(item, column_id)Reimplemented from AbstractItemModel.
Reimplemented from AbstractItemModel, returns the number of value models for the given item.
get_layer_item_by_identifier(layer_identifier)Find the first layer item that has the identifier
Checks if any layers are locked.
has_dirty_layers([include_omni_layers, ...])Checks if there are any dirty layers in the current stage.
Checks if there are any outdated layers in the sublayers cache.
refresh()Force full re-update
save_layers(layer_identifiers[, on_save_done])Saves multiple layers asynchronously and executes a callback on completion.
set_edit_target(layer_item[, saved])Sets the edit target with the given layer item's identifier.
Attributes
If the edit mode is 'AUTO_AUTHORING'.
The default edit layer.
If the layers' muteness scope is global.
If the layer is in live session.
If the edit mode is 'NORMAL'.
Root layer item.
The session layer item
If the edit mode is 'SPECS_LINKING'.
UsdContext corresponding to this model.
- __init__(usd_context, layer_settings=None)#
Initialize.
- Parameters:
usd_context (omni.usd.UsdContext) – The USD context for the layers.
layer_settings (LayerSettings) – The layer settings.
- add_dirtiness_listener(fn: Callable[[], None])#
Add a dirtiness listener.
- Parameters:
fn (Callable[[], None]) – The function to be added as a dirtiness listener.
- add_layer_muteness_scope_listener(
- fn: Callable[[], None],
Add a muteness scope listener.
- Parameters:
fn (Callable[[], None]) – The function to be added as a muteness scope listener.
- add_stage_attach_listener(
- fn: Callable[[bool], None],
Add a stage attachment listener.
- Parameters:
fn (Callable[[bool], None]) – The function to be added as a stage attachment listener.
- can_item_have_children(item)#
Check if an item can have children.
- Parameters:
item (omni.ui.AbstractItem) – The item to check.
- destroy()#
Destroys the LayerModel instance.
- drop(target_item, source, drop_location=-1)#
Reimplemented from AbstractItemModel. Called when dropping something to the item.
- Parameters:
target_item( – obj:’LayerItem’): The target item to drop onto.
source( – obj:’LayerItem’): The source item being dragged.
drop_location (int) – The location to drop the item (default: -1).
- drop_accepted(target_item, source, drop_location=-1)#
Reimplemented from AbstractItemModel. Called to highlight target when drag and drop. Returns whether the drop is accepted.
- Parameters:
target_item( – obj:’LayerItem’): The target item to drop onto.
source( – obj:’LayerItem’): The source item being dragged.
drop_location (int) – The location to drop the item (default: -1).
- Returns:
True if the drop is accepted, False otherwise.
- Return type:
bool
- filter_by_text(filter_name_text)#
Specify the filter string that is used to reduce the model.
- Parameters:
filter_name_text (str) – String used to filter layer’s name text.
- find_all_specs(paths: List[Path])#
Return the list of all the parent nodes and the node representing the given path.
- Parameters:
paths (List[Sdf.Path]) – Paths to find specs.
- Returns:
Tuble(LayerItem, List[PrimSpecItem])
- flatten_all_layers()#
Flatten all layers if there is not layer locked.
- get_all_dirty_layer_identifiers(
- include_omni_layers=True,
- include_local_layers=True,
Returns a list of all dirty layer identifiers.
- Parameters:
include_omni_layers (bool) – Whether to include Omni layers (default: True).
include_local_layers (bool) – Whether to include local layers (default: True).
- Returns:
List[str]
- get_drag_mime_data(item)#
Returns Multipurpose Internet Mail Extensions (MIME) data for be able to drop this item somewhere.
- Parameters:
item( – obj:’omni.ui.AbstractItem’): The target item to drop.
- Returns:
str
- get_item_children(item)#
Get the children of an item, reimplemented from AbstractItemModel.
- Parameters:
item (omni.ui.AbstractItem) – The item whose children are to be retrieved.
- Returns:
A list containing the children of the item.
- Return type:
List
- get_item_value_model(item, column_id)#
Reimplemented from AbstractItemModel. Returns the value model for the given item and column ID.
- Parameters:
item( – obj:’LayerItem’): The item to get the value model for.
column_id (int) – The column ID to get the value model for.
- Returns:
omni.ui.AbstractValueModel
- get_item_value_model_count(item)#
Reimplemented from AbstractItemModel, returns the number of value models for the given item.
- Parameters:
item – The item to get the value model count for.
- Returns:
The number of value models (7).
- Return type:
int
- get_layer_item_by_identifier(layer_identifier)#
Find the first layer item that has the identifier
- Parameters:
layer_identifier (str) – The identifier of the layer item to find.
- Returns:
obj:’LayerItem’: The first layer item with the given identifier, or None if not found.
- has_any_layers_locked()#
Checks if any layers are locked.
- Returns:
True if any layers are locked, False otherwise.
- Return type:
bool
- has_dirty_layers(
- include_omni_layers=True,
- include_local_layers=True,
Checks if there are any dirty layers in the current stage.
- Parameters:
include_omni_layers (bool, optional) – Whether to include omni layers. Defaults to True.
include_local_layers (bool, optional) – Whether to include local layers. Defaults to True.
- Returns:
True if there are any dirty layers, False otherwise.
- Return type:
bool
- has_outdated_layers()#
Checks if there are any outdated layers in the sublayers cache.
- Returns:
True if there are any outdated layers, False otherwise.
- Return type:
bool
- refresh()#
Force full re-update
- save_layers(
- layer_identifiers,
- on_save_done: Callable[[bool, str, List[str]], None] = None,
Saves multiple layers asynchronously and executes a callback on completion.
- Parameters:
layer_identifiers (List[str]) – A list of identifiers for the layers to be saved.
on_save_done (Callable[[bool, str, List[str]], None], optional) – A callback function to be called upon completion of the save operation. The function singature is: on_save_done(bool, str, List[str]).
- set_edit_target(
- layer_item: LayerItem,
- saved=False,
Sets the edit target with the given layer item’s identifier.
- Parameters:
( (layer_item) – obj:’LayerItem’): The LayerItem to set as the edit target.
saved (bool) – Whether the edit target has been saved (default: False).
- property auto_authoring_mode#
If the edit mode is ‘AUTO_AUTHORING’.
- Returns:
True if the edit mode is ‘AUTO_AUTHORING’, False otherwise.
- Return type:
bool
- property default_edit_layer#
The default edit layer. (Only useful when edit mode is AUTO_AUTHORING or SPECS_LINKING).
- Returns:
The default edit layer.
- Return type:
str
- property global_muteness_scope#
If the layers’ muteness scope is global.
- Returns:
True if the layers’ muteness scope is global, False otherwise.
- Return type:
bool
- property is_in_live_session#
If the layer is in live session.
- Returns:
True if the stage is in live session, False otherwise.
- Return type:
bool
- property normal_mode#
If the edit mode is ‘NORMAL’.
- Returns:
True if the edit mode is ‘NORMAL’, False otherwise.
- Return type:
bool
- property root_layer_item#
Root layer item.
- Returns:
obj:’LayerItem’.
- property session_layer_item#
The session layer item
- Returns:
obj:’LayerItem’.
- property spec_linking_mode#
If the edit mode is ‘SPECS_LINKING’.
- Returns:
True if the edit mode is ‘SPECS_LINKING’, False otherwise.
- Return type:
bool
- property usd_context#
UsdContext corresponding to this model.
- Returns:
obj:’omni.usd.UsdContext’.