file_path
stringlengths
32
153
content
stringlengths
0
3.14M
omniverse-code/kit/exts/omni.kit.window.file_exporter/omni/kit/window/file_exporter/tests/__init__.py
## Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## from .test_extension import *
omniverse-code/kit/exts/omni.kit.window.file_exporter/omni/kit/window/file_exporter/tests/test_extension.py
## Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## import os import omni.kit.test import omni.kit.ui_test as ui_test import asyncio import omni.appwindow from unittest.mock import Mock, patch, ANY from carb.settings import ISettings from omni.kit.window.filepicker import FilePickerDialog from omni.kit.test_suite.helpers import get_test_data_path from .. import get_file_exporter from ..test_helper import FileExporterTestHelper from ..extension import on_export, file_filter_handler, DEFAULT_FILE_POSTFIX_OPTIONS class TestFileExporter(omni.kit.test.AsyncTestCase): """ Testing omni.kit.window.file_exporter extension. NOTE that since the dialog is a singleton, we use an async lock to ensure that only one test runs at a time. In practice, this is not a issue because only one extension is accessing the dialog at any given time. """ __lock = asyncio.Lock() async def setUp(self): self._settings_path = "my_settings" self._test_settings = { "/exts/omni.kit.window.file_exporter/appSettings": self._settings_path, f"{self._settings_path}/directory": "C:/temp/folder", f"{self._settings_path}/filename": "my-file", } async def tearDown(self): pass def _mock_settings_get_string_impl(self, name: str) -> str: return self._test_settings.get(name) def _mock_settings_set_string_impl(self, name: str, value: str): self._test_settings[name] = value async def test_show_window_destroys_previous(self): """Testing show_window destroys previously allocated dialog""" async with self.__lock: under_test = get_file_exporter() with patch.object(FilePickerDialog, "destroy", autospec=True) as mock_destroy_dialog,\ patch("carb.windowing.IWindowing.hide_window"): under_test.show_window(title="first") under_test.show_window(title="second") mock_destroy_dialog.assert_called() dialog = mock_destroy_dialog.call_args[0][0] self.assertEqual(str(dialog._window), "first") async def test_hide_window_destroys_it(self): """Testing that hiding the window destroys it""" async with self.__lock: under_test = get_file_exporter() with patch.object(FilePickerDialog, "destroy", autospec=True) as mock_destroy_dialog: under_test.show_window(title="test") under_test._dialog.hide() # Dialog is destroyed after a couple frames await omni.kit.app.get_app().next_update_async() await omni.kit.app.get_app().next_update_async() mock_destroy_dialog.assert_called() dialog = mock_destroy_dialog.call_args[0][0] self.assertEqual(str(dialog._window), "test") async def test_hide_window_destroys_detached_window(self): """Testing that hiding the window destroys detached window.""" async with self.__lock: under_test = get_file_exporter() with patch.object(FilePickerDialog, "destroy", autospec=True) as mock_destroy_dialog: under_test.show_window(title="test_detached") await omni.kit.app.get_app().next_update_async() under_test.detach_from_main_window() main_window = omni.appwindow.get_default_app_window().get_window() self.assertFalse(main_window is under_test._dialog._window.app_window.get_window()) under_test.hide_window() # Dialog is destroyed after a couple frames await omni.kit.app.get_app().next_update_async() await omni.kit.app.get_app().next_update_async() mock_destroy_dialog.assert_called() dialog = mock_destroy_dialog.call_args[0][0] self.assertEqual(str(dialog._window), "test_detached") async def test_load_default_settings(self): """Testing that dialog applies saved settings""" async with self.__lock: under_test = get_file_exporter() with patch('omni.kit.window.file_exporter.extension.FilePickerDialog') as mock_dialog,\ patch.object(ISettings, "get_as_string", side_effect=self._mock_settings_get_string_impl): under_test.show_window(title="test_dialog") # Retrieve keyword args for the constructor (first call), and confirm called with expected values constructor_kwargs = mock_dialog.call_args_list[0][1] self.assertEqual(constructor_kwargs['current_directory'], self._test_settings[f"{self._settings_path}/directory"]) self.assertEqual(constructor_kwargs['current_filename'], "") async def test_override_default_settings(self): """Testing that user values override default settings""" async with self.__lock: test_url = "Omniverse://ov-test/my-folder/my-file.usd" under_test = get_file_exporter() with patch('omni.kit.window.file_exporter.extension.FilePickerDialog') as mock_dialog,\ patch.object(ISettings, "get_as_string", side_effect=self._mock_settings_get_string_impl),\ patch("carb.windowing.IWindowing.hide_window"): under_test.show_window(title="test_dialog", filename_url=test_url) # Retrieve keyword args for the constructor (first call), and confirm called with expected values constructor_kwargs = mock_dialog.call_args_list[0][1] dirname, filename = os.path.split(test_url) self.assertEqual(constructor_kwargs['current_directory'], dirname) self.assertEqual(constructor_kwargs['current_filename'], filename) async def test_save_settings_on_export(self): """Testing that settings are saved on export""" my_settings = { 'filename': "my-file", 'directory': "Omniverse://ov-test/my-folder", } mock_dialog = Mock() with patch.object(ISettings, "get_as_string", side_effect=self._mock_settings_get_string_impl),\ patch.object(ISettings, "set_string", side_effect=self._mock_settings_set_string_impl): on_export(None, mock_dialog, my_settings['filename'], my_settings['directory']) # Retrieve keyword args for the constructor (first call), and confirm called with expected values self.assertEqual(my_settings['filename'], self._test_settings[f"{self._settings_path}/filename"]) self.assertEqual(my_settings['directory'], self._test_settings[f"{self._settings_path}/directory"]) async def test_show_only_folders(self): """Testing show only folders option.""" mock_handler = Mock() async with self.__lock: under_test = get_file_exporter() test_path = get_test_data_path(__name__).replace("\\", '/') async with FileExporterTestHelper() as helper: with patch("carb.windowing.IWindowing.hide_window"): # under normal circumstance, files will be shown and could be selected. # under_test.show_window(title="test", filename_url=test_path) under_test.show_window(title="test", filename_url=test_path + "/") await ui_test.human_delay(10) item = await helper.get_item_async(None, "dummy.usd") self.assertIsNotNone(item) # apply button should be disabled self.assertFalse(under_test._dialog._widget.file_bar._apply_button.enabled) await helper.click_cancel_async() # if shown with show_only_folders, files will not be shown under_test.show_window(title="test", show_only_folders=True, export_handler=mock_handler) await ui_test.human_delay(10) item = await helper.get_item_async(None, "dummy.usd") self.assertIsNone(item) # try selecting a folder selections = await under_test.select_items_async(test_path, filenames=['folder']) self.assertEqual(len(selections), 1) selected = selections[0] # apply button should not be disabled self.assertTrue(under_test._dialog._widget.file_bar._apply_button.enabled) await ui_test.human_delay() await helper.click_apply_async() mock_handler.assert_called_once_with('', selected.path + "/", extension=".usd", selections=[selected.path]) async def test_cancel_handler(self): """Testing cancel handler.""" mock_handler = Mock() async with self.__lock: under_test = get_file_exporter() test_path = get_test_data_path(__name__).replace("\\", '/') async with FileExporterTestHelper() as helper: under_test.show_window("test_cancel_handler", filename_url=test_path + "/") await helper.wait_for_popup() await ui_test.human_delay(10) await helper.click_cancel_async(cancel_handler=mock_handler) await ui_test.human_delay(10) mock_handler.assert_called_once() class TestFileFilterHandler(omni.kit.test.AsyncTestCase): """Testing default_file_filter_handler correctly shows/hides files.""" async def setUp(self): ext_type = { 'usd': "*.usd", 'usda': "*.usda", 'usdc': "*.usdc", 'usdz': "*.usdz", } self.test_filenames = [ ("test.anim.usd", "anim", ext_type['usd'], True), ("test.anim.usdz", "anim", ext_type['usdz'], True), ("test.anim.usdc", "anim", ext_type['usdz'], False), ("test.anim.usda", None, ext_type['usda'], True), ("test.material.", None, ext_type['usda'], False), ("test.materials.usd", "material", ext_type['usd'], False), ] async def tearDown(self): pass async def test_file_filter_handler(self): """Testing file filter handler""" for test_filename in self.test_filenames: filename, postfix, ext, expected = test_filename result = file_filter_handler(filename, postfix, ext) self.assertEqual(result, expected) class TestOnExport(omni.kit.test.AsyncTestCase): """Testing on_export function correctly parses filename parts from dialog.""" async def setUp(self): self.test_sets = [ ("test", "anim", "*.usdc", "test", ".anim.usdc"), ("test.usd", "anim", "*.usdc", "test", ".anim.usdc"), ("test.cache.usdc", "geo", "*.usdz", "test", ".geo.usdz"), ("test.cache.any", "geo", "*.usd", "test.cache.any", ".geo.usd"), ("test.geo.usd", None, "*.usda", "test", ".usda"), ("test.png", "anim", "*.jpg", "test", ".anim.jpg"), ] async def tearDown(self): pass async def test_on_export(self): """Testing file filter handler""" mock_callback = Mock() mock_dialog = Mock() mock_extension_options = [ ('*.usd', 'Can be Binary or Ascii'), ('*.usda', 'Human-readable text format'), ('*.usdc', 'Binary format'), ('*.png', 'test'), ('*.jpg', 'another test') ] for test_set in self.test_sets: filename = test_set[0] mock_dialog.get_file_postfix.return_value = test_set[1] mock_dialog.get_file_extension.return_value = test_set[2] mock_dialog.get_file_postfix_options.return_value = DEFAULT_FILE_POSTFIX_OPTIONS mock_dialog.get_file_extension_options.return_value = mock_extension_options mock_dialog.get_current_selections.return_value = [] on_export(mock_callback, mock_dialog, filename, "C:/temp/test/") expected_basename = test_set[3] expected_extension = test_set[4] mock_callback.assert_called_with(expected_basename, "C:/temp/test/", extension=expected_extension, selections=ANY) async def test_export_filename_validation(self): """Test export with and without validation.""" mock_callback = Mock() mock_dialog = Mock() mock_dialog.get_file_postfix.return_value = None mock_dialog.get_file_extension.return_value = ".usd" mock_dialog.get_file_extension_options.return_value = [('*.usd', 'Can be Binary or Ascii')] on_export(mock_callback, mock_dialog, "", "", should_validate=True) mock_callback.assert_not_called() on_export(mock_callback, mock_dialog, "", "C:/temp/test/", should_validate=False) mock_callback.assert_called_once()
omniverse-code/kit/exts/omni.kit.window.file_exporter/docs/CHANGELOG.md
# Changelog The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [1.0.10] - 2022-11-14 ### Changed - Updated the docs. ## [1.0.9] - 2022-10-21 ### Changed - Add flag for show_window if file name input should be enabled. ## [1.0.8] - 2022-10-01 ### Changed - Add flag for if file name validation should be performed. ## [1.0.7] - 2022-09-19 ### Added - Added file name validation for file exports, do not allow empty filenames when exporting. ## [1.0.6] - 2022-07-07 ### Added - Added test helper function that waits for UI to be ready. ## [1.0.5] - 2022-06-15 ### Added - Adds test helper. ## [1.0.4] - 2022-04-06 ### Added - Disable unittests from loading at startup. ## [1.0.3] - 2022-03-17 ### Added - Disabled checkpoints. ## [1.0.2] - 2022-02-09 ### Added - Adds click_apply and click_cancel methods. ## [1.0.1] - 2022-02-02 ### Added - Adds postfix and extension options. ## [1.0.0] - 2021-11-05 ### Added - Initial add.
omniverse-code/kit/exts/omni.kit.window.file_exporter/docs/README.md
# Kit File Exporter Extension [omni.kit.window.file_exporter] The File Exporter extension
omniverse-code/kit/exts/omni.kit.window.file_exporter/docs/index.rst
omni.kit.window.file_exporter ############################# .. toctree:: :maxdepth: 1 CHANGELOG .. automodule:: omni.kit.window.file_exporter :platform: Windows-x86_64, Linux-x86_64 :members: :show-inheritance: :undoc-members: :imported-members:
omniverse-code/kit/exts/omni.kit.window.file_exporter/docs/Overview.md
# Overview The file_exporter extension provides a standardized dialog for exporting files. It is a wrapper around the {obj}`FilePickerDialog`, but with reasonable defaults for common settings, so it's a higher-level entry point to that interface. Nevertheless, users will still have the ability to customize some parts but we've boiled them down to just the essential ones. Why you should use this extension: * Present a consistent file export experience across the app. * Customize only the essential parts while inheriting sensible defaults elsewhere. * Reduce boilerplate code. * Inherit future improvements. * Checkpoints fully supported if available on the server. ```{image} ../../../../source/extensions/omni.kit.window.file_exporter/data/preview.png --- align: center --- ``` ## Quickstart You can pop-up a dialog in just 2 steps. First, retrieve the extension. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/scripts/demo_file_exporter.py --- language: python start-after: BEGIN-DOC-get_instance end-before: END-DOC-get_instance dedent: 8 --- ``` Then, invoke its show_window method. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/scripts/demo_file_exporter.py --- language: python start-after: BEGIN-DOC-show_window end-before: END-DOC-show_window dedent: 8 --- ``` Note that the extension is a singleton, meaning there's only one instance of it throughout the app. Basically, we are assuming that you'd never open more than one instance of the dialog at any one time. The advantage is that we can channel any development through this single extension and all users will inherit the same changes. ## Customizing the Dialog You can customize these parts of the dialog. * Title - The title of the dialog. * Collections - Which of these collections, ["bookmarks", "omniverse", "my-computer"] to display. * Filename Url - Url to open the dialog with. * Postfix options - List of content labels appended to the filename. * Extension options - List of filename extensions. * Export options - Options to apply during the export process. * Export label - Label for the export button. * Export handler - User provided callback to handle the export process. Note that these settings are applied when you show the window. Therefore, each time it's displayed, the dialog can be tailored to the use case. ## Filename postfix options Users might want to set up data libraries of just animations, materials, etc. However, one challenge of working in Omniverse is that everything is a USD file. To facilitate this workflow, we suggest adding a postfix to the filename, e.g. "file.animation.usd". The file bar contains a dropdown that lists the postfix labels. A default list is provided but you can also provide your own. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/omni/kit/window/file_exporter/extension.py --- language: python start-after: BEGIN-DOC-file_postfix_options end-before: END-DOC-file_postfix_options dedent: 0 --- ``` A list of file extensions, furthermore, allows the user to specify what flavor of USD to export. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/omni/kit/window/file_exporter/extension.py --- language: python start-after: BEGIN-DOC-file_extension_types end-before: END-DOC-file_extension_types dedent: 0 --- ``` When the user selects a combination of postfix and extension types, the file view will filter out all other file types, leaving only the matching ones. ## Export options A common need is to provide user options for the export process. You create the widget for accepting those inputs, then add it to the details pane of the dialog. Do this by subclassing from {obj}`ExportOptionsDelegate` and overriding the methods, :meth:`ExportOptionsDelegate._build_ui_impl` and (optionally) :meth:`ExportOptionsDelegate._destroy_impl`. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/scripts/demo_file_exporter.py --- language: python start-after: BEGIN-DOC-export_options end-before: END-DOC-export_options dedent: 0 --- ``` Then provide the controller to the file picker for display. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/scripts/demo_file_exporter.py --- language: python start-after: BEGIN-DOC-add_export_options end-before: END-DOC-add_export_options dedent: 8 --- ``` ## Export handler Pprovide a handler for when the Export button is clicked. In additon to :attr:`filename` and :attr:`dirname`, the handler should expect a list of :attr:`selections` made from the UI. ```{literalinclude} ../../../../source/extensions/omni.kit.window.file_exporter/scripts/demo_file_exporter.py --- language: python start-after: BEGIN-DOC-export_handler end-before: END-DOC-export_handler dedent: 4 --- ``` ## Demo app A complete demo, that includes the code snippets above, is included with this extension at "scripts/demo_file_exporter.py".
omniverse-code/kit/exts/omni.kit.property.bundle/PACKAGE-LICENSES/omni.kit.property.bundle-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.
omniverse-code/kit/exts/omni.kit.property.bundle/config/extension.toml
[package] # Semantic Versioning is used: https://semver.org/ version = "1.2.6" # Lists people or organizations that are considered the "authors" of the package. authors = ["NVIDIA"] # The title and description fields are primarly for displaying extension info in UI title = "Property Widgets Bundle" description="Load all property widgets" feature = true # URL of the extension source repository. repository = "" # Keywords for the extension keywords = ["kit", "usd", "property"] # Preview image. Folder named "data" automatically goes in git lfs (see .gitattributes file). preview_image = "data/preview.png" # Icon is shown in Extensions window, it is recommended to be square, of size 256x256. icon = "data/icon.png" # Location of change log file in target (final) folder of extension, relative to the root. # More info on writing changelog: https://keepachangelog.com/en/1.0.0/ changelog="docs/CHANGELOG.md" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" [dependencies] "omni.usd" = {} "omni.ui" = {} "omni.kit.window.property" = {} "omni.kit.property.camera" = {} "omni.kit.property.light" = {} "omni.kit.property.material" = {} "omni.kit.property.usd" = {} "omni.kit.property.geometry" = {} "omni.kit.property.audio" = {} "omni.kit.property.transform" = {} "omni.kit.property.render" = {} "omni.kit.property.skel" = {} [[python.module]] name = "omni.kit.property.bundle" [[test]] args = [ "--/app/window/dpiScaleOverride=1.0", "--/app/window/scaleToMonitor=false", "--no-window" ] dependencies = [ "omni.kit.renderer.capture", "omni.kit.mainwindow", "omni.kit.ui_test", "omni.kit.test_suite.helpers" ]
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/widgets.py
# Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import carb import omni.usd from pathlib import Path from .geom_scheme_delegate import GeomPrimSchemeDelegate from .path_scheme_delegate import PathPrimSchemeDelegate from .material_scheme_delegate import MaterialPrimSchemeDelegate, ShaderPrimSchemeDelegate TEST_DATA_PATH = "" class BundlePropertyWidgets(omni.ext.IExt): def __init__(self): self._registered = False super().__init__() def on_startup(self, ext_id): self._register_widget() manager = omni.kit.app.get_app().get_extension_manager() extension_path = manager.get_extension_path(ext_id) global TEST_DATA_PATH TEST_DATA_PATH = Path(extension_path).joinpath("data").joinpath("tests") def on_shutdown(self): self._unregister_widget() def _register_widget(self): import omni.kit.window.property as p w = p.get_window() w.register_scheme_delegate("prim", "xformable_prim", GeomPrimSchemeDelegate()) w.register_scheme_delegate("prim", "path_prim", PathPrimSchemeDelegate()) w.register_scheme_delegate("prim", "material_prim", MaterialPrimSchemeDelegate()) w.register_scheme_delegate("prim", "shade_prim", ShaderPrimSchemeDelegate()) physics_widgets = [ "physics_components", "physics_prim", "joint_prim", "vehicle_prim", "physics_material", "custom_properties", ] anim_graph_widgets = ["anim_graph", "anim_graph_node"] w.set_scheme_delegate_layout( "prim", [ "path_prim", "basis_curves_prim", "point_instancer_prim", "material_prim", "xformable_prim", "shade_prim", "audio_settings", ] + physics_widgets + anim_graph_widgets, ) def _unregister_widget(self): import omni.kit.window.property as p w = p.get_window() w.reset_scheme_delegate_layout("prim") w.unregister_scheme_delegate("prim", "xformable_prim") w.unregister_scheme_delegate("prim", "path_prim") w.unregister_scheme_delegate("prim", "material_prim") w.unregister_scheme_delegate("prim", "shade_prim")
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/__init__.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .widgets import *
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/material_scheme_delegate.py
import carb import omni.usd from pxr import Sdf, UsdShade from omni.kit.window.property.property_scheme_delegate import PropertySchemeDelegate class MaterialPrimSchemeDelegate(PropertySchemeDelegate): def get_widgets(self, payload): widgets_to_build = [] if self._should_enable_delegate(payload): widgets_to_build.append("path") widgets_to_build.append("material") return widgets_to_build def get_unwanted_widgets(self, payload): unwanted_widgets_to_build = [] if self._should_enable_delegate(payload): unwanted_widgets_to_build.append("transform") return unwanted_widgets_to_build def _should_enable_delegate(self, payload): stage = payload.get_stage() if stage: for prim_path in payload: prim = stage.GetPrimAtPath(prim_path) if prim: if not prim.IsA(UsdShade.Material): return False return True return False class ShaderPrimSchemeDelegate(PropertySchemeDelegate): def get_widgets(self, payload): widgets_to_build = [] if self._should_enable_delegate(payload): widgets_to_build.append("path") widgets_to_build.append("shader") return widgets_to_build def get_unwanted_widgets(self, payload): unwanted_widgets_to_build = [] if self._should_enable_delegate(payload): unwanted_widgets_to_build.append("transform") return unwanted_widgets_to_build def _should_enable_delegate(self, payload): stage = payload.get_stage() if stage: for prim_path in payload: prim = stage.GetPrimAtPath(prim_path) if prim: if not prim.IsA(UsdShade.Shader): return False return True return False
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/path_scheme_delegate.py
import carb import omni.usd from pxr import Sdf, UsdGeom from omni.kit.window.property.property_scheme_delegate import PropertySchemeDelegate class PathPrimSchemeDelegate(PropertySchemeDelegate): def get_widgets(self, payload): widgets_to_build = [] if len(payload): widgets_to_build.append("path") return widgets_to_build
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/geom_scheme_delegate.py
import carb import omni.usd from pxr import Sdf, UsdMedia, OmniAudioSchema, UsdGeom, UsdLux, UsdSkel from omni.kit.window.property.property_scheme_delegate import PropertySchemeDelegate class GeomPrimSchemeDelegate(PropertySchemeDelegate): def get_widgets(self, payload): widgets_to_build = [] anchor_prim = None stage = payload.get_stage() if stage: for prim_path in payload: prim = stage.GetPrimAtPath(prim_path) if prim: if not prim.IsA(UsdGeom.Imageable): return widgets_to_build anchor_prim = prim if anchor_prim is None: return widgets_to_build if ( anchor_prim and anchor_prim.IsA(UsdMedia.SpatialAudio) or anchor_prim.IsA(OmniAudioSchema.OmniSound) or anchor_prim.IsA(OmniAudioSchema.OmniListener) ): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("media") widgets_to_build.append("audio_sound") widgets_to_build.append("audio_listener") widgets_to_build.append("audio_settings") widgets_to_build.append("kind") elif anchor_prim and anchor_prim.IsA(UsdSkel.Root): # pragma: no cover widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("character_api") widgets_to_build.append("anim_graph_api") widgets_to_build.append("omni_graph_api") widgets_to_build.append("kind") elif anchor_prim.IsA(UsdSkel.Skeleton): # pragma: no cover widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("control_rig") widgets_to_build.append("skel_animation") elif anchor_prim and anchor_prim.IsA(UsdGeom.Camera): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("camera") widgets_to_build.append("geometry_imageable") widgets_to_build.append("kind") # https://github.com/PixarAnimationStudios/USD/commit/7540fdf3b2aa6b6faa0fce8e7b4c72b756286f51 elif anchor_prim and ((hasattr(UsdLux, 'LightAPI') and anchor_prim.HasAPI(UsdLux.LightAPI)) or ((hasattr(UsdLux, 'Light') and anchor_prim.IsA(UsdLux.Light)))): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("light") widgets_to_build.append("geometry_imageable") widgets_to_build.append("kind") elif anchor_prim and anchor_prim.IsA(UsdGeom.Scope): widgets_to_build.append("path") widgets_to_build.append("geometry_imageable") widgets_to_build.append("character_motion_library") widgets_to_build.append("kind") elif anchor_prim and anchor_prim.IsA(UsdGeom.Mesh): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("material_binding") widgets_to_build.append("geometry") widgets_to_build.append("geometry_imageable") widgets_to_build.append("character_interactive_object_api") widgets_to_build.append("mesh_skel_binding") widgets_to_build.append("kind") elif anchor_prim and anchor_prim.IsA(UsdGeom.Xform): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("material_binding") widgets_to_build.append("geometry_imageable") widgets_to_build.append("kind") elif anchor_prim and anchor_prim.IsA(UsdGeom.Xformable): widgets_to_build.append("path") widgets_to_build.append("transform") widgets_to_build.append("material_binding") widgets_to_build.append("geometry") widgets_to_build.append("geometry_imageable") widgets_to_build.append("character_interactive_object_api") widgets_to_build.append("kind") return widgets_to_build def get_unwanted_widgets(self, payload): unwanted_widgets_to_build = [] anchor_prim = None stage = payload.get_stage() if stage: for prim_path in payload: prim = stage.GetPrimAtPath(prim_path) if prim: if not prim.IsA(UsdGeom.Imageable): return unwanted_widgets_to_build anchor_prim = prim if anchor_prim is None: return unwanted_widgets_to_build if anchor_prim and anchor_prim.IsA(UsdGeom.Scope): unwanted_widgets_to_build.append("transform") unwanted_widgets_to_build.append("geometry") unwanted_widgets_to_build.append("kind") # https://github.com/PixarAnimationStudios/USD/commit/7540fdf3b2aa6b6faa0fce8e7b4c72b756286f51 elif anchor_prim and ((hasattr(UsdLux, 'LightAPI') and anchor_prim.HasAPI(UsdLux.LightAPI)) or ((hasattr(UsdLux, 'Light') and anchor_prim.IsA(UsdLux.Light)))): unwanted_widgets_to_build.append("geometry") elif ( anchor_prim and anchor_prim.IsA(UsdMedia.SpatialAudio) or anchor_prim.IsA(OmniAudioSchema.Sound) or anchor_prim.IsA(OmniAudioSchema.Listener) ): unwanted_widgets_to_build.append("geometry_imageable") elif anchor_prim and anchor_prim.IsA(UsdSkel.Skeleton) or anchor_prim.IsA(UsdSkel.Root): unwanted_widgets_to_build.append("geometry") unwanted_widgets_to_build.append("geometry_imageable") return unwanted_widgets_to_build
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/tests/__init__.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .test_bundle import *
omniverse-code/kit/exts/omni.kit.property.bundle/omni/kit/property/bundle/tests/test_bundle.py
## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## import platform import omni.kit.commands import omni.kit.test import omni.ui as ui from omni.ui.tests.test_base import OmniUiTest from omni.kit import ui_test from omni.kit.test_suite.helpers import arrange_windows, wait_stage_loading, get_prims from pxr import Kind, Sdf, Gf import pathlib class TestBundleWidget(OmniUiTest): # Before running each test async def setUp(self): await super().setUp() await arrange_windows() from omni.kit.property.bundle.widgets import TEST_DATA_PATH self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute() self._usd_path = TEST_DATA_PATH.absolute() from omni.kit.property.usd.usd_attribute_widget import UsdPropertiesWidget import omni.kit.window.property as p self._w = p.get_window() # After running each test async def tearDown(self): await super().tearDown() # Test(s) async def test_bundle_ui(self): usd_context = omni.usd.get_context() test_file_path = self._usd_path.joinpath("bundle.usda").absolute() await usd_context.open_stage_async(str(test_file_path)) await wait_stage_loading() stage = usd_context.get_stage() for prim_path in ['/World/Cube', '/World/Cone', '/World/OmniSound', '/World/Camera', '/World/DomeLight', '/World/Scope', '/World/Xform']: await self.docked_test_window( window=self._w._window, width=450, height=995, restore_window = ui.Workspace.get_window("Layer") or ui.Workspace.get_window("Stage"), restore_position = ui.DockPosition.BOTTOM) # Select the prim. usd_context.get_selection().set_selected_prim_paths([prim_path], True) prim = stage.GetPrimAtPath(prim_path) type = prim.GetTypeName().lower() # Need to wait for an additional frames for omni.ui rebuild to take effect await ui_test.human_delay(10) await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name=f"test_bundle_ui_{type}.png") # allow window to be restored to full size await ui_test.human_delay(50)
omniverse-code/kit/exts/omni.kit.property.bundle/docs/CHANGELOG.md
# Changelog The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [1.2.6] - 2022-05-13 ### Changes - Update test golden image ## [1.2.5] - 2022-05-05 ### Changes - Update test golden image ## [1.2.4] - 2021-04-15 ### Changes - Changed how material input is populated. ## [1.2.3] - 2021-02-19 ### Changes - Added UI test ## [1.2.2] - 2020-12-09 ### Changes - Added extension icon - Added readme - Updated preview image ## [1.2.1] - 2020-11-10 ### Changes - Added layer widget to ordering ## [1.2.0] - 2020-10-27 ### Changes - Added physics widgets to ordering ## [1.1.0] - 2020-10-21 ### Changes - Property schemas moved into bundle ## [1.0.3] - 2020-10-19 ### Changes - Loads property.transform ## [1.0.2] - 2020-10-13 ### Changes - Loads property.audio ## [1.0.1] - 2020-10-09 ### Changes - created - Loads property.geometry ## [1.0.0] - 2020-09-23 ### Changes - created - Loads property.camera, property.light, property.material & property.usd
omniverse-code/kit/exts/omni.kit.property.bundle/docs/README.md
# omni.kit.property.bundle ## Introduction Property window extensions are for viewing and editing Usd Prim Attributes ## This extension loads; - omni.kit.window.property - omni.kit.property.camera - omni.kit.property.light - omni.kit.property.material - omni.kit.property.usd - omni.kit.property.geometry - omni.kit.property.audio - omni.kit.property.transform ## so is a convenient way to load all the property extensions. ## This is also controls what properties are shown and in what order
omniverse-code/kit/exts/omni.kit.property.bundle/docs/index.rst
omni.kit.property.bundle ########################### Property Widget Loader .. toctree:: :maxdepth: 1 CHANGELOG
omniverse-code/kit/exts/omni.kit.property.bundle/data/tests/bundle.usda
#usda 1.0 ( customLayerData = { dictionary cameraSettings = { dictionary Front = { double3 position = (0, 0, 50000.00111758712) double radius = 500 } dictionary Perspective = { double3 position = (500, 500, 500) double3 target = (-0.0000039780385918675165, 0.00000795607684267452, -0.000003978038364493841) } dictionary Right = { double3 position = (-50000.00111758712, 0, 0) double radius = 500 } dictionary Top = { double3 position = (0, 50000.00111758712, 0) double radius = 500 } string boundCamera = "/OmniverseKit_Persp" } dictionary omni_layer = { string authoring_layer = "./bundle.usda" } dictionary renderSettings = { float3 "rtx:debugView:pixelDebug:textColor" = (0, 1e18, 0) float3 "rtx:fog:fogColor" = (0.75, 0.75, 0.75) float3 "rtx:index:regionOfInterestMax" = (0, 0, 0) float3 "rtx:index:regionOfInterestMin" = (0, 0, 0) float3 "rtx:iray:environment_dome_ground_position" = (0, 0, 0) float3 "rtx:iray:environment_dome_ground_reflectivity" = (0, 0, 0) float3 "rtx:iray:environment_dome_rotation_axis" = (3.4028235e38, 3.4028235e38, 3.4028235e38) float3 "rtx:post:backgroundZeroAlpha:backgroundDefaultColor" = (0, 0, 0) float3 "rtx:post:colorcorr:contrast" = (1, 1, 1) float3 "rtx:post:colorcorr:gain" = (1, 1, 1) float3 "rtx:post:colorcorr:gamma" = (1, 1, 1) float3 "rtx:post:colorcorr:offset" = (0, 0, 0) float3 "rtx:post:colorcorr:saturation" = (1, 1, 1) float3 "rtx:post:colorgrad:blackpoint" = (0, 0, 0) float3 "rtx:post:colorgrad:contrast" = (1, 1, 1) float3 "rtx:post:colorgrad:gain" = (1, 1, 1) float3 "rtx:post:colorgrad:gamma" = (1, 1, 1) float3 "rtx:post:colorgrad:lift" = (0, 0, 0) float3 "rtx:post:colorgrad:multiply" = (1, 1, 1) float3 "rtx:post:colorgrad:offset" = (0, 0, 0) float3 "rtx:post:colorgrad:whitepoint" = (1, 1, 1) float3 "rtx:post:lensDistortion:lensFocalLengthArray" = (10, 30, 50) float3 "rtx:post:lensFlares:anisoFlareFalloffX" = (450, 475, 500) float3 "rtx:post:lensFlares:anisoFlareFalloffY" = (10, 10, 10) float3 "rtx:post:lensFlares:cutoffPoint" = (2, 2, 2) float3 "rtx:post:lensFlares:haloFlareFalloff" = (10, 10, 10) float3 "rtx:post:lensFlares:haloFlareRadius" = (75, 75, 75) float3 "rtx:post:lensFlares:isotropicFlareFalloff" = (50, 50, 50) float3 "rtx:post:tonemap:whitepoint" = (1, 1, 1) float3 "rtx:raytracing:inscattering:singleScatteringAlbedo" = (0.9, 0.9, 0.9) float3 "rtx:raytracing:inscattering:transmittanceColor" = (0.5, 0.5, 0.5) float3 "rtx:sceneDb:ambientLightColor" = (0.1, 0.1, 0.1) } } defaultPrim = "World" endTimeCode = 100 metersPerUnit = 0.009999999776482582 startTimeCode = 0 timeCodesPerSecond = 24 upAxis = "Y" ) def Xform "World" { def DistantLight "defaultLight" ( prepend apiSchemas = ["ShapingAPI"] ) { float angle = 1 float intensity = 3000 float shaping:cone:angle = 180 float shaping:cone:softness float shaping:focus color3f shaping:focusTint asset shaping:ies:file double3 xformOp:rotateXYZ = (315, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Cube "Cube" ( kind = "component" ) { float3[] extent = [(-50, -50, -50), (50, 50, 50)] rel material:binding = </World/Looks/PreviewSurface> ( bindMaterialAs = "weakerThanDescendants" ) uniform token purpose = "render" double size = 100 double3 xformOp:rotateXYZ = (10, 20, 30) double3 xformOp:scale = (2, 3, 4) double3 xformOp:translate = (110, 45, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Scope "Looks" { def Material "PreviewSurface" { token outputs:surface.connect = </World/Looks/PreviewSurface/Shader.outputs:surface> def Shader "Shader" { reorder properties = ["inputs:diffuseColor", "inputs:emissiveColor", "inputs:useSpecularWorkflow", "inputs:specularColor", "inputs:metallic", "inputs:roughness", "inputs:clearcoat", "inputs:clearcoatRoughness", "inputs:opacity", "inputs:opacityThreshold", "inputs:ior", "inputs:normal", "inputs:displacement", "inputs:occlusion", "outputs:surface", "outputs:displacement"] uniform token info:id = "UsdPreviewSurface" float inputs:clearcoat = 0 float inputs:clearcoatRoughness = 0.01 color3f inputs:diffuseColor = (0.18, 0.18, 0.18) float inputs:displacement = 0 color3f inputs:emissiveColor = (0, 0, 0) float inputs:ior = 1.5 float inputs:metallic = 0 normal3f inputs:normal = (0, 0, 1) float inputs:occlusion = 1 float inputs:opacity = 1 float inputs:opacityThreshold = 0 float inputs:roughness = 0.5 ( customData = { dictionary range = { double max = 1 double min = 0 } } ) color3f inputs:specularColor = (0, 0, 0) int inputs:useSpecularWorkflow = 0 ( customData = { dictionary range = { int max = 1 int min = 0 } } ) token outputs:displacement token outputs:surface } } } def OmniSound "OmniSound" { double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Camera "Camera" { float2 clippingRange = (1, 10000000) float focalLength = 18.147562 float focusDistance = 400 double3 xformOp:rotateYXZ = (0, -0, -0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateYXZ", "xformOp:scale"] } def DomeLight "DomeLight" ( prepend apiSchemas = ["ShapingAPI"] ) { float inputs:intensity = 1000 float inputs:shaping:cone:angle = 180 float inputs:shaping:cone:softness float inputs:shaping:focus color3f inputs:shaping:focusTint asset inputs:shaping:ies:file token inputs:texture:format = "latlong" double3 xformOp:rotateXYZ = (270, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Scope "Scope" { } def Mesh "Cone" { float3[] extent = [(-50, -50, -50), (50, 49.9995, 50)] int[] faceVertexCounts = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] int[] faceVertexIndices = [0, 64, 65, 1, 1, 65, 66, 2, 2, 66, 67, 3, 3, 67, 68, 4, 4, 68, 69, 5, 5, 69, 70, 6, 6, 70, 71, 7, 7, 71, 72, 8, 8, 72, 73, 9, 9, 73, 74, 10, 10, 74, 75, 11, 11, 75, 76, 12, 12, 76, 77, 13, 13, 77, 78, 14, 14, 78, 79, 15, 15, 79, 80, 16, 16, 80, 81, 17, 17, 81, 82, 18, 18, 82, 83, 19, 19, 83, 84, 20, 20, 84, 85, 21, 21, 85, 86, 22, 22, 86, 87, 23, 23, 87, 88, 24, 24, 88, 89, 25, 25, 89, 90, 26, 26, 90, 91, 27, 27, 91, 92, 28, 28, 92, 93, 29, 29, 93, 94, 30, 30, 94, 95, 31, 31, 95, 96, 32, 32, 96, 97, 33, 33, 97, 98, 34, 34, 98, 99, 35, 35, 99, 100, 36, 36, 100, 101, 37, 37, 101, 102, 38, 38, 102, 103, 39, 39, 103, 104, 40, 40, 104, 105, 41, 41, 105, 106, 42, 42, 106, 107, 43, 43, 107, 108, 44, 44, 108, 109, 45, 45, 109, 110, 46, 46, 110, 111, 47, 47, 111, 112, 48, 48, 112, 113, 49, 49, 113, 114, 50, 50, 114, 115, 51, 51, 115, 116, 52, 52, 116, 117, 53, 53, 117, 118, 54, 54, 118, 119, 55, 55, 119, 120, 56, 56, 120, 121, 57, 57, 121, 122, 58, 58, 122, 123, 59, 59, 123, 124, 60, 60, 124, 125, 61, 61, 125, 126, 62, 62, 126, 127, 63, 63, 127, 64, 0, 64, 128, 129, 65, 65, 129, 130, 66, 66, 130, 131, 67, 67, 131, 132, 68, 68, 132, 133, 69, 69, 133, 134, 70, 70, 134, 135, 71, 71, 135, 136, 72, 72, 136, 137, 73, 73, 137, 138, 74, 74, 138, 139, 75, 75, 139, 140, 76, 76, 140, 141, 77, 77, 141, 142, 78, 78, 142, 143, 79, 79, 143, 144, 80, 80, 144, 145, 81, 81, 145, 146, 82, 82, 146, 147, 83, 83, 147, 148, 84, 84, 148, 149, 85, 85, 149, 150, 86, 86, 150, 151, 87, 87, 151, 152, 88, 88, 152, 153, 89, 89, 153, 154, 90, 90, 154, 155, 91, 91, 155, 156, 92, 92, 156, 157, 93, 93, 157, 158, 94, 94, 158, 159, 95, 95, 159, 160, 96, 96, 160, 161, 97, 97, 161, 162, 98, 98, 162, 163, 99, 99, 163, 164, 100, 100, 164, 165, 101, 101, 165, 166, 102, 102, 166, 167, 103, 103, 167, 168, 104, 104, 168, 169, 105, 105, 169, 170, 106, 106, 170, 171, 107, 107, 171, 172, 108, 108, 172, 173, 109, 109, 173, 174, 110, 110, 174, 175, 111, 111, 175, 176, 112, 112, 176, 177, 113, 113, 177, 178, 114, 114, 178, 179, 115, 115, 179, 180, 116, 116, 180, 181, 117, 117, 181, 182, 118, 118, 182, 183, 119, 119, 183, 184, 120, 120, 184, 185, 121, 121, 185, 186, 122, 122, 186, 187, 123, 123, 187, 188, 124, 124, 188, 189, 125, 125, 189, 190, 126, 126, 190, 191, 127, 127, 191, 128, 64, 128, 192, 193, 129, 129, 193, 194, 130, 130, 194, 195, 131, 131, 195, 196, 132, 132, 196, 197, 133, 133, 197, 198, 134, 134, 198, 199, 135, 135, 199, 200, 136, 136, 200, 201, 137, 137, 201, 202, 138, 138, 202, 203, 139, 139, 203, 204, 140, 140, 204, 205, 141, 141, 205, 206, 142, 142, 206, 207, 143, 143, 207, 208, 144, 144, 208, 209, 145, 145, 209, 210, 146, 146, 210, 211, 147, 147, 211, 212, 148, 148, 212, 213, 149, 149, 213, 214, 150, 150, 214, 215, 151, 151, 215, 216, 152, 152, 216, 217, 153, 153, 217, 218, 154, 154, 218, 219, 155, 155, 219, 220, 156, 156, 220, 221, 157, 157, 221, 222, 158, 158, 222, 223, 159, 159, 223, 224, 160, 160, 224, 225, 161, 161, 225, 226, 162, 162, 226, 227, 163, 163, 227, 228, 164, 164, 228, 229, 165, 165, 229, 230, 166, 166, 230, 231, 167, 167, 231, 232, 168, 168, 232, 233, 169, 169, 233, 234, 170, 170, 234, 235, 171, 171, 235, 236, 172, 172, 236, 237, 173, 173, 237, 238, 174, 174, 238, 239, 175, 175, 239, 240, 176, 176, 240, 241, 177, 177, 241, 242, 178, 178, 242, 243, 179, 179, 243, 244, 180, 180, 244, 245, 181, 181, 245, 246, 182, 182, 246, 247, 183, 183, 247, 248, 184, 184, 248, 249, 185, 185, 249, 250, 186, 186, 250, 251, 187, 187, 251, 252, 188, 188, 252, 253, 189, 189, 253, 254, 190, 190, 254, 255, 191, 191, 255, 192, 128, 192, 256, 193, 193, 256, 194, 194, 256, 195, 195, 256, 196, 196, 256, 197, 197, 256, 198, 198, 256, 199, 199, 256, 200, 200, 256, 201, 201, 256, 202, 202, 256, 203, 203, 256, 204, 204, 256, 205, 205, 256, 206, 206, 256, 207, 207, 256, 208, 208, 256, 209, 209, 256, 210, 210, 256, 211, 211, 256, 212, 212, 256, 213, 213, 256, 214, 214, 256, 215, 215, 256, 216, 216, 256, 217, 217, 256, 218, 218, 256, 219, 219, 256, 220, 220, 256, 221, 221, 256, 222, 222, 256, 223, 223, 256, 224, 224, 256, 225, 225, 256, 226, 226, 256, 227, 227, 256, 228, 228, 256, 229, 229, 256, 230, 230, 256, 231, 231, 256, 232, 232, 256, 233, 233, 256, 234, 234, 256, 235, 235, 256, 236, 236, 256, 237, 237, 256, 238, 238, 256, 239, 239, 256, 240, 240, 256, 241, 241, 256, 242, 242, 256, 243, 243, 256, 244, 244, 256, 245, 245, 256, 246, 246, 256, 247, 247, 256, 248, 248, 256, 249, 249, 256, 250, 250, 256, 251, 251, 256, 252, 252, 256, 253, 253, 256, 254, 254, 256, 255, 255, 256, 192, 0, 1, 257, 1, 2, 257, 2, 3, 257, 3, 4, 257, 4, 5, 257, 5, 6, 257, 6, 7, 257, 7, 8, 257, 8, 9, 257, 9, 10, 257, 10, 11, 257, 11, 12, 257, 12, 13, 257, 13, 14, 257, 14, 15, 257, 15, 16, 257, 16, 17, 257, 17, 18, 257, 18, 19, 257, 19, 20, 257, 20, 21, 257, 21, 22, 257, 22, 23, 257, 23, 24, 257, 24, 25, 257, 25, 26, 257, 26, 27, 257, 27, 28, 257, 28, 29, 257, 29, 30, 257, 30, 31, 257, 31, 32, 257, 32, 33, 257, 33, 34, 257, 34, 35, 257, 35, 36, 257, 36, 37, 257, 37, 38, 257, 38, 39, 257, 39, 40, 257, 40, 41, 257, 41, 42, 257, 42, 43, 257, 43, 44, 257, 44, 45, 257, 45, 46, 257, 46, 47, 257, 47, 48, 257, 48, 49, 257, 49, 50, 257, 50, 51, 257, 51, 52, 257, 52, 53, 257, 53, 54, 257, 54, 55, 257, 55, 56, 257, 56, 57, 257, 57, 58, 257, 58, 59, 257, 59, 60, 257, 60, 61, 257, 61, 62, 257, 62, 63, 257, 63, 0, 257] normal3f[] normals = [(0.8944272, 0.4472136, 0), (0.8944271, 0.44721356, 0), (0.8901202, 0.44721356, 0.08766919), (0.89012027, 0.4472136, 0.087669194), (0.89012027, 0.4472136, 0.087669194), (0.8901202, 0.44721356, 0.08766919), (0.87724096, 0.44721356, 0.17449406), (0.8772411, 0.44721362, 0.1744941), (0.8772411, 0.44721362, 0.1744941), (0.87724096, 0.44721356, 0.17449406), (0.85591346, 0.44721362, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.44721362, 0.25963852), (0.826343, 0.44721362, 0.34228247), (0.826343, 0.44721362, 0.34228247), (0.826343, 0.44721362, 0.34228247), (0.826343, 0.44721362, 0.34228247), (0.78881437, 0.44721362, 0.42163005), (0.78881437, 0.44721362, 0.42163005), (0.78881437, 0.44721362, 0.42163005), (0.78881437, 0.44721362, 0.42163005), (0.743689, 0.44721362, 0.4969171), (0.743689, 0.4472136, 0.49691713), (0.743689, 0.4472136, 0.49691713), (0.743689, 0.44721362, 0.4969171), (0.6914016, 0.44721362, 0.5674186), (0.6914016, 0.4472136, 0.56741863), (0.6914016, 0.4472136, 0.56741863), (0.6914016, 0.44721362, 0.5674186), (0.6324555, 0.44721356, 0.6324555), (0.6324555, 0.44721362, 0.6324555), (0.6324555, 0.44721362, 0.6324555), (0.6324555, 0.44721356, 0.6324555), (0.5674186, 0.44721362, 0.6914016), (0.56741863, 0.4472136, 0.6914016), (0.56741863, 0.4472136, 0.6914016), (0.5674186, 0.44721362, 0.6914016), (0.4969171, 0.44721362, 0.743689), (0.49691713, 0.4472136, 0.743689), (0.49691713, 0.4472136, 0.743689), (0.4969171, 0.44721362, 0.743689), (0.42163005, 0.44721362, 0.78881437), (0.42163005, 0.44721362, 0.78881437), (0.42163005, 0.44721362, 0.78881437), (0.42163005, 0.44721362, 0.78881437), (0.34228247, 0.44721362, 0.826343), (0.34228247, 0.44721362, 0.826343), (0.34228247, 0.44721362, 0.826343), (0.34228247, 0.44721362, 0.826343), (0.25963852, 0.44721362, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.44721362, 0.85591346), (0.17449409, 0.44721362, 0.8772411), (0.17449409, 0.4472136, 0.877241), (0.17449409, 0.4472136, 0.877241), (0.17449409, 0.44721362, 0.8772411), (0.08766919, 0.44721356, 0.8901202), (0.0876692, 0.44721362, 0.8901203), (0.0876692, 0.44721362, 0.8901203), (0.08766919, 0.44721356, 0.8901202), (5.4767863e-17, 0.44721356, 0.8944271), (5.4767867e-17, 0.4472136, 0.8944272), (5.4767867e-17, 0.4472136, 0.8944272), (5.4767863e-17, 0.44721356, 0.8944271), (-0.08766919, 0.44721356, 0.8901202), (-0.0876692, 0.44721362, 0.8901203), (-0.0876692, 0.44721362, 0.8901203), (-0.08766919, 0.44721356, 0.8901202), (-0.17449409, 0.44721362, 0.8772411), (-0.17449409, 0.4472136, 0.877241), (-0.17449409, 0.4472136, 0.877241), (-0.17449409, 0.44721362, 0.8772411), (-0.25963852, 0.44721362, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.44721362, 0.85591346), (-0.34228247, 0.44721362, 0.826343), (-0.34228247, 0.44721362, 0.826343), (-0.34228247, 0.44721362, 0.826343), (-0.34228247, 0.44721362, 0.826343), (-0.42163005, 0.44721362, 0.78881437), (-0.42163005, 0.44721362, 0.78881437), (-0.42163005, 0.44721362, 0.78881437), (-0.42163005, 0.44721362, 0.78881437), (-0.4969171, 0.44721362, 0.743689), (-0.49691713, 0.4472136, 0.743689), (-0.49691713, 0.4472136, 0.743689), (-0.4969171, 0.44721362, 0.743689), (-0.5674186, 0.44721362, 0.6914016), (-0.56741863, 0.4472136, 0.6914016), (-0.56741863, 0.4472136, 0.6914016), (-0.5674186, 0.44721362, 0.6914016), (-0.6324555, 0.44721356, 0.6324555), (-0.6324555, 0.44721362, 0.6324555), (-0.6324555, 0.44721362, 0.6324555), (-0.6324555, 0.44721356, 0.6324555), (-0.6914016, 0.44721362, 0.5674186), (-0.6914016, 0.4472136, 0.56741863), (-0.6914016, 0.4472136, 0.56741863), (-0.6914016, 0.44721362, 0.5674186), (-0.743689, 0.44721362, 0.4969171), (-0.743689, 0.4472136, 0.49691713), (-0.743689, 0.4472136, 0.49691713), (-0.743689, 0.44721362, 0.4969171), (-0.78881437, 0.44721362, 0.42163005), (-0.78881437, 0.44721362, 0.42163005), (-0.78881437, 0.44721362, 0.42163005), (-0.78881437, 0.44721362, 0.42163005), (-0.826343, 0.44721362, 0.34228247), (-0.826343, 0.44721362, 0.34228247), (-0.826343, 0.44721362, 0.34228247), (-0.826343, 0.44721362, 0.34228247), (-0.85591346, 0.44721362, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.44721362, 0.25963852), (-0.87724096, 0.44721356, 0.17449406), (-0.8772411, 0.44721362, 0.1744941), (-0.8772411, 0.44721362, 0.1744941), (-0.87724096, 0.44721356, 0.17449406), (-0.8901202, 0.44721356, 0.08766919), (-0.89012027, 0.4472136, 0.087669194), (-0.89012027, 0.4472136, 0.087669194), (-0.8901202, 0.44721356, 0.08766919), (-0.8944271, 0.44721356, 1.09535727e-16), (-0.8944272, 0.4472136, 1.0953573e-16), (-0.8944272, 0.4472136, 1.0953573e-16), (-0.8944271, 0.44721356, 1.09535727e-16), (-0.8901202, 0.44721356, -0.08766919), (-0.89012027, 0.4472136, -0.087669194), (-0.89012027, 0.4472136, -0.087669194), (-0.8901202, 0.44721356, -0.08766919), (-0.87724096, 0.44721356, -0.17449406), (-0.8772411, 0.44721362, -0.1744941), (-0.8772411, 0.44721362, -0.1744941), (-0.87724096, 0.44721356, -0.17449406), (-0.85591346, 0.44721362, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.44721362, -0.25963852), (-0.826343, 0.44721362, -0.34228247), (-0.826343, 0.44721362, -0.34228247), (-0.826343, 0.44721362, -0.34228247), (-0.826343, 0.44721362, -0.34228247), (-0.78881437, 0.44721362, -0.42163005), (-0.78881437, 0.44721362, -0.42163005), (-0.78881437, 0.44721362, -0.42163005), (-0.78881437, 0.44721362, -0.42163005), (-0.743689, 0.44721362, -0.4969171), (-0.743689, 0.4472136, -0.49691713), (-0.743689, 0.4472136, -0.49691713), (-0.743689, 0.44721362, -0.4969171), (-0.6914016, 0.44721362, -0.5674186), (-0.6914016, 0.4472136, -0.56741863), (-0.6914016, 0.4472136, -0.56741863), (-0.6914016, 0.44721362, -0.5674186), (-0.6324555, 0.44721356, -0.6324555), (-0.6324555, 0.44721362, -0.6324555), (-0.6324555, 0.44721362, -0.6324555), (-0.6324555, 0.44721356, -0.6324555), (-0.5674186, 0.44721362, -0.6914016), (-0.56741863, 0.4472136, -0.6914016), (-0.56741863, 0.4472136, -0.6914016), (-0.5674186, 0.44721362, -0.6914016), (-0.4969171, 0.44721362, -0.743689), (-0.49691713, 0.4472136, -0.743689), (-0.49691713, 0.4472136, -0.743689), (-0.4969171, 0.44721362, -0.743689), (-0.42163005, 0.44721362, -0.78881437), (-0.42163005, 0.44721362, -0.78881437), (-0.42163005, 0.44721362, -0.78881437), (-0.42163005, 0.44721362, -0.78881437), (-0.34228247, 0.44721362, -0.826343), (-0.34228247, 0.44721362, -0.826343), (-0.34228247, 0.44721362, -0.826343), (-0.34228247, 0.44721362, -0.826343), (-0.25963852, 0.44721362, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.44721362, -0.85591346), (-0.17449409, 0.44721362, -0.8772411), (-0.17449409, 0.4472136, -0.877241), (-0.17449409, 0.4472136, -0.877241), (-0.17449409, 0.44721362, -0.8772411), (-0.08766919, 0.44721356, -0.8901202), (-0.0876692, 0.44721362, -0.8901203), (-0.0876692, 0.44721362, -0.8901203), (-0.08766919, 0.44721356, -0.8901202), (-1.6430359e-16, 0.44721356, -0.8944271), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430359e-16, 0.44721356, -0.8944271), (0.08766919, 0.44721356, -0.8901202), (0.0876692, 0.44721362, -0.8901203), (0.0876692, 0.44721362, -0.8901203), (0.08766919, 0.44721356, -0.8901202), (0.17449409, 0.44721362, -0.8772411), (0.17449409, 0.4472136, -0.877241), (0.17449409, 0.4472136, -0.877241), (0.17449409, 0.44721362, -0.8772411), (0.25963852, 0.44721362, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.44721362, -0.85591346), (0.34228247, 0.44721362, -0.826343), (0.34228247, 0.44721362, -0.826343), (0.34228247, 0.44721362, -0.826343), (0.34228247, 0.44721362, -0.826343), (0.42163005, 0.44721362, -0.78881437), (0.42163005, 0.44721362, -0.78881437), (0.42163005, 0.44721362, -0.78881437), (0.42163005, 0.44721362, -0.78881437), (0.4969171, 0.44721362, -0.743689), (0.49691713, 0.4472136, -0.743689), (0.49691713, 0.4472136, -0.743689), (0.4969171, 0.44721362, -0.743689), (0.5674186, 0.44721362, -0.6914016), (0.56741863, 0.4472136, -0.6914016), (0.56741863, 0.4472136, -0.6914016), (0.5674186, 0.44721362, -0.6914016), (0.6324555, 0.44721356, -0.6324555), (0.6324555, 0.44721362, -0.6324555), (0.6324555, 0.44721362, -0.6324555), (0.6324555, 0.44721356, -0.6324555), (0.6914016, 0.44721362, -0.5674186), (0.6914016, 0.4472136, -0.56741863), (0.6914016, 0.4472136, -0.56741863), (0.6914016, 0.44721362, -0.5674186), (0.743689, 0.44721362, -0.4969171), (0.743689, 0.4472136, -0.49691713), (0.743689, 0.4472136, -0.49691713), (0.743689, 0.44721362, -0.4969171), (0.78881437, 0.44721362, -0.42163005), (0.78881437, 0.44721362, -0.42163005), (0.78881437, 0.44721362, -0.42163005), (0.78881437, 0.44721362, -0.42163005), (0.826343, 0.44721362, -0.34228247), (0.826343, 0.44721362, -0.34228247), (0.826343, 0.44721362, -0.34228247), (0.826343, 0.44721362, -0.34228247), (0.85591346, 0.44721362, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.44721362, -0.25963852), (0.87724096, 0.44721356, -0.17449406), (0.8772411, 0.44721362, -0.1744941), (0.8772411, 0.44721362, -0.1744941), (0.87724096, 0.44721356, -0.17449406), (0.8901202, 0.44721356, -0.08766919), (0.89012027, 0.4472136, -0.087669194), (0.89012027, 0.4472136, -0.087669194), (0.8901202, 0.44721356, -0.08766919), (0.8944271, 0.44721356, 0), (0.8944272, 0.4472136, 0), (0.8944271, 0.44721356, 0), (0.8944272, 0.4472136, 0), (0.89012027, 0.4472136, 0.08766919), (0.8901202, 0.44721356, 0.08766919), (0.8901202, 0.44721356, 0.08766919), (0.89012027, 0.4472136, 0.08766919), (0.8772411, 0.4472136, 0.17449409), (0.87724096, 0.44721356, 0.17449406), (0.87724096, 0.44721356, 0.17449406), (0.8772411, 0.4472136, 0.17449409), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.44721362, 0.25963852), (0.85591346, 0.44721362, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.826343, 0.4472136, 0.34228247), (0.826343, 0.44721362, 0.34228247), (0.826343, 0.44721362, 0.34228247), (0.826343, 0.4472136, 0.34228247), (0.78881437, 0.44721365, 0.42163008), (0.78881437, 0.44721362, 0.42163005), (0.78881437, 0.44721362, 0.42163005), (0.78881437, 0.44721365, 0.42163008), (0.74368906, 0.4472136, 0.49691716), (0.743689, 0.44721362, 0.4969171), (0.743689, 0.44721362, 0.4969171), (0.74368906, 0.4472136, 0.49691716), (0.6914016, 0.4472136, 0.5674186), (0.6914016, 0.44721362, 0.5674186), (0.6914016, 0.44721362, 0.5674186), (0.6914016, 0.4472136, 0.5674186), (0.6324555, 0.4472136, 0.6324555), (0.6324555, 0.44721356, 0.6324555), (0.6324555, 0.44721356, 0.6324555), (0.6324555, 0.4472136, 0.6324555), (0.5674186, 0.4472136, 0.6914016), (0.5674186, 0.44721362, 0.6914016), (0.5674186, 0.44721362, 0.6914016), (0.5674186, 0.4472136, 0.6914016), (0.49691716, 0.4472136, 0.74368906), (0.4969171, 0.44721362, 0.743689), (0.4969171, 0.44721362, 0.743689), (0.49691716, 0.4472136, 0.74368906), (0.42163008, 0.44721365, 0.78881437), (0.42163005, 0.44721362, 0.78881437), (0.42163005, 0.44721362, 0.78881437), (0.42163008, 0.44721365, 0.78881437), (0.34228247, 0.4472136, 0.826343), (0.34228247, 0.44721362, 0.826343), (0.34228247, 0.44721362, 0.826343), (0.34228247, 0.4472136, 0.826343), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.44721362, 0.85591346), (0.25963852, 0.44721362, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.17449409, 0.4472136, 0.8772411), (0.17449409, 0.44721362, 0.8772411), (0.17449409, 0.44721362, 0.8772411), (0.17449409, 0.4472136, 0.8772411), (0.08766919, 0.4472136, 0.89012027), (0.08766919, 0.44721356, 0.8901202), (0.08766919, 0.44721356, 0.8901202), (0.08766919, 0.4472136, 0.89012027), (5.476787e-17, 0.4472136, 0.8944272), (5.4767863e-17, 0.44721356, 0.8944271), (5.4767863e-17, 0.44721356, 0.8944271), (5.476787e-17, 0.4472136, 0.8944272), (-0.08766919, 0.4472136, 0.89012027), (-0.08766919, 0.44721356, 0.8901202), (-0.08766919, 0.44721356, 0.8901202), (-0.08766919, 0.4472136, 0.89012027), (-0.17449409, 0.4472136, 0.8772411), (-0.17449409, 0.44721362, 0.8772411), (-0.17449409, 0.44721362, 0.8772411), (-0.17449409, 0.4472136, 0.8772411), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.44721362, 0.85591346), (-0.25963852, 0.44721362, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.34228247, 0.4472136, 0.826343), (-0.34228247, 0.44721362, 0.826343), (-0.34228247, 0.44721362, 0.826343), (-0.34228247, 0.4472136, 0.826343), (-0.42163008, 0.44721365, 0.78881437), (-0.42163005, 0.44721362, 0.78881437), (-0.42163005, 0.44721362, 0.78881437), (-0.42163008, 0.44721365, 0.78881437), (-0.49691716, 0.4472136, 0.74368906), (-0.4969171, 0.44721362, 0.743689), (-0.4969171, 0.44721362, 0.743689), (-0.49691716, 0.4472136, 0.74368906), (-0.5674186, 0.4472136, 0.6914016), (-0.5674186, 0.44721362, 0.6914016), (-0.5674186, 0.44721362, 0.6914016), (-0.5674186, 0.4472136, 0.6914016), (-0.6324555, 0.4472136, 0.6324555), (-0.6324555, 0.44721356, 0.6324555), (-0.6324555, 0.44721356, 0.6324555), (-0.6324555, 0.4472136, 0.6324555), (-0.6914016, 0.4472136, 0.5674186), (-0.6914016, 0.44721362, 0.5674186), (-0.6914016, 0.44721362, 0.5674186), (-0.6914016, 0.4472136, 0.5674186), (-0.74368906, 0.4472136, 0.49691716), (-0.743689, 0.44721362, 0.4969171), (-0.743689, 0.44721362, 0.4969171), (-0.74368906, 0.4472136, 0.49691716), (-0.78881437, 0.44721365, 0.42163008), (-0.78881437, 0.44721362, 0.42163005), (-0.78881437, 0.44721362, 0.42163005), (-0.78881437, 0.44721365, 0.42163008), (-0.826343, 0.4472136, 0.34228247), (-0.826343, 0.44721362, 0.34228247), (-0.826343, 0.44721362, 0.34228247), (-0.826343, 0.4472136, 0.34228247), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.44721362, 0.25963852), (-0.85591346, 0.44721362, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.8772411, 0.4472136, 0.17449409), (-0.87724096, 0.44721356, 0.17449406), (-0.87724096, 0.44721356, 0.17449406), (-0.8772411, 0.4472136, 0.17449409), (-0.89012027, 0.4472136, 0.08766919), (-0.8901202, 0.44721356, 0.08766919), (-0.8901202, 0.44721356, 0.08766919), (-0.89012027, 0.4472136, 0.08766919), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.8944271, 0.44721356, 1.09535727e-16), (-0.8944271, 0.44721356, 1.09535727e-16), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.89012027, 0.4472136, -0.08766919), (-0.8901202, 0.44721356, -0.08766919), (-0.8901202, 0.44721356, -0.08766919), (-0.89012027, 0.4472136, -0.08766919), (-0.8772411, 0.4472136, -0.17449409), (-0.87724096, 0.44721356, -0.17449406), (-0.87724096, 0.44721356, -0.17449406), (-0.8772411, 0.4472136, -0.17449409), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.44721362, -0.25963852), (-0.85591346, 0.44721362, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.826343, 0.4472136, -0.34228247), (-0.826343, 0.44721362, -0.34228247), (-0.826343, 0.44721362, -0.34228247), (-0.826343, 0.4472136, -0.34228247), (-0.78881437, 0.44721365, -0.42163008), (-0.78881437, 0.44721362, -0.42163005), (-0.78881437, 0.44721362, -0.42163005), (-0.78881437, 0.44721365, -0.42163008), (-0.74368906, 0.4472136, -0.49691716), (-0.743689, 0.44721362, -0.4969171), (-0.743689, 0.44721362, -0.4969171), (-0.74368906, 0.4472136, -0.49691716), (-0.6914016, 0.4472136, -0.5674186), (-0.6914016, 0.44721362, -0.5674186), (-0.6914016, 0.44721362, -0.5674186), (-0.6914016, 0.4472136, -0.5674186), (-0.6324555, 0.4472136, -0.6324555), (-0.6324555, 0.44721356, -0.6324555), (-0.6324555, 0.44721356, -0.6324555), (-0.6324555, 0.4472136, -0.6324555), (-0.5674186, 0.4472136, -0.6914016), (-0.5674186, 0.44721362, -0.6914016), (-0.5674186, 0.44721362, -0.6914016), (-0.5674186, 0.4472136, -0.6914016), (-0.49691716, 0.4472136, -0.74368906), (-0.4969171, 0.44721362, -0.743689), (-0.4969171, 0.44721362, -0.743689), (-0.49691716, 0.4472136, -0.74368906), (-0.42163008, 0.44721365, -0.78881437), (-0.42163005, 0.44721362, -0.78881437), (-0.42163005, 0.44721362, -0.78881437), (-0.42163008, 0.44721365, -0.78881437), (-0.34228247, 0.4472136, -0.826343), (-0.34228247, 0.44721362, -0.826343), (-0.34228247, 0.44721362, -0.826343), (-0.34228247, 0.4472136, -0.826343), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.44721362, -0.85591346), (-0.25963852, 0.44721362, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.17449409, 0.4472136, -0.8772411), (-0.17449409, 0.44721362, -0.8772411), (-0.17449409, 0.44721362, -0.8772411), (-0.17449409, 0.4472136, -0.8772411), (-0.08766919, 0.4472136, -0.89012027), (-0.08766919, 0.44721356, -0.8901202), (-0.08766919, 0.44721356, -0.8901202), (-0.08766919, 0.4472136, -0.89012027), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430359e-16, 0.44721356, -0.8944271), (-1.6430359e-16, 0.44721356, -0.8944271), (-1.6430361e-16, 0.4472136, -0.8944272), (0.08766919, 0.4472136, -0.89012027), (0.08766919, 0.44721356, -0.8901202), (0.08766919, 0.44721356, -0.8901202), (0.08766919, 0.4472136, -0.89012027), (0.17449409, 0.4472136, -0.8772411), (0.17449409, 0.44721362, -0.8772411), (0.17449409, 0.44721362, -0.8772411), (0.17449409, 0.4472136, -0.8772411), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.44721362, -0.85591346), (0.25963852, 0.44721362, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.34228247, 0.4472136, -0.826343), (0.34228247, 0.44721362, -0.826343), (0.34228247, 0.44721362, -0.826343), (0.34228247, 0.4472136, -0.826343), (0.42163008, 0.44721365, -0.78881437), (0.42163005, 0.44721362, -0.78881437), (0.42163005, 0.44721362, -0.78881437), (0.42163008, 0.44721365, -0.78881437), (0.49691716, 0.4472136, -0.74368906), (0.4969171, 0.44721362, -0.743689), (0.4969171, 0.44721362, -0.743689), (0.49691716, 0.4472136, -0.74368906), (0.5674186, 0.4472136, -0.6914016), (0.5674186, 0.44721362, -0.6914016), (0.5674186, 0.44721362, -0.6914016), (0.5674186, 0.4472136, -0.6914016), (0.6324555, 0.4472136, -0.6324555), (0.6324555, 0.44721356, -0.6324555), (0.6324555, 0.44721356, -0.6324555), (0.6324555, 0.4472136, -0.6324555), (0.6914016, 0.4472136, -0.5674186), (0.6914016, 0.44721362, -0.5674186), (0.6914016, 0.44721362, -0.5674186), (0.6914016, 0.4472136, -0.5674186), (0.74368906, 0.4472136, -0.49691716), (0.743689, 0.44721362, -0.4969171), (0.743689, 0.44721362, -0.4969171), (0.74368906, 0.4472136, -0.49691716), (0.78881437, 0.44721365, -0.42163008), (0.78881437, 0.44721362, -0.42163005), (0.78881437, 0.44721362, -0.42163005), (0.78881437, 0.44721365, -0.42163008), (0.826343, 0.4472136, -0.34228247), (0.826343, 0.44721362, -0.34228247), (0.826343, 0.44721362, -0.34228247), (0.826343, 0.4472136, -0.34228247), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.44721362, -0.25963852), (0.85591346, 0.44721362, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.8772411, 0.4472136, -0.17449409), (0.87724096, 0.44721356, -0.17449406), (0.87724096, 0.44721356, -0.17449406), (0.8772411, 0.4472136, -0.17449409), (0.89012027, 0.4472136, -0.08766919), (0.8901202, 0.44721356, -0.08766919), (0.8901202, 0.44721356, -0.08766919), (0.89012027, 0.4472136, -0.08766919), (0.8944272, 0.4472136, 0), (0.8944271, 0.44721356, 0), (0.8944272, 0.4472136, 0), (0.8944272, 0.4472136, 0), (0.8901203, 0.44721362, 0.087669194), (0.89012027, 0.4472136, 0.08766919), (0.89012027, 0.4472136, 0.08766919), (0.8901203, 0.44721362, 0.087669194), (0.8772411, 0.4472136, 0.17449409), (0.8772411, 0.4472136, 0.17449409), (0.8772411, 0.4472136, 0.17449409), (0.8772411, 0.4472136, 0.17449409), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.85591346, 0.4472136, 0.25963852), (0.82634294, 0.4472136, 0.34228247), (0.826343, 0.4472136, 0.34228247), (0.826343, 0.4472136, 0.34228247), (0.82634294, 0.4472136, 0.34228247), (0.78881437, 0.4472136, 0.42163005), (0.78881437, 0.44721365, 0.42163008), (0.78881437, 0.44721365, 0.42163008), (0.78881437, 0.4472136, 0.42163005), (0.743689, 0.4472136, 0.49691713), (0.74368906, 0.4472136, 0.49691716), (0.74368906, 0.4472136, 0.49691716), (0.743689, 0.4472136, 0.49691713), (0.69140154, 0.4472136, 0.5674186), (0.6914016, 0.4472136, 0.5674186), (0.6914016, 0.4472136, 0.5674186), (0.69140154, 0.4472136, 0.5674186), (0.6324555, 0.4472136, 0.6324555), (0.6324555, 0.4472136, 0.6324555), (0.6324555, 0.4472136, 0.6324555), (0.6324555, 0.4472136, 0.6324555), (0.5674186, 0.4472136, 0.69140154), (0.5674186, 0.4472136, 0.6914016), (0.5674186, 0.4472136, 0.6914016), (0.5674186, 0.4472136, 0.69140154), (0.49691713, 0.4472136, 0.743689), (0.49691716, 0.4472136, 0.74368906), (0.49691716, 0.4472136, 0.74368906), (0.49691713, 0.4472136, 0.743689), (0.42163005, 0.4472136, 0.78881437), (0.42163008, 0.44721365, 0.78881437), (0.42163008, 0.44721365, 0.78881437), (0.42163005, 0.4472136, 0.78881437), (0.34228247, 0.4472136, 0.82634294), (0.34228247, 0.4472136, 0.826343), (0.34228247, 0.4472136, 0.826343), (0.34228247, 0.4472136, 0.82634294), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.25963852, 0.4472136, 0.85591346), (0.17449409, 0.4472136, 0.8772411), (0.17449409, 0.4472136, 0.8772411), (0.17449409, 0.4472136, 0.8772411), (0.17449409, 0.4472136, 0.8772411), (0.087669194, 0.44721362, 0.8901203), (0.08766919, 0.4472136, 0.89012027), (0.08766919, 0.4472136, 0.89012027), (0.087669194, 0.44721362, 0.8901203), (5.476787e-17, 0.4472136, 0.8944272), (5.476787e-17, 0.4472136, 0.8944272), (5.476787e-17, 0.4472136, 0.8944272), (5.476787e-17, 0.4472136, 0.8944272), (-0.087669194, 0.44721362, 0.8901203), (-0.08766919, 0.4472136, 0.89012027), (-0.08766919, 0.4472136, 0.89012027), (-0.087669194, 0.44721362, 0.8901203), (-0.17449409, 0.4472136, 0.8772411), (-0.17449409, 0.4472136, 0.8772411), (-0.17449409, 0.4472136, 0.8772411), (-0.17449409, 0.4472136, 0.8772411), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.25963852, 0.4472136, 0.85591346), (-0.34228247, 0.4472136, 0.82634294), (-0.34228247, 0.4472136, 0.826343), (-0.34228247, 0.4472136, 0.826343), (-0.34228247, 0.4472136, 0.82634294), (-0.42163005, 0.4472136, 0.78881437), (-0.42163008, 0.44721365, 0.78881437), (-0.42163008, 0.44721365, 0.78881437), (-0.42163005, 0.4472136, 0.78881437), (-0.49691713, 0.4472136, 0.743689), (-0.49691716, 0.4472136, 0.74368906), (-0.49691716, 0.4472136, 0.74368906), (-0.49691713, 0.4472136, 0.743689), (-0.5674186, 0.4472136, 0.69140154), (-0.5674186, 0.4472136, 0.6914016), (-0.5674186, 0.4472136, 0.6914016), (-0.5674186, 0.4472136, 0.69140154), (-0.6324555, 0.4472136, 0.6324555), (-0.6324555, 0.4472136, 0.6324555), (-0.6324555, 0.4472136, 0.6324555), (-0.6324555, 0.4472136, 0.6324555), (-0.69140154, 0.4472136, 0.5674186), (-0.6914016, 0.4472136, 0.5674186), (-0.6914016, 0.4472136, 0.5674186), (-0.69140154, 0.4472136, 0.5674186), (-0.743689, 0.4472136, 0.49691713), (-0.74368906, 0.4472136, 0.49691716), (-0.74368906, 0.4472136, 0.49691716), (-0.743689, 0.4472136, 0.49691713), (-0.78881437, 0.4472136, 0.42163005), (-0.78881437, 0.44721365, 0.42163008), (-0.78881437, 0.44721365, 0.42163008), (-0.78881437, 0.4472136, 0.42163005), (-0.82634294, 0.4472136, 0.34228247), (-0.826343, 0.4472136, 0.34228247), (-0.826343, 0.4472136, 0.34228247), (-0.82634294, 0.4472136, 0.34228247), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.85591346, 0.4472136, 0.25963852), (-0.8772411, 0.4472136, 0.17449409), (-0.8772411, 0.4472136, 0.17449409), (-0.8772411, 0.4472136, 0.17449409), (-0.8772411, 0.4472136, 0.17449409), (-0.8901203, 0.44721362, 0.087669194), (-0.89012027, 0.4472136, 0.08766919), (-0.89012027, 0.4472136, 0.08766919), (-0.8901203, 0.44721362, 0.087669194), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.8944272, 0.4472136, 1.0953574e-16), (-0.8901203, 0.44721362, -0.087669194), (-0.89012027, 0.4472136, -0.08766919), (-0.89012027, 0.4472136, -0.08766919), (-0.8901203, 0.44721362, -0.087669194), (-0.8772411, 0.4472136, -0.17449409), (-0.8772411, 0.4472136, -0.17449409), (-0.8772411, 0.4472136, -0.17449409), (-0.8772411, 0.4472136, -0.17449409), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.85591346, 0.4472136, -0.25963852), (-0.82634294, 0.4472136, -0.34228247), (-0.826343, 0.4472136, -0.34228247), (-0.826343, 0.4472136, -0.34228247), (-0.82634294, 0.4472136, -0.34228247), (-0.78881437, 0.4472136, -0.42163005), (-0.78881437, 0.44721365, -0.42163008), (-0.78881437, 0.44721365, -0.42163008), (-0.78881437, 0.4472136, -0.42163005), (-0.743689, 0.4472136, -0.49691713), (-0.74368906, 0.4472136, -0.49691716), (-0.74368906, 0.4472136, -0.49691716), (-0.743689, 0.4472136, -0.49691713), (-0.69140154, 0.4472136, -0.5674186), (-0.6914016, 0.4472136, -0.5674186), (-0.6914016, 0.4472136, -0.5674186), (-0.69140154, 0.4472136, -0.5674186), (-0.6324555, 0.4472136, -0.6324555), (-0.6324555, 0.4472136, -0.6324555), (-0.6324555, 0.4472136, -0.6324555), (-0.6324555, 0.4472136, -0.6324555), (-0.5674186, 0.4472136, -0.69140154), (-0.5674186, 0.4472136, -0.6914016), (-0.5674186, 0.4472136, -0.6914016), (-0.5674186, 0.4472136, -0.69140154), (-0.49691713, 0.4472136, -0.743689), (-0.49691716, 0.4472136, -0.74368906), (-0.49691716, 0.4472136, -0.74368906), (-0.49691713, 0.4472136, -0.743689), (-0.42163005, 0.4472136, -0.78881437), (-0.42163008, 0.44721365, -0.78881437), (-0.42163008, 0.44721365, -0.78881437), (-0.42163005, 0.4472136, -0.78881437), (-0.34228247, 0.4472136, -0.82634294), (-0.34228247, 0.4472136, -0.826343), (-0.34228247, 0.4472136, -0.826343), (-0.34228247, 0.4472136, -0.82634294), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.25963852, 0.4472136, -0.85591346), (-0.17449409, 0.4472136, -0.8772411), (-0.17449409, 0.4472136, -0.8772411), (-0.17449409, 0.4472136, -0.8772411), (-0.17449409, 0.4472136, -0.8772411), (-0.087669194, 0.44721362, -0.8901203), (-0.08766919, 0.4472136, -0.89012027), (-0.08766919, 0.4472136, -0.89012027), (-0.087669194, 0.44721362, -0.8901203), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430361e-16, 0.4472136, -0.8944272), (-1.6430361e-16, 0.4472136, -0.8944272), (0.087669194, 0.44721362, -0.8901203), (0.08766919, 0.4472136, -0.89012027), (0.08766919, 0.4472136, -0.89012027), (0.087669194, 0.44721362, -0.8901203), (0.17449409, 0.4472136, -0.8772411), (0.17449409, 0.4472136, -0.8772411), (0.17449409, 0.4472136, -0.8772411), (0.17449409, 0.4472136, -0.8772411), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.25963852, 0.4472136, -0.85591346), (0.34228247, 0.4472136, -0.82634294), (0.34228247, 0.4472136, -0.826343), (0.34228247, 0.4472136, -0.826343), (0.34228247, 0.4472136, -0.82634294), (0.42163005, 0.4472136, -0.78881437), (0.42163008, 0.44721365, -0.78881437), (0.42163008, 0.44721365, -0.78881437), (0.42163005, 0.4472136, -0.78881437), (0.49691713, 0.4472136, -0.743689), (0.49691716, 0.4472136, -0.74368906), (0.49691716, 0.4472136, -0.74368906), (0.49691713, 0.4472136, -0.743689), (0.5674186, 0.4472136, -0.69140154), (0.5674186, 0.4472136, -0.6914016), (0.5674186, 0.4472136, -0.6914016), (0.5674186, 0.4472136, -0.69140154), (0.6324555, 0.4472136, -0.6324555), (0.6324555, 0.4472136, -0.6324555), (0.6324555, 0.4472136, -0.6324555), (0.6324555, 0.4472136, -0.6324555), (0.69140154, 0.4472136, -0.5674186), (0.6914016, 0.4472136, -0.5674186), (0.6914016, 0.4472136, -0.5674186), (0.69140154, 0.4472136, -0.5674186), (0.743689, 0.4472136, -0.49691713), (0.74368906, 0.4472136, -0.49691716), (0.74368906, 0.4472136, -0.49691716), (0.743689, 0.4472136, -0.49691713), (0.78881437, 0.4472136, -0.42163005), (0.78881437, 0.44721365, -0.42163008), (0.78881437, 0.44721365, -0.42163008), (0.78881437, 0.4472136, -0.42163005), (0.82634294, 0.4472136, -0.34228247), (0.826343, 0.4472136, -0.34228247), (0.826343, 0.4472136, -0.34228247), (0.82634294, 0.4472136, -0.34228247), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.85591346, 0.4472136, -0.25963852), (0.8772411, 0.4472136, -0.17449409), (0.8772411, 0.4472136, -0.17449409), (0.8772411, 0.4472136, -0.17449409), (0.8772411, 0.4472136, -0.17449409), (0.8901203, 0.44721362, -0.087669194), (0.89012027, 0.4472136, -0.08766919), (0.89012027, 0.4472136, -0.08766919), (0.8901203, 0.44721362, -0.087669194), (0.8944272, 0.4472136, 0), (0.8944272, 0.4472136, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, 0.99999, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0)] ( interpolation = "faceVarying" ) point3f[] points = [(50, -50, 0), (49.759235, -50, 4.900857), (49.03926, -50, 9.754517), (47.84702, -50, 14.514234), (46.193974, -50, 19.13417), (44.096066, -50, 23.569838), (41.57348, -50, 27.778513), (38.65052, -50, 31.719664), (35.35534, -50, 35.35534), (31.719664, -50, 38.65052), (27.778513, -50, 41.57348), (23.569838, -50, 44.096066), (19.13417, -50, 46.193974), (14.514234, -50, 47.84702), (9.754517, -50, 49.03926), (4.900857, -50, 49.759235), (3.061617e-15, -50, 50), (-4.900857, -50, 49.759235), (-9.754517, -50, 49.03926), (-14.514234, -50, 47.84702), (-19.13417, -50, 46.193974), (-23.569838, -50, 44.096066), (-27.778513, -50, 41.57348), (-31.719664, -50, 38.65052), (-35.35534, -50, 35.35534), (-38.65052, -50, 31.719664), (-41.57348, -50, 27.778513), (-44.096066, -50, 23.569838), (-46.193974, -50, 19.13417), (-47.84702, -50, 14.514234), (-49.03926, -50, 9.754517), (-49.759235, -50, 4.900857), (-50, -50, 6.123234e-15), (-49.759235, -50, -4.900857), (-49.03926, -50, -9.754517), (-47.84702, -50, -14.514234), (-46.193974, -50, -19.13417), (-44.096066, -50, -23.569838), (-41.57348, -50, -27.778513), (-38.65052, -50, -31.719664), (-35.35534, -50, -35.35534), (-31.719664, -50, -38.65052), (-27.778513, -50, -41.57348), (-23.569838, -50, -44.096066), (-19.13417, -50, -46.193974), (-14.514234, -50, -47.84702), (-9.754517, -50, -49.03926), (-4.900857, -50, -49.759235), (-9.184851e-15, -50, -50), (4.900857, -50, -49.759235), (9.754517, -50, -49.03926), (14.514234, -50, -47.84702), (19.13417, -50, -46.193974), (23.569838, -50, -44.096066), (27.778513, -50, -41.57348), (31.719664, -50, -38.65052), (35.35534, -50, -35.35534), (38.65052, -50, -31.719664), (41.57348, -50, -27.778513), (44.096066, -50, -23.569838), (46.193974, -50, -19.13417), (47.84702, -50, -14.514234), (49.03926, -50, -9.754517), (49.759235, -50, -4.900857), (33.3335, -16.667, 0), (33.17299, -16.667, 3.2672544), (32.69301, -16.667, 6.503043), (31.89817, -16.667, 9.676205), (30.796137, -16.667, 12.756178), (29.397524, -16.667, 15.713303), (27.715794, -16.667, 18.5191), (25.767145, -16.667, 21.146547), (23.570343, -16.667, 23.570343), (21.146547, -16.667, 25.767145), (18.5191, -16.667, 27.715794), (15.713303, -16.667, 29.397524), (12.756178, -16.667, 30.796137), (9.676205, -16.667, 31.89817), (6.503043, -16.667, 32.69301), (3.2672544, -16.667, 33.17299), (2.041088e-15, -16.667, 33.3335), (-3.2672544, -16.667, 33.17299), (-6.503043, -16.667, 32.69301), (-9.676205, -16.667, 31.89817), (-12.756178, -16.667, 30.796137), (-15.713303, -16.667, 29.397524), (-18.5191, -16.667, 27.715794), (-21.146547, -16.667, 25.767145), (-23.570343, -16.667, 23.570343), (-25.767145, -16.667, 21.146547), (-27.715794, -16.667, 18.5191), (-29.397524, -16.667, 15.713303), (-30.796137, -16.667, 12.756178), (-31.89817, -16.667, 9.676205), (-32.69301, -16.667, 6.503043), (-33.17299, -16.667, 3.2672544), (-33.3335, -16.667, 4.082176e-15), (-33.17299, -16.667, -3.2672544), (-32.69301, -16.667, -6.503043), (-31.89817, -16.667, -9.676205), (-30.796137, -16.667, -12.756178), (-29.397524, -16.667, -15.713303), (-27.715794, -16.667, -18.5191), (-25.767145, -16.667, -21.146547), (-23.570343, -16.667, -23.570343), (-21.146547, -16.667, -25.767145), (-18.5191, -16.667, -27.715794), (-15.713303, -16.667, -29.397524), (-12.756178, -16.667, -30.796137), (-9.676205, -16.667, -31.89817), (-6.503043, -16.667, -32.69301), (-3.2672544, -16.667, -33.17299), (-6.1232647e-15, -16.667, -33.3335), (3.2672544, -16.667, -33.17299), (6.503043, -16.667, -32.69301), (9.676205, -16.667, -31.89817), (12.756178, -16.667, -30.796137), (15.713303, -16.667, -29.397524), (18.5191, -16.667, -27.715794), (21.146547, -16.667, -25.767145), (23.570343, -16.667, -23.570343), (25.767145, -16.667, -21.146547), (27.715794, -16.667, -18.5191), (29.397524, -16.667, -15.713303), (30.796137, -16.667, -12.756178), (31.89817, -16.667, -9.676205), (32.69301, -16.667, -6.503043), (33.17299, -16.667, -3.2672544), (16.667, 16.666, 0), (16.586742, 16.666, 1.6336517), (16.346748, 16.666, 3.2515705), (15.949326, 16.666, 4.838175), (15.3983, 16.666, 6.378185), (14.698982, 16.666, 7.856769), (13.858104, 16.666, 9.259689), (12.883764, 16.666, 10.573433), (11.785349, 16.666, 11.785349), (10.573433, 16.666, 12.883764), (9.259689, 16.666, 13.858104), (7.856769, 16.666, 14.698982), (6.378185, 16.666, 15.3983), (4.838175, 16.666, 15.949326), (3.2515705, 16.666, 16.346748), (1.6336517, 16.666, 16.586742), (1.0205594e-15, 16.666, 16.667), (-1.6336517, 16.666, 16.586742), (-3.2515705, 16.666, 16.346748), (-4.838175, 16.666, 15.949326), (-6.378185, 16.666, 15.3983), (-7.856769, 16.666, 14.698982), (-9.259689, 16.666, 13.858104), (-10.573433, 16.666, 12.883764), (-11.785349, 16.666, 11.785349), (-12.883764, 16.666, 10.573433), (-13.858104, 16.666, 9.259689), (-14.698982, 16.666, 7.856769), (-15.3983, 16.666, 6.378185), (-15.949326, 16.666, 4.838175), (-16.346748, 16.666, 3.2515705), (-16.586742, 16.666, 1.6336517), (-16.667, 16.666, 2.0411188e-15), (-16.586742, 16.666, -1.6336517), (-16.346748, 16.666, -3.2515705), (-15.949326, 16.666, -4.838175), (-15.3983, 16.666, -6.378185), (-14.698982, 16.666, -7.856769), (-13.858104, 16.666, -9.259689), (-12.883764, 16.666, -10.573433), (-11.785349, 16.666, -11.785349), (-10.573433, 16.666, -12.883764), (-9.259689, 16.666, -13.858104), (-7.856769, 16.666, -14.698982), (-6.378185, 16.666, -15.3983), (-4.838175, 16.666, -15.949326), (-3.2515705, 16.666, -16.346748), (-1.6336517, 16.666, -16.586742), (-3.0616783e-15, 16.666, -16.667), (1.6336517, 16.666, -16.586742), (3.2515705, 16.666, -16.346748), (4.838175, 16.666, -15.949326), (6.378185, 16.666, -15.3983), (7.856769, 16.666, -14.698982), (9.259689, 16.666, -13.858104), (10.573433, 16.666, -12.883764), (11.785349, 16.666, -11.785349), (12.883764, 16.666, -10.573433), (13.858104, 16.666, -9.259689), (14.698982, 16.666, -7.856769), (15.3983, 16.666, -6.378185), (15.949326, 16.666, -4.838175), (16.346748, 16.666, -3.2515705), (16.586742, 16.666, -1.6336517), (0.00049999997, 49.999, 0), (0.0004975924, 49.999, 0.00004900857), (0.0004903926, 49.999, 0.00009754516), (0.00047847015, 49.999, 0.00014514233), (0.00046193978, 49.999, 0.00019134172), (0.00044096063, 49.999, 0.00023569838), (0.0004157348, 49.999, 0.00027778512), (0.00038650524, 49.999, 0.00031719665), (0.0003535534, 49.999, 0.0003535534), (0.00031719665, 49.999, 0.00038650524), (0.00027778512, 49.999, 0.0004157348), (0.00023569838, 49.999, 0.00044096063), (0.00019134172, 49.999, 0.00046193978), (0.00014514233, 49.999, 0.00047847015), (0.00009754516, 49.999, 0.0004903926), (0.00004900857, 49.999, 0.0004975924), (3.0616168e-20, 49.999, 0.00049999997), (-0.00004900857, 49.999, 0.0004975924), (-0.00009754516, 49.999, 0.0004903926), (-0.00014514233, 49.999, 0.00047847015), (-0.00019134172, 49.999, 0.00046193978), (-0.00023569838, 49.999, 0.00044096063), (-0.00027778512, 49.999, 0.0004157348), (-0.00031719665, 49.999, 0.00038650524), (-0.0003535534, 49.999, 0.0003535534), (-0.00038650524, 49.999, 0.00031719665), (-0.0004157348, 49.999, 0.00027778512), (-0.00044096063, 49.999, 0.00023569838), (-0.00046193978, 49.999, 0.00019134172), (-0.00047847015, 49.999, 0.00014514233), (-0.0004903926, 49.999, 0.00009754516), (-0.0004975924, 49.999, 0.00004900857), (-0.00049999997, 49.999, 6.1232336e-20), (-0.0004975924, 49.999, -0.00004900857), (-0.0004903926, 49.999, -0.00009754516), (-0.00047847015, 49.999, -0.00014514233), (-0.00046193978, 49.999, -0.00019134172), (-0.00044096063, 49.999, -0.00023569838), (-0.0004157348, 49.999, -0.00027778512), (-0.00038650524, 49.999, -0.00031719665), (-0.0003535534, 49.999, -0.0003535534), (-0.00031719665, 49.999, -0.00038650524), (-0.00027778512, 49.999, -0.0004157348), (-0.00023569838, 49.999, -0.00044096063), (-0.00019134172, 49.999, -0.00046193978), (-0.00014514233, 49.999, -0.00047847015), (-0.00009754516, 49.999, -0.0004903926), (-0.00004900857, 49.999, -0.0004975924), (-9.184851e-20, 49.999, -0.00049999997), (0.00004900857, 49.999, -0.0004975924), (0.00009754516, 49.999, -0.0004903926), (0.00014514233, 49.999, -0.00047847015), (0.00019134172, 49.999, -0.00046193978), (0.00023569838, 49.999, -0.00044096063), (0.00027778512, 49.999, -0.0004157348), (0.00031719665, 49.999, -0.00038650524), (0.0003535534, 49.999, -0.0003535534), (0.00038650524, 49.999, -0.00031719665), (0.0004157348, 49.999, -0.00027778512), (0.00044096063, 49.999, -0.00023569838), (0.00046193978, 49.999, -0.00019134172), (0.00047847015, 49.999, -0.00014514233), (0.0004903926, 49.999, -0.00009754516), (0.0004975924, 49.999, -0.00004900857), (0, 49.9995, 0), (0, -50, 0)] texCoord2f[] primvars:st = [(1, 0), (1, 0.33333), (0.984375, 0.33333), (0.984375, 0), (0.984375, 0), (0.984375, 0.33333), (0.96875, 0.33333), (0.96875, 0), (0.96875, 0), (0.96875, 0.33333), (0.953125, 0.33333), (0.953125, 0), (0.953125, 0), (0.953125, 0.33333), (0.9375, 0.33333), (0.9375, 0), (0.9375, 0), (0.9375, 0.33333), (0.921875, 0.33333), (0.921875, 0), (0.921875, 0), (0.921875, 0.33333), (0.90625, 0.33333), (0.90625, 0), (0.90625, 0), (0.90625, 0.33333), (0.890625, 0.33333), (0.890625, 0), (0.890625, 0), (0.890625, 0.33333), (0.875, 0.33333), (0.875, 0), (0.875, 0), (0.875, 0.33333), (0.859375, 0.33333), (0.859375, 0), (0.859375, 0), (0.859375, 0.33333), (0.84375, 0.33333), (0.84375, 0), (0.84375, 0), (0.84375, 0.33333), (0.828125, 0.33333), (0.828125, 0), (0.828125, 0), (0.828125, 0.33333), (0.8125, 0.33333), (0.8125, 0), (0.8125, 0), (0.8125, 0.33333), (0.796875, 0.33333), (0.796875, 0), (0.796875, 0), (0.796875, 0.33333), (0.78125, 0.33333), (0.78125, 0), (0.78125, 0), (0.78125, 0.33333), (0.765625, 0.33333), (0.765625, 0), (0.765625, 0), (0.765625, 0.33333), (0.75, 0.33333), (0.75, 0), (0.75, 0), (0.75, 0.33333), (0.734375, 0.33333), (0.734375, 0), (0.734375, 0), (0.734375, 0.33333), (0.71875, 0.33333), (0.71875, 0), (0.71875, 0), (0.71875, 0.33333), (0.703125, 0.33333), (0.703125, 0), (0.703125, 0), (0.703125, 0.33333), (0.6875, 0.33333), (0.6875, 0), (0.6875, 0), (0.6875, 0.33333), (0.671875, 0.33333), (0.671875, 0), (0.671875, 0), (0.671875, 0.33333), (0.65625, 0.33333), (0.65625, 0), (0.65625, 0), (0.65625, 0.33333), (0.640625, 0.33333), (0.640625, 0), (0.640625, 0), (0.640625, 0.33333), (0.625, 0.33333), (0.625, 0), (0.625, 0), (0.625, 0.33333), (0.609375, 0.33333), (0.609375, 0), (0.609375, 0), (0.609375, 0.33333), (0.59375, 0.33333), (0.59375, 0), (0.59375, 0), (0.59375, 0.33333), (0.578125, 0.33333), (0.578125, 0), (0.578125, 0), (0.578125, 0.33333), (0.5625, 0.33333), (0.5625, 0), (0.5625, 0), (0.5625, 0.33333), (0.546875, 0.33333), (0.546875, 0), (0.546875, 0), (0.546875, 0.33333), (0.53125, 0.33333), (0.53125, 0), (0.53125, 0), (0.53125, 0.33333), (0.515625, 0.33333), (0.515625, 0), (0.515625, 0), (0.515625, 0.33333), (0.5, 0.33333), (0.5, 0), (0.5, 0), (0.5, 0.33333), (0.484375, 0.33333), (0.484375, 0), (0.484375, 0), (0.484375, 0.33333), (0.46875, 0.33333), (0.46875, 0), (0.46875, 0), (0.46875, 0.33333), (0.453125, 0.33333), (0.453125, 0), (0.453125, 0), (0.453125, 0.33333), (0.4375, 0.33333), (0.4375, 0), (0.4375, 0), (0.4375, 0.33333), (0.421875, 0.33333), (0.421875, 0), (0.421875, 0), (0.421875, 0.33333), (0.40625, 0.33333), (0.40625, 0), (0.40625, 0), (0.40625, 0.33333), (0.390625, 0.33333), (0.390625, 0), (0.390625, 0), (0.390625, 0.33333), (0.375, 0.33333), (0.375, 0), (0.375, 0), (0.375, 0.33333), (0.359375, 0.33333), (0.359375, 0), (0.359375, 0), (0.359375, 0.33333), (0.34375, 0.33333), (0.34375, 0), (0.34375, 0), (0.34375, 0.33333), (0.328125, 0.33333), (0.328125, 0), (0.328125, 0), (0.328125, 0.33333), (0.3125, 0.33333), (0.3125, 0), (0.3125, 0), (0.3125, 0.33333), (0.296875, 0.33333), (0.296875, 0), (0.296875, 0), (0.296875, 0.33333), (0.28125, 0.33333), (0.28125, 0), (0.28125, 0), (0.28125, 0.33333), (0.265625, 0.33333), (0.265625, 0), (0.265625, 0), (0.265625, 0.33333), (0.25, 0.33333), (0.25, 0), (0.25, 0), (0.25, 0.33333), (0.234375, 0.33333), (0.234375, 0), (0.234375, 0), (0.234375, 0.33333), (0.21875, 0.33333), (0.21875, 0), (0.21875, 0), (0.21875, 0.33333), (0.203125, 0.33333), (0.203125, 0), (0.203125, 0), (0.203125, 0.33333), (0.1875, 0.33333), (0.1875, 0), (0.1875, 0), (0.1875, 0.33333), (0.171875, 0.33333), (0.171875, 0), (0.171875, 0), (0.171875, 0.33333), (0.15625, 0.33333), (0.15625, 0), (0.15625, 0), (0.15625, 0.33333), (0.140625, 0.33333), (0.140625, 0), (0.140625, 0), (0.140625, 0.33333), (0.125, 0.33333), (0.125, 0), (0.125, 0), (0.125, 0.33333), (0.109375, 0.33333), (0.109375, 0), (0.109375, 0), (0.109375, 0.33333), (0.09375, 0.33333), (0.09375, 0), (0.09375, 0), (0.09375, 0.33333), (0.078125, 0.33333), (0.078125, 0), (0.078125, 0), (0.078125, 0.33333), (0.0625, 0.33333), (0.0625, 0), (0.0625, 0), (0.0625, 0.33333), (0.046875, 0.33333), (0.046875, 0), (0.046875, 0), (0.046875, 0.33333), (0.03125, 0.33333), (0.03125, 0), (0.03125, 0), (0.03125, 0.33333), (0.015625, 0.33333), (0.015625, 0), (0.015625, 0), (0.015625, 0.33333), (0, 0.33333), (0, 0), (1, 0.33333), (1, 0.66666), (0.984375, 0.66666), (0.984375, 0.33333), (0.984375, 0.33333), (0.984375, 0.66666), (0.96875, 0.66666), (0.96875, 0.33333), (0.96875, 0.33333), (0.96875, 0.66666), (0.953125, 0.66666), (0.953125, 0.33333), (0.953125, 0.33333), (0.953125, 0.66666), (0.9375, 0.66666), (0.9375, 0.33333), (0.9375, 0.33333), (0.9375, 0.66666), (0.921875, 0.66666), (0.921875, 0.33333), (0.921875, 0.33333), (0.921875, 0.66666), (0.90625, 0.66666), (0.90625, 0.33333), (0.90625, 0.33333), (0.90625, 0.66666), (0.890625, 0.66666), (0.890625, 0.33333), (0.890625, 0.33333), (0.890625, 0.66666), (0.875, 0.66666), (0.875, 0.33333), (0.875, 0.33333), (0.875, 0.66666), (0.859375, 0.66666), (0.859375, 0.33333), (0.859375, 0.33333), (0.859375, 0.66666), (0.84375, 0.66666), (0.84375, 0.33333), (0.84375, 0.33333), (0.84375, 0.66666), (0.828125, 0.66666), (0.828125, 0.33333), (0.828125, 0.33333), (0.828125, 0.66666), (0.8125, 0.66666), (0.8125, 0.33333), (0.8125, 0.33333), (0.8125, 0.66666), (0.796875, 0.66666), (0.796875, 0.33333), (0.796875, 0.33333), (0.796875, 0.66666), (0.78125, 0.66666), (0.78125, 0.33333), (0.78125, 0.33333), (0.78125, 0.66666), (0.765625, 0.66666), (0.765625, 0.33333), (0.765625, 0.33333), (0.765625, 0.66666), (0.75, 0.66666), (0.75, 0.33333), (0.75, 0.33333), (0.75, 0.66666), (0.734375, 0.66666), (0.734375, 0.33333), (0.734375, 0.33333), (0.734375, 0.66666), (0.71875, 0.66666), (0.71875, 0.33333), (0.71875, 0.33333), (0.71875, 0.66666), (0.703125, 0.66666), (0.703125, 0.33333), (0.703125, 0.33333), (0.703125, 0.66666), (0.6875, 0.66666), (0.6875, 0.33333), (0.6875, 0.33333), (0.6875, 0.66666), (0.671875, 0.66666), (0.671875, 0.33333), (0.671875, 0.33333), (0.671875, 0.66666), (0.65625, 0.66666), (0.65625, 0.33333), (0.65625, 0.33333), (0.65625, 0.66666), (0.640625, 0.66666), (0.640625, 0.33333), (0.640625, 0.33333), (0.640625, 0.66666), (0.625, 0.66666), (0.625, 0.33333), (0.625, 0.33333), (0.625, 0.66666), (0.609375, 0.66666), (0.609375, 0.33333), (0.609375, 0.33333), (0.609375, 0.66666), (0.59375, 0.66666), (0.59375, 0.33333), (0.59375, 0.33333), (0.59375, 0.66666), (0.578125, 0.66666), (0.578125, 0.33333), (0.578125, 0.33333), (0.578125, 0.66666), (0.5625, 0.66666), (0.5625, 0.33333), (0.5625, 0.33333), (0.5625, 0.66666), (0.546875, 0.66666), (0.546875, 0.33333), (0.546875, 0.33333), (0.546875, 0.66666), (0.53125, 0.66666), (0.53125, 0.33333), (0.53125, 0.33333), (0.53125, 0.66666), (0.515625, 0.66666), (0.515625, 0.33333), (0.515625, 0.33333), (0.515625, 0.66666), (0.5, 0.66666), (0.5, 0.33333), (0.5, 0.33333), (0.5, 0.66666), (0.484375, 0.66666), (0.484375, 0.33333), (0.484375, 0.33333), (0.484375, 0.66666), (0.46875, 0.66666), (0.46875, 0.33333), (0.46875, 0.33333), (0.46875, 0.66666), (0.453125, 0.66666), (0.453125, 0.33333), (0.453125, 0.33333), (0.453125, 0.66666), (0.4375, 0.66666), (0.4375, 0.33333), (0.4375, 0.33333), (0.4375, 0.66666), (0.421875, 0.66666), (0.421875, 0.33333), (0.421875, 0.33333), (0.421875, 0.66666), (0.40625, 0.66666), (0.40625, 0.33333), (0.40625, 0.33333), (0.40625, 0.66666), (0.390625, 0.66666), (0.390625, 0.33333), (0.390625, 0.33333), (0.390625, 0.66666), (0.375, 0.66666), (0.375, 0.33333), (0.375, 0.33333), (0.375, 0.66666), (0.359375, 0.66666), (0.359375, 0.33333), (0.359375, 0.33333), (0.359375, 0.66666), (0.34375, 0.66666), (0.34375, 0.33333), (0.34375, 0.33333), (0.34375, 0.66666), (0.328125, 0.66666), (0.328125, 0.33333), (0.328125, 0.33333), (0.328125, 0.66666), (0.3125, 0.66666), (0.3125, 0.33333), (0.3125, 0.33333), (0.3125, 0.66666), (0.296875, 0.66666), (0.296875, 0.33333), (0.296875, 0.33333), (0.296875, 0.66666), (0.28125, 0.66666), (0.28125, 0.33333), (0.28125, 0.33333), (0.28125, 0.66666), (0.265625, 0.66666), (0.265625, 0.33333), (0.265625, 0.33333), (0.265625, 0.66666), (0.25, 0.66666), (0.25, 0.33333), (0.25, 0.33333), (0.25, 0.66666), (0.234375, 0.66666), (0.234375, 0.33333), (0.234375, 0.33333), (0.234375, 0.66666), (0.21875, 0.66666), (0.21875, 0.33333), (0.21875, 0.33333), (0.21875, 0.66666), (0.203125, 0.66666), (0.203125, 0.33333), (0.203125, 0.33333), (0.203125, 0.66666), (0.1875, 0.66666), (0.1875, 0.33333), (0.1875, 0.33333), (0.1875, 0.66666), (0.171875, 0.66666), (0.171875, 0.33333), (0.171875, 0.33333), (0.171875, 0.66666), (0.15625, 0.66666), (0.15625, 0.33333), (0.15625, 0.33333), (0.15625, 0.66666), (0.140625, 0.66666), (0.140625, 0.33333), (0.140625, 0.33333), (0.140625, 0.66666), (0.125, 0.66666), (0.125, 0.33333), (0.125, 0.33333), (0.125, 0.66666), (0.109375, 0.66666), (0.109375, 0.33333), (0.109375, 0.33333), (0.109375, 0.66666), (0.09375, 0.66666), (0.09375, 0.33333), (0.09375, 0.33333), (0.09375, 0.66666), (0.078125, 0.66666), (0.078125, 0.33333), (0.078125, 0.33333), (0.078125, 0.66666), (0.0625, 0.66666), (0.0625, 0.33333), (0.0625, 0.33333), (0.0625, 0.66666), (0.046875, 0.66666), (0.046875, 0.33333), (0.046875, 0.33333), (0.046875, 0.66666), (0.03125, 0.66666), (0.03125, 0.33333), (0.03125, 0.33333), (0.03125, 0.66666), (0.015625, 0.66666), (0.015625, 0.33333), (0.015625, 0.33333), (0.015625, 0.66666), (0, 0.66666), (0, 0.33333), (1, 0.66666), (1, 1), (0.984375, 1), (0.984375, 0.66666), (0.984375, 0.66666), (0.984375, 1), (0.96875, 1), (0.96875, 0.66666), (0.96875, 0.66666), (0.96875, 1), (0.953125, 1), (0.953125, 0.66666), (0.953125, 0.66666), (0.953125, 1), (0.9375, 1), (0.9375, 0.66666), (0.9375, 0.66666), (0.9375, 1), (0.921875, 1), (0.921875, 0.66666), (0.921875, 0.66666), (0.921875, 1), (0.90625, 1), (0.90625, 0.66666), (0.90625, 0.66666), (0.90625, 1), (0.890625, 1), (0.890625, 0.66666), (0.890625, 0.66666), (0.890625, 1), (0.875, 1), (0.875, 0.66666), (0.875, 0.66666), (0.875, 1), (0.859375, 1), (0.859375, 0.66666), (0.859375, 0.66666), (0.859375, 1), (0.84375, 1), (0.84375, 0.66666), (0.84375, 0.66666), (0.84375, 1), (0.828125, 1), (0.828125, 0.66666), (0.828125, 0.66666), (0.828125, 1), (0.8125, 1), (0.8125, 0.66666), (0.8125, 0.66666), (0.8125, 1), (0.796875, 1), (0.796875, 0.66666), (0.796875, 0.66666), (0.796875, 1), (0.78125, 1), (0.78125, 0.66666), (0.78125, 0.66666), (0.78125, 1), (0.765625, 1), (0.765625, 0.66666), (0.765625, 0.66666), (0.765625, 1), (0.75, 1), (0.75, 0.66666), (0.75, 0.66666), (0.75, 1), (0.734375, 1), (0.734375, 0.66666), (0.734375, 0.66666), (0.734375, 1), (0.71875, 1), (0.71875, 0.66666), (0.71875, 0.66666), (0.71875, 1), (0.703125, 1), (0.703125, 0.66666), (0.703125, 0.66666), (0.703125, 1), (0.6875, 1), (0.6875, 0.66666), (0.6875, 0.66666), (0.6875, 1), (0.671875, 1), (0.671875, 0.66666), (0.671875, 0.66666), (0.671875, 1), (0.65625, 1), (0.65625, 0.66666), (0.65625, 0.66666), (0.65625, 1), (0.640625, 1), (0.640625, 0.66666), (0.640625, 0.66666), (0.640625, 1), (0.625, 1), (0.625, 0.66666), (0.625, 0.66666), (0.625, 1), (0.609375, 1), (0.609375, 0.66666), (0.609375, 0.66666), (0.609375, 1), (0.59375, 1), (0.59375, 0.66666), (0.59375, 0.66666), (0.59375, 1), (0.578125, 1), (0.578125, 0.66666), (0.578125, 0.66666), (0.578125, 1), (0.5625, 1), (0.5625, 0.66666), (0.5625, 0.66666), (0.5625, 1), (0.546875, 1), (0.546875, 0.66666), (0.546875, 0.66666), (0.546875, 1), (0.53125, 1), (0.53125, 0.66666), (0.53125, 0.66666), (0.53125, 1), (0.515625, 1), (0.515625, 0.66666), (0.515625, 0.66666), (0.515625, 1), (0.5, 1), (0.5, 0.66666), (0.5, 0.66666), (0.5, 1), (0.484375, 1), (0.484375, 0.66666), (0.484375, 0.66666), (0.484375, 1), (0.46875, 1), (0.46875, 0.66666), (0.46875, 0.66666), (0.46875, 1), (0.453125, 1), (0.453125, 0.66666), (0.453125, 0.66666), (0.453125, 1), (0.4375, 1), (0.4375, 0.66666), (0.4375, 0.66666), (0.4375, 1), (0.421875, 1), (0.421875, 0.66666), (0.421875, 0.66666), (0.421875, 1), (0.40625, 1), (0.40625, 0.66666), (0.40625, 0.66666), (0.40625, 1), (0.390625, 1), (0.390625, 0.66666), (0.390625, 0.66666), (0.390625, 1), (0.375, 1), (0.375, 0.66666), (0.375, 0.66666), (0.375, 1), (0.359375, 1), (0.359375, 0.66666), (0.359375, 0.66666), (0.359375, 1), (0.34375, 1), (0.34375, 0.66666), (0.34375, 0.66666), (0.34375, 1), (0.328125, 1), (0.328125, 0.66666), (0.328125, 0.66666), (0.328125, 1), (0.3125, 1), (0.3125, 0.66666), (0.3125, 0.66666), (0.3125, 1), (0.296875, 1), (0.296875, 0.66666), (0.296875, 0.66666), (0.296875, 1), (0.28125, 1), (0.28125, 0.66666), (0.28125, 0.66666), (0.28125, 1), (0.265625, 1), (0.265625, 0.66666), (0.265625, 0.66666), (0.265625, 1), (0.25, 1), (0.25, 0.66666), (0.25, 0.66666), (0.25, 1), (0.234375, 1), (0.234375, 0.66666), (0.234375, 0.66666), (0.234375, 1), (0.21875, 1), (0.21875, 0.66666), (0.21875, 0.66666), (0.21875, 1), (0.203125, 1), (0.203125, 0.66666), (0.203125, 0.66666), (0.203125, 1), (0.1875, 1), (0.1875, 0.66666), (0.1875, 0.66666), (0.1875, 1), (0.171875, 1), (0.171875, 0.66666), (0.171875, 0.66666), (0.171875, 1), (0.15625, 1), (0.15625, 0.66666), (0.15625, 0.66666), (0.15625, 1), (0.140625, 1), (0.140625, 0.66666), (0.140625, 0.66666), (0.140625, 1), (0.125, 1), (0.125, 0.66666), (0.125, 0.66666), (0.125, 1), (0.109375, 1), (0.109375, 0.66666), (0.109375, 0.66666), (0.109375, 1), (0.09375, 1), (0.09375, 0.66666), (0.09375, 0.66666), (0.09375, 1), (0.078125, 1), (0.078125, 0.66666), (0.078125, 0.66666), (0.078125, 1), (0.0625, 1), (0.0625, 0.66666), (0.0625, 0.66666), (0.0625, 1), (0.046875, 1), (0.046875, 0.66666), (0.046875, 0.66666), (0.046875, 1), (0.03125, 1), (0.03125, 0.66666), (0.03125, 0.66666), (0.03125, 1), (0.015625, 1), (0.015625, 0.66666), (0.015625, 0.66666), (0.015625, 1), (0, 1), (0, 0.66666), (1, 0.5), (0.5, 0.5), (0.99759233, 0.45099142), (0.99759233, 0.45099142), (0.5, 0.5), (0.99039257, 0.40245482), (0.99039257, 0.40245482), (0.5, 0.5), (0.9784702, 0.35485768), (0.9784702, 0.35485768), (0.5, 0.5), (0.9619397, 0.3086583), (0.9619397, 0.3086583), (0.5, 0.5), (0.94096065, 0.26430163), (0.94096065, 0.26430163), (0.5, 0.5), (0.91573477, 0.22221488), (0.91573477, 0.22221488), (0.5, 0.5), (0.88650525, 0.18280336), (0.88650525, 0.18280336), (0.5, 0.5), (0.8535534, 0.14644662), (0.8535534, 0.14644662), (0.5, 0.5), (0.8171966, 0.11349478), (0.8171966, 0.11349478), (0.5, 0.5), (0.7777851, 0.0842652), (0.7777851, 0.0842652), (0.5, 0.5), (0.73569834, 0.059039354), (0.73569834, 0.059039354), (0.5, 0.5), (0.6913417, 0.038060278), (0.6913417, 0.038060278), (0.5, 0.5), (0.6451423, 0.021529794), (0.6451423, 0.021529794), (0.5, 0.5), (0.59754515, 0.0096074045), (0.59754515, 0.0096074045), (0.5, 0.5), (0.5490086, 0.0024076402), (0.5490086, 0.0024076402), (0.5, 0.5), (0.5, 0), (0.5, 0), (0.5, 0.5), (0.45099145, 0.0024076402), (0.45099145, 0.0024076402), (0.5, 0.5), (0.40245485, 0.0096074045), (0.40245485, 0.0096074045), (0.5, 0.5), (0.35485768, 0.021529794), (0.35485768, 0.021529794), (0.5, 0.5), (0.3086583, 0.038060278), (0.3086583, 0.038060278), (0.5, 0.5), (0.26430166, 0.059039354), (0.26430166, 0.059039354), (0.5, 0.5), (0.22221488, 0.0842652), (0.22221488, 0.0842652), (0.5, 0.5), (0.18280339, 0.11349478), (0.18280339, 0.11349478), (0.5, 0.5), (0.14644659, 0.14644662), (0.14644659, 0.14644662), (0.5, 0.5), (0.113494754, 0.18280336), (0.113494754, 0.18280336), (0.5, 0.5), (0.08426523, 0.22221488), (0.08426523, 0.22221488), (0.5, 0.5), (0.059039354, 0.26430163), (0.059039354, 0.26430163), (0.5, 0.5), (0.038060308, 0.3086583), (0.038060308, 0.3086583), (0.5, 0.5), (0.021529794, 0.35485768), (0.021529794, 0.35485768), (0.5, 0.5), (0.009607434, 0.40245482), (0.009607434, 0.40245482), (0.5, 0.5), (0.00240767, 0.45099142), (0.00240767, 0.45099142), (0.5, 0.5), (0, 0.5), (0, 0.5), (0.5, 0.5), (0.00240767, 0.54900855), (0.00240767, 0.54900855), (0.5, 0.5), (0.009607434, 0.59754515), (0.009607434, 0.59754515), (0.5, 0.5), (0.021529794, 0.6451423), (0.021529794, 0.6451423), (0.5, 0.5), (0.038060308, 0.6913417), (0.038060308, 0.6913417), (0.5, 0.5), (0.059039354, 0.73569834), (0.059039354, 0.73569834), (0.5, 0.5), (0.08426523, 0.7777851), (0.08426523, 0.7777851), (0.5, 0.5), (0.113494754, 0.8171966), (0.113494754, 0.8171966), (0.5, 0.5), (0.14644659, 0.8535534), (0.14644659, 0.8535534), (0.5, 0.5), (0.18280339, 0.88650525), (0.18280339, 0.88650525), (0.5, 0.5), (0.22221488, 0.91573477), (0.22221488, 0.91573477), (0.5, 0.5), (0.26430166, 0.94096065), (0.26430166, 0.94096065), (0.5, 0.5), (0.3086583, 0.9619397), (0.3086583, 0.9619397), (0.5, 0.5), (0.35485768, 0.9784702), (0.35485768, 0.9784702), (0.5, 0.5), (0.40245485, 0.99039257), (0.40245485, 0.99039257), (0.5, 0.5), (0.45099145, 0.99759233), (0.45099145, 0.99759233), (0.5, 0.5), (0.5, 1), (0.5, 1), (0.5, 0.5), (0.5490086, 0.99759233), (0.5490086, 0.99759233), (0.5, 0.5), (0.59754515, 0.99039257), (0.59754515, 0.99039257), (0.5, 0.5), (0.6451423, 0.9784702), (0.6451423, 0.9784702), (0.5, 0.5), (0.6913417, 0.9619397), (0.6913417, 0.9619397), (0.5, 0.5), (0.73569834, 0.94096065), (0.73569834, 0.94096065), (0.5, 0.5), (0.7777851, 0.91573477), (0.7777851, 0.91573477), (0.5, 0.5), (0.8171966, 0.88650525), (0.8171966, 0.88650525), (0.5, 0.5), (0.8535534, 0.8535534), (0.8535534, 0.8535534), (0.5, 0.5), (0.88650525, 0.8171966), (0.88650525, 0.8171966), (0.5, 0.5), (0.91573477, 0.7777851), (0.91573477, 0.7777851), (0.5, 0.5), (0.94096065, 0.73569834), (0.94096065, 0.73569834), (0.5, 0.5), (0.9619397, 0.6913417), (0.9619397, 0.6913417), (0.5, 0.5), (0.9784702, 0.6451423), (0.9784702, 0.6451423), (0.5, 0.5), (0.99039257, 0.59754515), (0.99039257, 0.59754515), (0.5, 0.5), (0.99759233, 0.54900855), (0.99759233, 0.54900855), (0.5, 0.5), (1, 0.5), (1, 0.5), (0.99759233, 0.5490086), (0.5, 0.5), (0.99759233, 0.5490086), (0.99039257, 0.59754515), (0.5, 0.5), (0.99039257, 0.59754515), (0.9784702, 0.6451423), (0.5, 0.5), (0.9784702, 0.6451423), (0.9619397, 0.6913417), (0.5, 0.5), (0.9619397, 0.6913417), (0.94096065, 0.73569834), (0.5, 0.5), (0.94096065, 0.73569834), (0.91573477, 0.7777851), (0.5, 0.5), (0.91573477, 0.7777851), (0.88650525, 0.8171966), (0.5, 0.5), (0.88650525, 0.8171966), (0.8535534, 0.8535534), (0.5, 0.5), (0.8535534, 0.8535534), (0.8171966, 0.88650525), (0.5, 0.5), (0.8171966, 0.88650525), (0.7777851, 0.91573477), (0.5, 0.5), (0.7777851, 0.91573477), (0.73569834, 0.94096065), (0.5, 0.5), (0.73569834, 0.94096065), (0.6913417, 0.9619397), (0.5, 0.5), (0.6913417, 0.9619397), (0.6451423, 0.9784702), (0.5, 0.5), (0.6451423, 0.9784702), (0.59754515, 0.99039257), (0.5, 0.5), (0.59754515, 0.99039257), (0.5490086, 0.99759233), (0.5, 0.5), (0.5490086, 0.99759233), (0.5, 1), (0.5, 0.5), (0.5, 1), (0.45099145, 0.99759233), (0.5, 0.5), (0.45099145, 0.99759233), (0.40245485, 0.99039257), (0.5, 0.5), (0.40245485, 0.99039257), (0.35485768, 0.9784702), (0.5, 0.5), (0.35485768, 0.9784702), (0.3086583, 0.9619397), (0.5, 0.5), (0.3086583, 0.9619397), (0.26430166, 0.94096065), (0.5, 0.5), (0.26430166, 0.94096065), (0.22221488, 0.91573477), (0.5, 0.5), (0.22221488, 0.91573477), (0.18280339, 0.88650525), (0.5, 0.5), (0.18280339, 0.88650525), (0.14644659, 0.8535534), (0.5, 0.5), (0.14644659, 0.8535534), (0.113494754, 0.8171966), (0.5, 0.5), (0.113494754, 0.8171966), (0.08426523, 0.7777851), (0.5, 0.5), (0.08426523, 0.7777851), (0.059039354, 0.73569834), (0.5, 0.5), (0.059039354, 0.73569834), (0.038060308, 0.6913417), (0.5, 0.5), (0.038060308, 0.6913417), (0.021529794, 0.6451423), (0.5, 0.5), (0.021529794, 0.6451423), (0.009607434, 0.59754515), (0.5, 0.5), (0.009607434, 0.59754515), (0.00240767, 0.5490086), (0.5, 0.5), (0.00240767, 0.5490086), (0, 0.5), (0.5, 0.5), (0, 0.5), (0.00240767, 0.45099145), (0.5, 0.5), (0.00240767, 0.45099145), (0.009607434, 0.40245485), (0.5, 0.5), (0.009607434, 0.40245485), (0.021529794, 0.35485768), (0.5, 0.5), (0.021529794, 0.35485768), (0.038060308, 0.3086583), (0.5, 0.5), (0.038060308, 0.3086583), (0.059039354, 0.26430166), (0.5, 0.5), (0.059039354, 0.26430166), (0.08426523, 0.22221488), (0.5, 0.5), (0.08426523, 0.22221488), (0.113494754, 0.18280339), (0.5, 0.5), (0.113494754, 0.18280339), (0.14644659, 0.14644659), (0.5, 0.5), (0.14644659, 0.14644659), (0.18280339, 0.113494754), (0.5, 0.5), (0.18280339, 0.113494754), (0.22221488, 0.08426523), (0.5, 0.5), (0.22221488, 0.08426523), (0.26430166, 0.059039354), (0.5, 0.5), (0.26430166, 0.059039354), (0.3086583, 0.038060308), (0.5, 0.5), (0.3086583, 0.038060308), (0.35485768, 0.021529794), (0.5, 0.5), (0.35485768, 0.021529794), (0.40245485, 0.009607434), (0.5, 0.5), (0.40245485, 0.009607434), (0.45099145, 0.00240767), (0.5, 0.5), (0.45099145, 0.00240767), (0.5, 0), (0.5, 0.5), (0.5, 0), (0.5490086, 0.00240767), (0.5, 0.5), (0.5490086, 0.00240767), (0.59754515, 0.009607434), (0.5, 0.5), (0.59754515, 0.009607434), (0.6451423, 0.021529794), (0.5, 0.5), (0.6451423, 0.021529794), (0.6913417, 0.038060308), (0.5, 0.5), (0.6913417, 0.038060308), (0.73569834, 0.059039354), (0.5, 0.5), (0.73569834, 0.059039354), (0.7777851, 0.08426523), (0.5, 0.5), (0.7777851, 0.08426523), (0.8171966, 0.113494754), (0.5, 0.5), (0.8171966, 0.113494754), (0.8535534, 0.14644659), (0.5, 0.5), (0.8535534, 0.14644659), (0.88650525, 0.18280339), (0.5, 0.5), (0.88650525, 0.18280339), (0.91573477, 0.22221488), (0.5, 0.5), (0.91573477, 0.22221488), (0.94096065, 0.26430166), (0.5, 0.5), (0.94096065, 0.26430166), (0.9619397, 0.3086583), (0.5, 0.5), (0.9619397, 0.3086583), (0.9784702, 0.35485768), (0.5, 0.5), (0.9784702, 0.35485768), (0.99039257, 0.40245485), (0.5, 0.5), (0.99039257, 0.40245485), (0.99759233, 0.45099145), (0.5, 0.5), (0.99759233, 0.45099145), (1, 0.5), (0.5, 0.5)] ( interpolation = "faceVarying" ) uniform token subdivisionScheme = "none" double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Xform "Xform" { double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } }
omniverse-code/kit/exts/omni.kit.exec.debug/omni/kit/exec/debug/execution_debug_page.py
"""EF Execution Debugging Page""" import omni.ui as ui from omni.kit.exec.core.unstable import dump_graph_topology from omni.kit.window.preferences import PreferenceBuilder, SettingType class ExecutionDebugPage(PreferenceBuilder): """EF Execution Debugging Page""" def __init__(self): super().__init__("Execution") # Setting keys. When changing, make sure to update ExecutionController.cpp as well. self.serial_eg = "/app/execution/debug/forceSerial" self.parallel_eg = "/app/execution/debug/forceParallel" # ID counter for file path write-out. self.id = 0 self.file_name = "ExecutionGraph_" def build(self): """Build the EF execution debugging page""" with ui.VStack(height=0): with self.add_frame("Execution Debugging"): with ui.VStack(): dump_graph_topology_button = ui.Button("Dump execution graph", width=24) dump_graph_topology_button.set_clicked_fn(self._dump_graph_topology) dump_graph_topology_button.set_tooltip( "Writes the execution graph topology out as a GraphViz (.dot) file. File location\n" + "will differ depending on the kit app being run, whether the button was pressed\n" + "in a unit test, etc., but typically it can be found under something like\n" + "kit/_compiler/omni.app.dev; if not, then just search for .dot files containing\n" + "the name ExecutionGraph in the kit directory.\n" ) self.create_setting_widget("Force serial execution", self.serial_eg, SettingType.BOOL) self.create_setting_widget("Force parallel execution", self.parallel_eg, SettingType.BOOL) def _dump_graph_topology(self): """Dump graph topology with incremented file""" dump_graph_topology(self.file_name + str(self.id)) self.id += 1
omniverse-code/kit/exts/omni.kit.exec.debug/omni/kit/exec/debug/extension.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. import omni.ext from omni.kit.window.preferences import register_page, unregister_page from .execution_debug_page import ExecutionDebugPage class ExecutionDebugExtension(omni.ext.IExt): # The entry point for this extension (generates a page within the Preferences # tab with debugging flags for the Execution Framework). def on_startup(self): self.execution_debug_page = ExecutionDebugPage() register_page(self.execution_debug_page) def on_shutdown(self): unregister_page(self.execution_debug_page)
omniverse-code/kit/exts/omni.kit.exec.debug/omni/kit/exec/debug/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. from .extension import *
omniverse-code/kit/exts/omni.kit.exec.debug/omni/kit/exec/debug/tests/test_exec_debug.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. import carb.settings import omni.kit.test from omni.ui.tests.test_base import OmniUiTest from pathlib import Path import omni.kit.app import omni.kit.window.preferences as preferences from omni.kit.viewport.window import ViewportWindow import omni.ui as ui CURRENT_PATH = Path(__file__).parent TEST_DATA_PATH = CURRENT_PATH.parent.parent.parent.parent.parent.joinpath("data").joinpath("tests") TEST_WIDTH, TEST_HEIGHT = 1280, 600 class TestExecutionDebugWindow(OmniUiTest): """Test the EF Debugging Page""" async def setUp(self): """Test set-up before running each test""" await super().setUp() self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute() await self.create_test_area(width=TEST_WIDTH, height=TEST_HEIGHT) self._vw = ViewportWindow("TestWindow", width=TEST_WIDTH, height=TEST_HEIGHT) async def tearDown(self): """Test tear-down after running each test""" await super().tearDown() async def test_execution_page(self): """Test the EF Debugging Page""" title = "Execution" for page in preferences.get_page_list(): if page.get_title() == title: # Setting keys for the test. Flag some stuff to be true to make sure toggles work. carb.settings.get_settings().set(page.serial_eg, False) carb.settings.get_settings().set(page.parallel_eg, True) preferences.select_page(page) preferences.show_preferences_window() await omni.kit.app.get_app().next_update_async() pref_window = ui.Workspace.get_window("Preferences") await self.docked_test_window( window=pref_window, width=TEST_WIDTH, height=TEST_HEIGHT, ) await omni.kit.app.get_app().next_update_async() await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name=f"{title}.png")
omniverse-code/kit/exts/omni.kit.exec.debug/omni/kit/exec/debug/tests/__init__.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. from .test_exec_debug import TestExecutionDebugWindow
omniverse-code/kit/exts/omni.kit.exec.debug/docs/index.rst
omni.kit.exec.debug ########################### .. toctree:: :maxdepth: 1 CHANGELOG
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/welcome_page_item.py
from typing import Callable import carb import omni.kit.app import omni.ui as ui class WelcomePageItem(ui.AbstractItem): def __init__(self, raw_data: dict): super().__init__() self.text = raw_data.get("text", "") self.icon = raw_data.get("icon", "") self.active_icon = raw_data.get("active_icon", self.icon) self.extension_id = raw_data.get("extension_id") self.order = raw_data.get("order", 0xFFFFFFFF) self.build_fn: Callable[[None], None] = None carb.log_info(f"Register welcome page: {self}") def build_ui(self) -> None: # Enable page extension and call build_ui manager = omni.kit.app.get_app().get_extension_manager() manager.set_extension_enabled_immediate(self.extension_id, True) try: if self.build_fn: self.build_fn() else: carb.log_error(f"Failed to build page for `{self.text}` because build entry point not defined!") except Exception as e: carb.log_error(f"Failed to build page for `{self.text}`: {e}") def __repr__(self): return f"{self.text}:{self.extension_id}"
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/welcome_window.py
from typing import Dict, List, Optional import carb.settings import omni.ui as ui from omni.ui import constant as fl from .style import WELCOME_STYLE from .welcome_model import WelcomeModel from .welcome_page_item import WelcomePageItem SETTING_SHOW_AT_STARTUP = "/persistent/exts/omni.kit.welcome.window/visible_at_startup" SETTING_SHOW_SAS_CHECKBOX = "/exts/omni.kit.welcome.window/show_sas_checkbox" class WelcomeWindow(ui.Window): """ Window to show welcome content. Args: visible (bool): If visible when window created. """ def __init__(self, model: WelcomeModel, visible: bool=True): self._model = model self._delegates: List[WelcomePageItem] = [] self.__page_frames: Dict[WelcomePageItem, ui.Frame] = {} self.__page_buttons: Dict[WelcomePageItem, ui.Button] = {} self.__selected_page: Optional[WelcomePageItem] = None # TODO: model window? # If model window and open extensions manager, new extensions window unavailable # And if model window, checkpoing combobox does not pop up droplist because it is a popup window flags = (ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_COLLAPSE | ui.WINDOW_FLAGS_MODAL) super().__init__("Welcome Screen", flags=flags, width=1380, height=780, padding_x=2, padding_y=2, visible=visible) self.frame.set_build_fn(self._build_ui) self.frame.set_style(WELCOME_STYLE) def destroy(self) -> None: super().destroy() self.__page_frames = {} self.visible = False self.__sub_show_at_startup = None def _build_ui(self): self._pages = self._model.get_item_children(None) button_height = fl._find("welcome_page_button_height") with self.frame: with ui.HStack(): # Left for buttons to switch different pages with ui.VStack(width=250, spacing=0): for page in self._pages: self.__page_buttons[page] = ui.Button( page.text.upper(), height=button_height, image_width=button_height, image_height=button_height, spacing=4, image_url=page.icon, clicked_fn=lambda d=page: self.__show_page(d), style_type_name_override="Page.Button" ) ui.Spacer() self.__build_show_at_startup() # Right for page content with ui.ZStack(): for page in self._pages: self.__page_frames[page] = ui.Frame(build_fn=lambda p=page: p.build_ui(), visible=False) # Default always show first page self.__show_page(self._pages[0]) def __build_show_at_startup(self) -> None: settings = carb.settings.get_settings() self.__show_at_startup_model = ui.SimpleBoolModel(settings.get(SETTING_SHOW_AT_STARTUP)) def __on_show_at_startup_changed(model: ui.SimpleBoolModel): settings.set(SETTING_SHOW_AT_STARTUP, model.as_bool) self.__sub_show_at_startup = self.__show_at_startup_model.subscribe_value_changed_fn(__on_show_at_startup_changed) if settings.get_as_bool(SETTING_SHOW_SAS_CHECKBOX): with ui.HStack(height=0, spacing=5): ui.Spacer(width=5) ui.CheckBox(self.__show_at_startup_model, width=0) ui.Label("Show at Startup", width=0) ui.Spacer(height=5) def __show_page(self, page: WelcomePageItem): if self.__selected_page: self.__page_frames[self.__selected_page].visible = False self.__page_buttons[self.__selected_page].selected = False self.__page_buttons[self.__selected_page].image_url = self.__selected_page.icon if page: self.__page_frames[page].visible = True self.__page_buttons[page].selected = True self.__page_buttons[page].image_url = page.active_icon self.__selected_page = page
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/style.py
from pathlib import Path import omni.ui as ui from omni.ui import color as cl from omni.ui import constant as fl CURRENT_PATH = Path(__file__).parent ICON_PATH = CURRENT_PATH.parent.parent.parent.joinpath("data/icons") cl.welcome_window_background = cl.shade(cl("#363636")) cl.welcome_content_background = cl.shade(cl("#1F2123")) cl.welcome_button_text = cl.shade(cl("#979797")) cl.welcome_button_text_selected = cl.shade(cl("#E3E3E3")) cl.welcome_label = cl.shade(cl("#A1A1A1")) cl.welcome_label_selected = cl.shade(cl("#34C7FF")) fl.welcome_page_button_size = 24 fl.welcome_title_font_size = 18 fl.welcome_page_button_height = 80 fl.welcome_page_title_height = fl._find("welcome_page_button_height") + 8 fl.welcome_content_padding_x = 10 fl.welcome_content_padding_y = 10 WELCOME_STYLE = { "Window": { "background_color": cl.welcome_window_background, "border_width": 0, "padding": 0, "marging" : 0, "padding_width": 0, "margin_width": 0, }, "Page.Button": { "background_color": cl.welcome_window_background, "stack_direction": ui.Direction.LEFT_TO_RIGHT, "padding_x": 10, "margin": 0, }, "Page.Button:hovered": { "background_color": cl.welcome_content_background, }, "Page.Button:pressed": { "background_color": cl.welcome_content_background, }, "Page.Button:selected": { "background_color": cl.welcome_content_background, }, "Page.Button.Label": { "font_size": fl.welcome_page_button_size, "alignment": ui.Alignment.LEFT_CENTER, "color": cl.welcome_button_text, }, "Page.Button.Label:selected": { "color": cl.welcome_button_text_selected, }, "Content": { "background_color": cl.welcome_content_background, }, "Title.Button": { "background_color": cl.transparent, "stack_direction": ui.Direction.RIGHT_TO_LEFT, }, "Title.Button.Label": { "font_size": fl.welcome_title_font_size, }, "Title.Button.Image": { "color": cl.welcome_label_selected, "alignment": ui.Alignment.LEFT_CENTER, }, "Doc.Background": {"background_color": cl.white}, "CheckBox": { "background_color": cl.welcome_button_text, "border_radius": 0, }, "Label": {"color": cl.welcome_button_text}, }
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/extension.py
import asyncio from typing import Callable, Optional import carb import carb.settings import omni.ext import omni.kit.app import omni.kit.menu.utils import omni.kit.ui import omni.ui as ui from omni.kit.menu.utils import MenuItemDescription from .actions import deregister_actions, register_actions from .welcome_model import WelcomeModel from .welcome_window import WelcomeWindow WELCOME_MENU_ROOT = "File" _extension_instance = None class WelcomeExtension(omni.ext.IExt): def on_startup(self, ext_id): self._ext_name = omni.ext.get_extension_name(ext_id) self.__stage_opened = False # Window self._model = WelcomeModel() visible = carb.settings.get_settings().get("/persistent/exts/omni.kit.welcome.window/visible_at_startup") self._window = WelcomeWindow(self._model, visible=visible) self._window.set_visibility_changed_fn(self.__on_visibility_changed) if visible: self.__center_window() else: # Listen for the app ready event def _on_app_ready(event): self.__on_close() self._app_ready_sub = None startup_event_stream = omni.kit.app.get_app().get_startup_event_stream() self._app_ready_sub = startup_event_stream.create_subscription_to_pop_by_type( omni.kit.app.EVENT_APP_READY, _on_app_ready, name="Welcome window" ) # Menu item self._register_menuitem() global _extension_instance _extension_instance = self # Action register_actions(self._ext_name, _extension_instance) def on_shutdown(self): self._hooks = None self._app_ready_sub = None deregister_actions(self._ext_name) self._model = None if self._menu_list is not None: omni.kit.menu.utils.remove_menu_items(self._menu_list, WELCOME_MENU_ROOT) self._menu_list = None if self._window is not None: self._window.destroy() self._window = None global _extension_instance _extension_instance = self def toggle_window(self): self._window.visible = not self._window.visible def _register_menuitem(self): self._menu_list = [ MenuItemDescription( name="Welcome", glyph="none.svg", ticked=True, ticked_fn=self._on_tick, onclick_action=(self._ext_name, "toggle_window"), appear_after="Open", ) ] omni.kit.menu.utils.add_menu_items(self._menu_list, WELCOME_MENU_ROOT) def _on_tick(self): if self._window: return self._window.visible else: return False def _on_click(self, *args): self._window.visible = not self._window.visible def __on_visibility_changed(self, visible: bool): omni.kit.menu.utils.refresh_menu_items(WELCOME_MENU_ROOT) if visible: # Always center. Cannot use layout file to change window position because window may be invisible when startup self.__center_window() return self.__on_close() def __open_default_stage(self): self.__execute_action("omni.kit.stage.templates", "create_new_stage_empty") def __on_close(self): # When welcome window is closed, setup the Viewport to a complete state settings = carb.settings.get_settings() if settings.get("/exts/omni.kit.welcome.window/autoSetupOnClose"): self.__execute_action("omni.app.setup", "enable_viewport_rendering") # Do not open default stage if stage already opened if not self.__stage_opened and not omni.usd.get_context().get_stage(): self.__open_default_stage() workflow = settings.get("/exts/omni.kit.welcome.window/default_workflow") if workflow: self.__active_workflow(workflow) def __active_workflow(self, workflow: str): carb.log_info(f"Trying to active workflow '{workflow}'...") self.__execute_action("omni.app.setup", "active_workflow", workflow) def __center_window(self): async def __delay_center(): await omni.kit.app.get_app().next_update_async() app_width = ui.Workspace.get_main_window_width() app_height = ui.Workspace.get_main_window_height() self._window.position_x = (app_width - self._window.frame.computed_width) / 2 self._window.position_y = (app_height - self._window.frame.computed_height) / 2 asyncio.ensure_future(__delay_center()) def __execute_action(self, ext_id: str, action_id: str, *args, **kwargs): try: import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action_registry.execute_action(ext_id, action_id, *args, **kwargs) except Exception as e: carb.log_error(f"Failed to execute action '{ext_id}::{action_id}': {e}") def register_page(self, ext_id: str, build_fn: Callable[[None], None]) -> bool: return self._model.register_page(ext_id, build_fn) def show_window(self, visible: bool = True, stage_opened: bool = False) -> None: self.__stage_opened = stage_opened or self.__stage_opened self._window.visible = visible def register_page(ext_id: str, build_fn: Callable[[None], None]) -> bool: if _extension_instance: return _extension_instance.register_page(ext_id, build_fn) else: return False def show_window(visible: bool = True, stage_opened: bool = False) -> None: if _extension_instance: _extension_instance.show_window(visible=visible, stage_opened=stage_opened)
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/__init__.py
from .extension import *
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/welcome_model.py
from typing import Callable, List, Optional import carb import carb.settings import omni.ui as ui from .welcome_page_item import WelcomePageItem SETTING_WELCOME_PAGES = "/app/welcome/page" class WelcomeModel(ui.AbstractItemModel): def __init__(self): super().__init__() self.__settings = carb.settings.get_settings() self._items = [WelcomePageItem(page) for page in self.__settings.get(SETTING_WELCOME_PAGES)] self._items.sort(key=lambda item: item.order) def get_item_children(self, item: Optional[WelcomePageItem]) -> List[WelcomePageItem]: return self._items def register_page(self, ext_id: str, build_fn: Callable[[None], None]) -> bool: for item in self._items: if item.extension_id == ext_id: item.build_fn = build_fn return True carb.log_warn(f"Extension {ext_id} not defined in welcome window.") return False
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/actions.py
def register_actions(extension_id, extension_inst): try: import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() actions_tag = "Welcome" action_registry.register_action( extension_id, "toggle_window", extension_inst.toggle_window, display_name="File->Welcome", description="Show/Hide welcome window", tag=actions_tag, ) except ImportError: pass def deregister_actions(extension_id): try: import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action_registry.deregister_all_actions_for_extension(extension_id) except ImportError: pass
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/tests/__init__.py
from .test_window import *
omniverse-code/kit/exts/omni.kit.welcome.window/omni/kit/welcome/window/tests/test_window.py
from omni.ui.tests.test_base import OmniUiTest from pathlib import Path import omni.ui as ui from ..extension import register_page, _extension_instance as welcome_instance CURRENT_PATH = Path(__file__).parent TEST_DATA_PATH = CURRENT_PATH.parent.parent.parent.parent.parent.joinpath("data").joinpath("tests") class TestWelcomeWindow(OmniUiTest): # Before running each test async def setUp(self): await super().setUp() self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute() # Register page build function register_page("omni.kit.welcome.window", self.__build_ui) # Show window self._window = welcome_instance._window self._window.visible = True # After running each test async def tearDown(self): await super().tearDown() async def test_window(self): await self.docked_test_window(window=self._window, width=1280, height=720, block_devices=False) await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name="window.png") def __build_ui(self): with ui.VStack(): ui.Label("PLACE PAGE WIDGETS HERE!", height=0)
omniverse-code/kit/exts/omni.kit.welcome.window/docs/index.rst
omni.kit.welcome.window ########################### .. toctree:: :maxdepth: 1 CHANGELOG
omniverse-code/kit/exts/omni.kit.widget.live_session_management/PACKAGE-LICENSES/omni.kit.widget.live_session_management-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.
omniverse-code/kit/exts/omni.kit.widget.live_session_management/config/extension.toml
[package] version = "1.1.3" title = "Live Session Management Widgets" category = "Internal" description = "This extension includes shared live session widgets used by other extentions to re-use widgets for session management." keywords = ["Live Session", "Layers", "Widget"] changelog = "docs/CHANGELOG.md" authors = ["NVIDIA"] repository = "" [dependencies] "omni.ui" = {} "omni.client" = {} "omni.kit.usd.layers" = {} "omni.kit.widget.prompt" = {} "omni.kit.window.filepicker" = {} "omni.kit.notification_manager" = {} "omni.kit.collaboration.channel_manager" = {} "omni.kit.window.file" = {} [[python.module]] name = "omni.kit.widget.live_session_management" [[test]] waiver = "Tests covered in omni.kit.widget.layers"
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/share_session_link_window.py
import carb import omni.kit.usd.layers as layers import omni.ui as ui import omni.kit.clipboard from .live_session_model import LiveSessionModel from .layer_icons import LayerIcons class ShareSessionLinkWindow: def __init__(self, layers_interface: layers.Layers, layer_identifier): self._window = None self._layers_interface = layers_interface self._base_layer_identifier = layer_identifier self._buttons = [] self._existing_sessions_combo = None self._existing_sessions_model = LiveSessionModel(self._layers_interface, layer_identifier, False) self._key_functions = { int(carb.input.KeyboardInput.ENTER): self._on_ok_button_fn, int(carb.input.KeyboardInput.ESCAPE): self._on_cancel_button_fn } self._build_ui() def _on_layer_event(event: carb.events.IEvent): payload = layers.get_layer_event_payload(event) if payload.event_type == layers.LayerEventType.LIVE_SESSION_LIST_CHANGED: if self._base_layer_identifier not in payload.identifiers_or_spec_paths: return self._existing_sessions_model.refresh_sessions(force=True) self._update_dialog_states() self._layers_event_subscription = layers_interface.get_event_stream().create_subscription_to_pop( _on_layer_event, name="Session Start Window Events" ) def destroy(self): self._layers_interface = None for button in self._buttons: button.set_clicked_fn(None) self._buttons.clear() if self._window: self._window.visible = False self._window = None if self._existing_sessions_model: self._existing_sessions_model.destroy() self._existing_sessions_model = None self._layers_event_subscription = None self._existing_sessions_combo = None self._existing_sessions_empty_hint = None self._error_label = None @property def visible(self): return self._window and self._window.visible @visible.setter def visible(self, value): if self._window: self._window.visible = value if not self._window.visible: self._existing_sessions_model.stop_channel() def _on_ok_button_fn(self): current_session = self._existing_sessions_model.current_session if not current_session or self._existing_sessions_model.empty(): self._error_label.text = "No Valid Session Selected." return omni.kit.clipboard.copy(current_session.shared_link) self._error_label.text = "" self.visible = False def _on_cancel_button_fn(self): self.visible = False def _on_key_pressed_fn(self, key, mod, pressed): if not pressed: return func = self._key_functions.get(key) if func: func() def _update_dialog_states(self): if self._existing_sessions_model.empty(): self._existing_sessions_empty_hint.visible = True else: self._existing_sessions_empty_hint.visible = False self._error_label.text = "" def _build_ui(self): """Construct the window based on the current parameters""" self._window = ui.Window( "SHARE LIVE SESSION LINK", visible=False, height=0, auto_resize=True, dockPreference=ui.DockPreference.DISABLED ) self._window.flags = ( ui.WINDOW_FLAGS_NO_COLLAPSE | ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_RESIZE | ui.WINDOW_FLAGS_NO_MOVE ) self._window.set_key_pressed_fn(self._on_key_pressed_fn) self._window.flags = self._window.flags | ui.WINDOW_FLAGS_MODAL self._existing_sessions_model.refresh_sessions(True) STYLES = { "Button.Image::confirm_button": { "image_url": LayerIcons.get("link"), "alignment" : ui.Alignment.RIGHT_CENTER }, "Label::copy_link": {"font_size": 14}, "Rectangle::hovering": {"border_radius": 2, "margin": 0, "padding": 0}, "Rectangle::hovering:hovered": {"background_color": 0xCC9E9E9E}, } with self._window.frame: with ui.VStack(height=0, style=STYLES): ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer(width=20) self._error_label = ui.Label( "", name="error_label", style={"color": 0xFF0000CC}, alignment=ui.Alignment.LEFT, word_wrap=True ) ui.Spacer(width=20) ui.Spacer(width=0, height=5) with ui.HStack(height=0): ui.Spacer(width=20) with ui.ZStack(height=0): self._existing_sessions_combo = ui.ComboBox( self._existing_sessions_model, width=self._window.width - 40, height=0 ) self._existing_sessions_empty_hint = ui.Label( " No Existing Sessions", alignment=ui.Alignment.LEFT_CENTER, style={"color": 0xFF3F3F3F} ) ui.Spacer(width=20) ui.Spacer(width=0, height=30) with ui.HStack(height=0): ui.Spacer() with ui.ZStack(width=120, height=30): ui.Rectangle(name="hovering") with ui.HStack(): ui.Spacer() ui.Label("Copy Link", width=0, name="copy_link") ui.Spacer(width=8) ui.Image(LayerIcons.get("link"), width=20) ui.Spacer() ok_button = ui.InvisibleButton(name="confirm_button") ok_button.set_clicked_fn(self._on_ok_button_fn) self._buttons.append(ok_button) ui.Spacer() ui.Spacer(width=0, height=20) self._update_dialog_states()
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/layer_icons.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from pathlib import Path class LayerIcons: """A singleton that scans the icon folder and returns the icon depending on the type""" _icons = {} @staticmethod def on_startup(extension_path): current_path = Path(extension_path) icon_path = current_path.joinpath("icons") # Read all the svg files in the directory LayerIcons._icons = {icon.stem: icon for icon in icon_path.glob("*.svg")} @staticmethod def get(name, default=None): """Checks the icon cache and returns the icon if exists""" found = LayerIcons._icons.get(name) if not found and default: found = LayerIcons._icons.get(default) if found: return str(found) return None
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_user_list.py
__all__ = ["LiveSessionUserList"] import carb import omni.usd import omni.client.utils as clientutils import omni.ui as ui import omni.kit.usd.layers as layers import omni.kit.collaboration.presence_layer as pl from .utils import build_live_session_user_layout, is_extension_loaded from omni.ui import color as cl TOOLTIP_STYLE = { "color": cl("#979797"), "Tooltip": {"background_color": 0xEE222222} } PRESENTER_STYLE = {"background_color": 0xff2032dc} # blue alternative: 0xffff851a class LiveSessionUserList: """Widget to build an user list to show all live session users of interested layer.""" def __init__(self, usd_context: omni.usd.UsdContext, base_layer_identifier: str, **kwargs): """ Constructor. Args: usd_context (omni.usd.UsdContext): USD Context instance. base_layer_identifier (str): Interested layer to listen to. follow_user_with_double_click (bool): Whether to enable follow user function of double click. Kwargs: icon_size (int): The width and height of the user icon. 16 pixel by default. spacing (int): The horizonal spacing between two icons. 2 pixel by default. show_myself (int): Whether to show local user or not. True by default show_myself_to_leftmost (bool): Whether to show local user to the left most, or right most otherwise. True by default. maximum_users (int): The maximum users to show, and show others with overflow. Unlimited by default. prim_path (Sdf.Path): Track Live Session for this prim only. """ self.__icon_size = kwargs.get("icon_size", 16) self.__spacing = kwargs.get("spacing", 2) self.__show_myself = kwargs.get("show_myself", True) self.__show_myself_to_leftmost = kwargs.get("show_myself_to_leftmost", True) self.__maximum_count = kwargs.get("maximum_users", None) self.__follow_user_with_double_click = kwargs.get("follow_user_with_double_click", False) timeline_ext_loaded = is_extension_loaded("omni.timeline.live_session") self.__allow_timeline_settings = kwargs.get("allow_timeline_settings", False) and timeline_ext_loaded self.__prim_path = kwargs.get("prim_path", None) self.__base_layer_identifier = base_layer_identifier self.__usd_context = usd_context self.__layers = layers.get_layers(usd_context) self.__live_syncing = layers.get_live_syncing() self.__layers_event_subscriptions = [] self.__main_layout: ui.HStack = ui.HStack(width=0, height=0) self.__all_user_layouts = {} self.__overflow = None self.__overflow_button = None self.__initialize() @property def layout(self) -> ui.HStack: return self.__main_layout def track_layer(self, layer_identifier): """Switches the base layer to listen to.""" if self.__base_layer_identifier != layer_identifier: self.__base_layer_identifier = layer_identifier self.__initialize() def empty(self): return len(self.__all_user_layouts) == 0 def __initialize(self): if not clientutils.is_local_url(self.__base_layer_identifier): for event in [ layers.LayerEventType.LIVE_SESSION_STATE_CHANGED, layers.LayerEventType.LIVE_SESSION_USER_JOINED, layers.LayerEventType.LIVE_SESSION_USER_LEFT, ]: layers_event_subscription = self.__layers.get_event_stream().create_subscription_to_pop_by_type( event, self.__on_layers_event, name=f"omni.kit.widget.live_session_management.LiveSessionUserList {str(event)}" ) self.__layers_event_subscriptions.append(layers_event_subscription) else: self.__layers_event_subscriptions = [] self.__build_ui() def __is_in_session(self): if self.__prim_path: return self.__live_syncing.is_prim_in_live_session(self.__prim_path, self.__base_layer_identifier) else: return self.__live_syncing.is_layer_in_live_session(self.__base_layer_identifier) def __build_myself(self): current_live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) if not current_live_session: return logged_user = current_live_session.logged_user with ui.ZStack(width=0, height=0): with ui.HStack(): ui.Spacer() self.__build_user_layout_or_overflow(current_live_session, logged_user, True, spacing=0) ui.Spacer() if self.__is_presenting(logged_user): with ui.VStack(): ui.Spacer() with ui.HStack(height=2, width=24): ui.Rectangle( height=2, width=12, alignment=ui.Alignment.BOTTOM, style={"background_color": 0xff00b86b} ) ui.Rectangle( height=2, width=12, alignment=ui.Alignment.BOTTOM, style=PRESENTER_STYLE ) else: with ui.VStack(): ui.Spacer() ui.Rectangle( height=2, width=24, alignment=ui.Alignment.BOTTOM, style={"background_color": 0xff00b86b} ) def __build_ui(self): # Destroyed if not self.__main_layout: return self.__overflow = False self.__main_layout.clear() self.__all_user_layouts.clear() self.__overflow_button = None if not self.__is_in_session(): return current_live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) with self.__main_layout: if self.__show_myself and self.__show_myself_to_leftmost: self.__build_myself() for peer_user in current_live_session.peer_users: self.__build_user_layout_or_overflow(current_live_session, peer_user, False, self.__spacing) if self.__overflow: break if self.__show_myself and not self.__show_myself_to_leftmost: ui.Spacer(self.__spacing) self.__build_myself() if self.empty(): self.__main_layout.visible = False else: self.__main_layout.visible = True @carb.profiler.profile def __on_layers_event(self, event): payload = layers.get_layer_event_payload(event) if payload.event_type == layers.LayerEventType.LIVE_SESSION_STATE_CHANGED: if not payload.is_layer_influenced(self.__base_layer_identifier): return if self.__allow_timeline_settings: import omni.timeline.live_session timeline_session = omni.timeline.live_session.get_timeline_session() if timeline_session is not None: timeline_session.add_presenter_changed_fn(self.__on_presenter_changed) self.__build_ui() elif ( payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_JOINED or payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_LEFT ): if not payload.is_layer_influenced(self.__base_layer_identifier): return if not self.__is_in_session(): return current_live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) user_id = payload.user_id if payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_LEFT: self.__all_user_layouts.pop(user_id, None) # FIXME: omni.ui does not support to remove single child. self.__build_ui() else: if user_id in self.__all_user_layouts or self.__overflow: # OMFP-2909: Refresh overflow button to rebuild tooltip. if self.__overflow and self.__overflow_button: self.__overflow_button.set_tooltip_fn(self.__build_tooltip) return user_info = current_live_session.get_peer_user_info(user_id) if not user_info: return self.__main_layout.add_child( self.__build_user_layout_or_overflow(current_live_session, user_info, False, self.__spacing) ) def destroy(self): # pragma: no cover self.__overflow_button = None self.__main_layout = None self.__layers_event_subscriptions = [] self.__layers = None self.__live_syncing = None self.__user_menu = None self.__all_user_layouts.clear() def __on_follow_user( self, x : float, y : float, button : int, modifier, user_info: layers.LiveSessionUser ): if button != int(carb.input.MouseInput.LEFT_BUTTON): # only left MB click return current_live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) if not current_live_session or current_live_session.logged_user_id == user_info.user_id: return presence_layer = pl.get_presence_layer_interface(self.__usd_context) if presence_layer: presence_layer.enter_follow_mode(user_info.user_id) def __on_mouse_clicked( self, x : float, y : float, button : int, modifier, user_info: layers.LiveSessionUser ): if button == int(carb.input.MouseInput.RIGHT_BUTTON): # right click to open menu import omni.timeline.live_session timeline_session = omni.timeline.live_session.get_timeline_session() if timeline_session is not None and timeline_session.am_i_owner(): self.__user_menu = ui.Menu("global_live_timeline_user") show = False with self.__user_menu: if timeline_session.is_presenter(user_info) and not timeline_session.is_owner(user_info): ui.MenuItem( "Withdraw Timeline Presenter", triggered_fn=lambda *args: self.__set_presenter(timeline_session, timeline_session.owner) ) show = True elif not timeline_session.is_presenter(user_info): ui.MenuItem( "Set as Timeline Presenter", triggered_fn=lambda *args: self.__set_presenter(timeline_session, user_info) ) show = True if show: self.__user_menu.show() def __set_presenter(self, timeline_session, user_info: layers.LiveSessionUser): timeline_session.presenter = user_info def __is_presenting(self, user_info: layers.LiveSessionUser) -> bool: if not self.__allow_timeline_settings: return False timeline_session = omni.timeline.live_session.get_timeline_session() return timeline_session.is_presenter(user_info) if timeline_session is not None else False def __on_presenter_changed(self, _): self.__build_ui() def __build_user_layout( self, live_session: layers.LiveSession, user_info: layers.LiveSessionUser, me: bool, spacing=2 ): if me: tooltip = f"{user_info.user_name} - Me" if live_session.merge_permission: tooltip += " (owner)" else: tooltip = f"{user_info.user_name} ({user_info.from_app})" if not live_session.merge_permission and live_session.owner == user_info.user_name: tooltip += " - owner" layout = ui.ZStack(width=0, height=0) with layout: with ui.HStack(): ui.Spacer(width=spacing) user_layout = build_live_session_user_layout( user_info, self.__icon_size, tooltip, self.__on_follow_user if self.__follow_user_with_double_click else None, self.__on_mouse_clicked if self.__allow_timeline_settings else None ) user_layout.set_style(TOOLTIP_STYLE) current_live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) logged_user = current_live_session.logged_user if logged_user.user_id != user_info.user_id and self.__is_presenting(user_info): with ui.VStack(): ui.Spacer() ui.Rectangle( height=2, width=24, alignment=ui.Alignment.BOTTOM, style=PRESENTER_STYLE ) return layout def __build_tooltip(self): # pragma: no cover live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) if not live_session: return total_users = len(live_session.peer_users) if self.__show_myself: total_users += 1 with ui.VStack(): with ui.HStack(style={"color": cl("#757575")}): ui.Spacer() ui.Label(f"{total_users} Users Connected", style={"font_size": 12}) ui.Spacer() ui.Spacer(height=0) ui.Separator(style={"color": cl("#4f4f4f")}) ui.Spacer(height=4) all_users = [] if self.__show_myself: all_users = [live_session.logged_user] all_users.extend(live_session.peer_users) for user in all_users: item_title = f"{user.user_name} ({user.from_app})" if live_session.owner == user.user_name: item_title += " - owner" with ui.HStack(): build_live_session_user_layout( user, self.__icon_size, "", self.__on_follow_user if self.__follow_user_with_double_click else None, self.__on_mouse_clicked if self.__allow_timeline_settings else None ) ui.Spacer(width=4) ui.Label(item_title, style={"font_size": 14}) ui.Spacer(height=2) @carb.profiler.profile def __build_user_layout_or_overflow( self, live_session: layers.LiveSession, user_info: layers.LiveSessionUser, me: bool, spacing=2 ): # pragma: no cover current_count = len(self.__all_user_layouts) if self.__overflow: return None if self.__maximum_count is not None and current_count >= self.__maximum_count: layout = ui.HStack(width=0) with layout: ui.Spacer(width=4) with ui.ZStack(): ui.Label("...", style={"font_size": 16}, aligment=ui.Alignment.V_CENTER) self.__overflow_button = ui.InvisibleButton(style=TOOLTIP_STYLE) self.__overflow_button.set_tooltip_fn(self.__build_tooltip) self.__overflow = True else: layout = self.__build_user_layout(live_session, user_info, me, spacing) self.__all_user_layouts[user_info.user_id] = layout self.__main_layout.visible = True self.__overflow_button = None return layout
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_preferences.py
from .utils import QUICK_JOIN_ENABLED from .utils import SESSION_LIST_SELECT, SESSION_LIST_SELECT_DEFAULT_SESSION, SESSION_LIST_SELECT_LAST_SESSION import carb.settings import omni.ui as ui from omni.kit.widget.settings import SettingType from omni.kit.window.preferences import PreferenceBuilder class LiveSessionPreferences(PreferenceBuilder): SETTING_PAGE_NAME = "Live" def __init__(self): super().__init__(LiveSessionPreferences.SETTING_PAGE_NAME) self._settings = carb.settings.get_settings() self._checkbox_quick_join_enabled = None self._combobox_session_list_select = None def destroy(self): self._settings = None self._checkbox_quick_join_enabled = None self._combobox_session_list_select = None def build(self): self._checkbox_quick_join_enabled = None self._combobox_session_list_select = None with ui.VStack(height=0): with self.add_frame("Join"): with ui.VStack(): checkbox = self.create_setting_widget( "Quick Join Enabled", QUICK_JOIN_ENABLED, SettingType.BOOL, tooltip="Quick Join, creates and joins a Default session and bypasses dialogs." ) self._checkbox_quick_join_enabled = checkbox ui.Spacer() combo = self.create_setting_widget_combo( "Session List Select", SESSION_LIST_SELECT, [SESSION_LIST_SELECT_DEFAULT_SESSION, SESSION_LIST_SELECT_LAST_SESSION] ) self._combobox_session_list_select = combo ui.Spacer() ui.Spacer(height=10)
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/extension.py
__all__ = ["stop_or_show_live_session_widget", "LiveSessionWidgetExtension"] import asyncio import os import carb import omni.ext import omni.kit.app import omni.usd import omni.client import omni.ui as ui import omni.kit.notification_manager as nm import omni.kit.usd.layers as layers import omni.kit.clipboard from typing import Union from enum import Enum from omni.kit.widget.prompt import PromptButtonInfo, PromptManager from .layer_icons import LayerIcons from .live_session_start_window import LiveSessionStartWindow from .live_session_end_window import LiveSessionEndWindow from .utils import is_extension_loaded, join_live_session, is_viewer_only_mode, is_quick_join_enabled from .join_with_session_link_window import JoinWithSessionLinkWindow from .share_session_link_window import ShareSessionLinkWindow from pxr import Sdf from .live_style import Styles _extension_instance = None _debugCollaborationWindow = None class LiveSessionMenuOptions(Enum): QUIT_ONLY = 0 MERGE_AND_QUIT = 1 class LiveSessionWidgetExtension(omni.ext.IExt): def on_startup(self, ext_id): global _extension_instance _extension_instance = self extension_path = omni.kit.app.get_app_interface().get_extension_manager().get_extension_path(ext_id) self._settings = None LayerIcons.on_startup(extension_path) self._live_session_end_window = None self._live_session_start_window = None self._join_with_session_link_window = None self._share_session_link_window = None self._live_session_menu = None self._app = omni.kit.app.get_app() try: from omni.kit.window.preferences import register_page from .live_session_preferences import LiveSessionPreferences self._settings = register_page(LiveSessionPreferences()) except ImportError: # pragma: no cover pass Styles.on_startup() def on_shutdown(self): global _extension_instance _extension_instance = None self._live_session_menu = None if self._live_session_end_window: self._live_session_end_window.destroy() self._live_session_end_window = None if self._live_session_start_window: self._live_session_start_window.destroy() self._live_session_start_window = None if self._join_with_session_link_window: self._join_with_session_link_window.destroy() self._join_with_session_link_window = None if self._share_session_link_window: self._share_session_link_window.destroy() self._share_session_link_window = None if self._settings: try: from omni.kit.window.preferences import unregister_page unregister_page(self._settings) except ImportError: pass self._settings = None @staticmethod def get_instance(): global _extension_instance return _extension_instance def _show_live_session_end_window(self, layers_interface: layers.Layers, layer_identifier): if self._live_session_end_window: self._live_session_end_window.destroy() async def show_dialog(): self._live_session_end_window = LiveSessionEndWindow(layers_interface, layer_identifier) async with self._live_session_end_window: pass asyncio.ensure_future(show_dialog()) def _show_join_with_session_link_window(self, layers_interface): current_session_link = None # Destroys it to center the window. if self._join_with_session_link_window: current_session_link = self._join_with_session_link_window.current_session_link self._join_with_session_link_window.destroy() self._join_with_session_link_window = JoinWithSessionLinkWindow(layers_interface) self._join_with_session_link_window.visible = True if current_session_link: self._join_with_session_link_window.current_session_link = current_session_link def _show_share_session_link_window(self, layers_interface, layer_identifier): # Destroys it to center the window. if self._share_session_link_window: self._share_session_link_window.destroy() self._share_session_link_window = ShareSessionLinkWindow(layers_interface, layer_identifier) self._share_session_link_window.visible = True def _show_live_session_menu_options(self, layers_interface, layer_identifier, is_stage_session, prim_path=None): live_syncing = layers_interface.get_live_syncing() current_session = live_syncing.get_current_live_session(layer_identifier) self._live_session_menu = ui.Menu("global_live_update") is_omniverse_stage = layer_identifier.startswith("omniverse://") is_live_prim = prim_path or live_syncing.is_layer_in_live_session(layer_identifier, live_prim_only=True) with self._live_session_menu: if is_omniverse_stage: if current_session: # If layer is in the live session already, showing `leave` and `end and merge` ui.MenuItem( "Leave Session", triggered_fn=lambda *args: self._on_leave_live_session_menu_options( layers_interface, LiveSessionMenuOptions.QUIT_ONLY, layer_identifier ), ) if not is_viewer_only_mode(): ui.MenuItem( "End and Merge", triggered_fn=lambda *args: self._on_leave_live_session_menu_options( layers_interface, LiveSessionMenuOptions.MERGE_AND_QUIT, layer_identifier ), ) ui.Separator() else: # If it's not in the live session, show `join` and `create`. ui.MenuItem( "Join Session", triggered_fn=lambda *args: self._show_live_session_start_window( layers_interface, layer_identifier, True, prim_path ), ) ui.MenuItem( "Create Session", triggered_fn=lambda *args: self._show_live_session_start_window( layers_interface, layer_identifier, False, prim_path ), ) # Don't show those options for live prim if not is_live_prim: # If layer_identifier is given, it's to show menu options for sublayer. # Show `copy` to copy session link. Otherwise, show share session dialog # to choose session to share. if is_stage_session: ui.Separator() ui.MenuItem( "Share Session Link", triggered_fn=lambda *args: self._show_share_session_link_window( layers_interface, layer_identifier ), ) elif current_session: ui.Separator() ui.MenuItem( "Copy Session Link", triggered_fn=lambda *args: self._copy_session_link(layers_interface), ) # If layer identifier is gven, it will not show `join with session link` menu option. if is_stage_session and not is_live_prim: ui.MenuItem( "Join With Session Link", triggered_fn=lambda *args: self._show_join_with_session_link_window(layers_interface), ) if is_extension_loaded("omni.kit.collaboration.debug_options"): # pragma: no cover ui.Separator() ui.MenuItem( "Open Debug Window", triggered_fn=lambda *args: self._on_open_debug_window(), ) if is_omniverse_stage and current_session and is_extension_loaded("omni.timeline.live_session"): ui.Separator() import omni.timeline.live_session timeline_session = omni.timeline.live_session.get_timeline_session() if timeline_session is not None: session_window = omni.timeline.live_session.get_session_window() ui.MenuItem( "Synchronize Timeline", triggered_fn=lambda *args: self._on_timeline_sync_triggered( layers_interface, layer_identifier, timeline_session ), checkable=True, checked=timeline_session.is_sync_enabled() ) if timeline_session.am_i_owner(): ui.MenuItem( "Set Timeline Owner", triggered_fn=lambda *args: self._on_open_timeline_session_window( layers_interface, layer_identifier, timeline_session, session_window ), ) elif not timeline_session.am_i_presenter(): if not self._requested_timeline_control(timeline_session): ui.MenuItem( "Request Timeline Ownership", triggered_fn=lambda *args: self._on_request_timeline_control(timeline_session), ) else: ui.MenuItem( "Withdraw Timeline Ownership Request", triggered_fn=lambda *args: self._on_withdraw_timeline_control(timeline_session), ) self._live_session_menu.show() def _show_live_session_start_window(self, layers_interface, layer_identifier, join_session=None, prim_path=None): if self._live_session_start_window: self._live_session_start_window.destroy() self._live_session_start_window = LiveSessionStartWindow(layers_interface, layer_identifier, prim_path) self._live_session_start_window.visible = True if join_session is not None: self._live_session_start_window.set_focus(join_session) def _show_session_start_window_or_menu( self, layers_interface: layers.Layers, show_join_options, layer_identifier, is_stage_session, join_session=None, prim_path=None ): if show_join_options: return self._show_live_session_menu_options( layers_interface, layer_identifier, is_stage_session, prim_path ) else: self._show_live_session_start_window(layers_interface, layer_identifier, join_session, prim_path) return None def _requested_timeline_control(self, timeline_session) -> bool: return timeline_session is not None and\ timeline_session.live_session_user in timeline_session.get_request_controls() def _on_request_timeline_control(self, timeline_session): if timeline_session is not None: timeline_session.request_control(True) def _on_withdraw_timeline_control(self, timeline_session): if timeline_session is not None: timeline_session.request_control(False) def _on_timeline_sync_triggered( self, layers_interface: layers.Layers, layer_identifier: str, timeline_session ): timeline_session.enable_sync(not timeline_session.is_sync_enabled()) def _on_open_timeline_session_window( self, layers_interface: layers.Layers, layer_identifier: str, timeline_session, session_window, ): session_window.show() def _on_open_debug_window( self, ): # pragma: no cover import omni.kit.collaboration.debug_options from omni.kit.collaboration.debug_options import CollaborationWindow global _debugCollaborationWindow if _debugCollaborationWindow is None : _debugCollaborationWindow = CollaborationWindow(width=480, height=320) _debugCollaborationWindow.visible = True def _on_leave_live_session_menu_options( self, layers_interface: layers.Layers, options: LiveSessionMenuOptions, layer_identifier: str, ): live_syncing = layers_interface.get_live_syncing() current_session = live_syncing.get_current_live_session(layer_identifier) if current_session: if options == LiveSessionMenuOptions.QUIT_ONLY: if self._can_quit_session_directly(live_syncing, layer_identifier): live_syncing.stop_live_session(layer_identifier) else: PromptManager.post_simple_prompt( "Leave Session", f"You are about to leave '{current_session.name}' session.", PromptButtonInfo("LEAVE", lambda: live_syncing.stop_live_session(layer_identifier)), PromptButtonInfo("CANCEL") ) elif options == LiveSessionMenuOptions.MERGE_AND_QUIT: layers_state = layers_interface.get_layers_state() is_read_only_on_disk = layers_state.is_layer_readonly_on_disk(layer_identifier) if current_session.merge_permission and not is_read_only_on_disk: self._show_live_session_end_window(layers_interface, layer_identifier) else: if is_read_only_on_disk: owner = layers_state.get_layer_owner(layer_identifier) else: owner = current_session.owner logged_user_name = current_session.logged_user_name if logged_user_name == owner and current_session.merge_permission: message = f"You currently do not have merge privileges as base layer is read-only on disk."\ " Do you want to quit this live session?" else: if is_read_only_on_disk: message = f"You currently do not have merge privileges as base layer is read-only on disk."\ f" Please contact '{owner}' to grant you write access. Do you want to quit this live session?" else: message = f"You currently do not have merge privileges, please contact '{owner}'"\ " to merge any changes from the live session. Do you want to quit this live session?" PromptManager.post_simple_prompt( "Permission Denied", message, PromptButtonInfo("YES", lambda: live_syncing.stop_live_session(layer_identifier)), PromptButtonInfo("NO") ) def _can_quit_session_directly(self, live_syncing: layers.LiveSyncing, layer_identifier): current_live_session = live_syncing.get_current_live_session(layer_identifier) if current_live_session: if current_live_session.peer_users: return False layer = Sdf.Find(current_live_session.root) if layer and len(layer.rootPrims) > 0: return False return True def _copy_session_link(self, layers_interface): live_syncing = layers_interface.get_live_syncing() current_session = live_syncing.get_current_live_session() if not current_session: return omni.kit.clipboard.copy(current_session.shared_link) def _stop_or_show_live_session_widget_internal( self, layers_interface: layers.Layers, stop_session_only, stop_session_forcely, show_join_options, layer_identifier, quick_join="", prim_path=None ): usd_context = layers_interface.usd_context stage = usd_context.get_stage() # Skips it if stage is not opened. if not stage: return None # By default, it will join live session of tht root layer. if not layer_identifier: # If layer identifier is not provided, it's to show global # menu that includes share sesison link and join session with link. # Otherwise, it will show menu for the sublayer session only. is_stage_session = True root_layer = stage.GetRootLayer() layer_identifier = root_layer.identifier else: is_stage_session = False layer_handle = Sdf.Find(layer_identifier) if ( not layer_handle or (not prim_path and not stage.HasLocalLayer(layer_handle)) or (prim_path and layer_handle not in stage.GetUsedLayers()) ): nm.post_notification( "Only a layer opened in the current stage can start a live-sync session.", status=nm.NotificationStatus.WARNING ) return None if not layer_identifier.startswith("omniverse://"): if is_stage_session and not prim_path: return self._show_live_session_menu_options(layers_interface, layer_identifier, is_stage_session) else: nm.post_notification( "Only a layer in Nucleus can start a live-sync session.", status=nm.NotificationStatus.WARNING ) return None live_syncing = layers_interface.get_live_syncing() if not live_syncing.is_layer_in_live_session(layer_identifier): if not quick_join and not show_join_options: quick_join = "Default" elif quick_join and show_join_options: show_join_options = False if quick_join: # This runs when the main live button is pressed. live_syncing = layers_interface.get_live_syncing() quick_session = live_syncing.find_live_session_by_name(layer_identifier, quick_join) if is_quick_join_enabled(): if not quick_session: quick_session = live_syncing.create_live_session( layer_identifier=layer_identifier, name=quick_join ) if not quick_session: nm.post_notification( "Cannot create a Live session on a read only location. Please\n" "save root file in a writable location.", status=nm.NotificationStatus.WARNING ) return None join_live_session( layers_interface, layer_identifier, quick_session, prim_path, is_viewer_only_mode() ) return None else: join_session = True if quick_session is not None else False return self._show_session_start_window_or_menu( layers_interface, False, layer_identifier, False, join_session, prim_path ) else: return self._show_session_start_window_or_menu( layers_interface, show_join_options, layer_identifier, is_stage_session, prim_path ) elif stop_session_forcely: live_syncing.stop_live_session(layer_identifier) elif stop_session_only: self._on_leave_live_session_menu_options( layers_interface, LiveSessionMenuOptions.QUIT_ONLY, layer_identifier ) else: return self._show_live_session_menu_options(layers_interface, layer_identifier, is_stage_session, prim_path) return None def stop_or_show_live_session_widget( usd_context: Union[str, omni.usd.UsdContext] = "", stop_session_only: bool = False, stop_session_forcely: bool = False, show_join_options: bool = True, layer_identifier: str = None, quick_join: str = False, prim_path: Union[str, Sdf.Path] = None, ): """Stops current live session or shows widget to join/leave session. If current session is empty, it will show the session start dialog. If current session is not empty, it will stop session directly or show stop session menu. Args: usd_context: The current usd context to operate on. stop_session_only: If it's true, it will ask user to stop session if session is not empty without showing merge options. If it's false, it will show both leave and merge session options. stop_session_forcely: If it's true, it will stop session forcely even if current sesison is not empty. Otherwise, it will show leave session or both leave and merge options that's dependent on if stop_session_only is true or false. show_join_options: If it's true, it will show menu options. If it's false, it will show session dialog directly. This option is only used when layer is not in a live session. If both quick_join and this param have the same value, it will do quick join. layer_identifier: By default, it will join/stop the live session of the root layer. If layer_identifier is not None, it will join/stop the live session for the specific sublayer. quick_join: Quick Join / Leave a session without bringing up a dialog. This option is only used when layer is not in a live session. If both show_join_options and this param have the same value, this param will be True. prim_path: If prim path is specified, it will join live session for the prim instead of sublayers. Only prim with references or payloads supports to join a live session. Prim path is not needed when it's to stop a live session. Returns: It will return the menu widgets created if it needs to create options menu. Otherwise, it will return None. """ instance = LiveSessionWidgetExtension.get_instance() if not instance: # pragma: no cover carb.log_error("omni.kit.widget.live_session_management extension must be enabled.") return layers_interface = layers.get_layers(usd_context) return instance._stop_or_show_live_session_widget_internal( layers_interface, stop_session_only, stop_session_forcely, show_join_options, layer_identifier, quick_join=quick_join, prim_path=prim_path )
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/__init__.py
from .extension import * from .utils import * from .live_session_user_list import * from .live_session_model import * from .live_session_camera_follower_list import *
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/file_picker.py
import omni import carb import os import omni.client import omni.kit.notification_manager as nm from omni.kit.widget.prompt import PromptButtonInfo, PromptManager from .filebrowser import FileBrowserMode, FileBrowserSelectionType, FileBrowserUI class FilePicker: def __init__(self, title, mode, file_type, filter_options, save_extensions=None): self._mode = mode self._ui_handler = None self._app = omni.kit.app.get_app() self._open_handler = None self._cancel_handler = None self._save_extensions = save_extensions self._ui_handler = FileBrowserUI( title, mode, file_type, filter_options, enable_versioning_pane=(mode == FileBrowserMode.OPEN) ) def _show_prompt(self, file_path, file_save_handler): def _on_file_save(): if file_save_handler: file_save_handler(file_path, True) PromptManager.post_simple_prompt( f'{omni.kit.ui.get_custom_glyph_code("${glyphs}/exclamation.svg")} Overwrite', f"File {os.path.basename(file_path)} already exists, do you want to overwrite it?", ok_button_info=PromptButtonInfo("YES", _on_file_save), cancel_button_info=PromptButtonInfo("NO") ) def _save_and_prompt_if_exists(self, file_path, file_save_handler=None): result, _ = omni.client.stat(file_path) if result == omni.client.Result.OK: self._show_prompt(file_path, file_save_handler) elif file_save_handler: file_save_handler(file_path, False) def _on_file_open(self, path, filter_index=-1): if self._mode == FileBrowserMode.SAVE: _, ext = os.path.splitext(path) if ( filter_index >= 0 and self._save_extensions and filter_index < len(self._save_extensions) and ext not in self._save_extensions ): path += self._save_extensions[filter_index] self._save_and_prompt_if_exists(path, self._open_handler) elif self._open_handler: self._open_handler(path, False) def _on_cancel_open(self): if self._cancel_handler: self._cancel_handler() def set_file_selected_fn(self, file_open_handler): self._open_handler = file_open_handler def set_cancel_fn(self, cancel_handler): self._cancel_handler = cancel_handler def show(self, dir=None, filename=None): if self._ui_handler: if dir: self._ui_handler.set_current_directory(dir) if filename: self._ui_handler.set_current_filename(filename) self._ui_handler.open(self._on_file_open, self._on_cancel_open) def hide(self): if self._ui_handler: self._ui_handler.hide() def set_current_directory(self, dir): if self._ui_handler: self._ui_handler.set_current_directory(dir) def set_current_filename(self, filename): if self._ui_handler: self._ui_handler.set_current_filename(filename) def get_current_filename(self): if self._ui_handler: return self._ui_handler.get_current_filename() return None def destroy(self): if self._ui_handler: self._ui_handler.destroy() self._ui_handler = None
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/utils.py
__all__ = ["build_live_session_user_layout", "is_viewer_only_mode", "VIEWER_ONLY_MODE_SETTING"] import asyncio import carb import os import omni.usd import omni.kit.app import omni.ui as ui import omni.kit.usd.layers as layers from omni.kit.async_engine import run_coroutine from omni.kit.widget.prompt import PromptManager, PromptButtonInfo from pxr import Sdf from typing import Union, List # When this setting is True, it will following the rules: # * When joining a live session, if the user has unsaved changes, # skip the dialog and automatically reload the stage, then join the session. # * When creating a live session, if the user has unsaved changes, # skip the dialog and automatically reload the stage, then create the session. # * When leaving a live session, do not offer to merge changes, # instead reload the stage to its original state VIEWER_ONLY_MODE_SETTING = "/exts/omni.kit.widget.live_session_management/viewer_only_mode" # When this setting is True, it will show the Join/Create Session dialog wqhen the quick live button is pressed. # When this setting if False, it will auto Create Session or Join with no dialog shown. QUICK_JOIN_ENABLED = "/exts/omni.kit.widget.live_session_management/quick_join_enabled" SESSION_LIST_SELECT = "/exts/omni.kit.widget.live_session_management/session_list_select" SESSION_LIST_SELECT_DEFAULT_SESSION = "DefaultSession" SESSION_LIST_SELECT_LAST_SESSION = "LastSession" def is_viewer_only_mode(): return carb.settings.get_settings().get(VIEWER_ONLY_MODE_SETTING) or False def is_quick_join_enabled(): return carb.settings.get_settings().get(QUICK_JOIN_ENABLED) or False def get_session_list_select(): return carb.settings.get_settings().get(SESSION_LIST_SELECT) def join_live_session(layers_interface, layer_identifier, current_session, prim_path=None, force_reload=False): layers_state = layers_interface.get_layers_state() live_syncing = layers_interface.get_live_syncing() layer_handle = Sdf.Find(layer_identifier) def fetch_and_join(layer_identifier): with Sdf.ChangeBlock(): layer = Sdf.Find(layer_identifier) if layer: layer.Reload(True) if layers_state.is_auto_reload_layer(layer_identifier): layers_state.remove_auto_reload_layer(layer_identifier) return live_syncing.join_live_session(current_session, prim_path) async def post_simple_prompt(title, text, ok_button_info, cancel_button_info): await omni.kit.app.get_app().next_update_async() PromptManager.post_simple_prompt( title, text, ok_button_info=ok_button_info, cancel_button_info=cancel_button_info ) is_outdated = layers_state.is_layer_outdated(layer_identifier) if force_reload and (is_outdated or layer_handle.dirty): fetch_and_join(layer_identifier) elif is_outdated: asyncio.ensure_future( post_simple_prompt( "Join Session", "The file you would like to go live on is not up to date, " "a newer version must be fetched for joining a live session. " "Press Fetch to get the most recent version or use Cancel " "if you would like to save a copy first.", ok_button_info=PromptButtonInfo( "Fetch", lambda: fetch_and_join(layer_identifier) ), cancel_button_info=PromptButtonInfo("Cancel") ) ) elif layer_handle.dirty: asyncio.ensure_future( post_simple_prompt( "Join Session", "There are unsaved changes to your file. Joining this live session will discard any unsaved changes.", ok_button_info=PromptButtonInfo( "Join", lambda: fetch_and_join(layer_identifier) ), cancel_button_info=PromptButtonInfo("Cancel") ) ) else: if layers_state.is_auto_reload_layer(layer_identifier): layers_state.remove_auto_reload_layer(layer_identifier) return live_syncing.join_live_session(current_session, prim_path) return True def is_extension_loaded(extansion_name: str) -> bool: """ Returns True if the extension with the given name is loaded. """ def is_ext(id: str, extension_name: str) -> bool: id_name = id.split("-")[0] return id_name == extension_name app = omni.kit.app.get_app_interface() ext_manager = app.get_extension_manager() extensions = ext_manager.get_extensions() loaded = next((ext for ext in extensions if is_ext(ext["id"], extansion_name) and ext["enabled"]), None) return not not loaded def build_live_session_user_layout(user_info: layers.LiveSessionUser, size=16, tooltip = "", on_double_click_fn: callable = None, on_mouse_click_fn: callable = None) -> ui.ZStack: """Builds user icon.""" user_layout = ui.ZStack(width=size, height=size) with user_layout: circle = ui.Circle( style={"background_color": ui.color(*user_info.user_color)} ) if on_double_click_fn: circle.set_mouse_double_clicked_fn(lambda x, y, b, m, user_info_t=user_info: on_double_click_fn( x, y, b, m, user_info_t)) if on_mouse_click_fn: circle.set_mouse_pressed_fn(lambda x, y, b, m, user_info_t=user_info: on_mouse_click_fn( x, y, b, m, user_info_t)) ui.Label( layers.get_short_user_name(user_info.user_name), style={"font_size": size - 5, "color": 0xFFFFFFFF}, alignment=ui.Alignment.CENTER ) if tooltip: user_layout.set_tooltip(tooltip) return user_layout def reload_outdated_layers( layer_identifiers: Union[str, List[str]], usd_context_name_or_instance: Union[str, omni.usd.UsdContext] = None ) -> None: """Reloads outdated layer. It will show prompt to user if layer is in a Live Session.""" if isinstance(usd_context_name_or_instance, str): usd_context = omni.usd.get_context(usd_context_name_or_instance) elif isinstance(usd_context_name_or_instance, omni.usd.UsdContext): usd_context = usd_context_name_or_instance elif not usd_context_name_or_instance: usd_context = omni.usd.get_context() if not usd_context: carb.log_error("Failed to reload layer as usd context is not invalid.") return if isinstance(layer_identifiers, str): layer_identifiers = [layer_identifiers] live_syncing = layers.get_live_syncing(usd_context) layers_state = layers.get_layers_state(usd_context) all_layer_ids = layers_state.get_all_outdated_layer_identifiers() if not all_layer_ids: return layer_identifiers = [layer_id for layer_id in layer_identifiers if layer_id in all_layer_ids] if not layer_identifiers: return count = 0 for layer_identifier in layer_identifiers: if live_syncing.is_layer_in_live_session(layer_identifier): count += 1 if count == 1: title = f"{os.path.basename(layer_identifier)} is in a Live Session" else: title = "Reload Layers In Live Session" def reload_layers(layer_identifiers): async def reload(layer_identifiers): layers.LayerUtils.reload_all_layers(layer_identifiers) run_coroutine(reload(layer_identifiers)) if count != 0: PromptManager.post_simple_prompt( title, "Reloading live layers has performance implications and some live edits may be lost - OK to proceed?", PromptButtonInfo("YES", lambda: reload_layers(layer_identifiers)), PromptButtonInfo("NO") ) else: reload_layers(layer_identifiers)
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/join_with_session_link_window.py
__all__ = ["JoinWithSessionLinkWindow"] import asyncio import carb import omni.kit.usd.layers as layers import omni.ui as ui import omni.kit.notification_manager as nm import omni.kit.app import omni.kit.clipboard from pxr import Usd from .layer_icons import LayerIcons class JoinWithSessionLinkWindow: def __init__(self, layers_interface: layers.Layers): self._window = None self._layers_interface = layers_interface self._buttons = [] self._session_link_input_field = None self._session_link_input_hint = None self._error_label = None self._session_link_begin_edit_cb = None self._session_link_end_edit_cb = None self._session_link_edit_cb = None self._key_functions = { int(carb.input.KeyboardInput.ENTER): self._on_ok_button_fn, int(carb.input.KeyboardInput.ESCAPE): self._on_cancel_button_fn } self._build_ui() def destroy(self): self._layers_interface = None for button in self._buttons: button.set_clicked_fn(None) self._buttons.clear() if self._window: self._window.visible = False self._window = None self._session_link_input_hint = None self._session_link_input_field = None self._session_link_begin_edit_cb = None self._session_link_end_edit_cb = None self._session_link_edit_cb = None self._error_label = None @property def visible(self): return self._window and self._window.visible @visible.setter def visible(self, value): if self._window: self._window.visible = value if value: async def focus_field(): await omni.kit.app.get_app().next_update_async() if self._session_link_input_field: self._session_link_input_field.focus_keyboard() asyncio.ensure_future(focus_field()) @property def current_session_link(self): if self._session_link_input_field: return self._session_link_input_field.model.get_value_as_string() return "" @current_session_link.setter def current_session_link(self, value): if self._session_link_input_field: self._session_link_input_field.model.set_value(value) def _validate_session_link(self, str): return str and Usd.Stage.IsSupportedFile(str) def _on_ok_button_fn(self): if not self._update_button_status(): return self._error_label.text = "" self.visible = False session_link = self._session_link_input_field.model.get_value_as_string() session_link = session_link.strip() live_syncing = self._layers_interface.get_live_syncing() async def open_stage_with_live_session(live_syncing, session_link): (success, error) = await live_syncing.open_stage_with_live_session_async(session_link) if not success: nm.post_notification(f"Failed to open stage {session_link} with live session: {error}.") asyncio.ensure_future(open_stage_with_live_session(live_syncing, session_link)) def _on_cancel_button_fn(self): self.visible = False def _on_key_pressed_fn(self, key, mod, pressed): if not pressed: return func = self._key_functions.get(key) if func: func() def _update_button_status(self): if not self._session_link_input_field: return False session_link = self._session_link_input_field.model.get_value_as_string() session_link = session_link.strip() join_button = self._buttons[0] if not self._validate_session_link(session_link): if session_link: self._error_label.text = "The link is not supported for USD." else: self._error_label.text = "" join_button.enabled = False else: self._error_label.text = "" join_button.enabled = True if not session_link: self._session_link_input_hint.visible = True else: self._session_link_input_hint.visible = False return join_button.enabled def _on_session_link_begin_edit(self, model): self._update_button_status() def _on_session_link_end_edit(self, model): self._update_button_status() def _on_session_link_edit(self, model): self._update_button_status() def _on_paste_link_fn(self): link = omni.kit.clipboard.paste() if link: self._session_link_input_field.model.set_value(link) def _build_ui(self): """Construct the window based on the current parameters""" self._window = ui.Window( "JOIN LIVE SESSION WITH LINK", visible=False, width=500, height=0, auto_resize=True, dockPreference=ui.DockPreference.DISABLED ) self._window.flags = ( ui.WINDOW_FLAGS_NO_COLLAPSE | ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_RESIZE | ui.WINDOW_FLAGS_NO_MOVE ) self._window.set_key_pressed_fn(self._on_key_pressed_fn) self._window.flags = self._window.flags | ui.WINDOW_FLAGS_MODAL STYLES = { "Rectangle::hovering": {"background_color": 0x0, "border_radius": 2, "margin": 0, "padding": 0}, "Rectangle::hovering:hovered": {"background_color": 0xFF9E9E9E}, "Button.Image::paste_button": {"image_url": LayerIcons().get("paste"), "color": 0xFFD0D0D0}, "Button::paste_button": {"background_color": 0x0, "margin": 0}, "Button::paste_button:checked": {"background_color": 0x0}, "Button::paste_button:hovered": {"background_color": 0x0}, "Button::paste_button:pressed": {"background_color": 0x0}, } with self._window.frame: with ui.VStack(height=0, style=STYLES): ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer(width=20) self._error_label = ui.Label("", name="error_label", style={"color": 0xFF0000CC}, alignment=ui.Alignment.LEFT, word_wrap=True) ui.Spacer(width=20) ui.Spacer(width=0, height=5) with ui.ZStack(height=0): with ui.HStack(height=0): ui.Spacer(width=20) with ui.ZStack(width=20, height=20): ui.Rectangle(name="hovering") paste_link_button = ui.ToolButton(name="paste_button", image_width=20, image_height=20) paste_link_button.set_clicked_fn(self._on_paste_link_fn) ui.Spacer(width=4) with ui.VStack(): ui.Spacer() with ui.ZStack(height=0): self._session_link_input_field = ui.StringField( name="new_session_link_field", width=self._window.width - 40, height=0 ) self._session_link_input_hint = ui.Label( " Paste Live Session Link Here", alignment=ui.Alignment.LEFT_CENTER, style={"color": 0xFF3F3F3F} ) self._session_link_begin_edit_cb = self._session_link_input_field.model.subscribe_begin_edit_fn( self._on_session_link_begin_edit ) self._session_link_end_edit_cb = self._session_link_input_field.model.subscribe_end_edit_fn( self._on_session_link_end_edit ) self._session_link_edit_cb = self._session_link_input_field.model.subscribe_value_changed_fn( self._on_session_link_edit ) ui.Spacer() ui.Spacer(width=20) ui.Spacer(width=0, height=30) with ui.HStack(height=0): ui.Spacer(height=0) ok_button = ui.Button("JOIN", name="confirm_button", width=120, height=0) ok_button.set_clicked_fn(self._on_ok_button_fn) cancel_button = ui.Button("CANCEL", name="cancel_button", width=120, height=0) cancel_button.set_clicked_fn(self._on_cancel_button_fn) self._buttons.append(ok_button) self._buttons.append(cancel_button) ui.Spacer(height=0, width=20) ui.Spacer(width=0, height=20) # 0 for ok button, 0 for cancel button and appends paste link button at last self._buttons.append(paste_link_button) self._update_button_status()
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/reload_widget.py
__all__ = ["build_reload_widget"] import carb import omni.usd import omni.kit.app import omni.ui as ui import omni.kit.usd.layers as layers import weakref from functools import partial from typing import Union from .live_style import Styles from .layer_icons import LayerIcons from .utils import reload_outdated_layers from omni.kit.async_engine import run_coroutine class ReloadWidgetWrapper(ui.ZStack): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.auto_reload_menu = None def __del__(self): if self.auto_reload_menu: self.auto_reload_menu.hide() self.auto_reload_menu = None def show_reload_menu(layer_identifier, usd_context, widget, button, global_auto): """Creates and shows a reload menu relative to widget position""" layers_state = layers.get_layers_state(usd_context) live_syncing = layers.get_live_syncing() is_outdated = layers_state.is_layer_outdated(layer_identifier) in_session = live_syncing.is_layer_in_live_session(layer_identifier) def toggle_auto_reload(layer_identifier, widget): async def toggle(layer_identifier): is_auto = layers_state.is_auto_reload_layer(layer_identifier) if not is_auto: layers_state.add_auto_reload_layer(layer_identifier) widget.set_style(Styles.RELOAD_AUTO) button.tooltip = "Auto Reload Enabled" else: layers_state.remove_auto_reload_layer(layer_identifier) widget.set_style(Styles.RELOAD_BTN) button.tooltip = "Reload" run_coroutine(toggle(layer_identifier)) def reload_layer(layer_identifier): reload_outdated_layers(layer_identifier, layers_state._usd_context) auto_reload_menu = ui.Menu("auto_reload_menu") with auto_reload_menu: ui.MenuItem( "Reload Layer", triggered_fn=lambda *args: reload_layer(layer_identifier), enabled=is_outdated, visible=not global_auto ) ui.MenuItem( "Auto Reload", triggered_fn=lambda *args: toggle_auto_reload(layer_identifier, widget), checkable=True, checked=layers_state.is_auto_reload_layer(layer_identifier), visible=not global_auto, enabled=not in_session ) _x = widget.screen_position_x _y = widget.screen_position_y _h = widget.computed_height auto_reload_menu.show_at(_x - 95, _y + _h / 2 + 2) return auto_reload_menu def build_reload_widget( layer_identifier: str, usd_context_name_or_instance: Union[str, omni.usd.UsdContext] = None, is_outdated=False, is_auto=False, global_auto=False ) -> None: """Builds reload widget.""" if isinstance(usd_context_name_or_instance, str): usd_context = omni.usd.get_context(usd_context_name_or_instance) elif isinstance(usd_context_name_or_instance, omni.usd.UsdContext): usd_context = usd_context_name_or_instance elif not usd_context_name_or_instance: usd_context = omni.usd.get_context() if not usd_context: carb.log_error("Failed to reload layer as usd context is not invalid.") return reload_stack = ReloadWidgetWrapper(width=0, height=0) if global_auto: is_auto = global_auto reload_stack.name = "reload-auto" if is_auto else "reload-outd" if is_outdated else "reload" reload_stack.set_style(Styles.RELOAD_AUTO if is_auto and not is_outdated else Styles.RELOAD_OTD if is_outdated else Styles.RELOAD_BTN) with reload_stack: with ui.VStack(width=0, height=0): ui.Spacer(width=22, height=12) with ui.HStack(width=0): ui.Spacer(width=16) ui.Image( LayerIcons.get("drop_down"), width=6, height=6, alignment=ui.Alignment.RIGHT_BOTTOM, name="drop_down" ) ui.Image(LayerIcons.get("reload"), width=20, name="reload") tooltip = "Auto Reload All Enabled" if global_auto else "Auto Reload Enabled" if is_auto else "Reload" if is_outdated: tooltip = "Reload Outdated" reload_button = ui.InvisibleButton(width=20, tooltip=tooltip) def on_reload_clicked(layout_weakref, x, y, b, m): if (b == 0): reload_outdated_layers(layer_identifier, usd_context) return auto_reload_menu = show_reload_menu(layer_identifier, usd_context, reload_stack, reload_button, global_auto) if layout_weakref(): # Hold the menu handle to release it along with the stack. layout_weakref().auto_reload_menu = auto_reload_menu layout_weakref = weakref.ref(reload_stack) reload_button.set_mouse_pressed_fn(partial(on_reload_clicked, layout_weakref)) return reload_stack
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_start_window.py
import asyncio import carb import omni.kit.app import omni.kit.usd.layers as layers import omni.ui as ui import re from .layer_icons import LayerIcons from .utils import join_live_session, is_viewer_only_mode, get_session_list_select, SESSION_LIST_SELECT_DEFAULT_SESSION from omni.kit.widget.prompt import PromptButtonInfo, PromptManager from pxr import Sdf from .live_session_model import LiveSessionModel class LiveSessionStartWindow: def __init__(self, layers_interface: layers.Layers, layer_identifier, prim_path): self._window = None self._layers_interface = layers_interface self._base_layer_identifier = layer_identifier self._live_prim_path = prim_path self._buttons = [] self._existing_sessions_combo = None self._session_name_input_field = None self._session_name_input_hint = None self._error_label = None self._session_name_begin_edit_cb = None self._session_name_end_edit_cb = None self._session_name_edit_cb = None self._existing_sessions_model = LiveSessionModel(self._layers_interface, layer_identifier) self._participants_list = None self._participants_layout = None self._existing_sessions_model.set_user_update_callback(self._on_channel_users_update) self._existing_sessions_model.add_value_changed(self._on_session_list_changed) self._update_user_list_task: asyncio.Future = None self._join_create_radios = None self._key_functions = { int(carb.input.KeyboardInput.ENTER): self._on_ok_button_fn, int(carb.input.KeyboardInput.ESCAPE): self._on_cancel_button_fn } self._build_ui() def _on_layer_event(event: carb.events.IEvent): payload = layers.get_layer_event_payload(event) if payload.event_type == layers.LayerEventType.LIVE_SESSION_LIST_CHANGED: if self._base_layer_identifier not in payload.identifiers_or_spec_paths: return self._existing_sessions_model.refresh_sessions(force=True) self._update_dialog_states() self._layers_event_subscription = layers_interface.get_event_stream().create_subscription_to_pop( _on_layer_event, name="Session Start Window Events" ) def destroy(self): self._layers_interface = None for button in self._buttons: button.set_clicked_fn(None) self._buttons.clear() self._participants_list = None if self._window: self._window.visible = False self._window = None if self._existing_sessions_model: self._existing_sessions_model.set_user_update_callback(None) self._existing_sessions_model.destroy() self._existing_sessions_model = None self._participants_layout = None self._layers_event_subscription = None self._existing_sessions_combo = None self._existing_sessions_empty_hint = None self._join_create_radios = None self._session_name_input_hint = None self._session_name_input_field = None self._session_name_begin_edit_cb = None self._session_name_end_edit_cb = None self._session_name_edit_cb = None self._error_label = None if self._update_user_list_task: try: self._update_user_list_task.cancel() except Exception: pass self._update_user_list_task = None @property def visible(self): return self._window and self._window.visible @visible.setter def visible(self, value): if self._window: self._window.visible = value if not self._window.visible: if self._update_user_list_task: try: self._update_user_list_task.cancel() except Exception: pass self._update_user_list_task = None self._existing_sessions_model.stop_channel() def set_focus(self, join_session): if not self._join_create_radios: return if join_session: self._join_create_radios.model.set_value(0) if get_session_list_select() == SESSION_LIST_SELECT_DEFAULT_SESSION: self._existing_sessions_model.select_default_session() else: self._join_create_radios.model.set_value(1) async def async_focus_keyboard(): await omni.kit.app.get_app().next_update_async() self._session_name_input_field.focus_keyboard() omni.kit.async_engine.run_coroutine(async_focus_keyboard()) def _on_channel_users_update(self): async def _update_users(): all_users = self._existing_sessions_model.all_users current_session = self._existing_sessions_model.current_session if not current_session: return self._participants_list.clear() with self._participants_list: if len(all_users) > 0: for _, user in all_users.items(): is_owner = current_session.owner == user.user_name with ui.VStack(height=0): ui.Spacer(height=5) with ui.HStack(height=0): ui.Spacer(width=10) if is_owner: ui.Label(f"{user.user_name} - {user.from_app} (owner)", style={"color": 0xFF808080}) else: ui.Label(f"{user.user_name} - {user.from_app}", style={"color": 0xFF808080}) else: self._build_empty_participants_list() if not self._update_user_list_task or self._update_user_list_task.done(): self._update_user_list_task = asyncio.ensure_future(_update_users()) def _validate_session_name(self, str): if re.match(r'^[a-zA-Z][a-zA-Z0-9-_]*$', str): return True return False def _on_join_session(self, current_session): layer_identifier = self._base_layer_identifier layers_interface = self._layers_interface prim_path = self._live_prim_path return join_live_session( layers_interface, layer_identifier, current_session, prim_path, is_viewer_only_mode() ) def _on_ok_button_fn(self): # pragma: no cover live_syncing = self._layers_interface.get_live_syncing() current_option = self._join_create_radios.model.as_int join_session = current_option == 0 if join_session: current_session = self._existing_sessions_model.current_session if not current_session: self._error_label.text = "No Valid Session Selected" self._error_label.visible = True elif self._on_join_session(current_session): self._error_label.text = "" self._error_label.visible = False self.visible = False else: self._error_label.text = "Failed to join session, please check console for more details." self._error_label.visible = True else: session_name = self._session_name_input_field.model.get_value_as_string() session_name = session_name.strip() if not session_name or not self._validate_session_name(session_name): self._update_button_status(session_name) self._error_label.text = "Session name must be given." self._error_label.visible = True else: session = live_syncing.create_live_session(layer_identifier=self._base_layer_identifier, name=session_name) if not session: self._error_label.text = "Failed to create session, please check console for more details." self._error_label.visible = True elif not self._on_join_session(session): self._error_label.text = "Failed to join session, please check console for more details." self._error_label.visible = True else: self._error_label.text = "" self._error_label.visible = False self.visible = False def _on_cancel_button_fn(self): self.visible = False def _on_key_pressed_fn(self, key, mod, pressed): if not pressed: return func = self._key_functions.get(key) if func: func() def _build_option_checkbox(self, name, text, default_value, tooltip=""): # pragma: no cover with ui.HStack(height=0, width=0): checkbox = ui.CheckBox(width=20, name=name) checkbox.model.set_value(default_value) label = ui.Label(text, alignment=ui.Alignment.LEFT) if tooltip: label.set_tooltip(tooltip) return checkbox, label def _build_option_radio(self, collection, name, text, tooltip=""): style = { "": {"background_color": 0x0, "image_url": LayerIcons.get("radio_off")}, ":checked": {"image_url": LayerIcons.get("radio_on")}, } with ui.HStack(height=0, width=0): radio = ui.RadioButton(radio_collection=collection, width=28, height=28, name=name, style=style) ui.Spacer(width=4) label = ui.Label(text, alignment=ui.Alignment.LEFT_CENTER) if tooltip: label.set_tooltip(tooltip) return radio def _update_button_status(self, session_name): join_button = self._buttons[0] if session_name and not self._validate_session_name(session_name): if not str.isalpha(session_name[0]): self._error_label.text = "Session name must be prefixed with letters." else: self._error_label.text = "Only alphanumeric letters, hyphens, or underscores are supported." self._error_label.visible = True join_button.enabled = False else: self._error_label.text = "" self._error_label.visible = False join_button.enabled = True def _on_session_name_begin_edit(self, model): self._session_name_input_hint.visible = False session_name = model.get_value_as_string().strip() self._update_button_status(session_name) def _on_session_name_end_edit(self, model): if len(model.get_value_as_string()) == 0: self._session_name_input_hint.visible = True session_name = model.get_value_as_string().strip() self._update_button_status(session_name) def _on_session_name_edit(self, model): session_name = model.get_value_as_string().strip() self._update_button_status(session_name) def _update_dialog_states(self): self._error_label.text = "" current_option = self._join_create_radios.model.as_int show_join_session = current_option == 0 join_button = self._buttons[0] if show_join_session: self._existing_sessions_combo.visible = True self._session_name_input_field.visible = False self._session_name_input_hint.visible = False self._participants_layout.visible = True self._existing_sessions_model.refresh_sessions() if self._existing_sessions_model.empty(): self._existing_sessions_empty_hint.visible = True else: self._existing_sessions_empty_hint.visible = False join_button.text = "JOIN" else: self._participants_layout.visible = False self._existing_sessions_combo.visible = False self._session_name_input_field.visible = True self._session_name_input_hint.visible = False self._existing_sessions_empty_hint.visible = False self._existing_sessions_model.clear() join_button.text = "CREATE" new_session_name = self._existing_sessions_model.create_new_session_name() self._session_name_input_field.model.set_value(new_session_name) self._session_name_input_field.focus_keyboard() def _on_radios_changed_fn(self, model): self._update_dialog_states() self._on_checkbox_changed_called = False def _on_session_list_changed(self, model): if self._participants_list: self._participants_list.clear() def _build_ui(self): """Construct the window based on the current parameters""" self._window = ui.Window("Live Session", visible=False, height=0, auto_resize=True, dockPreference=ui.DockPreference.DISABLED) self._window.flags = ( ui.WINDOW_FLAGS_NO_COLLAPSE | ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_RESIZE | ui.WINDOW_FLAGS_NO_MOVE ) self._window.set_key_pressed_fn(self._on_key_pressed_fn) self._window.flags = self._window.flags | ui.WINDOW_FLAGS_MODAL self._existing_sessions_model.refresh_sessions() empty_sessions = self._existing_sessions_model.empty() with self._window.frame: with ui.VStack(height=0): ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer() self._join_create_radios = ui.RadioCollection() self._build_option_radio(self._join_create_radios, "join_session_radio_button", "Join Session") ui.Spacer(width=20) self._build_option_radio(self._join_create_radios, "create_session_radio_button", "Create Session") ui.Spacer() self._join_create_radios.model.add_value_changed_fn(lambda _: self._update_dialog_states()) ui.Spacer(width=0, height=15) with ui.HStack(height=0): ui.Spacer(width=20) self._error_label = ui.Label("", name="error_label", style={"color": 0xFF0000CC}, alignment=ui.Alignment.LEFT, word_wrap=True) ui.Spacer(width=20) ui.Spacer(width=0, height=5) with ui.ZStack(height=0): with ui.HStack(height=0): ui.Spacer(width=20) with ui.ZStack(height=0): self._session_name_input_field = ui.StringField( name="new_session_name_field", width=self._window.width - 40, height=0 ) self._session_name_input_hint = ui.Label( " New Session Name", alignment=ui.Alignment.LEFT_CENTER, style={"color": 0xFF3F3F3F} ) self._session_name_begin_edit_cb = self._session_name_input_field.model.subscribe_begin_edit_fn( self._on_session_name_begin_edit ) self._session_name_end_edit_cb = self._session_name_input_field.model.subscribe_end_edit_fn( self._on_session_name_end_edit ) self._session_name_edit_cb = self._session_name_input_field.model.subscribe_value_changed_fn( self._on_session_name_edit ) ui.Spacer(width=20) with ui.HStack(height=0): ui.Spacer(width=20) with ui.ZStack(height=0): self._existing_sessions_combo = ui.ComboBox( self._existing_sessions_model, width=self._window.width - 40, height=0 ) self._existing_sessions_empty_hint = ui.Label( " No Existing Sessions", alignment=ui.Alignment.LEFT_CENTER, style={"color": 0xFF3F3F3F} ) ui.Spacer(width=20) ui.Spacer(width=0, height=10) self._participants_layout = ui.VStack(height=0) with self._participants_layout: with ui.HStack(height=0): ui.Spacer(width=20) with ui.VStack(height=0, width=0): with ui.HStack(height=0, width=0): ui.Label("Participants: ", alignment=ui.Alignment.CENTER) with ui.HStack(): ui.Spacer() ui.Image(LayerIcons.get("participants"), width=28, height=28) ui.Spacer() ui.Spacer(width=0, height=5) with ui.HStack(height=0): with ui.ScrollingFrame(height=120, style={"background_color": 0xFF24211F}): self._participants_list = ui.VStack(height=0) with self._participants_list: self._build_empty_participants_list() ui.Spacer(width=20) ui.Spacer(width=0, height=30) with ui.HStack(height=0): ui.Spacer(height=0) ok_button = ui.Button("JOIN", name="confirm_button", width=120, height=0) ok_button.set_clicked_fn(self._on_ok_button_fn) cancel_button = ui.Button("CANCEL", name="cancel_button", width=120, height=0) cancel_button.set_clicked_fn(self._on_cancel_button_fn) self._buttons.append(ok_button) self._buttons.append(cancel_button) ui.Spacer(height=0, width=20) ui.Spacer(width=0, height=20) if empty_sessions: self._join_create_radios.model.set_value(1) else: self._update_dialog_states() def _build_empty_participants_list(self): with ui.VStack(height=0): ui.Spacer(height=5) with ui.HStack(height=0): ui.Spacer(width=10) ui.Label("No users currently in session.", style={"color": 0xFF808080})
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_end_window.py
import carb import asyncio import omni.ui as ui import omni.kit.app import omni.kit.usd.layers as layers import omni.kit.notification_manager as nm from omni.kit.widget.prompt import PromptManager from pxr import Sdf from .file_picker import FilePicker, FileBrowserMode, FileBrowserSelectionType class LiveSessionEndWindow: def __init__(self, layers_interface: layers.Layers, layer_identifier): self._window = None self._live_syncing = layers_interface.get_live_syncing() self._base_layer_identifier = layer_identifier self._buttons = [] self._options_combo = None self._file_picker = None self._key_functions = { int(carb.input.KeyboardInput.ENTER): self._on_ok_button_fn, int(carb.input.KeyboardInput.ESCAPE): self._on_cancel_button_fn } self._build_ui() def destroy(self): for button in self._buttons: button.set_clicked_fn(None) self._buttons.clear() if self._window: self._window.visible = False self._window = None self._options_combo = None if self._file_picker: self._file_picker.destroy() self._file_picker = None async def __aenter__(self): await self._live_syncing.broadcast_merge_started_message_async(self._base_layer_identifier) self.visible = True # Wait until dialog disappears while self.visible: await asyncio.sleep(0.1) async def __aexit__(self, exc_type, exc, tb): self.visible = False @property def visible(self): return self._window and self._window.visible @visible.setter def visible(self, value): if self._window: self._window.visible = value def _on_ok_button_fn(self): self.visible = False if not self._live_syncing.is_layer_in_live_session(self._base_layer_identifier): return prompt = None async def pre_merge(current_session): nonlocal prompt app = omni.kit.app.get_app() await app.next_update_async() await app.next_update_async() prompt = PromptManager.post_simple_prompt( "Merging", "Merging live layers into base layers...", None, shortcut_keys=False ) async def post_merge(success): nonlocal prompt if prompt: prompt.destroy() prompt = None if success: await self._live_syncing.broadcast_merge_done_message_async( layer_identifier=self._base_layer_identifier ) current_session = self._live_syncing.get_current_live_session(self._base_layer_identifier) comment = self._description_field.model.get_value_as_string() option = self._options_combo.model.get_item_value_model().as_int if option == 1: def save_model(file_path: str, overwrite_existing: bool): layer = Sdf.Layer.FindOrOpen(file_path) if not layer: layer = Sdf.Layer.CreateNew(file_path) if not layer: error = f"Failed to save live changes to layer {file_path} as it's not writable." carb.log_error(error) nm.post_notification(error, status=nm.NotificationStatus.WARNING) return asyncio.ensure_future( self._live_syncing.merge_and_stop_live_session_async( file_path, comment, pre_merge=pre_merge, post_merge=post_merge, layer_identifier=self._base_layer_identifier ) ) usd_context = self._live_syncing.usd_context stage = usd_context.get_stage() root_layer_identifier = stage.GetRootLayer().identifier root_layer_name = current_session.name self._show_file_picker(save_model, root_layer_identifier, root_layer_name) elif option == 0: asyncio.ensure_future( self._live_syncing.merge_and_stop_live_session_async( comment=comment, pre_merge=pre_merge, post_merge=post_merge, layer_identifier=self._base_layer_identifier ) ) def _on_cancel_button_fn(self): self.visible = False def _on_key_pressed_fn(self, key, mod, pressed): if not pressed: return func = self._key_functions.get(key) if func: func() def _create_file_picker(self): filter_options = [ (r"^(?=.*.usd$)((?!.*\.(sublayer)\.usd).)*$", "USD File (*.usd)"), (r"^(?=.*.usda$)((?!.*\.(sublayer)\.usda).)*$", "USDA File (*.usda)"), (r"^(?=.*.usdc$)((?!.*\.(sublayer)\.usdc).)*$", "USDC File (*.usdc)"), ("(.*?)", "All Files (*.*)"), ] layer_file_picker = FilePicker( "Save Live Changes", FileBrowserMode.SAVE, FileBrowserSelectionType.FILE_ONLY, filter_options, [".usd", ".usda", ".usdc", ".usd"], ) return layer_file_picker def _show_file_picker(self, file_handler, default_location=None, default_filename=None): if not self._file_picker: self._file_picker = self._create_file_picker() self._file_picker.set_file_selected_fn(file_handler) self._file_picker.show(default_location, default_filename) def _on_description_begin_edit(self, model): self._description_field_hint_label.visible = False def _on_description_end_edit(self, model): if len(model.get_value_as_string()) == 0: self._description_field_hint_label.visible = True def _build_ui(self): """Construct the window based on the current parameters""" self._window = ui.Window("Merge Options", visible=False, height=0, dockPreference=ui.DockPreference.DISABLED) self._window.flags = ( ui.WINDOW_FLAGS_NO_COLLAPSE | ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_RESIZE | ui.WINDOW_FLAGS_NO_MOVE ) self._window.set_key_pressed_fn(self._on_key_pressed_fn) self._window.flags = self._window.flags | ui.WINDOW_FLAGS_MODAL current_session = self._live_syncing.get_current_live_session(self._base_layer_identifier) with self._window.frame: with ui.VStack(height=0): ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer() ui.Label( "Live Session is ending.", word_wrap=True, alignment=ui.Alignment.CENTER, width=self._window.width - 80, height=0 ) ui.Spacer() with ui.HStack(height=0): ui.Spacer() ui.Label( f"How do you want to merge changes from '{current_session.name}' session?", alignment=ui.Alignment.CENTER, word_wrap=True, width=self._window.width - 80, height=0 ) ui.Spacer() ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer() self._options_combo = ui.ComboBox( 0, "Merge to corresponding layers", "Merge to a new layer", word_wrap=True, width=self._window.width - 80, height=0 ) ui.Spacer() ui.Spacer(width=0, height=10) with ui.HStack(height=0): ui.Spacer(width=40) self._checkpoint_comment_frame = ui.Frame() with self._checkpoint_comment_frame: with ui.VStack(height=0, spacing=5): ui.Label("Checkpoint Description") with ui.ZStack(): self._description_field = ui.StringField(multiline=True, height=80) self._description_field_hint_label = ui.Label( " Description", alignment=ui.Alignment.LEFT_TOP, style={"color": 0xFF3F3F3F} ) self._description_begin_edit_sub = self._description_field.model.subscribe_begin_edit_fn( self._on_description_begin_edit ) self._description_end_edit_sub = self._description_field.model.subscribe_end_edit_fn( self._on_description_end_edit ) ui.Spacer(width=40) ui.Spacer(width=0, height=30) with ui.HStack(height=0): ui.Spacer(height=0) ok_button = ui.Button("CONTINUE", name="confirm_button", width=120, height=0) ok_button.set_clicked_fn(self._on_ok_button_fn) cancel_button = ui.Button("CANCEL", name="cancel_button", width=120, height=0) cancel_button.set_clicked_fn(self._on_cancel_button_fn) self._buttons.append(ok_button) self._buttons.append(cancel_button) ui.Spacer(height=0) ui.Spacer(width=0, height=10)
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_style.py
class Styles: RELOAD_BTN = None RELOAD_AUTO = None RELOAD_OTD = None LIVE_TOOL_TIP = None @staticmethod def on_startup(): # from .layer_icons import LayerIcons as li from omni.ui import color as cl c_otd = cl("#eb9d00") c_otdh = cl("#ffaa00") c_live = cl("#76B900") c_liveh = cl("#9bf400") c_lived = cl("#76B900") c_auto = cl("#34C7FF") c_autoh = cl("#82dcff") c_white = cl("#ffffff") c_rel = cl("#888888") c_relh = cl("#BBBBBB") c_disabled = cl("#555555") Styles.LIVE_TOOL_TIP = {"background_color": 0xEE222222, "color": 0x33333333} Styles.LIVE_GREEN = {"color": c_live, "Tooltip": Styles.LIVE_TOOL_TIP} Styles.LIVE_SEL = {"color": c_liveh, "Tooltip": Styles.LIVE_TOOL_TIP} Styles.LIVE_GREEN_DARKER = {"color": c_lived, "Tooltip": Styles.LIVE_TOOL_TIP} Styles.RELOAD_BTN = { "color": c_rel, ":hovered": {"color": c_relh}, ":pressed": {"color": c_white}, ":disabled": {"color": c_disabled}, } Styles.RELOAD_AUTO = { "color": c_auto, "Tooltip": Styles.LIVE_TOOL_TIP, ":hovered": {"color": c_autoh}, ":pressed": {"color": c_white}, ":disabled": {"color": c_disabled}, } Styles.RELOAD_OTD = { "color": c_otd, "Tooltip": Styles.LIVE_TOOL_TIP, ":hovered": {"color": c_otdh}, ":pressed": {"color": c_white}, ":disabled": {"color": c_disabled}, }
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_model.py
__all__ = ["LiveSessionItem", "LiveSessionModel"] import asyncio import omni.kit.usd.layers as layers import omni.ui as ui from typing import Callable import itertools _last_sessions = {} class LiveSessionItem(ui.AbstractItem): def __init__(self, session: layers.LiveSession) -> None: super().__init__() self._session = session self.model = ui.SimpleStringModel(session.name) @property def session(self): return self._session def __str__(self) -> str: return self._session.name class LiveSessionModel(ui.AbstractItemModel): def __init__(self, layers_interface: layers.Layers, layer_identifier, update_users=True) -> None: super().__init__() self._layers_interface = layers_interface self._base_layer_identifier = layer_identifier self._current_index = ui.SimpleIntModel() self._current_index.set_value(-1) id = self._current_index.add_value_changed_fn(self._value_changed_fn) self._items = [] self._current_session = None self._current_session_channel = None self._channel_subscriber = None self._join_channel_task = None self._all_users = {} self._user_update_callback: Callable[[], None] = None self._all_value_changed_fns = [id] self._update_users = update_users self._refreshing_item = False self._is_default_session_selected = False def __del__(self): self.destroy() @property def all_users(self): return self._all_users @property def is_default_session_selected(self): return self._is_default_session_selected def set_user_update_callback(self, callback: Callable[[], None]): self._user_update_callback = callback def stop_channel(self): self._cancel_current_task() def _join_current_channel(self): if not self._current_session or not self._update_users: return try: # OM-108516: Make channel_manager optional import omni.kit.collaboration.channel_manager as cm except ImportError: return if not self._current_session_channel or self._current_session_channel.url != self._current_session.url: self._cancel_current_task() async def join_stage_async(url): self._current_session_channel = await cm.join_channel_async(url, True) if not self._current_session_channel: return self._channel_subscriber = self._current_session_channel.add_subscriber(self._on_channel_message) self._join_channel_task = asyncio.ensure_future(join_stage_async(self._current_session.channel_url)) def _on_channel_message(self, message): try: # OM-108516: Make channel_manager optional import omni.kit.collaboration.channel_manager as cm except ImportError: return user = message.from_user if message.message_type == cm.MessageType.LEFT and user.user_id in self._all_users: self._all_users.pop(user.user_id, None) changed = True elif user.user_id not in self._all_users: self._all_users[user.user_id] = user changed = True else: changed = False if changed and self._user_update_callback: self._user_update_callback() def _cancel_current_task(self): if self._join_channel_task and not self._join_channel_task.done(): try: self._join_channel_task.cancel() except Exception: pass if self._current_session_channel: self._current_session_channel.stop() self._current_session_channel = None self._join_channel_task = None self._channel_subscriber = None def add_value_changed(self, fn): if self._current_index: id = self._current_index.add_value_changed_fn(fn) self._all_value_changed_fns.append(id) def _value_changed_fn(self, model): if self._refreshing_item: return global _last_sessions index = self._current_index.as_int if index < 0 or index >= len(self._items): return self._current_session = self._items[index].session self._is_default_session_selected = (self._current_session and self._current_index.as_int == 0) _last_sessions[self._base_layer_identifier] = self._current_session.url self._all_users.clear() if self._user_update_callback: self._user_update_callback() self._join_current_channel() self._refreshing_item = True self._item_changed(None) self._refreshing_item = False def destroy(self): self._user_update_callback = None self._cancel_current_task() if self._current_index: for fn in self._all_value_changed_fns: self._current_index.remove_value_changed_fn(fn) self._all_value_changed_fns.clear() self._current_index = None self._layers_interface = None self._current_session = None self._items = [] self._all_users = {} self._layers_event_subscription = None def clear(self): self._items = [] self._current_session = None self._current_index.set_value(-1) def empty(self): return len(self._items) == 0 def get_item_children(self, item): return self._items @property def current_session(self): return self._current_session def refresh_sessions(self, force=False): global _last_sessions live_syncing = self._layers_interface.get_live_syncing() current_live_session = live_syncing.get_current_live_session(self._base_layer_identifier) live_sessions = live_syncing.get_all_live_sessions(self._base_layer_identifier) live_sessions.sort(key=lambda s: s.get_last_modified_time(), reverse=True) identifier = self._base_layer_identifier pre_sort = [] for session in live_sessions: if session.name == "Default": pre_sort.insert(0, session) else: pre_sort.append(session) self._items.clear() index = 0 if live_sessions else -1 for i, session in enumerate(pre_sort): item = LiveSessionItem(session) if current_live_session and current_live_session.url == session.url: index = i elif identifier in _last_sessions and _last_sessions[identifier] == session.url: index = i self._items.append(item) current_index = self._current_index.as_int if current_index != index: self._current_index.set_value(index) elif force: self._item_changed(None) self._is_default_session_selected = (self._current_session and self._current_index.as_int == 0) def get_item_value_model(self, item, column_id): if item is None: return self._current_index return item.model def select_default_session(self): live_syncing = self._layers_interface.get_live_syncing() live_sessions = live_syncing.get_all_live_sessions(self._base_layer_identifier) if live_sessions and self._current_index.as_int != 0: self._current_index.set_value(0) self._item_changed(None) return def create_new_session_name(self) -> str: live_syncing = self._layers_interface.get_live_syncing() live_sessions = live_syncing.get_all_live_sessions(self._base_layer_identifier) # first we attempt creating a "Default" as the first new session. default_session_name = "Default" if not live_syncing.find_live_session_by_name(self._base_layer_identifier, default_session_name): return default_session_name # if there already is a `Default`, then we use <username>_01, <username>_02, ... layers_instance = live_syncing._layers_instance live_syncing_interface = live_syncing._live_syncing_interface logged_user_name = live_syncing_interface.get_logged_in_user_name_for_layer(layers_instance, self._base_layer_identifier) if "@" in logged_user_name: logged_user_name = logged_user_name.split('@')[0] for i in itertools.count(start=1): user_session_name = "{}_{:02d}".format(logged_user_name, i) if not live_syncing.find_live_session_by_name(self._base_layer_identifier, user_session_name): return user_session_name
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/live_session_camera_follower_list.py
__all__ = ["LiveSessionCameraFollowerList"] import carb import omni.usd import omni.client.utils as clientutils import omni.ui as ui import omni.kit.usd.layers as layers import omni.kit.collaboration.presence_layer as pl from .utils import build_live_session_user_layout from pxr import Sdf from omni.ui import color as cl TOOLTIP_STYLE = { "color": cl("#979797"), "Tooltip": {"background_color": 0xEE222222} } class LiveSessionCameraFollowerList: """Widget to build an user list to show all followers to the specific camera.""" def __init__(self, usd_context: omni.usd.UsdContext, camera_path: Sdf.Path, **kwargs): """ Constructor. Args: usd_context (omni.usd.UsdContext): USD Context instance. camera_path (str): Interested camera. Kwargs: icon_size (int): The width and height of the user icon. 16 pixel by default. spacing (int): The horizonal spacing between two icons. 2 pixel by default. maximum_users (int): The maximum users to show, and show others with overflow. show_my_following_users (bool): Whether it should show the users that are following me or not. """ self.__icon_size = kwargs.get("icon_size", 16) self.__spacing = kwargs.get("spacing", 2) self.__maximum_count = kwargs.get("maximum_users", 3) self.__show_my_following_users = kwargs.get("show_my_following_users", True) self.__camera_path = camera_path self.__usd_context = usd_context self.__presence_layer = pl.get_presence_layer_interface(self.__usd_context) self.__layers = layers.get_layers(usd_context) self.__live_syncing = layers.get_live_syncing() self.__layers_event_subscriptions = [] self.__main_layout: ui.HStack = ui.HStack(width=0, height=0) self.__all_user_layouts = {} self.__initialize() self.__overflow = False self.__overflow_button = None @property def layout(self) -> ui.HStack: return self.__main_layout def empty(self): return len(self.__all_user_layouts) == 0 def track_camera(self, camera_path: Sdf.Path): """Switches the camera path to listen to.""" if self.__camera_path != camera_path: self.__camera_path = camera_path self.__initialize() def __initialize(self): layer_identifier = self.__usd_context.get_stage_url() if self.__camera_path and not clientutils.is_local_url(layer_identifier): for event in [ layers.LayerEventType.LIVE_SESSION_STATE_CHANGED, layers.LayerEventType.LIVE_SESSION_USER_JOINED, layers.LayerEventType.LIVE_SESSION_USER_LEFT, pl.PresenceLayerEventType.BOUND_CAMERA_CHANGED ]: layers_event_subscription = self.__layers.get_event_stream().create_subscription_to_pop_by_type( event, self.__on_layers_event, name=f"omni.kit.widget.live_session_management.LiveSessionCameraFollowerList {str(event)}" ) self.__layers_event_subscriptions.append(layers_event_subscription) else: self.__layers_event_subscriptions = [] self.__build_ui() def __build_ui(self): # Destroyed if not self.__main_layout: return self.__main_layout.clear() self.__all_user_layouts.clear() self.__overflow = False self.__overflow_button = None current_live_session = self.__live_syncing.get_current_live_session() if not current_live_session or not self.__camera_path: return with self.__main_layout: for peer_user in current_live_session.peer_users: self.__add_user(current_live_session, peer_user.user_id, False) if self.__overflow: break if self.empty(): self.__main_layout.visible = False else: self.__main_layout.visible = True def __build_tooltip(self): # pragma: no cover live_session = self.__live_syncing.get_current_live_session(self.__base_layer_identifier) if not live_session: return with ui.VStack(): with ui.HStack(style={"color": cl("#757575")}): ui.Spacer() title_label = ui.Label( "Following by 0 Users", style={"font_size": 12}, width=0 ) ui.Spacer() ui.Spacer(height=0) ui.Separator(style={"color": cl("#4f4f4f")}) ui.Spacer(height=4) valid_users = 0 for user in live_session.peer_users: if not self.__show_my_following_users: following_user_id = self.__presence_layer.get_following_user_id(user.user_id) if following_user_id == live_session.logged_user_id: continue bound_camera_prim = self.__presence_layer.get_bound_camera_prim(user.user_id) if not bound_camera_prim or bound_camera_prim.GetPath() != self.__camera_path: continue valid_users += 1 item_title = f"{user.user_name} ({user.from_app})" with ui.HStack(): build_live_session_user_layout(user, self.__icon_size, "") ui.Spacer(width=4) ui.Label(item_title, style={"font_size": 14}) ui.Spacer(height=2) title_label.text = f"Following by {valid_users} Users" @carb.profiler.profile def __add_user(self, current_live_session, user_id, add_child=False): bound_camera_prim = self.__presence_layer.get_bound_camera_prim(user_id) if not bound_camera_prim: return False if bound_camera_prim.GetPath() == self.__camera_path: user_info = current_live_session.get_peer_user_info(user_id) if not user_info: return False if not self.__show_my_following_users: following_user_id = self.__presence_layer.get_following_user_id(user_id) if following_user_id == current_live_session.logged_user_id: return False if user_id not in self.__all_user_layouts: current_count = len(self.__all_user_layouts) if current_count > self.__maximum_count or self.__overflow: # OMFP-2909: Refresh overflow button to rebuild tooltip. if self.__overflow and self.__overflow_button: self.__overflow_button.set_tooltip_fn(self.__build_tooltip) return True elif current_count == self.__maximum_count: self.__overflow = True layout = ui.HStack(width=0) with layout: ui.Spacer(width=4) with ui.ZStack(): ui.Label("...", style={"font_size": 16}, aligment=ui.Alignment.V_CENTER) self.__overflow_button = ui.InvisibleButton(style=TOOLTIP_STYLE) self.__overflow_button.set_tooltip_fn(self.__build_tooltip) if add_child: self.__main_layout.add_child(layout) else: if self.empty(): spacer = 0 else: spacer = self.__spacing layout = self.__build_user_layout(user_info, spacer) if add_child: self.__main_layout.add_child(layout) self.__main_layout.visible = True self.__all_user_layouts[user_id] = layout return True return False @carb.profiler.profile def __on_layers_event(self, event): payload = layers.get_layer_event_payload(event) stage_url = self.__usd_context.get_stage_url() if payload.event_type == layers.LayerEventType.LIVE_SESSION_STATE_CHANGED: if stage_url not in payload.identifiers_or_spec_paths: return self.__build_ui() elif ( payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_JOINED or payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_LEFT ): if stage_url != payload.layer_identifier: return current_live_session = self.__live_syncing.get_current_live_session() if not current_live_session: self.__build_ui() return user_id = payload.user_id if payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_LEFT: user = self.__all_user_layouts.pop(user_id, None) if user: # FIXME: omni.ui does not support to remove single child. self.__build_ui() else: self.__add_user(current_live_session, user_id, True) else: current_live_session = self.__live_syncing.get_current_live_session() if not current_live_session: return payload = pl.get_presence_layer_event_payload(event) if not payload or not payload.event_type: return if payload.event_type == pl.PresenceLayerEventType.BOUND_CAMERA_CHANGED: changed_user_ids = payload.changed_user_ids needs_rebuild = False for user_id in changed_user_ids: if not self.__add_user(current_live_session, user_id, True): # It's not bound to this camera already. needs_rebuild = user_id in self.__all_user_layouts break if needs_rebuild: self.__build_ui() def destroy(self): # pragma: no cover self.__main_layout = None self.__layers_event_subscriptions = [] self.__layers = None self.__live_syncing = None self.__all_user_layouts.clear() self.__overflow_button = None def __build_user_layout(self, user_info: layers.LiveSessionUser, spacing=2): tooltip = f"{user_info.user_name} ({user_info.from_app})" layout = ui.HStack() with layout: ui.Spacer(width=spacing) build_live_session_user_layout(user_info, self.__icon_size, tooltip) return layout
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/filebrowser/__init__.py
from .app_filebrowser import FileBrowserUI, FileBrowserSelectionType, FileBrowserMode
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/filebrowser/app_filebrowser.py
import asyncio import re import omni.client import omni.client.utils as clientutils from omni.kit.window.filepicker import FilePickerDialog from omni.kit.widget.filebrowser import FileBrowserItem from typing import Iterable, Tuple, Union class FileBrowserSelectionType: FILE_ONLY = 0 DIRECTORY_ONLY = 1 ALL = 2 class FileBrowserMode: OPEN = 0 SAVE = 1 class FileBrowserUI: def __init__(self, title, mode, selection_type, filter_options, **kwargs): if mode == FileBrowserMode.OPEN: confirm_text = "Open" else: confirm_text = "Save" self._file_picker = FilePickerApp(title, confirm_text, selection_type, filter_options, **kwargs) def set_current_directory(self, dir): self._file_picker.set_current_directory(dir) def set_current_filename(self, filename): self._file_picker.set_current_filename(filename) def get_current_filename(self): return self._file_picker.get_current_filename() def open(self, select_fn, cancel_fn): self._file_picker.set_custom_fn(select_fn, cancel_fn) self._file_picker.show_dialog() def destroy(self): self._file_picker.set_custom_fn(None, None) self._file_picker = None def hide(self): self._file_picker.hide_dialog() class FilePickerApp: """ Standalone app to demonstrate the use of the FilePicker dialog. Args: title (str): Title of the window. apply_button_name (str): Name of the confirm button. selection_type (FileBrowserSelectionType): The file type that confirm event will respond to. item_filter_options (list): Array of filter options. Element of array is a tuple that first element of this tuple is the regex string for filtering, and second element of this tuple is the descriptions, like ("*.*", "All Files"). By default, it will list all files. kwargs: additional keyword arguments to be passed to FilePickerDialog. """ def __init__( self, title: str, apply_button_name: str, selection_type: FileBrowserSelectionType = FileBrowserSelectionType.ALL, item_filter_options: Iterable[Tuple[Union[re.Pattern, str], str]] = (( re.compile(".*"), "All Files (*.*)")), **kwargs, ): self._title = title self._filepicker = None self._selection_type = selection_type self._custom_select_fn = None self._custom_cancel_fn = None self._apply_button_name = apply_button_name self._filter_regexes = [] self._filter_descriptions = [] self._current_directory = None for regex, desc in item_filter_options: if not isinstance(regex, re.Pattern): regex = re.compile(regex, re.IGNORECASE) self._filter_regexes.append(regex) self._filter_descriptions.append(desc) self._build_ui(**kwargs) def set_custom_fn(self, select_fn, cancel_fn): self._custom_select_fn = select_fn self._custom_cancel_fn = cancel_fn def show_dialog(self): self._filepicker.show(self._current_directory) self._current_directory = None def hide_dialog(self): self._filepicker.hide() def set_current_directory(self, dir: str): self._current_directory = dir if not self._current_directory.endswith("/"): self._current_directory += "/" def set_current_filename(self, filename: str): self._filepicker.set_filename(filename) def get_current_filename(self): return self._filepicker.get_filename() def _build_ui(self, **kwargs): on_click_open = lambda f, d: asyncio.ensure_future(self._on_click_open(f, d)) on_click_cancel = lambda f, d: asyncio.ensure_future(self._on_click_cancel(f, d)) # Create the dialog self._filepicker = FilePickerDialog( self._title, allow_multi_selection=False, apply_button_label=self._apply_button_name, click_apply_handler=on_click_open, click_cancel_handler=on_click_cancel, item_filter_options=self._filter_descriptions, item_filter_fn=lambda item: self._on_filter_item(item), error_handler=lambda m: self._on_error(m), **kwargs, ) # Start off hidden self.hide_dialog() def _on_filter_item(self, item: FileBrowserItem) -> bool: if not item or item.is_folder: return True if self._filepicker.current_filter_option >= len(self._filter_regexes): return False regex = self._filter_regexes[self._filepicker.current_filter_option] if regex.match(item.path): return True else: return False def _on_error(self, msg: str): """ Demonstrates error handling. Instead of just printing to the shell, the App can display the error message to a console window. """ print(msg) async def _on_click_open(self, filename: str, dirname: str): """ The meat of the App is done in this callback when the user clicks 'Accept'. This is a potentially costly operation so we implement it as an async operation. The inputs are the filename and directory name. Together they form the fullpath to the selected file. """ dirname = dirname.strip() if dirname and not dirname.endswith("/"): dirname += "/" fullpath = clientutils.make_absolute_url_if_possible(dirname, filename) result, entry = omni.client.stat(fullpath) if result == omni.client.Result.OK and entry.flags & omni.client.ItemFlags.CAN_HAVE_CHILDREN: is_folder = True else: is_folder = False if not is_folder and self._selection_type == FileBrowserSelectionType.DIRECTORY_ONLY: return self.hide_dialog() await omni.kit.app.get_app().next_update_async() if self._custom_select_fn: self._custom_select_fn(fullpath, self._filepicker.current_filter_option) async def _on_click_cancel(self, filename: str, dirname: str): """ This function is called when the user clicks 'Cancel'. """ self.hide_dialog() await omni.kit.app.get_app().next_update_async() if self._custom_cancel_fn: self._custom_cancel_fn()
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/tests/mock_utils.py
import carb import asyncio import os import functools import uuid import omni.usd import omni.client import omni.kit.usd.layers as layers from typing import Callable, Awaitable from omni.kit.collaboration.channel_manager.types import PeerUser from omni.kit.usd.layers import LayersState, LiveSyncing, LiveSession from ..live_session_model import LiveSessionModel from ..file_picker import FilePicker from omni.kit.usd.layers._omni_kit_usd_layers import IWorkflowLiveSyncing from unittest.mock import Mock, MagicMock from pxr import Sdf, Usd _mock_sdf_save_layer_api = None _mock_layer_states_get_all_outdated_layer_identifiers_api = None _mock_live_session_model_all_users_api = None _mock_live_syncing_merge_and_stop_live_session_async_api = None _mock_filepicker_show_api = None _mock_filepicker_set_file_selected_fn_api = None _mock_outdated_layers = [] file_save_handler = None merge_and_stop_live_session_async_called = False def append_outdated_layers(layer_id): global _mock_outdated_layers _mock_outdated_layers.append(layer_id) def clear_outdated_layers(): global _mock_outdated_layers _mock_outdated_layers = [] def get_merge_and_stop_live_session_async_called(): global merge_and_stop_live_session_async_called return merge_and_stop_live_session_async_called def _start_mock_api_for_live_session_management(): carb.log_info("Start mock api for live session management...") def __mock_sdf_save_layer(force): pass global _mock_sdf_save_layer_api _mock_sdf_save_layer_api = Sdf.Layer.Save Sdf.Layer.Save = Mock(side_effect=__mock_sdf_save_layer) def __mock_layer_states_get_all_outdated_layer_identifiers_(): global _mock_outdated_layers return _mock_outdated_layers global _mock_layer_states_get_all_outdated_layer_identifiers_api _mock_layer_states_get_all_outdated_layer_identifiers_api = LayersState.get_all_outdated_layer_identifiers LayersState.get_all_outdated_layer_identifiers = Mock(side_effect=__mock_layer_states_get_all_outdated_layer_identifiers_) global _mock_live_session_model_all_users_api _mock_live_session_model_all_users_api = LiveSessionModel.all_users LiveSessionModel.all_users = {f"user_{i}": PeerUser(f"user_{i}", f"user_{i}", "Kit") for i in range(3)} async def __mock_live_syncing_merge_and_stop_live_session_async( self, target_layer: str = None, comment="", pre_merge: Callable[[LiveSession], Awaitable] = None, post_merge: Callable[[bool], Awaitable] = None, layer_identifier: str = None ) -> bool: global merge_and_stop_live_session_async_called merge_and_stop_live_session_async_called = True return True global _mock_live_syncing_merge_and_stop_live_session_async_api _mock_live_syncing_merge_and_stop_live_session_async_api = LiveSyncing.merge_and_stop_live_session_async LiveSyncing.merge_and_stop_live_session_async = Mock(side_effect=__mock_live_syncing_merge_and_stop_live_session_async) def __mock_filepicker_show(dummy1, dummy2): global file_save_handler if file_save_handler: file_save_handler(dummy1, False) global _mock_filepicker_show_api _mock_filepicker_show_api = FilePicker.show FilePicker.show = Mock(side_effect=__mock_filepicker_show) def __mock_filepicker_set_file_selected_fn(fn): global file_save_handler file_save_handler = fn global _mock_filepicker_set_file_selected_fn_api _mock_filepicker_set_file_selected_fn_api = FilePicker.set_file_selected_fn FilePicker.set_file_selected_fn = Mock(side_effect=__mock_filepicker_set_file_selected_fn) def _end_mock_api_for_live_session_management(): carb.log_info("Start mock api for live session management...") global _mock_sdf_save_layer_api Sdf.Layer.Save = _mock_sdf_save_layer_api _mock_sdf_save_layer_api = None global _mock_layer_states_get_all_outdated_layer_identifiers_api LayersState.get_all_outdated_layer_identifiers = _mock_layer_states_get_all_outdated_layer_identifiers_api _mock_layer_states_get_all_outdated_layer_identifiers_api = None global _mock_live_session_model_all_users_api LiveSessionModel.all_users = _mock_live_session_model_all_users_api _mock_live_session_model_all_users_api = None global _mock_live_syncing_merge_and_stop_live_session_async_api LiveSyncing.merge_and_stop_live_session_async = _mock_live_syncing_merge_and_stop_live_session_async_api _mock_live_syncing_merge_and_stop_live_session_async_api = None global _mock_filepicker_show_api FilePicker.show = _mock_filepicker_show_api _mock_filepicker_show_api = None global _mock_filepicker_set_file_selected_fn_api FilePicker.set_file_selected_fn = _mock_filepicker_set_file_selected_fn_api _mock_filepicker_set_file_selected_fn_api = None global merge_and_stop_live_session_async_called merge_and_stop_live_session_async_called = False def MockApiForLiveSessionManagement(*args, **kwargs): if len(args) == 1 and len(kwargs) == 0 and callable(args[0]): func = args[0] args = args[1:] else: func = None def wrapper(func): @functools.wraps(func) def wrapper_api(*args, **kwargs): try: _start_mock_api_for_live_session_management() return func(*args, **kwargs) finally: _end_mock_api_for_live_session_management() @functools.wraps(func) async def wrapper_api_async(*args, **kwargs): try: _start_mock_api_for_live_session_management() return await func(*args, **kwargs) finally: _end_mock_api_for_live_session_management() if asyncio.iscoroutinefunction(func): return wrapper_api_async else: return wrapper_api if func: return wrapper(func) else: return wrapper
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/tests/__init__.py
from .test_live_session_management import *
omniverse-code/kit/exts/omni.kit.widget.live_session_management/omni/kit/widget/live_session_management/tests/test_live_session_management.py
import os import carb import omni.usd import omni.kit.ui_test as ui_test import omni.ui as ui import omni.kit.usd.layers as layers import omni.timeline.live_session import omni.kit.collaboration.presence_layer as pl import omni.kit.collaboration.presence_layer.utils as pl_utils import unittest import tempfile import random import uuid from omni.kit.test import AsyncTestCase from omni.kit.window.preferences import register_page, unregister_page from pxr import Sdf, Usd from omni.kit.usd.layers.tests.mock_utils import MockLiveSyncingApi, join_new_simulated_user, quit_simulated_user, forbid_session_merge from ..extension import LiveSessionWidgetExtension, stop_or_show_live_session_widget from ..live_session_camera_follower_list import LiveSessionCameraFollowerList from ..live_session_user_list import LiveSessionUserList from ..file_picker import FilePicker, FileBrowserMode, FileBrowserSelectionType from ..live_session_preferences import LiveSessionPreferences from ..reload_widget import build_reload_widget from ..live_session_start_window import LiveSessionStartWindow from .mock_utils import ( MockApiForLiveSessionManagement, append_outdated_layers, clear_outdated_layers, get_merge_and_stop_live_session_async_called ) TEST_URL = "omniverse://__omni.kit.widget.live_session_management__/tests/" LIVE_SESSION_CONFIRM_BUTTON_PATH = "Live Session//Frame/**/Button[*].name=='confirm_button'" LIVE_SESSION_CANCEL_BUTTON_PATH = "Live Session//Frame/**/Button[*].name=='cancel_button'" LEAVE_SESSION_CONFIRM_BUTTON_PATH = "Leave Session//Frame/**/Button[*].name=='confirm_button'" JOIN_LIVE_SESSION_WITH_LINK_CANCEL_BUTTON_PATH = "JOIN LIVE SESSION WITH LINK//Frame/**/Button[*].name=='cancel_button'" SHARE_LIVE_SESSION_LINK_COMBO_BOX_PATH = "SHARE LIVE SESSION LINK//Frame/**/ComboBox[0]" SHARE_LIVE_SESSION_LINK_CONFIRM_BUTTON_PATH = "SHARE LIVE SESSION LINK//Frame/**/InvisibleButton[*].name=='confirm_button'" MERGE_OPTIONS_CONFIRM_BUTTON_PATH = "Merge Options//Frame/**/Button[*].name=='confirm_button'" MERGE_OPTIONS_COMBO_BOX_PATH = "Merge Options//Frame/**/ComboBox[0]" MERGE_PROMPT_LEAVE_BUTTON_PATH = "Permission Denied//Frame/**/Button[*].name=='confirm_button'" QUICK_JOIN_ENABLED = "/exts/omni.kit.widget.live_session_management/quick_join_enabled" def _menu_items_as_string_list(items): return [i.text for i in items] def _find_menu_item(items, text): for i in items: if i.text == text: return i return None def enable_server_tests(): settings = carb.settings.get_settings() return True or settings.get_as_bool("/exts/omni.kit.widget.live_session_management/enable_server_tests") class TestLiveSessionManagement(AsyncTestCase): def get_live_syncing(self): usd_context = omni.usd.get_context() self.assertIsNotNone(layers.get_layers(usd_context)) self.assertIsNotNone(layers.get_layers(usd_context).get_live_syncing()) return layers.get_layers(usd_context).get_live_syncing() async def setUp(self): self._instance = LiveSessionWidgetExtension.get_instance() self.assertIsNotNone(self._instance) self.assertFalse(self.get_live_syncing().is_stage_in_live_session()) pass async def _close_case(self): if omni.usd.get_context().get_stage(): live_syncing = self.get_live_syncing() if live_syncing: if live_syncing.is_stage_in_live_session(): await self._leave_current_session() live_syncing.stop_all_live_sessions() await omni.usd.get_context().close_stage_async() await ui_test.human_delay(6) async def _click_menu_item(self, item, right_click=False): offset = ui_test.Vec2(5, 5) pos = ui_test.Vec2(item.screen_position_x, item.screen_position_y) + offset await ui_test.emulate_mouse_move(pos, 4) await ui_test.human_delay(6) await ui_test.emulate_mouse_click(right_click=right_click) await ui_test.human_delay(6) async def _create_test_usd(self, filename = 'test'): await omni.client.delete_async(TEST_URL) stage_url = TEST_URL + f"{filename}.usd" layer = Sdf.Layer.CreateNew(stage_url) stage = Usd.Stage.Open(layer.identifier) self.assertIsNotNone(stage) return stage async def _create_test_sublayer_usd(self, filename = 'sublayer'): layer_url = TEST_URL + f"{filename}.usd" layer = Sdf.Layer.CreateNew(layer_url) return layer async def _expand_live_session_menu(self, layer_identifier: str=None, quick_join: str=None): stop_or_show_live_session_widget(layer_identifier=layer_identifier, quick_join=quick_join) await ui_test.human_delay(6) menu = self._instance._live_session_menu self.assertIsNotNone(menu) items = ui.Inspector.get_children(menu) await ui_test.human_delay(6) return items def _get_current_menu_item_string_list(self): menu = ui.Menu.get_current() self.assertIsNotNone(menu) items = ui.Inspector.get_children(menu) return _menu_items_as_string_list(items) async def _click_on_current_menu(self, text: str): menu = ui.Menu.get_current() self.assertIsNotNone(menu) items = ui.Inspector.get_children(menu) item_str_list = self._get_current_menu_item_string_list() self.assertIn(text, item_str_list) item = _find_menu_item(items, text) self.assertIsNotNone(item) await self._click_menu_item(item) await ui_test.human_delay(6) async def _click_live_session_menu_item(self, text: str, layer_identifier = None, quick_join: str = None): items = await self._expand_live_session_menu(layer_identifier, quick_join) self.assertTrue(len(items) > 0) item_str_list = _menu_items_as_string_list(items) self.assertIn(text, item_str_list) item = _find_menu_item(items, text) self.assertIsNotNone(item) await self._click_menu_item(item) await ui_test.human_delay(6) @MockLiveSyncingApi async def test_create_session_dialog(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._click_live_session_menu_item("Create Session") frame = ui_test.find("Live Session") self.assertIsNotNone(frame) cancal_button = ui_test.find(LIVE_SESSION_CANCEL_BUTTON_PATH) self.assertIsNotNone(cancal_button) await cancal_button.click() await self._close_case() async def _create_session(self, session_name: str=None): await self._click_live_session_menu_item("Create Session") frame = ui_test.find("Live Session") self.assertIsNotNone(frame) if session_name: name_field = ui_test.find("Live Session//Frame/**/StringField[0]") self.assertIsNotNone(name_field) name_field.model.set_value(session_name) ok_button = ui_test.find(LIVE_SESSION_CONFIRM_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) async def _create_session_then_leave(self, session_name: str): self.assertFalse(self.get_live_syncing().is_stage_in_live_session()) await self._create_session(session_name) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) await self._leave_current_session() self.assertFalse(self.get_live_syncing().is_stage_in_live_session()) async def _leave_current_session(self): await self._click_live_session_menu_item("Leave Session") if ui_test.find("Leave Session"): button = ui_test.find(LEAVE_SESSION_CONFIRM_BUTTON_PATH) self.assertIsNotNone(button) await button.click() await ui_test.human_delay(6) @MockLiveSyncingApi async def test_create_session(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test") self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) self.get_live_syncing().stop_all_live_sessions() self.assertFalse(self.get_live_syncing().is_stage_in_live_session()) await self._close_case() @MockLiveSyncingApi async def test_leave_session(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._close_case() @MockLiveSyncingApi async def test_join_session(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session_then_leave("test") await self._click_live_session_menu_item("Join Session") frame = ui_test.find("Live Session") self.assertIsNotNone(frame) ok_button = ui_test.find(LIVE_SESSION_CONFIRM_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) await self._close_case() @MockLiveSyncingApi @MockApiForLiveSessionManagement async def test_join_session_participants(self): stage = await self._create_test_usd("test") await omni.usd.get_context().attach_stage_async(stage) live_session_start_window = LiveSessionStartWindow(layers.get_layers(), stage.GetRootLayer().identifier, None) await self._create_session("test") live_session_start_window.visible = True live_session_start_window.set_focus(True) await ui_test.human_delay(6) live_session_start_window.visible = False await self._close_case() @MockLiveSyncingApi async def test_join_session_quick(self): settings = carb.settings.get_settings() before = settings.get_as_bool(QUICK_JOIN_ENABLED) settings.set(QUICK_JOIN_ENABLED, True) stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session_then_leave("test") await self._expand_live_session_menu(quick_join="test") self.assertEqual("test", self.get_live_syncing().get_current_live_session().name) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) settings.set(QUICK_JOIN_ENABLED, before) await self._close_case() @MockLiveSyncingApi async def test_join_session_quick_create(self): settings = carb.settings.get_settings() before = settings.get_as_bool(QUICK_JOIN_ENABLED) settings.set(QUICK_JOIN_ENABLED, True) stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._expand_live_session_menu(quick_join="test") self.assertEqual("test", self.get_live_syncing().get_current_live_session().name) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) settings.set(QUICK_JOIN_ENABLED, before) await self._close_case() @MockLiveSyncingApi async def test_join_session_options(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session_then_leave(None) await self._create_session_then_leave(None) for i in range(3): await self._create_session_then_leave(f"test_{i}") await self._click_live_session_menu_item("Join Session") frame = ui_test.find("Live Session") self.assertIsNotNone(frame) combo_box = ui_test.find("Live Session//Frame/**/ComboBox[0]") items = combo_box.model.get_item_children(None) names = [i.session.name for i in items] carb.log_warn(names) self.assertIn("Default", names) self.assertIn("simulated_user_name___01", names) for i in range(3): self.assertIn(f"test_{i}", names) index_of_second_test_usd = names.index('test_1') self.assertTrue(index_of_second_test_usd > -1) combo_box.model.get_item_value_model(None, 0).set_value(index_of_second_test_usd) await ui_test.human_delay(6) ok_button = ui_test.find(LIVE_SESSION_CONFIRM_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) self.assertEqual("test_1", self.get_live_syncing().get_current_live_session().name) await self._close_case() @MockLiveSyncingApi async def test_menu_item_join_with_session_link_without_stage(self): self.assertIsNone(stop_or_show_live_session_widget()) await self._close_case() @MockLiveSyncingApi async def test_menu_item_join_with_session_link_dialog(self): await omni.usd.get_context().new_stage_async() await self._click_live_session_menu_item("Join With Session Link") frame = ui_test.find("JOIN LIVE SESSION WITH LINK") self.assertIsNotNone(frame) cancal_button = ui_test.find(JOIN_LIVE_SESSION_WITH_LINK_CANCEL_BUTTON_PATH) self.assertIsNotNone(cancal_button) await cancal_button.click() await self._close_case() @MockLiveSyncingApi async def test_menu_item_copy_session_link(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test") layer = stage.GetRootLayer() await self._click_live_session_menu_item("Copy Session Link", layer.identifier) current_session = self.get_live_syncing().get_current_live_session() live_session_link = omni.kit.clipboard.paste() self.assertEqual(live_session_link, current_session.shared_link) await self._close_case() @MockLiveSyncingApi async def test_menu_item_share_session_link(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) for i in range(3): await self._create_session_then_leave(f"test_{i}") await self._click_live_session_menu_item("Share Session Link") frame = ui_test.find("SHARE LIVE SESSION LINK") self.assertIsNotNone(frame) combo_box = ui_test.find(SHARE_LIVE_SESSION_LINK_COMBO_BOX_PATH) items = combo_box.model.get_item_children(None) names = [i.session.name for i in items] index_of_second_test_usd = -1 for i in range(3): self.assertIn(f"test_{i}", names) if names[i] == "test_1": index_of_second_test_usd = i self.assertTrue(index_of_second_test_usd > -1) combo_box.model.get_item_value_model(None, 0).set_value(index_of_second_test_usd) await ui_test.human_delay(6) confirm_button = ui_test.find(SHARE_LIVE_SESSION_LINK_CONFIRM_BUTTON_PATH) await confirm_button.click() live_session_link = omni.kit.clipboard.paste() self.assertEqual(live_session_link, items[index_of_second_test_usd].session.shared_link) await self._close_case() def _create_test_camera(self, name: str='camera'): camera_path = f"/{name}" omni.kit.commands.execute("CreatePrimWithDefaultXform", prim_type="Camera", prim_path=camera_path) return Sdf.Path(camera_path) async def _setup_camera_follower_list(self, camera_path, maximum_users=3): camera = omni.usd.get_context().get_stage().GetPrimAtPath(camera_path) self.assertIsNotNone(camera) return LiveSessionCameraFollowerList(omni.usd.get_context(), camera_path, maximum_users=maximum_users) @MockLiveSyncingApi async def test_live_session_camera_follower_list(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) camera_path = self._create_test_camera() camera_follower_list = await self._setup_camera_follower_list(camera_path) await self._close_case() async def _bound_camera(self, shared_stage: Usd.Stage, user_id: str, camera_path: Sdf.Path): if not camera_path: camera_path = Sdf.Path.emptyPath camera_path = Sdf.Path(camera_path) bound_camera_property_path = pl_utils.get_bound_camera_property_path(user_id) property_spec = pl_utils.get_or_create_property_spec( shared_stage.GetRootLayer(), bound_camera_property_path, Sdf.ValueTypeNames.String ) builtin_camera_name = pl_utils.is_local_builtin_camera(camera_path) if not builtin_camera_name: property_spec.default = str(camera_path) else: property_spec.default = builtin_camera_name if builtin_camera_name: persp_camera = pl_utils.get_user_shared_root_path(user_id).AppendChild(builtin_camera_name) camera_prim = shared_stage.DefinePrim(persp_camera, "Camera") await ui_test.human_delay(12) def _get_shared_stage(self, current_session: layers.LiveSession): shared_data_stage_url = current_session.url + "/shared_data/users.live" layer = Sdf.Layer.FindOrOpen(shared_data_stage_url) if not layer: layer = Sdf.Layer.CreateNew(shared_data_stage_url) return Usd.Stage.Open(layer) async def _follow_user( self, shared_stage: Usd.Stage, user_id: str, following_user_id: str ): following_user_property_path = pl_utils.get_following_user_property_path(user_id) property_spec = pl_utils.get_or_create_property_spec( shared_stage.GetRootLayer(), following_user_property_path, Sdf.ValueTypeNames.String ) property_spec.default = following_user_id await ui_test.human_delay(6) def _create_shared_stage(self): current_session = self.get_live_syncing().get_current_live_session() self.assertIsNotNone(current_session) shared_stage = self._get_shared_stage(current_session) self.assertIsNotNone(shared_stage) return shared_stage def _create_users(self, count): return [f"user_{i}" for i in range(count)] @MockLiveSyncingApi async def test_live_session_camera_follower_list_user_join(self): stage = await self._create_test_usd("test_camera") usd_context = omni.usd.get_context() presence_layer = pl.get_presence_layer_interface(usd_context) await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test_camera") stage_url = usd_context.get_stage_url() presence_layer = pl.get_presence_layer_interface(usd_context) shared_stage = self._create_shared_stage() camera_path = self._create_test_camera() camera_follower_list = await self._setup_camera_follower_list(camera_path) user_list = LiveSessionUserList(usd_context, stage_url) users = self._create_users(3) await self._bound_camera(shared_stage, users[0], camera_path) for user_id in users: join_new_simulated_user(user_id, user_id) await ui_test.human_delay(6) self.assertIsNotNone(presence_layer.get_bound_camera_prim(users[0])) user_0 = self._get_user_in_session(users[0]) user_list._LiveSessionUserList__on_follow_user( 0.0, 0.0, int(carb.input.MouseInput.LEFT_BUTTON), None, user_0 ) await ui_test.human_delay(6) async def right_click_on(user): user_list._LiveSessionUserList__on_mouse_clicked( 0.0, 0.0, int(carb.input.MouseInput.RIGHT_BUTTON), None, user ) await ui_test.human_delay(6) timeline_session = omni.timeline.live_session.get_timeline_session() self.assertFalse(timeline_session.is_presenter(user_0)) await right_click_on(user_0) await self._click_on_current_menu("Set as Timeline Presenter") self.assertTrue(timeline_session.is_presenter(user_0)) await right_click_on(user_0) await self._click_on_current_menu("Withdraw Timeline Presenter") self.assertFalse(timeline_session.is_presenter(user_0)) self.assertEqual(users[0], presence_layer.get_following_user_id()) await ui_test.human_delay(600) for user_id in users: quit_simulated_user(user_id) await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi async def test_live_session_camera_follower_list_bound_change(self): stage = await self._create_test_usd("test_camera") usd_context = omni.usd.get_context() presence_layer = pl.get_presence_layer_interface(usd_context) await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test_camera") stage_url = usd_context.get_stage_url() presence_layer = pl.get_presence_layer_interface(usd_context) shared_stage = self._create_shared_stage() camera_path_1 = self._create_test_camera("camera1") camera_path_2 = self._create_test_camera("camera2") camera_follower_list = await self._setup_camera_follower_list(camera_path_1) user_list = LiveSessionUserList(usd_context, stage_url) users = self._create_users(2) for user_id in users: join_new_simulated_user(user_id, user_id) await ui_test.human_delay(6) await self._bound_camera(shared_stage, users[0], camera_path_1) await self._bound_camera(shared_stage, users[1], camera_path_2) await self._bound_camera(shared_stage, users[0], camera_path_2) await self._bound_camera(shared_stage, users[1], camera_path_1) for user_id in users: quit_simulated_user(user_id) await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi async def test_live_session_camera_follower_list_user_join_exceed_maximum(self): stage = await self._create_test_usd("test_camera") usd_context = omni.usd.get_context() presence_layer = pl.get_presence_layer_interface(usd_context) await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test_camera") UI_MAXIMUM_USERS = 3 stage_url = usd_context.get_stage_url() presence_layer = pl.get_presence_layer_interface(usd_context) shared_stage = self._create_shared_stage() camera_path = self._create_test_camera() camera_follower_list = await self._setup_camera_follower_list(camera_path, maximum_users=UI_MAXIMUM_USERS) user_list = LiveSessionUserList(usd_context, stage_url) users = self._create_users(UI_MAXIMUM_USERS + 1) for user in users: await self._bound_camera(shared_stage, user, camera_path) for user_id in users: join_new_simulated_user(user_id, user_id) await ui_test.human_delay(6) for user_id in users: quit_simulated_user(user_id) await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi async def test_end_and_merge(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test") self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) await self._click_live_session_menu_item("End and Merge") frame = ui_test.find("Merge Options") self.assertIsNotNone(frame) combo = ui_test.find(MERGE_OPTIONS_COMBO_BOX_PATH) combo.model.get_item_value_model(None, 0).set_value(0) ok_button = ui_test.find(MERGE_OPTIONS_CONFIRM_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi @MockApiForLiveSessionManagement async def test_end_and_merge_save_file(self): self.assertFalse(get_merge_and_stop_live_session_async_called()) stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test") self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) await self._click_live_session_menu_item("End and Merge") frame = ui_test.find("Merge Options") self.assertIsNotNone(frame) combo = ui_test.find(MERGE_OPTIONS_COMBO_BOX_PATH) combo.model.get_item_value_model(None, 0).set_value(1) ok_button = ui_test.find(MERGE_OPTIONS_CONFIRM_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) self.assertTrue(get_merge_and_stop_live_session_async_called()) await self._close_case() @MockLiveSyncingApi async def test_end_and_merge_without_permission(self): stage = await self._create_test_usd() await omni.usd.get_context().attach_stage_async(stage) await self._create_session("test") current_session = self.get_live_syncing().get_current_live_session() forbid_session_merge(current_session) self.assertTrue(self.get_live_syncing().is_stage_in_live_session()) await self._click_live_session_menu_item("End and Merge") frame = ui_test.find("Permission Denied") self.assertIsNotNone(frame) ok_button = ui_test.find(MERGE_PROMPT_LEAVE_BUTTON_PATH) self.assertIsNotNone(ok_button) await ok_button.click() await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi async def test_reload_widget_on_layer(self): stage = await self._create_test_usd("test") usd_context = omni.usd.get_context() await usd_context.attach_stage_async(stage) await self._create_session("test") layer = stage.GetSessionLayer() window = omni.ui.Window(title='test_reload') with window.frame: reload_widget = build_reload_widget(layer.identifier, usd_context, True, True, False) self.assertIsNotNone(reload_widget) reload_widget.visible = True await ui_test.human_delay(10) window.width, window.height = 50, 50 reload_button = ui_test.find("test_reload//Frame/**/InvisibleButton[0]") self.assertIsNotNone(reload_button) await reload_button.click(right_click=True) await ui_test.human_delay(6) item_str_list = self._get_current_menu_item_string_list() self.assertIn("Auto Reload", item_str_list) self.assertIn("Reload Layer", item_str_list) self.assertFalse(layers.get_layers_state(usd_context).is_auto_reload_layer(layer.identifier)) await self._click_on_current_menu("Auto Reload") self.assertTrue(layers.get_layers_state(usd_context).is_auto_reload_layer(layer.identifier)) await reload_button.click(right_click=True) await ui_test.human_delay(6) await self._click_on_current_menu("Auto Reload") self.assertFalse(layers.get_layers_state(usd_context).is_auto_reload_layer(layer.identifier)) await reload_button.click() await ui_test.human_delay(6) await self._close_case() @MockLiveSyncingApi @MockApiForLiveSessionManagement async def test_reload_widget_on_outdated_layer(self): stage = await self._create_test_usd("test") usd_context = omni.usd.get_context() await usd_context.attach_stage_async(stage) await self._create_session("test") all_layers = [] for i in range(3): layer = await self._create_test_sublayer_usd(f"layer_{i}") self.assertIsNotNone(layer) all_layers.append(layer) stage.GetRootLayer().subLayerPaths.append(layer.identifier) window = omni.ui.Window(title='test_reload') with window.frame: reload_widget = build_reload_widget(all_layers[0].identifier, usd_context, True, True, False) self.assertIsNotNone(reload_widget) reload_widget.visible = True await ui_test.human_delay(10) window.width, window.height = 50, 50 reload_button = ui_test.find("test_reload//Frame/**/InvisibleButton[0]") self.assertIsNotNone(reload_button) layer = all_layers[0] custom_data = layer.customLayerData custom_data['test'] = random.randint(0, 10000000) layer.customLayerData = custom_data layer.Save(True) await ui_test.human_delay(6) append_outdated_layers(all_layers[0].identifier) await reload_button.click() await ui_test.human_delay(6) clear_outdated_layers() await self._close_case() async def test_live_session_preferences(self): preferences = register_page(LiveSessionPreferences()) omni.kit.window.preferences.show_preferences_window() await ui_test.human_delay(6) label = ui_test.find("Preferences//Frame/**/ScrollingFrame[0]/TreeView[0]/Label[*].text=='Live'") await label.click() await ui_test.human_delay(6) self.assertIsNotNone(preferences._checkbox_quick_join_enabled) self.assertIsNotNone(preferences._combobox_session_list_select) await ui_test.human_delay(6) omni.kit.window.preferences.hide_preferences_window() unregister_page(preferences) def _get_user_in_session(self, user_id): current_session = self.get_live_syncing().get_current_live_session() session_channel = current_session._session_channel() return session_channel._peer_users.get(user_id, None) @MockLiveSyncingApi async def test_file_picker(self): temp_dir = tempfile.TemporaryDirectory() def file_save_handler(file_path: str, overwrite_existing: bool): prefix = "file:/" self.assertTrue(file_path.startswith(prefix)) nonlocal called called = True def file_open_handler(file_path: str, overwrite_existing: bool): nonlocal called called = True filter_options = [ ("(.*?)", "All Files (*.*)"), ] FILE_PICKER_DIALOG_TITLE = "test file picker" file_picker = FilePicker( FILE_PICKER_DIALOG_TITLE, FileBrowserMode.SAVE, FileBrowserSelectionType.FILE_ONLY, filter_options, ) called = False file_picker.set_file_selected_fn(file_save_handler) file_picker.show(temp_dir.name, 'test_file_picker') await ui_test.human_delay(6) button = ui_test.find(f"{FILE_PICKER_DIALOG_TITLE}//Frame/**/Button[*].text=='Save'") self.assertIsNotNone(button) await button.click() await ui_test.human_delay(6) self.assertTrue(called) file_picker = FilePicker( FILE_PICKER_DIALOG_TITLE, FileBrowserMode.OPEN, FileBrowserSelectionType.FILE_ONLY, filter_options, ) called = False file_picker.set_file_selected_fn(file_open_handler) file_picker.show(temp_dir.name) await ui_test.human_delay(6) button = ui_test.find(f"{FILE_PICKER_DIALOG_TITLE}//Frame/**/Button[*].text=='Open'") self.assertIsNotNone(button) await button.click() await ui_test.human_delay(6) self.assertTrue(called)
omniverse-code/kit/exts/omni.kit.widget.live_session_management/docs/CHANGELOG.md
# Changelog Omniverse Kit Shared Live Session Widgets ## [1.1.3] - 2022-11-21 ### Changed - Prompt if layer is outdate or dirty before live. ## [1.1.2] - 2022-10-27 ### Changed - Fix deprecated API warnings. ## [1.1.1] - 2022-10-15 ### Changed - Fix issue to refresh session list. ## [1.1.0] - 2022-09-29 ### Changed - Supports sublayer live session workflow. ## [1.0.6] - 2022-09-02 ### Changed - Add name validator for session name input. ## [1.0.5] - 2022-08-30 ### Changed - Show menu options for join. ## [1.0.4] - 2022-08-25 ### Changed - Notifications for read-only stage. ## [1.0.3] - 2022-08-09 ### Changed - Notify user before quitting application that session is live still. ## [1.0.2] - 2022-07-19 ### Changed - Shows menu still even session is empty when it's not forcely quit. ## [1.0.1] - 2022-06-29 ### Changed - Supports more options to control session menus. ## [1.0.0] - 2022-06-15 ### Fixed - Initialize extension.
omniverse-code/kit/exts/omni.kit.property.camera/PACKAGE-LICENSES/omni.kit.property.camera-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.
omniverse-code/kit/exts/omni.kit.property.camera/config/extension.toml
[package] # Semantic Versioning is used: https://semver.org/ version = "1.0.3" category = "Internal" feature = true # Lists people or organizations that are considered the "authors" of the package. authors = ["NVIDIA"] # The title and description fields are primarly for displaying extension info in UI title = "Camera Property Widget" description="View and Edit Camera Property Values" # URL of the extension source repository. repository = "" # Preview image. Folder named "data" automatically goes in git lfs (see .gitattributes file). preview_image = "data/preview.png" # Icon is shown in Extensions window, it is recommended to be square, of size 256x256. icon = "data/icon.png" # Keywords for the extension keywords = ["kit", "usd", "property", "camera"] # Location of change log file in target (final) folder of extension, relative to the root. # More info on writing changelog: https://keepachangelog.com/en/1.0.0/ changelog="docs/CHANGELOG.md" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" [dependencies] "omni.usd" = {} "omni.ui" = {} "omni.kit.window.property" = {} "omni.kit.property.usd" = {} [[python.module]] name = "omni.kit.property.camera" [[test]] args = [ "--/app/window/dpiScaleOverride=1.0", "--/app/window/scaleToMonitor=false", "--no-window" ] dependencies = [ "omni.kit.renderer.capture", "omni.kit.mainwindow", "omni.kit.ui_test", "omni.kit.test_suite.helpers" ] stdoutFailPatterns.exclude = [ "*Failed to acquire interface*while unloading all plugins*" ]
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/__init__.py
from .scripts import *
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/scripts/camera_properties.py
import os import carb import omni.ext from typing import List from pathlib import Path from pxr import Kind, Sdf, Usd, UsdGeom, Vt from omni.kit.property.usd.usd_property_widget import MultiSchemaPropertiesWidget, UsdPropertyUiEntry from omni.kit.property.usd.usd_property_widget import create_primspec_token, create_primspec_float, create_primspec_bool, create_primspec_string TEST_DATA_PATH = "" class CameraPropertyExtension(omni.ext.IExt): def __init__(self): self._registered = False super().__init__() def on_startup(self, ext_id): self._register_widget() manager = omni.kit.app.get_app().get_extension_manager() extension_path = manager.get_extension_path(ext_id) global TEST_DATA_PATH TEST_DATA_PATH = Path(extension_path).joinpath("data").joinpath("tests") def on_shutdown(self): if self._registered: self._unregister_widget() def _register_widget(self): import omni.kit.window.property as p from omni.kit.window.property.property_scheme_delegate import PropertySchemeDelegate from . import CameraSchemaAttributesWidget w = p.get_window() if w: w.register_widget( "prim", "camera", CameraSchemaAttributesWidget( "Camera", UsdGeom.Camera, [], [ "cameraProjectionType", "fthetaWidth", "fthetaHeight", "fthetaCx", "fthetaCy", "fthetaMaxFov", "fthetaPolyA", "fthetaPolyB", "fthetaPolyC", "fthetaPolyD", "fthetaPolyE", "fthetaPolyF", "p0", "p1", "s0", "s1", "s2", "s3", "fisheyeResolutionBudget", "fisheyeFrontFaceResolutionScale", "interpupillaryDistance", # Only required for 'omniDirectionalStereo' "isLeftEye", # Only required for 'omniDirectionalStereo' "cameraSensorType", "sensorModelPluginName", "sensorModelConfig", "sensorModelSignals", "crossCameraReferenceName" ], [], ), ) self._registered = True def _unregister_widget(self): import omni.kit.window.property as p w = p.get_window() if w: w.unregister_widget("prim", "camera") self._registered = False class CameraSchemaAttributesWidget(MultiSchemaPropertiesWidget): def __init__(self, title: str, schema, schema_subclasses: list, include_list: list = [], exclude_list: list = []): """ Constructor. Args: title (str): Title of the widgets on the Collapsable Frame. schema: The USD IsA schema or applied API schema to filter attributes. schema_subclasses (list): list of subclasses include_list (list): list of additional schema named to add exclude_list (list): list of additional schema named to remove """ super().__init__(title, schema, schema_subclasses, include_list, exclude_list) # custom attributes cpt_tokens = Vt.TokenArray(9, ("pinhole", "fisheyeOrthographic", "fisheyeEquidistant", "fisheyeEquisolid", "fisheyePolynomial", "fisheyeSpherical", "fisheyeKannalaBrandtK3", "fisheyeRadTanThinPrism", "omniDirectionalStereo")) cst_tokens = Vt.TokenArray(4, ("camera", "radar", "lidar", "rtxsensor")) self.add_custom_schema_attribute("cameraProjectionType", lambda p: p.IsA(UsdGeom.Camera), None, "Projection Type", create_primspec_token(cpt_tokens, "pinhole")) self.add_custom_schema_attribute("fthetaWidth", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(1936.0)) self.add_custom_schema_attribute("fthetaHeight", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(1216.0)) self.add_custom_schema_attribute("fthetaCx", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(970.942444)) self.add_custom_schema_attribute("fthetaCy", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(600.374817)) self.add_custom_schema_attribute("fthetaMaxFov", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(200.0)) self.add_custom_schema_attribute("fthetaPolyA", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(0.0)) self.add_custom_schema_attribute("fthetaPolyB", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(2.45417095720768e-3)) self.add_custom_schema_attribute("fthetaPolyC", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(3.72747912535942e-8)) self.add_custom_schema_attribute("fthetaPolyD", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-1.43520517692508e-9)) self.add_custom_schema_attribute("fthetaPolyE", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(9.76061787817672e-13)) self.add_custom_schema_attribute("fthetaPolyF", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(0.0)) self.add_custom_schema_attribute("p0", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-0.0003672190538065101)) self.add_custom_schema_attribute("p1", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-0.0007413905358394097)) self.add_custom_schema_attribute("s0", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-0.0005839984838196491)) self.add_custom_schema_attribute("s1", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-0.0002193412417918993)) self.add_custom_schema_attribute("s2", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(0.0001936268547567258)) self.add_custom_schema_attribute("s3", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(-0.0002042473404798113)) self.add_custom_schema_attribute("fisheyeResolutionBudget", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(1.5)) self.add_custom_schema_attribute("fisheyeFrontFaceResolutionScale", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(1.0)) self.add_custom_schema_attribute("interpupillaryDistance", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_float(6.4)) self.add_custom_schema_attribute("isLeftEye", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_bool(False)) self.add_custom_schema_attribute("sensorModelPluginName", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_string()) self.add_custom_schema_attribute("sensorModelConfig", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_string()) self.add_custom_schema_attribute("sensorModelSignals", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_string()) self.add_custom_schema_attribute("crossCameraReferenceName", lambda p: p.IsA(UsdGeom.Camera), None, "", create_primspec_string()) self.add_custom_schema_attribute("cameraSensorType", lambda p: p.IsA(UsdGeom.Camera), None, "Sensor Type", create_primspec_token(cst_tokens, "camera")) def on_new_payload(self, payload): """ See PropertyWidget.on_new_payload """ if not super().on_new_payload(payload): return False if not self._payload or len(self._payload) == 0: return False used = [] for prim_path in self._payload: prim = self._get_prim(prim_path) if not prim or not prim.IsA(self._schema): return False used += [attr for attr in prim.GetAttributes() if attr.GetName() in self._schema_attr_names and not attr.IsHidden()] camProjTypeAttr = prim.GetAttribute("cameraProjectionType") if prim.IsA(UsdGeom.Camera) and camProjTypeAttr.GetTypeName() == Sdf.ValueTypeNames.Token: tokens = camProjTypeAttr.GetMetadata("allowedTokens") if not tokens: camProjTypeAttr.SetMetadata("allowedTokens", ["pinhole", "fisheyeOrthographic", "fisheyeEquidistant", "fisheyeEquisolid", "fisheyePolynomial", "fisheyeSpherical", "fisheyeKannalaBrandtK3", "fisheyeRadTanThinPrism", "omniDirectionalStereo"]) if self.is_custom_schema_attribute_used(prim): used.append(None) camSensorTypeAttr = prim.GetAttribute("cameraSensorType") if prim.IsA(UsdGeom.Camera) and camSensorTypeAttr.GetTypeName() == Sdf.ValueTypeNames.Token: tokens = camSensorTypeAttr.GetMetadata("allowedTokens") if not tokens: camSensorTypeAttr.SetMetadata("allowedTokens", ["camera", "radar", "lidar", "rtxsensor"]) return used def _customize_props_layout(self, attrs): from omni.kit.property.usd.custom_layout_helper import ( CustomLayoutFrame, CustomLayoutGroup, CustomLayoutProperty, ) from omni.kit.window.property.templates import ( SimplePropertyWidget, LABEL_WIDTH, LABEL_HEIGHT, HORIZONTAL_SPACING, ) self.add_custom_schema_attributes_to_props(attrs) anchor_prim = self._get_prim(self._payload[-1]) frame = CustomLayoutFrame(hide_extra=False) with frame: with CustomLayoutGroup("Lens"): CustomLayoutProperty("focalLength", "Focal Length") CustomLayoutProperty("focusDistance", "Focus Distance") CustomLayoutProperty("fStop", "fStop") CustomLayoutProperty("projection", "Projection") CustomLayoutProperty("stereoRole", "Stereo Role") with CustomLayoutGroup("Horizontal Aperture"): CustomLayoutProperty("horizontalAperture", "Aperture") CustomLayoutProperty("horizontalApertureOffset", "Offset") with CustomLayoutGroup("Vertical Aperture"): CustomLayoutProperty("verticalAperture", "Aperture") CustomLayoutProperty("verticalApertureOffset", "Offset") with CustomLayoutGroup("Clipping"): CustomLayoutProperty("clippingPlanes", "Clipping Planes") CustomLayoutProperty("clippingRange", "Clipping Range") with CustomLayoutGroup("Fisheye Lens", collapsed=True): CustomLayoutProperty("cameraProjectionType", "Projection Type") CustomLayoutProperty("fthetaWidth", "Nominal Width") CustomLayoutProperty("fthetaHeight", "Nominal Height") CustomLayoutProperty("fthetaCx", "Optical Center X") CustomLayoutProperty("fthetaCy", "Optical Center Y") CustomLayoutProperty("fthetaMaxFov", "Max FOV") CustomLayoutProperty("fthetaPolyA", "Poly k0") CustomLayoutProperty("fthetaPolyB", "Poly k1") CustomLayoutProperty("fthetaPolyC", "Poly k2") CustomLayoutProperty("fthetaPolyD", "Poly k3") CustomLayoutProperty("fthetaPolyE", "Poly k4") CustomLayoutProperty("fthetaPolyF", "Poly k5") CustomLayoutProperty("p0", "p0") CustomLayoutProperty("p1", "p1") CustomLayoutProperty("s0", "s0") CustomLayoutProperty("s1", "s1") CustomLayoutProperty("s2", "s2") CustomLayoutProperty("s3", "s3") CustomLayoutProperty("fisheyeResolutionBudget", "Max Fisheye Resolution (% of Viewport Resolution") CustomLayoutProperty("fisheyeFrontFaceResolutionScale", "Front Face Resolution Scale") CustomLayoutProperty("interpupillaryDistance", "Interpupillary Distance (cm)") CustomLayoutProperty("isLeftEye", "Is left eye") with CustomLayoutGroup("Shutter", collapsed=True): CustomLayoutProperty("shutter:open", "Open") CustomLayoutProperty("shutter:close", "Close") with CustomLayoutGroup("Sensor Model", collapsed=True): CustomLayoutProperty("cameraSensorType", "Sensor Type") CustomLayoutProperty("sensorModelPluginName", "Sensor Plugin Name") CustomLayoutProperty("sensorModelConfig", "Sensor Config") CustomLayoutProperty("sensorModelSignals", "Sensor Signals") with CustomLayoutGroup("Synthetic Data Generation", collapsed=True): CustomLayoutProperty("crossCameraReferenceName", "Cross Camera Reference") return frame.apply(attrs) def get_additional_kwargs(self, ui_prop: UsdPropertyUiEntry): """ Override this function if you want to supply additional arguments when building the label or ui widget. """ additional_widget_kwargs = None if ui_prop.prop_name == "fisheyeResolutionBudget": additional_widget_kwargs = {"min": 0, "max": 10} if ui_prop.prop_name == "fisheyeFrontFaceResolutionScale": additional_widget_kwargs = {"min": 0, "max": 10} return None, additional_widget_kwargs
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/scripts/__init__.py
from .camera_properties import *
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/tests/__init__.py
from .test_camera import * from .test_prim_edits_and_auto_target import *
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/tests/test_prim_edits_and_auto_target.py
## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## import os import carb import omni.kit.app import omni.kit.commands import omni.kit.test import omni.ui as ui from omni.ui.tests.test_base import OmniUiTest from pxr import Kind, Sdf, Gf, Usd class TestPrimEditsAndAutoTarget(omni.kit.test.AsyncTestCase): def __init__(self, tests=()): super().__init__(tests) # Before running each test async def setUp(self): self._usd_context = omni.usd.get_context() await self._usd_context.new_stage_async() self._stage = self._usd_context.get_stage() from omni.kit.test_suite.helpers import arrange_windows await arrange_windows(topleft_window="Property", topleft_height=64, topleft_width=800.0) await self.wait() # After running each test async def tearDown(self): from omni.kit.test_suite.helpers import wait_stage_loading await wait_stage_loading() async def wait(self, updates=3): for i in range(updates): await omni.kit.app.get_app().next_update_async() async def test_built_in_camera_editing(self): from omni.kit.test_suite.helpers import select_prims, wait_stage_loading from omni.kit import ui_test # wait for material to load & UI to refresh await wait_stage_loading() prim_path = "/OmniverseKit_Persp" await select_prims([prim_path]) # Loading all inputs await self.wait() all_widgets = ui_test.find_all("Property//Frame/**/.identifier!=''") self.assertNotEqual(all_widgets, []) for w in all_widgets: id = w.widget.identifier if id.startswith("float_slider_"): w.widget.scroll_here_y(0.5) await ui_test.human_delay() await w.input(str(0.3456)) await ui_test.human_delay() elif id.startswith("integer_slider_"): w.widget.scroll_here_y(0.5) attr = self._stage.GetPrimAtPath(prim_path).GetAttribute(id[15:]) await ui_test.human_delay() old_value = attr.Get() new_value = old_value + 1 await w.input(str(new_value)) await ui_test.human_delay() elif id.startswith("drag_per_channel_int"): w.widget.scroll_here_y(0.5) await ui_test.human_delay() sub_widgets = w.find_all("**/IntSlider[*]") if sub_widgets == []: sub_widgets = w.find_all("**/IntDrag[*]") self.assertNotEqual(sub_widgets, []) for child in sub_widgets: child.model.set_value(0) await child.input("9999") await ui_test.human_delay() elif id.startswith("drag_per_channel_"): w.widget.scroll_here_y(0.5) await ui_test.human_delay() sub_widgets = w.find_all("**/FloatSlider[*]") if sub_widgets == []: sub_widgets = w.find_all("**/FloatDrag[*]") self.assertNotEqual(sub_widgets, []) for child in sub_widgets: await child.input("0.12345") await self.wait() elif id.startswith("bool_"): w.widget.scroll_here_y(0.5) attr = self._stage.GetPrimAtPath(prim_path).GetAttribute(id[5:]) await ui_test.human_delay() old_value = attr.Get() new_value = not old_value w.widget.model.set_value(new_value) elif id.startswith("sdf_asset_"): w.widget.scroll_here_y(0.5) await ui_test.human_delay() new_value = "testpath/abc.png" w.widget.model.set_value(new_value) await ui_test.human_delay() # All property edits to built-in cameras should be retargeted into session layer. root_layer = self._stage.GetRootLayer() prim_spec = root_layer.GetPrimAtPath("/OmniverseKit_Persp") self.assertTrue(bool(prim_spec))
omniverse-code/kit/exts/omni.kit.property.camera/omni/kit/property/camera/tests/test_camera.py
## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## import omni.kit.app import omni.kit.commands import omni.kit.test import omni.ui as ui from omni.kit import ui_test from omni.ui.tests.test_base import OmniUiTest from pxr import Kind, Sdf, Gf import pathlib class TestCameraWidget(OmniUiTest): # Before running each test async def setUp(self): await super().setUp() from omni.kit.property.camera.scripts.camera_properties import TEST_DATA_PATH self._golden_img_dir = TEST_DATA_PATH.absolute().joinpath("golden_img").absolute() self._usd_path = TEST_DATA_PATH.absolute() from omni.kit.property.usd.usd_attribute_widget import UsdPropertiesWidget import omni.kit.window.property as p self._w = p.get_window() # After running each test async def tearDown(self): await super().tearDown() async def test_camera_ui(self): usd_context = omni.usd.get_context() await self.docked_test_window( window=self._w._window, width=450, height=675, restore_window = ui.Workspace.get_window("Layer") or ui.Workspace.get_window("Stage"), restore_position = ui.DockPosition.BOTTOM) test_file_path = self._usd_path.joinpath("camera_test.usda").absolute() await usd_context.open_stage_async(str(test_file_path)) await omni.kit.app.get_app().next_update_async() # Select the prim. usd_context.get_selection().set_selected_prim_paths(["/World/Camera"], True) # Need to wait for an additional frames for omni.ui rebuild to take effect await ui_test.human_delay(10) await self.finalize_test(golden_img_dir=self._golden_img_dir, golden_img_name="test_camera_ui.png")
omniverse-code/kit/exts/omni.kit.property.camera/docs/CHANGELOG.md
# Changelog The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [1.0.3] - 2021-02-19 ### Changes - Added UI test ## [1.0.2] - 2020-12-09 ### Changes - Added extension icon - Added readme - Updated preview image ## [1.0.1] - 2020-10-22 ### Changes - Improved layout ## [1.0.0] - 2020-09-17 ### Changes - Created
omniverse-code/kit/exts/omni.kit.property.camera/docs/README.md
# omni.kit.property.camera ## Introduction Property window extensions are for viewing and editing Usd Prim Attributes ## This extension supports editing of these Usd Types; - UsdGeom.Camera
omniverse-code/kit/exts/omni.kit.property.camera/docs/index.rst
omni.kit.property.camera ########################### Property Camera Values .. toctree:: :maxdepth: 1 CHANGELOG
omniverse-code/kit/exts/omni.kit.property.camera/data/tests/camera_test.usda
#usda 1.0 ( defaultPrim = "World" endTimeCode = 100 metersPerUnit = 0.009999999776482582 startTimeCode = 0 timeCodesPerSecond = 24 upAxis = "Y" ) def Xform "World" { def Camera "Camera" { float focalLength = 24 float focusDistance = 400 double3 xformOp:rotateXYZ = (0, 0, 4) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } }
omniverse-code/kit/exts/omni.rtx.multinode.dev/PACKAGE-LICENSES/omni.rtx.multinode.dev-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.
omniverse-code/kit/exts/omni.rtx.multinode.dev/config/extension.toml
[package] title = "RTX Multi-Node Prototype" description="Developer prototype controls for RTX multi-node rendering." authors = ["NVIDIA"] version = "0.1.0" category = "Rendering" keywords = ["kit", "rtx", "rendering", "multi-node"] repository = "" [dependencies] "omni.gpu_foundation" = {} "omni.graph.core" = {} "omni.physx.bundle" = {} "omni.physx.flatcache" = {} [[python.module]] name = "omni.rtx.multinode.dev" [[test]] waiver = "Extension is tested externally"
omniverse-code/kit/exts/omni.rtx.multinode.dev/omni/rtx/multinode/dev/multinode.py
import traceback import uuid import carb import carb.settings import omni.ext import omni.ui as ui import omni.gpu_foundation_factory import omni.client from random import random import math from omni.physx.scripts import physicsUtils from pxr import UsdLux, UsdGeom, Gf, UsdPhysics def print_exception(exc_info): print(f"===== Exception: {exc_info[0]}, {exc_info[1]}. Begin Stack Trace =====") traceback.print_tb(exc_info[2]) print("===== End Stack Trace ===== ") class Extension(omni.ext.IExt): def on_startup(self): # Obtain multi process info gpu = omni.gpu_foundation_factory.get_gpu_foundation_factory_interface() processIndex = gpu.get_process_index() processCount = gpu.get_process_count() # Settings self._settings = carb.settings.get_settings() self._settings.set("/persistent/physics/updateToUsd", False) self._settings.set("/persistent/physics/updateVelocitiesToUsd", False) self._settings.set("/persistent/omnihydra/useFastSceneDelegate", True) self._settings.set("/app/renderer/sleepMsOutOfFocus", 0) if processIndex > 0: self._settings.set("/app/window/title", "Kit Worker {} //".format(processIndex)) # UI self._window = ui.Window("RTX Multi-Node Prototype", dockPreference=ui.DockPreference.LEFT_BOTTOM) self._window.deferred_dock_in("Console", ui.DockPolicy.CURRENT_WINDOW_IS_ACTIVE) with self._window.frame: with omni.ui.HStack(height=0): omni.ui.Spacer(width=6) with omni.ui.VStack(height=0): omni.ui.Spacer(height=10) with omni.ui.HStack(height=0): if processIndex == 0: omni.ui.Label("Master process of {}".format(processCount)) else: omni.ui.Label("Worker process {} of {}".format(processIndex, processCount)) if processIndex == 0: omni.ui.Spacer(height=20) with omni.ui.HStack(): with omni.ui.VStack(height=0): omni.ui.Label("Settings") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=10) with omni.ui.VStack(width = 200, height = 0): with omni.ui.HStack(): omni.ui.Label("Fabric Replication") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/flatcacheReplication/enabled")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/flatcacheReplication/enabled", a.get_value_as_bool())) omni.ui.Label("Enabled") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/flatcacheReplication/profile")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/flatcacheReplication/profile", a.get_value_as_bool())) omni.ui.Label("Profile") omni.ui.Spacer(height=10) with omni.ui.HStack(): omni.ui.Label("Gather Render Results") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/gatherResults/enabled")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/gatherResults/enabled", a.get_value_as_bool())) omni.ui.Label("Enabled") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/gatherResults/profile")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/gatherResults/profile", a.get_value_as_bool())) omni.ui.Label("Profile") with omni.ui.VStack(width = 200, height=0): with omni.ui.HStack(): omni.ui.Label("Render Product Replication") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/renderProductReplication/enabled")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/renderProductReplication/enabled", a.get_value_as_bool())) omni.ui.Label("Enabled") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/renderProductReplication/includeCameraAttributes")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/renderProductReplication/includeCameraAttributes", a.get_value_as_bool())) omni.ui.Label("Include Camera Attributes") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/renderProductReplication/fullSessionLayer")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/renderProductReplication/fullSessionLayer", a.get_value_as_bool())) omni.ui.Label("Full Session Layer") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/renderProductReplication/profile")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/renderProductReplication/profile", a.get_value_as_bool())) omni.ui.Label("Profile") omni.ui.Spacer(height=5) with omni.ui.HStack(): omni.ui.Spacer(width=20) box = omni.ui.CheckBox(width = 22) box.model.set_value(self._settings.get("/multiNode/renderProductReplication/print")) box.model.add_value_changed_fn(lambda a: self._settings.set("/multiNode/renderProductReplication/print", a.get_value_as_bool())) omni.ui.Label("Print") omni.ui.Spacer(width=200) with omni.ui.VStack(height=0): omni.ui.Label("Deprecated: Physics prototype") omni.ui.Spacer(height=10) with omni.ui.HStack(height=0): load_button = omni.ui.Button("Load Stage", width=150, height=30) load_button.set_clicked_fn(self._on_load_button_fn) omni.ui.Spacer(height=5) with omni.ui.HStack(height=0): self._numBoxesDrag = omni.ui.IntDrag(min = 1, max = 1000000, step = 1, width = 100) self._numBoxesDrag.model.set_value(1000) omni.ui.Spacer(width=10) omni.ui.Label("Boxes") omni.ui.Spacer(height=5) with omni.ui.HStack(height=0): init_button = omni.ui.Button("Init Simulation", width=150, height=30) init_button.set_clicked_fn(self._on_init_button_fn) omni.ui.Spacer(height=5) with omni.ui.HStack(height=0): play_button = omni.ui.Button("Play Simulation", width=150, height=30) play_button.set_clicked_fn(self._on_play_button_fn) omni.ui.Spacer() def on_shutdown(self): pass def _on_load_button_fn(self): carb.log_warn("Load stage") srcPath = "omniverse://content.ov.nvidia.com/Users/tbiedert@nvidia.com/multi-node/empty.usd" dstPath = "omniverse://content.ov.nvidia.com/Users/tbiedert@nvidia.com/multi-node/gen/" + str(uuid.uuid4()) + ".usd" # Create a temporary copy try: result = omni.client.copy(srcPath, dstPath, omni.client.CopyBehavior.OVERWRITE) if result != omni.client.Result.OK: carb.log_error(f"Cannot copy from {srcPath} to {dstPath}, error code: {result}.") else: carb.log_warn(f"Copied from {srcPath} to {dstPath}.") except Exception as e: traceback.print_exc() carb.log_error(str(e)) # Load the temporary copy omni.usd.get_context().open_stage(str(dstPath)) # FIXME: Add compatible API for legacy usage. # Enable live sync # omni.usd.get_context().set_stage_live(layers.LayerLiveMode.ALWAYS_ON) def _on_init_button_fn(self): carb.log_warn("Init simulation") # Disable FlatCache replication self._settings.set("/multiNode/flatcacheReplication/enabled", False) # set up axis to z stage = omni.usd.get_context().get_stage() UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.z) UsdGeom.SetStageMetersPerUnit(stage, 0.01) # Disable default light defaultPrimPath = str(stage.GetDefaultPrim().GetPath()) stage.RemovePrim(defaultPrimPath + "/defaultLight") # light sphereLight = UsdLux.SphereLight.Define(stage, defaultPrimPath + "/SphereLight") sphereLight.CreateRadiusAttr(30) sphereLight.CreateIntensityAttr(50000) sphereLight.AddTranslateOp().Set(Gf.Vec3f(0.0, 0.0, 150.0)) # Boxes numBoxes = self._numBoxesDrag.model.get_value_as_int() size = 25.0 radius = 100.0 self._boxes = [None] * numBoxes for i in range(numBoxes): box = UsdGeom.Cube.Define(stage, defaultPrimPath + "/box_" + str(i)) box.CreateSizeAttr(size) box.CreateExtentAttr([(-size / 2, -size / 2, -size / 2), (size / 2, size / 2, size / 2)]) box.AddTranslateOp().Set(Gf.Vec3f(radius * math.cos(0.5 * i), radius * math.sin(0.5 * i), size + (i * 0.2) * size)) box.AddOrientOp().Set(Gf.Quatf(random(), random(), random(), random()).GetNormalized()) box.CreateDisplayColorAttr().Set([Gf.Vec3f(random(), random(), random())]) self._boxes[i] = box.GetPrim() # Plane planeActorPath = defaultPrimPath + "/plane" size = 1500.0 planeGeom = UsdGeom.Cube.Define(stage, planeActorPath) self._plane = stage.GetPrimAtPath(planeActorPath) planeGeom.CreateSizeAttr(size) planeGeom.CreateExtentAttr([(-size / 2, -size / 2, -size / 2), (size / 2, size / 2, size / 2)]) planeGeom.AddTranslateOp().Set(Gf.Vec3f(0.0, 0.0, 0.0)) planeGeom.AddOrientOp().Set(Gf.Quatf(1.0)) planeGeom.AddScaleOp().Set(Gf.Vec3f(1.0, 1.0, 0.01)) planeGeom.CreateDisplayColorAttr().Set([Gf.Vec3f(0.5)]) def _on_play_button_fn(self): carb.log_warn("Play simulation") # FIXME: Add compatible API for legacy usage. # Disable live sync # omni.usd.get_context().set_stage_live(layers.LayerLiveMode.TOGGLE_OFF) # Enable FlatCache replication self._settings.set("/multiNode/flatcacheReplication/enabled", True) # Add physics to scene stage = omni.usd.get_context().get_stage() defaultPrimPath = str(stage.GetDefaultPrim().GetPath()) scene = UsdPhysics.Scene.Define(stage, defaultPrimPath + "/physicsScene") scene.CreateGravityDirectionAttr().Set(Gf.Vec3f(0.0, 0.0, -1.0)) scene.CreateGravityMagnitudeAttr().Set(981.0) for box in self._boxes: UsdPhysics.CollisionAPI.Apply(box) physicsAPI = UsdPhysics.RigidBodyAPI.Apply(box) UsdPhysics.MassAPI.Apply(box) UsdPhysics.CollisionAPI.Apply(self._plane) # Play animation omni.timeline.get_timeline_interface().play()
omniverse-code/kit/exts/omni.rtx.multinode.dev/omni/rtx/multinode/dev/__init__.py
from .multinode import *
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/extension.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import carb import omni.ext from .stage_listener import StageListener _global_instance = None class SelectionOutlineExtension(omni.ext.IExt): def on_startup(self): global _global_instance _global_instance = self self._stage_listener = StageListener() self._stage_listener.start() def on_shutdown(self): global _global_instance _global_instance = None self._stage_listener.stop() @staticmethod def _get_instance(): global _global_instance return _global_instance
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/__init__.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .extension import SelectionOutlineExtension
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/stage_listener.py
import asyncio import carb import omni.client import omni.usd import omni.kit.usd.layers as layers import omni.kit.collaboration.presence_layer as pl from omni.kit.async_engine import run_coroutine from .manipulator import PeerUserList from pxr import Sdf, Usd, UsdGeom, Tf, Trace from typing import Dict, List, Union SETTING_MULTI_USER_OUTLINE = "/app/viewport/multiUserOutlineMode" SETTING_SAVED_OUTLINE_COLOR = "/persistent/app/viewport/live_session/saved_outline_color" SETTING_OUTLINE_COLOR = "/persistent/app/viewport/outline/color" SETTING_MAXIMUM_SELECTION_ICONS_PER_USER = "/exts/omni/kit/collaboration/selection_outline/maximum_selection_icons_per_user" class MultiUserSelectionOutlineManager: def __init__(self, usd_context: omni.usd.UsdContext) -> None: self.__usd_context = usd_context self.__settings = carb.settings.get_settings() self.__user_last_selected_prims = {} self.__prim_selection_queue = {} self.__user_selection_group = {} self.__selection_group_pool = [] self.__prim_viewport_widget = {} self._delay_refresh_task_or_future = None def clear_all_selection(self): self.__user_last_selected_prims = {} self.__prim_selection_queue = {} self.__user_selection_group = {} for widget in self.__prim_viewport_widget.values(): widget.destroy() self.__prim_viewport_widget = {} if self._delay_refresh_task_or_future: self._delay_refresh_task_or_future.cancel() self._delay_refresh_task_or_future = None def clear_selection(self, user_id): """Deregister user from selection group.""" selection_group = self.__user_selection_group.pop(user_id, None) if selection_group: self.__update_selection_outline_internal(user_id, selection_group, {}) # Returns selection group to re-use as it supports 255 at maximum due to limitation of renderer. self.__selection_group_pool.append(selection_group) def on_usd_objects_changed(self, notice): stage = self.__usd_context.get_stage() to_remove_paths = [] to_update_paths = [] for widget_path, widget in self.__prim_viewport_widget.items(): prim = stage.GetPrimAtPath(widget_path) if not prim or not prim.IsActive() or not prim.IsDefined(): to_remove_paths.append(widget_path) elif notice.ResyncedObject(prim): to_update_paths.append(widget_path) else: changed_info_only_paths = notice.GetChangedInfoOnlyPaths() slice_object = Sdf.Path.FindPrefixedRange(changed_info_only_paths, widget_path) if not slice_object: continue paths = changed_info_only_paths[slice_object] if not paths: continue for path in paths: if UsdGeom.Xformable.IsTransformationAffectedByAttrNamed(path.name): to_update_paths.append(widget_path) break for path in to_remove_paths: widget = self.__prim_viewport_widget.pop(path, None) widget.destroy() for path in to_update_paths: widget = self.__prim_viewport_widget.get(path, None) widget.on_transform_changed() def refresh_selection(self, selection_paths: List[Sdf.Path]): """ Calls this to refresh selection. This is normally called after selection changed, which will override the outline of remote users. """ if not selection_paths: return for path in selection_paths: self.__set_prim_outline(0, path) async def delay_refresh(paths): await omni.kit.app.get_app().next_update_async() for path in paths: selection_queue = self.__get_selection_queue(path) for _, group in selection_queue.items(): self.__set_prim_outline(group, path) break self._delay_refresh_task_or_future = None if self._delay_refresh_task_or_future and not self._delay_refresh_task_or_future.done(): self._delay_refresh_task_or_future.cancel() self._delay_refresh_task_or_future = run_coroutine(delay_refresh(selection_paths)) def update_selection_outline(self, user_info: layers.LiveSessionUser, selection_paths: List[Sdf.Path]): user_id = user_info.user_id selection_group = self.__user_selection_group.get(user_id, None) if not selection_group: # Re-use selection group. if self.__selection_group_pool: selection_group = self.__selection_group_pool.pop(0) else: selection_group = self.__usd_context.register_selection_group() self.__user_selection_group[user_id] = selection_group # RGBA color = ( user_info.user_color[0] / 255.0, user_info.user_color[1] / 255.0, user_info.user_color[2] / 255.0, 1.0 ) self.__usd_context.set_selection_group_outline_color(selection_group, color) self.__usd_context.set_selection_group_shade_color(selection_group, (0.0, 0.0, 0.0, 0.0)) if selection_group == 0: carb.log_error("The maximum number (255) of selection groups is reached.") return selection_paths = [Sdf.Path(path) for path in selection_paths] selection_paths = Sdf.Path.RemoveDescendentPaths(selection_paths) stage = self.__usd_context.get_stage() # Find all renderable prims all_renderable_prims = {} for path in selection_paths: prim = stage.GetPrimAtPath(path) if not prim: continue renderable_prims = [] for prim in Usd.PrimRange(prim, Usd.TraverseInstanceProxies(Usd.PrimAllPrimsPredicate)): # Camera in Kit has special representation, which needs to be excluded. if ( not prim.IsActive() or omni.usd.editor.is_hide_in_ui(prim) or omni.usd.editor.is_hide_in_stage_window(prim) ): break if ( not prim.GetPath().name == "CameraModel" and not prim.GetPath().GetParentPath().name == "OmniverseKitViewportCameraMesh" and prim.IsA(UsdGeom.Gprim) ): renderable_prims.append(prim.GetPath()) if renderable_prims: all_renderable_prims[path] = renderable_prims selection_paths = all_renderable_prims # Draw user icon maximum_count = self.__settings.get(SETTING_MAXIMUM_SELECTION_ICONS_PER_USER) if not maximum_count or maximum_count <= 0: maximum_count = 3 for index, path in enumerate(selection_paths.keys()): path = Sdf.Path(path) widget = self.__prim_viewport_widget.get(path, None) if not widget: widget = PeerUserList(self.__usd_context, path) self.__prim_viewport_widget[path] = widget widget.add_user(user_info) # OMFP-2736: Don't show all selections to avoid cluttering the viewport. if index + 1 >= maximum_count: break self.__update_selection_outline_internal(user_id, selection_group, selection_paths) def __update_selection_outline_internal( self, user_id, selection_group, all_renderable_paths: Dict[Sdf.Path, List[Sdf.Path]] ): last_selected_prim_and_renderable_paths = self.__user_last_selected_prims.get(user_id, {}) last_selected_prim_paths = set(last_selected_prim_and_renderable_paths.keys()) selection_paths = set(all_renderable_paths.keys()) if last_selected_prim_paths == selection_paths: return if last_selected_prim_paths: old_selected_paths = last_selected_prim_paths.difference(selection_paths) new_selected_paths = selection_paths.difference(last_selected_prim_paths) else: old_selected_paths = set() new_selected_paths = selection_paths # Update selection outline for old paths to_clear_paths = [] for path in old_selected_paths: # Remove user icon widget = self.__prim_viewport_widget.get(path, None) if widget: widget.remove_user(user_id) if widget.empty_user_list(): self.__prim_viewport_widget.pop(path, None) widget.destroy() # Remove outline of all renderable prims under the selected path. renderable_paths = last_selected_prim_and_renderable_paths.get(path, None) for renderable_path in renderable_paths: selection_queue = self.__get_selection_queue(renderable_path) if selection_queue: # FIFO queue that first user that selects the prim decides the color of selection. group = next(iter(selection_queue.values())) same_group = selection_group == group # Pop this user and outline the prim with next user's selection color. selection_queue.pop(user_id, None) if same_group and selection_queue: for _, group in selection_queue.items(): self.__set_prim_outline(group, renderable_path) break elif same_group: to_clear_paths.append(renderable_path) # Update selection outline for new paths to_select_paths = [] for path in new_selected_paths: renderable_paths = all_renderable_paths.get(path, None) if not renderable_paths: continue for renderable_path in renderable_paths: selection_queue = self.__get_selection_queue(renderable_path) has_outline = not not selection_queue selection_queue[user_id] = selection_group if not has_outline: to_select_paths.append(renderable_path) if to_clear_paths: self.__clear_prim_outline(to_clear_paths) if to_select_paths: self.__set_prim_outline(selection_group, to_select_paths) self.__user_last_selected_prims[user_id] = all_renderable_paths def __get_selection_queue(self, prim_path): prim_path = Sdf.Path(prim_path) if prim_path not in self.__prim_selection_queue: # Value is dict to keep order of insertion. self.__prim_selection_queue[prim_path] = {} return self.__prim_selection_queue[prim_path] def __set_prim_outline(self, selection_group, prim_path: Union[Sdf.Path, List[Sdf.Path]]): if isinstance(prim_path, list): paths = [str(path) for path in prim_path] else: paths = [str(prim_path)] selection = self.__usd_context.get_selection().get_selected_prim_paths() for path in paths: # If it's locally selected, don't override the outline. if path in selection: continue self.__usd_context.set_selection_group(selection_group, path) def __clear_prim_outline(self, prim_path: Union[Sdf.Path, List[Sdf.Path]]): self.__set_prim_outline(0, prim_path) class StageListener: def __init__(self, usd_context_name=""): self.__usd_context = omni.usd.get_context(usd_context_name) self.__presence_layer = pl.get_presence_layer_interface(self.__usd_context) self.__live_syncing = layers.get_live_syncing(self.__usd_context) self.__layers = layers.get_layers(self.__usd_context) self.__layers_event_subscriptions = [] self.__stage_event_subscription = None self.__settings = carb.settings.get_settings() self.__selection_paths_initialized = False self.__stage_objects_changed = None self.__multi_user_selection_manager = MultiUserSelectionOutlineManager(self.__usd_context) self.__delayed_task_or_future = None self.__changed_user_ids = set() def start(self): self.__restore_local_outline_color() for event in [ layers.LayerEventType.LIVE_SESSION_STATE_CHANGED, layers.LayerEventType.LIVE_SESSION_USER_JOINED, layers.LayerEventType.LIVE_SESSION_USER_LEFT, pl.PresenceLayerEventType.SELECTIONS_CHANGED, ]: layers_event_sub = self.__layers.get_event_stream().create_subscription_to_pop_by_type( event, self.__on_layers_event, name=f"omni.kit.collaboration.selection_outline {str(event)}" ) self.__layers_event_subscriptions.append(layers_event_sub) self.__stage_event_subscription = self.__usd_context.get_stage_event_stream().create_subscription_to_pop( self.__on_stage_event, name="omni.kit.collaboration.selection_outline stage event" ) self.__start_subscription() def __start_subscription(self): self.__settings.set(SETTING_MULTI_USER_OUTLINE, True) live_session = self.__live_syncing.get_current_live_session() if not live_session: return for peer_user in live_session.peer_users: selection_paths = self.__presence_layer.get_selections(peer_user.user_id) self.__multi_user_selection_manager.update_selection_outline(peer_user, selection_paths) if not self.__selection_paths_initialized: self.__selection_paths_initialized = True selection = self.__usd_context.get_selection().get_selected_prim_paths() self.__on_selection_changed(selection) root_layer_session = self.__live_syncing.get_current_live_session() if root_layer_session: logged_user = root_layer_session.logged_user user_color = logged_user.user_color rgba = (user_color[0] / 255.0, user_color[1] / 255.0, user_color[2] / 255.0, 1.0) self.__save_and_set_local_outline_color(rgba) self.__stage_objects_changed = Tf.Notice.Register( Usd.Notice.ObjectsChanged, self.__on_usd_changed, self.__usd_context.get_stage() ) @Trace.TraceFunction @carb.profiler.profile def __on_usd_changed(self, notice, sender): if not sender or sender != self.__usd_context.get_stage(): return self.__multi_user_selection_manager.on_usd_objects_changed(notice) def __stop_subscription(self): self.__changed_user_ids.clear() if self.__delayed_task_or_future and not self.__delayed_task_or_future.done(): self.__delayed_task_or_future.cancel() self.__delayed_task_or_future = None self.__restore_local_outline_color() self.__selection_paths_initialized = False self.__multi_user_selection_manager.clear_all_selection() self.__settings.set(SETTING_MULTI_USER_OUTLINE, False) if self.__stage_objects_changed: self.__stage_objects_changed.Revoke() self.__stage_objects_changed = None def stop(self): self.__stop_subscription() self.__layers_event_subscription = None self.__stage_event_subscription = None def __save_and_set_local_outline_color(self, color): old_color = self.__settings.get(SETTING_OUTLINE_COLOR) if old_color: self.__settings.set(SETTING_SAVED_OUTLINE_COLOR, old_color) old_color[-4:] = color else: # It has maximum 255 group + selection_outline old_color = [0] * 256 old_color[-4:] = color color = old_color self.__settings.set(SETTING_OUTLINE_COLOR, color) def __restore_local_outline_color(self): # It's possible that Kit is shutdown abnormally. So it can # be used to restore the outline color before live session or abort. color = self.__settings.get(SETTING_SAVED_OUTLINE_COLOR) if not color: return self.__settings.set(SETTING_OUTLINE_COLOR, color) # Clear saved color self.__settings.set(SETTING_SAVED_OUTLINE_COLOR, None) def __on_stage_event(self, event): if event.type == int(omni.usd.StageEventType.SELECTION_CHANGED): if not self.__live_syncing.get_current_live_session(): return selection = self.__usd_context.get_selection().get_selected_prim_paths() self.__on_selection_changed(selection) elif event.type == int(omni.usd.StageEventType.CLOSING): self.__stop_subscription() def __on_selection_changed(self, selection_paths): self.__multi_user_selection_manager.refresh_selection(selection_paths) def __on_layers_event(self, event): payload = layers.get_layer_event_payload(event) if payload.event_type == layers.LayerEventType.LIVE_SESSION_STATE_CHANGED: if not payload.is_layer_influenced(self.__usd_context.get_stage_url()): return if self.__live_syncing.get_current_live_session(): self.__start_subscription() else: self.__stop_subscription() elif payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_JOINED: if not payload.is_layer_influenced(self.__usd_context.get_stage_url()): return user_id = payload.user_id live_session = self.__live_syncing.get_current_live_session() user_info = live_session.get_peer_user_info(user_id) selection_paths = self.__presence_layer.get_selections(user_id) self.__multi_user_selection_manager.update_selection_outline(user_info, selection_paths) elif payload.event_type == layers.LayerEventType.LIVE_SESSION_USER_LEFT: if not payload.is_layer_influenced(self.__usd_context.get_stage_url()): return user_id = payload.user_id self.__multi_user_selection_manager.clear_selection(user_id) else: payload = pl.get_presence_layer_event_payload(event) if payload.event_type == pl.PresenceLayerEventType.SELECTIONS_CHANGED: self.__changed_user_ids.update(payload.changed_user_ids) # Delay the selection updates. if not self.__delayed_task_or_future or self.__delayed_task_or_future.done(): self.__delayed_task_or_future = run_coroutine(self.__handle_selection_changes()) async def __handle_selection_changes(self): current_live_session = self.__live_syncing.get_current_live_session() if not current_live_session: return for user_id in self.__changed_user_ids: user_info = current_live_session.get_peer_user_info(user_id) if not user_info: continue selection_paths = self.__presence_layer.get_selections(user_id) self.__multi_user_selection_manager.update_selection_outline(user_info, selection_paths) self.__changed_user_ids.clear() self.__delayed_task_or_future = None
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/manipulator/peer_user_list_manipulator_model.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # __all__ = ["PeerUserListManipulatorModel"] import carb import omni.usd import omni.kit.usd.layers as layers from omni.ui import scene as sc from pxr import Gf, UsdGeom, Usd, Sdf, Tf, Trace class PeerUserListManipulatorModel(sc.AbstractManipulatorModel): """The model tracks the position of peer user's camera in a live session.""" class PositionItem(sc.AbstractManipulatorItem): def __init__(self): super().__init__() self.value = [0, 0, 0] class UserListItem(sc.AbstractManipulatorItem): def __init__(self): super().__init__() self.value = {} def __init__(self, prim_path, usd_context: omni.usd.UsdContext): super().__init__() self.position = PeerUserListManipulatorModel.PositionItem() self.user_list = PeerUserListManipulatorModel.UserListItem() self.__prim_path = Sdf.Path(prim_path) self.__usd_context = usd_context self.__update_position = True def destroy(self): self.position = None self.__usd_context = None def add_user(self, user_info: layers.LiveSessionUser): if user_info.user_id in self.user_list.value: return self.user_list.value[user_info.user_id] = user_info # This makes the manipulator updated self._item_changed(self.user_list) def remove_user(self, user_id): item = self.user_list.value.pop(user_id, None) if not item: # This makes the manipulator updated self._item_changed(self.user_list) def empty_user_list(self): return len(self.user_list.value) == 0 def get_item(self, identifier): if identifier == "position": return self.position elif identifier == "user_list": return self.user_list return None def get_as_floats(self, item): if item == self.position: # Requesting position if self.__update_position: self.position.value = self._get_position() self.__update_position = False return self.position.value return [] def set_floats(self, item, value): if item != self.position: return if not value or item.value == value: return # Set directly to the item item.value = value self.__update_position = False # This makes the manipulator updated self._item_changed(item) def on_transform_changed(self, position=None): """When position is provided, it will not re-calculate position but use provided value instead.""" # Position is changed if position: self.set_floats(self.position, position) else: self.__update_position = True self._item_changed(self.position) def _get_position(self): """Returns center position at the top of the bbox for the current selected object.""" stage = self.__usd_context.get_stage() prim = stage.GetPrimAtPath(self.__prim_path) if not prim: return [] # Get bounding box from prim aabb_min, aabb_max = self.__usd_context.compute_path_world_bounding_box( str(self.__prim_path) ) gf_range = Gf.Range3d( Gf.Vec3d(aabb_min[0], aabb_min[1], aabb_min[2]), Gf.Vec3d(aabb_max[0], aabb_max[1], aabb_max[2]) ) if gf_range.IsEmpty(): # May be empty (UsdGeom.Xform for example), so build a scene-scaled constant box world_units = UsdGeom.GetStageMetersPerUnit(stage) if Gf.IsClose(world_units, 0.0, 1e-6): world_units = 0.01 xformable_prim = UsdGeom.Xformable(prim) world_xform = xformable_prim.ComputeLocalToWorldTransform(Usd.TimeCode.Default()) ref_position = world_xform.ExtractTranslation() extent = Gf.Vec3d(0.1 / world_units) # 10cm by default gf_range.SetMin(ref_position - extent) gf_range.SetMax(ref_position + extent) bboxMin = gf_range.GetMin() bboxMax = gf_range.GetMax() position = [(bboxMin[0] + bboxMax[0]) * 0.5, bboxMax[1], (bboxMin[2] + bboxMax[2]) * 0.5] return position
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/manipulator/__init__.py
from .peer_user_list import PeerUserList
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/manipulator/peer_user_list_manipulator.py
## Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## __all__ = ["PeerUserListManipulator"] import omni.ui as ui import omni.kit.usd.layers as layers from omni.ui import scene as sc from omni.ui import color as cl class PeerUserListManipulator(sc.Manipulator): def __init__(self, **kwargs): super().__init__(**kwargs) self.__position_transform = None self.__user_list_transform = None self.__hover_gesture = sc.HoverGesture( on_began_fn=lambda sender: self.__show_tooltip(sender), on_ended_fn=lambda sender: self.__show_tooltip(sender) ) def destroy(self): self.__hover_gesture = None self.__clear() def __clear(self): if self.__position_transform: self.__position_transform.clear() self.__position_transform = None if self.__user_list_transform: self.__user_list_transform.clear() self.__user_list_transform = None def __show_tooltip(self, sender): pass def on_build(self): """Called when the model is changed and rebuilds the whole slider""" if not self.model: return position = self.model.get_as_floats(self.model.get_item("position")) if not position: return user_list_item = self.model.get_item("user_list") if not user_list_item: return self.__position_transform = sc.Transform(transform=sc.Matrix44.get_translation_matrix(*position)) with self.__position_transform: with sc.Transform(look_at=sc.Transform.LookAt.CAMERA): with sc.Transform(scale_to=sc.Space.SCREEN): self.__user_list_transform = sc.Transform(transform=sc.Matrix44.get_translation_matrix(0, 30, 0)) with self.__user_list_transform: self.__build_user_list(user_list_item.value) def __invalidate(self): self.__clear() self.invalidate() def __build_user_list(self, user_list): size = min(3, len(user_list)) index = 0 current_offset = 0 space = 4 icon_size = 28 self.__user_list_transform.clear() with self.__user_list_transform: for user_info in user_list.values(): if index == size: with sc.Transform(transform=sc.Matrix44.get_translation_matrix(current_offset, 0, 0)): sc.Label("...", color=cl.white, alignment=ui.Alignment.CENTER, size=28) break with sc.Transform(transform=sc.Matrix44.get_translation_matrix(current_offset, 0, 0)): color = ui.color(*user_info.user_color) sc.Arc(radius=icon_size, color=color) sc.Label( layers.get_short_user_name(user_info.user_name), color=cl.white, alignment=ui.Alignment.CENTER, size=16 ) current_offset += icon_size * 2 + space index += 1 if index > size: break def on_model_updated(self, item): if not self.__position_transform or not self.__user_list_transform or not item: self.__invalidate() return position_item = self.model.get_item("position") user_list_item = self.model.get_item("user_list") if item == position_item: position = self.model.get_as_floats(position_item) if not position: return self.__position_transform.transform = sc.Matrix44.get_translation_matrix(*position) elif item == user_list_item: self.__build_user_list(user_list_item.value)
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/manipulator/peer_user_list.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # __all__ = ["PeerUserList"] import omni.usd import omni.kit.usd.layers as layers from pxr import Sdf from omni.ui import scene as sc from omni.kit.viewport.utility import get_active_viewport_window from .peer_user_list_manipulator_model import PeerUserListManipulatorModel from .peer_user_list_manipulator import PeerUserListManipulator class PeerUserList: def __init__(self, usd_context: omni.usd.UsdContext, prim_path: Sdf.Path): self.__usd_context = usd_context self.__prim_path = Sdf.Path(prim_path) self.__manipulator = None self.__manipulator_model = None self.__scene_view = None self.__build_window() def destroy(self): if self.__manipulator: self.__manipulator.destroy() self.__manipulator = None if self.__manipulator_model: self.__manipulator_model.destroy() self.__manipulator_model = None if self.__viewport_window: vp_api = self.__viewport_window.viewport_api if self.__scene_view: vp_api.remove_scene_view(self.__scene_view) self.__scene_view.scene.clear() self.__scene_view.destroy() self.__scene_view = None self.__viewport_window = None def add_user(self, user_info: layers.LiveSessionUser): if self.__manipulator_model: self.__manipulator_model.add_user(user_info) def remove_user(self, user_id): if self.__manipulator_model: self.__manipulator_model.remove_user(user_id) def empty_user_list(self): if self.__manipulator_model: return self.__manipulator_model.empty_user_list() return True @property def position(self): if self.__manipulator_model: return self.__manipulator_model._get_position() return None def on_transform_changed(self, position=None): if self.__manipulator_model: self.__manipulator_model.on_transform_changed(position) def __build_window(self): """Called to build the widgets of the window""" self.__viewport_window = get_active_viewport_window() frame = self.__viewport_window.get_frame("selection_outline." + str(self.__prim_path)) with frame: self.__scene_view = sc.SceneView() with self.__scene_view.scene: self.__manipulator_model = PeerUserListManipulatorModel(self.__prim_path, self.__usd_context) self.__manipulator = PeerUserListManipulator(model=self.__manipulator_model) vp_api = self.__viewport_window.viewport_api vp_api.add_scene_view(self.__scene_view)
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/tests/__init__.py
from .test_collaboration_selection_outline import TestCollaborationSelectionOutline
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/omni/kit/collaboration/selection_outline/tests/test_collaboration_selection_outline.py
from pathlib import Path import omni.usd import omni.client import omni.kit.app import omni.kit.usd.layers as layers from omni.ui.tests.test_base import OmniUiTest import omni.kit.collaboration.presence_layer.utils as pl_utils from pxr import Usd, Sdf, UsdGeom, Gf from typing import List from omni.kit.usd.layers.tests.mock_utils import MockLiveSyncingApi, join_new_simulated_user, quit_simulated_user CURRENT_PATH = Path(omni.kit.app.get_app().get_extension_manager().get_extension_path_by_module(__name__) + "/data") class TestCollaborationSelectionOutline(OmniUiTest): user_counter = 0 # Before running each test async def setUp(self): self.previous_retry_values = omni.client.set_retries(0, 0, 0) self.app = omni.kit.app.get_app() self.usd_context = omni.usd.get_context() self.layers = layers.get_layers(self.usd_context) self.live_syncing = self.layers.get_live_syncing() await omni.usd.get_context().new_stage_async() self._golden_img_dir = CURRENT_PATH.absolute().resolve().joinpath("tests") self.simulated_user_names = [] self.simulated_user_ids = [] self.test_session_name = "test" self.stage_url = "omniverse://__faked_omniverse_server__/test/live_session.usd" async def tearDown(self): if omni.usd.get_context().get_stage(): await omni.usd.get_context().close_stage_async() self.stage = None omni.client.set_retries(*self.previous_retry_values) self.live_syncing.stop_all_live_sessions() async def __create_fake_stage(self): format = Sdf.FileFormat.FindByExtension(".usd") # Sdf.Layer.New will not save layer so it won't fail. # This can be used to test layer identifier with omniverse sheme without # touching real server. layer = Sdf.Layer.New(format, self.stage_url) stage = Usd.Stage.Open(layer.identifier) session = self.live_syncing.create_live_session(self.test_session_name, layer_identifier=layer.identifier) self.assertTrue(session) await self.usd_context.attach_stage_async(stage) self.live_syncing.join_live_session(session) return stage, layer def __manipulate_stage(self, stage): sphere = stage.DefinePrim('/sphere01', 'Sphere') cube = stage.DefinePrim('/cube01', 'Cube') UsdGeom.XformCommonAPI(sphere).SetTranslate((100, 0, 0)) UsdGeom.XformCommonAPI(sphere).SetScale(Gf.Vec3f(40.0, 40.0, 40.0)) UsdGeom.XformCommonAPI(cube).SetTranslate((0, 100, 0)) UsdGeom.XformCommonAPI(cube).SetScale(Gf.Vec3f(40.0, 40.0, 40.0)) async def __create_simulated_users(self, count=2): for i in range(count): user_name = chr(ord('A') + TestCollaborationSelectionOutline.user_counter) # f"test{i}" user_id = user_name self.simulated_user_names.append(user_name) self.simulated_user_ids.append(user_id) join_new_simulated_user(user_name, user_id) await self.wait_n_updates(2) TestCollaborationSelectionOutline.user_counter += 1 def __get_shared_stage(self, current_session: layers.LiveSession): shared_data_stage_url = current_session.url + "/shared_data/users.live" layer = Sdf.Layer.FindOrOpen(shared_data_stage_url) if not layer: layer = Sdf.Layer.CreateNew(shared_data_stage_url) return Usd.Stage.Open(layer) async def __select_prims(self, shared_stage: Usd.Stage, user_id: str, selections: List[str]): selection_property_path = pl_utils.get_selection_property_path(user_id) property_spec = pl_utils.get_or_create_property_spec( shared_stage.GetRootLayer(), selection_property_path, Sdf.ValueTypeNames.StringArray ) property_spec.default = selections await self.wait_n_updates() async def __prepare_stage(self, num_users=2): await self.wait_n_updates(n_frames=10) # create stage and add users stage, layer = await self.__create_fake_stage() await self.wait_n_updates(n_frames=10) self.__manipulate_stage(stage) await self.__create_simulated_users(num_users) await self.wait_n_updates(n_frames=10) current_session = self.live_syncing.get_current_live_session() shared_stage = self.__get_shared_stage(current_session) assert(stage is not shared_stage) return shared_stage async def __check_and_leave(self): await self.finalize_test(golden_img_dir=self._golden_img_dir) self.live_syncing.stop_all_live_sessions() await self.wait_n_updates(n_frames=10) @MockLiveSyncingApi(user_name="test", user_id="test") async def test_1_selection(self): shared_stage = await self.__prepare_stage() selections = ["/cube01"] await self.__select_prims(shared_stage, self.simulated_user_ids[0], selections) await self.wait_n_updates(n_frames=10) await self.__check_and_leave() @MockLiveSyncingApi(user_name="test", user_id="test") async def test_2_select_two_prims(self): shared_stage = await self.__prepare_stage() selections = ["/sphere01", "/cube01"] await self.__select_prims(shared_stage, self.simulated_user_ids[0], selections) await self.wait_n_updates(n_frames=10) await self.__check_and_leave() @MockLiveSyncingApi(user_name="test", user_id="test") async def test_3_select_identical_prim(self): shared_stage = await self.__prepare_stage() selections = ["/cube01"] await self.__select_prims(shared_stage, self.simulated_user_ids[0], selections) await self.wait_n_updates(n_frames=10) await self.__select_prims(shared_stage, self.simulated_user_ids[1], selections) await self.wait_n_updates(n_frames=10) await self.__check_and_leave() @MockLiveSyncingApi(user_name="test", user_id="test") async def test_4_selection_overflow(self): num_users = 4 shared_stage = await self.__prepare_stage(num_users=num_users) selections = ["/cube01"] for i in range(num_users): await self.__select_prims(shared_stage, self.simulated_user_ids[i], selections) await self.__check_and_leave() @MockLiveSyncingApi(user_name="test", user_id="test") async def test_5_select_and_unselect(self): shared_stage = await self.__prepare_stage() selections = ["/cube01", "/sphere01"] await self.__select_prims(shared_stage, self.simulated_user_ids[0], selections) await self.wait_n_updates(n_frames=10) selections = ["/sphere01"] await self.__select_prims(shared_stage, self.simulated_user_ids[0], selections) await self.wait_n_updates(n_frames=10) await self.__check_and_leave()
omniverse-code/kit/exts/omni.kit.collaboration.selection_outline/docs/index.rst
omni.kit.collaboration.selection_outline ######################################## Live Session: Selection Outline Introduction ============ This extension adds support to share selections across live session to visualize the selections of multi-users in the same live session for more spatial awareness.
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/imgui_helper.py
import carb def _trans_color(color): if isinstance(color, (list, tuple)): if len(color) == 3: return carb.Float4(color[0], color[1], color[2], 1.0) elif len(color) == 4: return carb.Float4(color[0], color[1], color[2], color[3]) elif isinstance(color, str): argb_int = int(color, 16) r = ((argb_int >> 16) & 0x000000FF) / 255.0 g = ((argb_int >> 8) & 0x000000FF) / 255.0 b = (argb_int & 0x000000FF) / 255.0 w = ((argb_int >> 24) & 0x000000FF) / 255.0 return carb.Float4(r, g, b, w) elif isinstance(color, float): return carb.Float4(color, color, color, 1.0) else: return None def setup_imgui(): settings = carb.settings.get_settings() import omni.kit.imgui as _imgui imgui = _imgui.acquire_imgui() imgui_configs = settings.get("/exts/omni.app.setup/imgui") if not imgui_configs: return colors = imgui_configs.get("color", {}) if colors: for name, value in colors.items(): color = _trans_color(value) if color: def _push_color(imgui, name, color): try: source = f"imgui.push_style_color(carb.imgui.StyleColor.{name}, {color})" carb.log_info(f"config style color {name} tp {color}") exec(source) except Exception as e: carb.log_error(f"Failed to config imgui style color {name} to {color}: {e}") _push_color(imgui, name, color) else: carb.log_error(f"Unknown color format for {name}: {value}") floats = imgui_configs.get("float", {}) if floats: for name, value in floats.items(): if value != "": def _push_float_var(imgui, name, value): try: source = f"imgui.push_style_var_float(carb.imgui.StyleVar.{name}, {value})" carb.log_info(f"config float var {name} tp {value}") exec(source) except Exception as e: carb.log_error(f"Failed to config imgui float var {name} to {color}: {e}") _push_float_var(imgui, name, value)
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/application_setup.py
import asyncio import sys import os import carb.tokens import omni.ui as ui import omni.kit.ui import omni.kit.app import carb.settings import omni.kit.menu.utils import carb.input import omni.kit.stage_templates as stage_templates from omni.kit.window.title import get_main_window_title from typing import Optional, Tuple class ApplicationSetup: def __init__(self): self._settings = carb.settings.get_settings_interface() # storage for the lazy menu items self._lazy_menus = [] # storage for the layout menu items self._layout_menu = None # storage for workflows self._workflows = [] async def _load_layout(self, layout_file: str, keep_windows_open=False): try: from omni.kit.quicklayout import QuickLayout # few frames delay to avoid the conflict with the layout of omni.kit.mainwindow for i in range(3): await omni.kit.app.get_app().next_update_async() QuickLayout.load_file(layout_file, keep_windows_open) # load layout file again to make sure layout correct for i in range(3): await omni.kit.app.get_app().next_update_async() QuickLayout.load_file(layout_file, keep_windows_open) except Exception as exc: pass def force_viewport_settings(self): display_options = self._settings.get("/persistent/app/viewport/displayOptions") # Note: flags are from omni/kit/ViewportTypes.h kShowFlagAxis = 1 << 1 kShowFlagGrid = 1 << 6 kShowFlagSelectionOutline = 1 << 7 kShowFlagLight = 1 << 8 display_options = ( display_options | (kShowFlagAxis) | (kShowFlagGrid) | (kShowFlagSelectionOutline) | (kShowFlagLight) ) self._settings.set("/persistent/app/viewport/displayOptions", display_options) # Make sure these are in sync from changes above self._settings.set("/app/viewport/show/lights", True) self._settings.set("/app/viewport/grid/enabled", True) self._settings.set("/app/viewport/outline/enabled", True) def setup_application_title(self): # Adjust the Window Title to show the Create Version window_title = get_main_window_title() app_version = self._settings.get("/app/version") if not app_version: app_version = open( carb.tokens.get_tokens_interface().resolve("${app}/../VERSION") ).read() if app_version: if "+" in app_version: app_version, _ = app_version.split("+") # for RC version we remove some details production = self._settings.get("/privacy/externalBuild") if production: if "-" in app_version: app_version, _ = app_version.split("-") if self._settings.get("/app/beta"): window_title.set_app_version(app_version + " Beta") else: window_title.set_app_version(app_version) def load_default_layout(self, keep_windows_open=False): default_layout = self._settings.get("/app/layout/default") default_layout = carb.tokens.get_tokens_interface().resolve(default_layout) self.__setup_window_task = asyncio.ensure_future( self._load_layout(default_layout, keep_windows_open=keep_windows_open) ) def __load_extension_and_show_window(self, menu_path, ext_id, window_name): # Remove "lazy" menu here because it could not handle menu states while window closed # Extension should create menu item again and handle menu states editor_menu = omni.kit.ui.get_editor_menu() editor_menu.remove_item(menu_path) manager = omni.kit.app.get_app().get_extension_manager() # if the extension is not enabled, enable it and show the window if not manager.is_extension_enabled(ext_id): manager.set_extension_enabled_immediate(ext_id, True) ui.Workspace.show_window(window_name, True) else: # the extensions was enabled already check for the window and toggle it window: ui.WindowHandle = ui.Workspace.get_window(window_name) if window: ui.Workspace.show_window(window_name, not window.visible) else: ui.Workspace.show_window(window_name, True) def create_trigger_menu(self): """ Create a menu item for each extension that has a [[trigger]] entry with a menu in it's config.""" editor_menu = omni.kit.ui.get_editor_menu() manager = omni.kit.app.get_app().get_extension_manager() include_list = self._settings.get("/exts/omni.app.setup/lazy_menu/include_list") or [] exclude_list = self._settings.get("/exts/omni.app.setup/lazy_menu/exclude_list") or [] for ext in manager.get_extensions(): # if the extensions is already enabled skip it, it already has a menu item if it need if ext["enabled"]: continue ext_id = ext["id"] info = manager.get_extension_dict(ext_id) for trigger in info.get("trigger", []): menu = trigger.get("menu", {}) # enable to discover and debug the auto menu creation # print(f'menu: {menu} {menu.__class__}') menu_name = menu.get("name", None) # If the menu path not in white list or in black list, ignore if include_list and menu_name not in include_list: continue if exclude_list and menu_name in exclude_list: continue window_name = menu.get("window", None) if window_name is None or menu_name is None: carb.log_error(f"Invalid [[trigger]] entry for extension: {ext_id}") continue # get priority or default to 0 priority = menu.get("priority", 0) self._lazy_menus.append( editor_menu.add_item( menu_name, lambda window, value, menu_path=menu_name, ext_id=ext_id, window_name=window_name: self.__load_extension_and_show_window( menu_path, ext_id, window_name ), toggle=True, value=False, priority=priority, ) ) # TODO: this should be validated and those settings clean up def set_defaults(self): """ this is trying to setup some defaults for extensions to avoid warning """ self._settings.set_default("/persistent/app/omniverse/bookmarks", {}) self._settings.set_default("/persistent/app/stage/timeCodeRange", [0, 100]) self._settings.set_default( "/persistent/audio/context/closeAudioPlayerOnStop", False ) self._settings.set_default( "/persistent/app/primCreation/PrimCreationWithDefaultXformOps", True ) self._settings.set_default( "/persistent/app/primCreation/DefaultXformOpType", "Scale, Rotate, Translate", ) self._settings.set_default( "/persistent/app/primCreation/DefaultRotationOrder", "ZYX" ) self._settings.set_default( "/persistent/app/primCreation/DefaultXformOpPrecision", "Double" ) # omni.kit.property.tagging self._settings.set_default( "/persistent/exts/omni.kit.property.tagging/showAdvancedTagView", False ) self._settings.set_default( "/persistent/exts/omni.kit.property.tagging/showHiddenTags", False ) self._settings.set_default( "/persistent/exts/omni.kit.property.tagging/modifyHiddenTags", False ) # adjust couple of viewport settings self._settings.set("/app/viewport/boundingBoxes/enabled", True) def build_layout_menu(self): """Build the layout menu based on registered Layouts and main views""" editor_menu = omni.kit.ui.get_editor_menu() self._layout_menu_items = [] self._current_layout_priority = 20 self._current_key_index = 1 def add_layout_menu_entry(name, parameter, workflow=None): import inspect menu_path = f"Layout/{name}" menu = editor_menu.add_item( menu_path, None, False, self._current_layout_priority ) self._current_layout_priority = self._current_layout_priority + 1 hotkey = (carb.input.KEYBOARD_MODIFIER_FLAG_CONTROL, eval(f"carb.input.KeyboardInput.KEY_{self._current_key_index}")) if self._current_key_index <= 9 else None self._current_key_index += 1 if inspect.isfunction(parameter): menu_action = omni.kit.menu.utils.add_action_to_menu( menu_path, lambda *_: parameter(), name, hotkey, ) else: menu_action = omni.kit.menu.utils.add_action_to_menu( menu_path, lambda *_: asyncio.ensure_future(self._activate_layout(parameter, workflow)), name, hotkey, ) self._layout_menu_items.append((menu, menu_action)) # Default layout menu items add_layout_menu_entry( "Reset Layout", lambda: self.load_default_layout() ) add_layout_menu_entry( "Viewport Only", "${omni.app.setup}/layouts/viewport_only.json", ) # Layout menu items for workflows workflows = self._settings.get("/exts/omni.app.setup/workflow") active_now = self._settings.get("/exts/omni.app.setup/activeWorkflowAtStartup") self._workflows = [] if workflows: for workflow in workflows: name = workflow.get("name", None) workflow_name = workflow.get("workflow", None) layout_name = workflow.get("layout", None) if name is None: carb.log_error(f"Invalid [[app.workflow]] entry for extension: {workflow}") continue self._workflows.append(workflow) add_layout_menu_entry( " ".join([n.capitalize() for n in name.split(" ")]), layout_name, workflow_name, ) if active_now: self.active_workflow(name) async def _activate_layout(self, layout: str, workflow: str): if workflow: ext_manager = omni.kit.app.get_app_interface().get_extension_manager() ext_manager.set_extension_enabled_immediate(workflow, True) if not layout: layout = self._settings.get(f"/exts/{workflow}/default_layout") if layout: await omni.kit.app.get_app().next_update_async() layout_path = carb.tokens.get_tokens_interface().resolve(layout) if layout_path: await self._load_layout(layout_path) def active_workflow(self, name: str) -> None: for workflow in self._workflows: if workflow.get("name") == name: asyncio.ensure_future(self._activate_layout(workflow.get("layout"), workflow.get("workflow"))) return else: carb.log_error(f"Cannot find workflow '{name}'!") def __config_menu_layout(self, title, info: dict, default_type="Menu"): from omni.kit.menu.utils import MenuLayout, LayoutSourceSearch def __split_title(title: str) -> Tuple[str, Optional[str], bool]: (name, source) = title.split("=") if "=" in title else (title, None) if name.startswith("-"): remove = True name = name[1:] else: remove = False return (name, source, remove) (name, source, remove) = __split_title(title) items = info.get("items", None) if info else None type = info.get("type", default_type) if info else default_type children = [] if items: for item_title in items: (item_name, item_source, _) = __split_title(item_title) item_info = info.get(item_name, None) child = self.__config_menu_layout(item_title, item_info, default_type="Item") if child: children.append(child) source_search = LayoutSourceSearch.EVERYWHERE if source else LayoutSourceSearch.LOCAL_ONLY if name == "": return MenuLayout.Seperator() elif type == "Menu": return MenuLayout.Menu(name, items=children, source=source, source_search=source_search, remove=remove) elif type == "SubMenu": return MenuLayout.SubMenu(name, items=children, source=source, source_search=source_search, remove=remove) elif type == "Item": return MenuLayout.Item(name, source=source, source_search=source_search, remove=remove) elif type == "Group": return MenuLayout.Group(name, items=children, source_search=source_search, source=source) elif type == "Sort": exclude_items = info.get("exclude_items", []) if info else [] sort_submenus = info.get("sort_submenus", False) if info else False return MenuLayout.Sort(exclude_items=exclude_items, sort_submenus=sort_submenus) else: return None def setup_menu_layout(self): menu_layouts = self._settings.get("/exts/omni.app.setup/menu_layout") if not menu_layouts: return self._layout_menu = [] for (menu_name, menu_info) in menu_layouts.items(): menu = self.__config_menu_layout(menu_name, menu_info) if menu: self._layout_menu.append(menu) omni.kit.menu.utils.add_layout(self._layout_menu) def setup_menu_order(self): menu_order_presets = self._settings.get("/exts/omni.app.setup/menu_order") if menu_order_presets: menu_self = omni.kit.menu.utils.get_instance() _, menu_order, _ = menu_self.get_menu_data() menu_order.update(menu_order_presets) menu_self.rebuild_menus()
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/extension.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import carb import omni.ext import carb.settings import omni.kit.app import asyncio from .application_setup import ApplicationSetup from .actions import register_actions, deregister_actions from .viewport_rendering import enable_viewport_rendering from .imgui_helper import setup_imgui class AppSetupExtension(omni.ext.IExt): """Create Final Configuration""" def on_startup(self, ext_id): """ setup the window layout, menu, final configuration of the extensions etc """ self.__ext_id = omni.ext.get_extension_name(ext_id) self._settings = carb.settings.get_settings() setup_editor = self._settings.get("/app/kit/editor/setup") if not setup_editor: return self._application_setup = ApplicationSetup() self._menu_layout = [] # this is a work around as some Extensions don't properly setup their default setting in time self._application_setup.set_defaults() # Force enable Axis, Grid, Outline and Lights forceEnable = self._settings.get("/app/kit/editor/forceViewportSettings") if forceEnable: self._application_setup.force_viewport_settings() # setup the application title based on settings and few rules self._application_setup.setup_application_title() # Keep windows open to make sure Welcome window could be visible at startup self._application_setup.load_default_layout(keep_windows_open=True) self._application_setup.create_trigger_menu() self._application_setup.build_layout_menu() self._application_setup.setup_menu_layout() self._application_setup.setup_menu_order() def on_app_ready(*args, **kwargs): self._app_ready_sub = None # OM-93646: setup imgui when app ready otherwise there will be crash in Linux setup_imgui() # Start background loading of renderer if requested bg_render_load = self._settings.get("/exts/omni.app.setup/backgroundRendererLoad/renderer") if not bg_render_load: return # We delay loading those so we leave time for the welcome window # and the first tab to be displayed async def __load_renderer(bg_render_load): # Get setting whether to show the renderer init progress in Viewport show_viewport_ready = self._settings.get("/exts/omni.app.setup/backgroundRendererLoad/showViewportReady") # Get setting for the number of frames to wait before starting the load initial_wait = self._settings.get("/exts/omni.app.setup/backgroundRendererLoad/initialWait") # When not set it will default to 20 if initial_wait is None: initial_wait = 20 if initial_wait: app = omni.kit.app.get_app() for _ in range(initial_wait): await app.next_update_async() # await self._application_setup.start_loading_renderer(bg_render_load) carb.log_info(f"Loading {bg_render_load} in background") show_viewport_ready = self._settings.get("/exts/omni.app.setup/backgroundRendererLoad/showViewportReady") enable_viewport_rendering(renderer=bg_render_load, show_viewport_ready=show_viewport_ready) self.__setup_window_task = asyncio.ensure_future(__load_renderer(bg_render_load)) self._app_ready_sub = omni.kit.app.get_app().get_startup_event_stream().create_subscription_to_pop_by_type( omni.kit.app.EVENT_APP_READY, on_app_ready, name="omni.app.setup.app_ready.startup" ) """ # At some points around here we will want to close the splash Images splash_interface = None try: import omni.splash splash_interface = omni.splash.acquire_splash_screen_interface() except (ImportError, ModuleNotFoundError): splash_interface = None if splash_interface: splash_interface.close_all() """ register_actions(self.__ext_id, self._application_setup) def on_shutdown(self): deregister_actions(self.__ext_id) self._app_ready_sub = None
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/__init__.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .extension import AppSetupExtension # API to setup your own application from .application_setup import ApplicationSetup
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/viewport_rendering.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # __all__ = ["enable_viewport_rendering", "start_render_loading_ui"] from typing import Optional import omni.usd _g_enabled_renderers = [] g_renderers_ready = [] def start_render_loading_ui(ext_manager: "omni.ext.ExtensionManager", renderer: str): import carb import time time_begin = time.time() # Extension to show viewport loading progress ext_manager.set_extension_enabled_immediate("omni.activity.profiler", True) ext_manager.set_extension_enabled_immediate("omni.activity.pump", True) carb.settings.get_settings().set("/exts/omni.kit.viewport.ready/startup/enabled", False) ext_manager.set_extension_enabled_immediate("omni.kit.viewport.ready", True) from omni.kit.viewport.ready.viewport_ready import ViewportReady, ViewportReadyDelegate class TimerDelegate(ViewportReadyDelegate): def __init__(self, time_begin): super().__init__() self.__timer_start = time.time() self.__vp_ready_cost = self.__timer_start - time_begin @property def font_size(self) -> float: return 48 @property def message(self) -> str: rtx_mode = { "RaytracedLighting": "Real-Time", "PathTracing": "Interactive (Path Tracing)", "LightspeedAperture": "Aperture (Game Path Tracer)" }.get(carb.settings.get_settings().get("/rtx/rendermode"), "Real-Time") renderer_label = { "rtx": f"RTX - {rtx_mode}", "iray": "RTX - Accurate (Iray)", "pxr": "Pixar Storm", "index": "RTX - Scientific (IndeX)" }.get(renderer, renderer) return f"Waiting for {renderer_label} to start" def on_complete(self): global g_renderers_ready g_renderers_ready.append(renderer) rtx_load_time = time.time() - self.__timer_start super().on_complete() carb.log_info(f"Time until pixel: {rtx_load_time}") carb.log_info(f"ViewportReady cost: {self.__vp_ready_cost}") settings = carb.settings.get_settings() if settings.get("/exts/omni.kit.welcome.window/autoSetupOnClose"): async def async_enable_all_renderers(app, renderer: str, all_renderers: str): for enabled_renderer in all_renderers.split(","): if enabled_renderer != renderer: enable_viewport_rendering(enabled_renderer, False) await app.next_update_async() import omni.kit.app import omni.kit.async_engine omni.kit.async_engine.run_coroutine(async_enable_all_renderers(omni.kit.app.get_app(), renderer, settings.get("/renderer/enabled") or "")) return ViewportReady(TimerDelegate(time_begin)) def enable_viewport_rendering(renderer: Optional[str] = None, show_viewport_ready: bool = True): import carb settings = carb.settings.get_settings() # If no renderer is specified, choose the 'active' one or what is set as active, or finally RTX - Realtime if renderer is None: renderer = (settings.get("/renderer/active") or settings.get("/exts/omni.app.setup/backgroundRendererLoad/renderer") or "rtx") # Only enable the Viewport for a renderer once, and only do Viewport Ready the first time global _g_enabled_renderers if renderer in _g_enabled_renderers: if renderer not in g_renderers_ready and show_viewport_ready: import omni.kit.app app = omni.kit.app.get_app() ext_manager = app.get_extension_manager() start_render_loading_ui(ext_manager, renderer) return elif show_viewport_ready and bool(_g_enabled_renderers): show_viewport_ready = False _g_enabled_renderers.append(renderer) settings.set("/renderer/asyncInit", True) settings.set("/rtx/hydra/mdlMaterialWarmup", True) import omni.kit.app app = omni.kit.app.get_app() ext_manager = app.get_extension_manager() ext_manager.set_extension_enabled_immediate("omni.kit.viewport.bundle", True) if renderer == "iray" or renderer == "index": ext_manager.set_extension_enabled_immediate(f"omni.hydra.rtx", True) ext_manager.set_extension_enabled_immediate(f"omni.hydra.{renderer}", True) else: ext_manager.set_extension_enabled_immediate(f"omni.kit.viewport.{renderer}", True) # we might need to have the engine_name as part of the flow ext_manager.set_extension_enabled("omni.rtx.settings.core", True) # TODO: It will block omni.kit.viewport.Ready.ViewportReady while it is enabled before this function # omni.usd.add_hydra_engine(renderer, usd_context) if show_viewport_ready: start_render_loading_ui(ext_manager, renderer)
omniverse-code/kit/exts/omni.app.setup/omni/app/setup/actions.py
from .application_setup import ApplicationSetup from .viewport_rendering import enable_viewport_rendering def register_actions(extension_id: str, application_setup: ApplicationSetup): """ Register actions. Args: extension_id (str): Extension ID which actions belongs to application_setup: Instance of application_setup """ try: import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() actions_tag = "app.setup" action_registry.register_action( extension_id, "active_workflow", lambda name: application_setup.active_workflow(name), display_name="Active workflow", description="Active workflow", tag=actions_tag, ) action_registry.register_action( extension_id, "enable_viewport_rendering", lambda: enable_viewport_rendering(), display_name="Enable viewport rendering", description="Enable viewport rendering", tag=actions_tag, ) except ImportError: pass def deregister_actions(extension_id: str): """ Deregister actions. Args: extension_id (str): Extension ID whcih actions belongs to """ try: import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action_registry.deregister_all_actions_for_extension(extension_id) except ImportError: pass
omniverse-code/kit/exts/omni.kit.search_example/PACKAGE-LICENSES/omni.kit.search_example-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.
omniverse-code/kit/exts/omni.kit.search_example/config/extension.toml
[package] # Semantic Versioning is used: https://semver.org/ version = "1.0.0" # Lists people or organizations that are considered the "authors" of the package. authors = ["NVIDIA"] # The title and description fields are primarly for displaying extension info in UI title = "Search Extension Example" description=""" The example extension adds a new search engine to the content browser. The extension is based on `omni.client` and is searching for files in the current directory. The recursive search is not implemented. """ # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # Keywords for the extension keywords = ["search", "filepicker", "content"] # Location of change log file in target (final) folder of extension, relative to the root. # More info on writing changelog: https://keepachangelog.com/en/1.0.0/ changelog="docs/CHANGELOG.md" # Preview image. Folder named "data" automatically goes in git lfs (see .gitattributes file). preview_image = "data/preview.png" # We only depend on testing framework currently: [dependencies] "omni.kit.test" = {} "omni.kit.search_core" = {} "omni.client" = {} # Main python module this extension provides, it will be publicly available as "import omni.example.hello". [[python.module]] name = "omni.kit.search_example" # Additional python module with tests, to make them discoverable by test system. [[python.module]] name = "omni.kit.search_example.tests"
omniverse-code/kit/exts/omni.kit.search_example/omni/kit/search_example/search_model.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from omni.kit.search_core import AbstractSearchItem from omni.kit.search_core import AbstractSearchModel import asyncio import carb import functools import omni.client import traceback def handle_exception(func): """ Decorator to print exception in async functions """ @functools.wraps(func) async def wrapper(*args, **kwargs): try: return await func(*args, **kwargs) except asyncio.CancelledError: pass except Exception as e: carb.log_error(f"Exception when async '{func}'") carb.log_error(f"{e}") carb.log_error(f"{traceback.format_exc()}") return wrapper class SearchItem(AbstractSearchItem): def __init__(self, dir_path, file_entry): super().__init__() self._dir_path = dir_path self._file_entry = file_entry @property def path(self): return f"{self._dir_path}/{self._file_entry.relative_path}" @property def name(self): return str(self._file_entry.relative_path) @property def date(self): # TODO: Grid View needs datatime, but Tree View needs a string. We need to make them the same. return self._file_entry.modified_time @property def size(self): # TODO: Grid View needs int, but Tree View needs a string. We need to make them the same. return self._file_entry.size @property def is_folder(self): return (self._file_entry.flags & omni.client.ItemFlags.CAN_HAVE_CHILDREN) > 0 class SearchModel(AbstractSearchModel): def __init__(self, **kwargs): super().__init__() self._search_text = kwargs.get("search_text", None) self._current_dir = kwargs.get("current_dir", None) self._search_lifetime = kwargs.get("search_lifetime", None) # omni.client doesn't understand my-computer if self._current_dir.startswith("my-computer://"): self._current_dir = self._current_dir[len("my-computer://"):] self.__list_task = asyncio.ensure_future(self.__list()) self.__items = [] def destroy(self): if not self.__list_task.done(): self.__list_task.cancel() self._search_lifetime = None @property def items(self): return self.__items @handle_exception async def __list(self): result, entries = await omni.client.list_async(self._current_dir) if result != omni.client.Result.OK: self.__items = [] else: self.__items = [ SearchItem(self._current_dir, entry) for entry in entries if self._search_text in entry.relative_path ] self._item_changed() self._search_lifetime = None
omniverse-code/kit/exts/omni.kit.search_example/omni/kit/search_example/search_extension.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .search_model import SearchModel from omni.kit.search_core import SearchEngineRegistry import omni.ext class SearchExampleExtension(omni.ext.IExt): def on_startup(self, ext_id): self._subscription = SearchEngineRegistry().register_search_model("Example Search", SearchModel) def on_shutdown(self): self._subscription = None
omniverse-code/kit/exts/omni.kit.search_example/omni/kit/search_example/__init__.py
from .search_extension import SearchExampleExtension
omniverse-code/kit/exts/omni.kit.search_example/omni/kit/search_example/tests/__init__.py
## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## from .test_search_example import TestSearchExample
omniverse-code/kit/exts/omni.kit.search_example/omni/kit/search_example/tests/test_search_example.py
## Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. ## ## NVIDIA CORPORATION and its licensors retain all intellectual property ## and proprietary rights in and to this software, related documentation ## and any modifications thereto. Any use, reproduction, disclosure or ## distribution of this software and related documentation without an express ## license agreement from NVIDIA CORPORATION is strictly prohibited. ## import omni.kit.test from pathlib import Path from omni.kit.search_core import SearchEngineRegistry from ..search_model import SearchModel from ..search_model import SearchItem import asyncio from functools import partial CURRENT_PATH = Path(__file__).parent async def _wait_model_changed_async(model: SearchModel): """Async wait when the model is changed""" def _on_item_changed(item: SearchItem, future: asyncio.Future): """Callback set the future when called""" if not future.done(): future.set_result(None) f = asyncio.Future() sub = model.subscribe_item_changed(partial(_on_item_changed, future=f)) return await f class TestSearchExample(omni.kit.test.AsyncTestCase): async def test_search(self): model_type = SearchEngineRegistry().get_search_model("Example Search") self.assertIs(model_type, SearchModel) model = model_type(search_text="test", current_dir=f"{CURRENT_PATH}") await _wait_model_changed_async(model) # In the current folder we only have the file "test_search_example.py" self.assertEqual(["test_search_example.py"], [item.name for item in model.items])
omniverse-code/kit/exts/omni.kit.search_example/docs/CHANGELOG.md
# Changelog This document records all notable changes to ``omni.kit.search_example`` extension. ## [1.0.0] - 2020-10-05 ### Added - Initial example implementation of search using omni.client
omniverse-code/kit/exts/omni.kit.search_example/docs/README.md
# omni.kit.search_example ## Python Search Extension Example The example extension adds a new search engine to the content browser. The extension is based on `omni.client` and is searching for files in the current directory. The recursive search is not implemented.
omniverse-code/kit/exts/omni.kit.tool.collect/PACKAGE-LICENSES/omni.kit.tool.collect-LICENSE.md
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary rights in and to this software, related documentation and any modifications thereto. Any use, reproduction, disclosure or distribution of this software and related documentation without an express license agreement from NVIDIA CORPORATION is strictly prohibited.