Skip to content

Commit ecf2745

Browse files
author
Shona Gillard
committed
Merge branch 'dev/sgillard/visibility_filter_sm' into 'main'
REMIX-4552: Adding visibility filter for stage manager See merge request lightspeedrtx/lightspeed-kit!1066
2 parents 510df0d + 49e1264 commit ecf2745

File tree

17 files changed

+110
-6
lines changed

17 files changed

+110
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- REMIX-4813: Added Logic Graph sidebar button for quick layout switching with dedicated Logic Graph layout
3333
- REMIX-4807: Added Escape key support to close Stage Prim Picker dropdown
3434
- REMIX-4793: Added a function to check if tree items need to be expanded in the Stage Manager
35+
- REMIX-4552: Added Visibility Filter to the Stage Manager
3536

3637
### Changed
3738
- Update hdremix and omni_core_materials to ext-822f7b6-main

source/extensions/lightspeed.trex.stage_manager.plugin.interaction.usd/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
# Semantic Versionning is used: https://semver.org/
3-
version = "2.3.0"
3+
version = "2.4.0"
44

55
# Lists people or organizations that are considered the "authors" of the package.
66
authors = ["Shona Gillard <[email protected]>", "Scott Fitzpatrick <[email protected]"]

source/extensions/lightspeed.trex.stage_manager.plugin.interaction.usd/docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

4+
## [2.4.0]
5+
### Added
6+
- Added `VisiblePrimsFilterPlugin` to the interactions plugins
7+
48
## [2.3.0]
59
### Added
610
- Added `DeleteRestoreActionWidgetPlugin`

source/extensions/lightspeed.trex.stage_manager.plugin.interaction.usd/lightspeed/trex/stage_manager/plugin/interaction/usd/all_categories.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AllCategoriesInteractionPlugin(_StageManagerUSDInteractionPlugin):
3636
"IgnorePrimsFilterPlugin",
3737
"IsCaptureFilterPlugin",
3838
"IsCategoryFilterPlugin",
39+
"VisiblePrimsFilterPlugin",
3940
"LightPrimsFilterPlugin",
4041
"MeshPrimsFilterPlugin",
4142
"OmniPrimsFilterPlugin",

source/extensions/lightspeed.trex.stage_manager.plugin.interaction.usd/lightspeed/trex/stage_manager/plugin/interaction/usd/all_meshes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class AllMeshesInteractionPlugin(_StageManagerUSDInteractionPlugin):
4040
"IgnorePrimsFilterPlugin",
4141
"IsCaptureFilterPlugin",
4242
"IsCategoryFilterPlugin",
43+
"VisiblePrimsFilterPlugin",
4344
"LightPrimsFilterPlugin",
4445
"MeshPrimsFilterPlugin",
4546
"OmniPrimsFilterPlugin",

source/extensions/omni.flux.stage_manager.plugin.filter.usd/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
# Semantic Versionning is used: https://semver.org/
3-
version = "2.4.1"
3+
version = "2.5.0"
44

55
# Lists people or organizations that are considered the "authors" of the package.
66
authors = ["Pierre-Olivier Trottier <[email protected]>"]

source/extensions/omni.flux.stage_manager.plugin.filter.usd/docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

4+
## [2.5.0]
5+
### Added
6+
- Added `VisiblePrimsFilterPlugin`
7+
48
## [2.4.1]
59
### Changed
610
- Changed default value for SearchFilterPlugin

source/extensions/omni.flux.stage_manager.plugin.filter.usd/omni/flux/stage_manager/plugin/filter/usd/additional_filters.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def build_item(self):
6060

6161
with self._container:
6262
ui.Spacer(width=0)
63-
self.filter_obj.build_ui()
63+
with ui.VStack(width=0, spacing=ui.Pixel(4)):
64+
self.filter_obj.build_ui()
65+
if not isinstance(self.filter_obj, _ToggleableUSDFilterPlugin):
66+
ui.Spacer(width=0)
6467
ui.Spacer(width=0)
6568

6669
def destroy(self):
@@ -75,8 +78,10 @@ def __init__(self, title, filters: list[_StageManagerUSDFilterPlugin], on_filter
7578
self.filters = filters
7679

7780
def build_menu_items(self):
78-
for item in self._delegate.items:
79-
item.build_item()
81+
with ui.VStack(width=0, spacing=ui.Pixel(4)):
82+
ui.Spacer(width=0)
83+
for item in self._delegate.items:
84+
item.build_item()
8085

8186

8287
class AdditionalFiltersPopupMenuDelegate(PopupMenuDelegate):

source/extensions/omni.flux.stage_manager.plugin.filter.usd/omni/flux/stage_manager/plugin/filter/usd/extension.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .omni_prims import OmniPrimsFilterPlugin as _OmniPrimsFilterPlugin
2828
from .search import SearchFilterPlugin as _SearchFilterPlugin
2929
from .skeleton_prims import SkeletonPrimsFilterPlugin as _SkeletonPrimsFilterPlugin
30+
from .visible_prims import VisiblePrimsFilterPlugin as _VisiblePrimsFilterPlugin
3031

3132

3233
class StageManagerUSDFilterPluginsExtension(omni.ext.IExt):
@@ -39,6 +40,7 @@ class StageManagerUSDFilterPluginsExtension(omni.ext.IExt):
3940
_OmniPrimsFilterPlugin,
4041
_SearchFilterPlugin,
4142
_SkeletonPrimsFilterPlugin,
43+
_VisiblePrimsFilterPlugin,
4244
]
4345

4446
def on_startup(self, _):
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
"""
17+
18+
from typing import TYPE_CHECKING
19+
20+
from omni import ui
21+
from omni.flux.stage_manager.factory import StageManagerItem as _StageManagerItem
22+
from omni.flux.stage_manager.plugin.filter.usd.base import StageManagerUSDFilterPlugin as _StageManagerUSDFilterPlugin
23+
from pxr import Usd, UsdGeom
24+
from pydantic import Field, PrivateAttr
25+
26+
if TYPE_CHECKING:
27+
from omni.flux.stage_manager.factory.plugins.tree_plugin import StageManagerTreeItem as _StageManagerTreeItem
28+
from omni.flux.stage_manager.factory.plugins.tree_plugin import StageManagerTreeModel as _StageManagerTreeModel
29+
30+
31+
class VisiblePrimsFilterPlugin(_StageManagerUSDFilterPlugin):
32+
display_name: str = Field(default="Visibility Filter", exclude=True)
33+
tooltip: str = Field(default="Filter prims by their visibility status.", exclude=True)
34+
35+
visible_prims_type: str = Field(default="All Prims", description="Filter prims by their visibility status.")
36+
37+
_VISIBLE_PRIMS_DISPLAY_LABELS: dict = PrivateAttr(
38+
default={"All": "All Prims", "Visible": "Visible Prims", "Hidden": "Hidden Prims"}
39+
)
40+
_COMBO_BOX_WIDTH: int = PrivateAttr(default=130)
41+
_visible_prims_combobox: ui.ComboBox | None = PrivateAttr(default=None)
42+
_current_index: int | None = PrivateAttr(default=None)
43+
_current_attr: str | None = PrivateAttr(default=None)
44+
45+
def filter_predicate(self, item: _StageManagerItem) -> bool:
46+
if self.visible_prims_type == "All Prims":
47+
return True
48+
49+
imageable = UsdGeom.Imageable(item.data)
50+
if not imageable:
51+
return False
52+
53+
is_visible = imageable.ComputeVisibility(Usd.TimeCode.Default()) != UsdGeom.Tokens.invisible
54+
if self.visible_prims_type == "Visible Prims":
55+
return bool(is_visible)
56+
if self.visible_prims_type == "Hidden Prims":
57+
return bool(not is_visible)
58+
return True
59+
60+
def build_ui(self):
61+
with ui.HStack(spacing=ui.Pixel(8)):
62+
ui.Spacer(width=0)
63+
ui.Label(self.display_name, width=ui.Pixel(self._LABEL_WIDTH), alignment=ui.Alignment.RIGHT)
64+
self._visible_prims_combobox = ui.ComboBox(
65+
self._current_index or 0,
66+
*self._VISIBLE_PRIMS_DISPLAY_LABELS.values(),
67+
width=ui.Pixel(self._COMBO_BOX_WIDTH),
68+
)
69+
self._visible_prims_combobox.model.add_item_changed_fn(self._on_visible_prims_type_changed)
70+
71+
def _on_visible_prims_type_changed(self, model: "_StageManagerTreeModel", item: "_StageManagerTreeItem"):
72+
selected_index = model.get_item_value_model().get_value_as_int()
73+
self.visible_prims_type = list(self._VISIBLE_PRIMS_DISPLAY_LABELS.values())[selected_index]
74+
self._current_index = selected_index
75+
self._current_attr = list(self._VISIBLE_PRIMS_DISPLAY_LABELS.keys())[selected_index]
76+
77+
self._filter_items_changed()

0 commit comments

Comments
 (0)