file_path
stringlengths
32
153
content
stringlengths
0
3.14M
omniverse-code/kit/exts/omni.graph.io/ogn/docs/OgnBundleToUSDA.rst
.. _omni_graph_BundleToUSDA_1: .. _omni_graph_BundleToUSDA: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Bundle to usda text :keywords: lang-en omnigraph node threadsafe graph bundle-to-u-s-d-a Bundle to usda text =================== .. <description> Outputs a represention of the content of a bundle as usda text .. </description> Installation ------------ To use this node enable :ref:`omni.graph.io<ext_omni_graph_io>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:bundle", "``bundle``", "The bundle to convert to usda text.", "None" "inputs:outputAncestors", "``bool``", "If usePath is true and this is also true, ancestor ""primPath"" entries will be output.", "False" "", "*displayGroup*", "parameters", "" "inputs:outputValues", "``bool``", "If true, the values of attributes will be output, else values will be omitted.", "True" "", "*displayGroup*", "parameters", "" "inputs:usePrimPath", "``bool``", "Use the attribute named ""primPath"" for the usda prim path.", "True" "", "*displayGroup*", "parameters", "" "inputs:usePrimType", "``bool``", "Use the attribute named ""primType"" for the usda prim type name.", "True" "", "*displayGroup*", "parameters", "" "inputs:usePrimvarMetadata", "``bool``", "Identify attributes representing metadata like the interpolation type for primvars, and include them as usda metadata in the output text.", "True" "", "*displayGroup*", "parameters", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:text", "``token``", "Output usda text representing the bundle contents.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.BundleToUSDA" "Version", "1" "Extension", "omni.graph.io" "Icon", "ogn/icons/omni.graph.BundleToUSDA.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Bundle to usda text" "Generated Class Name", "OgnBundleToUSDADatabase" "Python Module", "omni.graph.io"
omniverse-code/kit/exts/omni.graph.io/ogn/docs/OgnExportUSDPrim.rst
.. _omni_graph_ExportUSDPrim_1: .. _omni_graph_ExportUSDPrim: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: export USD prim data :keywords: lang-en omnigraph node WriteOnly graph export-u-s-d-prim export USD prim data ==================== .. <description> Exports data from an input bundle into a USD prim .. </description> Installation ------------ To use this node enable :ref:`omni.graph.io<ext_omni_graph_io>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:applyTransform", "``bool``", "If true, apply the transform necessary to transform any transforming attributes from the space of the node into the space of the specified prim.", "False" "", "*displayGroup*", "parameters", "" "Attributes To Export (*inputs:attrNamesToExport*)", "``token``", "Comma or space separated text, listing the names of attributes in the input data to be exported or empty to import all attributes.", "" "", "*displayGroup*", "parameters", "" "inputs:bundle", "``bundle``", "The bundle from which data should be exported.", "None" "Attributes To Exclude (*inputs:excludedAttrNames*)", "``token``", "Attributes to be excluded from being exported", "" "Export to Root Layer (*inputs:exportToRootLayer*)", "``bool``", "If true, prims are exported in the root layer, otherwise the layer specified by ""layerName"" is used.", "True" "Attributes To Rename (*inputs:inputAttrNames*)", "``token``", "Comma or space separated text, listing the names of attributes in the input data to be renamed", "" "Layer Name (*inputs:layerName*)", "``token``", "Identifier of the layer to export to if ""exportToRootLayer"" is false, or leave this blank to export to the session layer", "" "inputs:onlyExportToExisting", "``bool``", "If true, only attributes that already exist in the specified output prim will have data transferred to them from the input bundle.", "False" "", "*displayGroup*", "parameters", "" "New Attribute Names (*inputs:outputAttrNames*)", "``token``", "Comma or space separated text, listing the new names for the attributes listed in inputAttrNames", "" "inputs:primPathFromBundle", "``bool``", "When true, if there is a ""primPath"" token attribute inside the bundle, that will be the path of the USD prim to write to, else the ""outputs:prim"" attribute below will be used for the USD prim path.", "False" "", "*displayGroup*", "parameters", "" "Export to Root Layer (*inputs:removeMissingAttrs*)", "``bool``", "If true, any attributes on the USD prim(s) being written to, that aren't in the input data, will be removed from the USD prim(s).", "False" "inputs:renameAttributes", "``bool``", "If true, attributes listed in ""inputAttrNames"" will be exported to attributes with the names specified in ""outputAttrNames"". Note: to avoid potential issues with redundant attributes being created while typing, keep this off until after specifying all input and output attribute names.", "False" "", "*displayGroup*", "parameters", "" "inputs:timeVaryingAttributes", "``bool``", "Check whether the USD attributes should be time-varying and if so, export their data to a time sample at the time ""usdTimecode"".", "False" "", "*displayGroup*", "parameters", "" "inputs:usdTimecode", "``double``", "The time at which to evaluate the transform of the USD prim for applyTransform.", "0" "", "*displayGroup*", "parameters", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:prim", "``bundle``", "The USD prim(s) to which data should be exported if primPathFromBundle is false or if the bundle doesn't have a ""primPath"" token attribute. Note: this is really an input, since the node just receives the path to the prim. The node does not contain the prim.", "None" "", "*hidden*", "true", "" State ----- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "state:prevApplyTransform", "``bool``", "Value of ""applyTransform"" input from previous run", "None" "state:prevAttrNamesToExport", "``token``", "Value of ""attrNamesToExport"" input from previous run", "None" "state:prevBundleDirtyID", "``uint64``", "Dirty ID of input bundle from previous run", "None" "state:prevExcludedAttrNames", "``token``", "Value of ""excludedAttrNames"" input from previous run", "None" "state:prevExportToRootLayer", "``bool``", "Value of ""exportToRootLayer"" input from previous run", "None" "state:prevInputAttrNames", "``token``", "Value of ""inputAttrNames"" input from previous run", "None" "state:prevLayerName", "``token``", "Value of ""layerName"" input from previous run", "None" "state:prevOnlyExportToExisting", "``bool``", "Value of ""onlyExportToExisting"" input from previous run", "None" "state:prevOutputAttrNames", "``token``", "Value of ""outputAttrNames"" input from previous run", "None" "state:prevPrimDirtyIDs", "``uint64[]``", "Dirty IDs of input prims from previous run", "None" "state:prevPrimPathFromBundle", "``bool``", "Value of ""primPathFromBundle"" input from previous run", "None" "state:prevRemoveMissingAttrs", "``bool``", "Value of ""removeMissingAttrs"" input from previous run", "None" "state:prevRenameAttributes", "``bool``", "Value of ""renameAttributes"" input from previous run", "None" "state:prevTimeVaryingAttributes", "``bool``", "Value of ""timeVaryingAttributes"" input from previous run", "None" "state:prevUsdTimecode", "``double``", "Value of ""usdTimecode"" input from previous run", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ExportUSDPrim" "Version", "1" "Extension", "omni.graph.io" "Icon", "ogn/icons/omni.graph.ExportUSDPrim.svg" "Has State?", "True" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "export USD prim data" "__tokens", "{""primPath"": ""primPath"", ""primType"": ""primType"", ""primTime"": ""primTime"", ""primCount"": ""primCount"", ""transform"": ""transform""}" "Generated Class Name", "OgnExportUSDPrimDatabase" "Python Module", "omni.graph.io"
omniverse-code/kit/exts/omni.graph.io/PACKAGE-LICENSES/omni.graph.io-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.graph.io/config/extension.toml
[package] # Semantic Versioning is used: https://semver.org/ version = "1.2.5" # Lists people or organizations that are considered the "authors" of the package. authors = ["NVIDIA"] # The title and description fields are primarily for displaying extension info in UI title = "OmniGraph IO" description="Input/output node types for OmniGraph" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Graph" # Keywords for the extension keywords = ["graph, input, output, io"] # Location of change log file in target (final) folder of extension, relative to the root. Can also be just a content # of it instead of file path. More info on writing changelog: https://keepachangelog.com/en/1.0.0/ changelog="docs/CHANGELOG.md" # Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file). # Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image. preview_image = "data/preview.png" # Icon is shown in Extensions window, it is recommended to be square, of size 256x256. icon = "data/icon.png" # Main module for the Python interface [[python.module]] name = "omni.graph.io" # Additional module used to make .ogn test files auto-discoverable [[python.module]] name = "omni.graph.io.ogn.tests" # Watch the .ogn files for hot reloading (only works for Python files) [fswatcher.patterns] include = ["*.ogn", "*.py"] exclude = ["Ogn*Database.py"] # Extensions required to load before this one [dependencies] "omni.graph" = {} "omni.graph.ui" = {optional = true} "omni.usd" = {} [[native.plugin]] path = "bin/*.plugin" recursive = false [[test]] # RTX regression OM-51983 timeout = 600 dependencies = [ "omni.graph.ui" #force load dependency to test the functionality ] [documentation] pages = [ "docs/Overview.md", "docs/CHANGELOG.md", ]
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/__init__.py
"""There is no public API to this module.""" __all__ = []
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/OgnBundleToUSDADatabase.py
"""Support for simplified access to data on nodes of type omni.graph.BundleToUSDA Outputs a represention of the content of a bundle as usda text """ import carb import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnBundleToUSDADatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.BundleToUSDA Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.bundle inputs.outputAncestors inputs.outputValues inputs.usePrimPath inputs.usePrimType inputs.usePrimvarMetadata Outputs: outputs.text """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:bundle', 'bundle', 0, None, 'The bundle to convert to usda text.', {}, True, None, False, ''), ('inputs:outputAncestors', 'bool', 0, None, 'If usePath is true and this is also true, ancestor "primPath" entries will be output.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:outputValues', 'bool', 0, None, 'If true, the values of attributes will be output, else values will be omitted.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usePrimPath', 'bool', 0, None, 'Use the attribute named "primPath" for the usda prim path.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usePrimType', 'bool', 0, None, 'Use the attribute named "primType" for the usda prim type name.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usePrimvarMetadata', 'bool', 0, None, 'Identify attributes representing metadata like the interpolation type for primvars, and include them as usda metadata in the output text.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('outputs:text', 'token', 0, None, 'Output usda text representing the bundle contents.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.bundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.bundle""" return self.__bundles.bundle @property def outputAncestors(self): data_view = og.AttributeValueHelper(self._attributes.outputAncestors) return data_view.get() @outputAncestors.setter def outputAncestors(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.outputAncestors) data_view = og.AttributeValueHelper(self._attributes.outputAncestors) data_view.set(value) @property def outputValues(self): data_view = og.AttributeValueHelper(self._attributes.outputValues) return data_view.get() @outputValues.setter def outputValues(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.outputValues) data_view = og.AttributeValueHelper(self._attributes.outputValues) data_view.set(value) @property def usePrimPath(self): data_view = og.AttributeValueHelper(self._attributes.usePrimPath) return data_view.get() @usePrimPath.setter def usePrimPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePrimPath) data_view = og.AttributeValueHelper(self._attributes.usePrimPath) data_view.set(value) @property def usePrimType(self): data_view = og.AttributeValueHelper(self._attributes.usePrimType) return data_view.get() @usePrimType.setter def usePrimType(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePrimType) data_view = og.AttributeValueHelper(self._attributes.usePrimType) data_view.set(value) @property def usePrimvarMetadata(self): data_view = og.AttributeValueHelper(self._attributes.usePrimvarMetadata) return data_view.get() @usePrimvarMetadata.setter def usePrimvarMetadata(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePrimvarMetadata) data_view = og.AttributeValueHelper(self._attributes.usePrimvarMetadata) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def text(self): data_view = og.AttributeValueHelper(self._attributes.text) return data_view.get() @text.setter def text(self, value): data_view = og.AttributeValueHelper(self._attributes.text) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnBundleToUSDADatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnBundleToUSDADatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnBundleToUSDADatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/OgnTransformBundleDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.TransformBundle Applies a transform to an input bundle, storing the result in an output bundle """ import carb import numpy import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTransformBundleDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.TransformBundle Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.input inputs.transform Outputs: outputs.output """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:input', 'bundle', 0, None, 'Input bundle containing the attributes to be transformed.', {}, True, None, False, ''), ('inputs:transform', 'matrix4d', 0, None, 'The transform to apply to the bundle', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: '[[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]'}, True, [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], False, ''), ('outputs:output', 'bundle', 0, None, 'Output bundle containing all of the transformed attributes', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.input = og.AttributeRole.BUNDLE role_data.inputs.transform = og.AttributeRole.MATRIX role_data.outputs.output = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def input(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.input""" return self.__bundles.input @property def transform(self): data_view = og.AttributeValueHelper(self._attributes.transform) return data_view.get() @transform.setter def transform(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.transform) data_view = og.AttributeValueHelper(self._attributes.transform) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def output(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.output""" return self.__bundles.output @output.setter def output(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.output with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.output.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTransformBundleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTransformBundleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTransformBundleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/OgnImportUSDPrimDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ImportUSDPrim Imports data from a USD prim into attributes in an output bundle """ import carb import numpy import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnImportUSDPrimDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ImportUSDPrim Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.applySkelBinding inputs.applyTransform inputs.attrNamesToImport inputs.computeBoundingBox inputs.importAttributes inputs.importPath inputs.importPrimvarMetadata inputs.importTime inputs.importTransform inputs.importType inputs.inputAttrNames inputs.keepPrimsSeparate inputs.outputAttrNames inputs.prim inputs.renameAttributes inputs.timeVaryingAttributes inputs.usdTimecode Outputs: outputs.output State: state.prevApplySkelBinding state.prevApplyTransform state.prevAttrNamesToImport state.prevComputeBoundingBox state.prevImportAttributes state.prevImportPath state.prevImportPrimvarMetadata state.prevImportTime state.prevImportTransform state.prevImportType state.prevInputAttrNames state.prevInvNodeTransform state.prevKeepPrimsSeparate state.prevOnlyImportSpecified state.prevOutputAttrNames state.prevPaths state.prevRenameAttributes state.prevTimeVaryingAttributes state.prevTransforms state.prevUsdTimecode """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:applySkelBinding', 'bool', 0, None, 'If the input USD prim is a Mesh, and has SkelBindingAPI schema applied, compute skinned points and normals.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:applyTransform', 'bool', 0, None, 'If importAttributes is true, apply the transform necessary to transform any transforming attributes into the space of this node.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:attrNamesToImport', 'token', 0, 'Attributes To Import', 'Comma or space separated text, listing the names of attributes in the input data to be imported \nor empty to import all attributes.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:computeBoundingBox', 'bool', 0, None, 'Compute and store local bounding box of a prim and its children.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:importAttributes', 'bool', 0, None, 'Import attribute data from the USD prim.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:importPath', 'bool', 0, None, 'Record the input USD prim\'s path into the output bundle in an attribute named "primPath".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:importPrimvarMetadata', 'bool', 0, None, 'Import metadata like the interpolation type for primvars, and store it as attributes in the output bundle.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:importTime', 'bool', 0, None, 'Record the usdTimecode above into the output bundle in an attribute named "primTime".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:importTransform', 'bool', 0, None, 'Record the transform required to take any attributes of the input USD prim \ninto the space of this node, i.e. the world transform of the input prim times the \ninverse world transform of this node, into the output bundle in an attribute named "transform".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:importType', 'bool', 0, None, 'Deprecated, prim type is always imported', {ogn.MetadataKeys.HIDDEN: 'true', 'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:inputAttrNames', 'token', 0, 'Attributes To Rename', 'Comma or space separated text, listing the names of attributes in the input data to be renamed', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:keepPrimsSeparate', 'bool', 0, None, 'Prefix output attribute names with "prim" followed by a unique number and a colon, \nto keep the attributes for separate input prims separate. The prim paths will \nbe in the "primPaths" token array attribute.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:outputAttrNames', 'token', 0, 'New Attribute Names', 'Comma or space separated text, listing the new names for the attributes listed in inputAttrNames', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:prim', 'bundle', 0, None, 'The USD prim from which to import data.', {}, False, None, False, ''), ('inputs:renameAttributes', 'bool', 0, None, 'If true, attributes listed in "inputAttrNames" will be imported to attributes with the names specified in "outputAttrNames".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:timeVaryingAttributes', 'bool', 0, None, 'Check whether the USD attributes are time-varying and if so, import their data at the time "usdTimecode".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usdTimecode', 'double', 0, None, 'The time at which to evaluate the transform of the USD prim.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:output', 'bundle', 0, None, 'Output bundle containing all of the imported data.', {}, True, None, False, ''), ('state:prevApplySkelBinding', 'bool', 0, None, 'Value of "applySkelBinding" input from previous run', {}, True, None, False, ''), ('state:prevApplyTransform', 'bool', 0, None, 'Value of "applyTransform" input from previous run', {}, True, None, False, ''), ('state:prevAttrNamesToImport', 'token', 0, None, 'Value of "attrNamesToImport" input from previous run', {}, True, None, False, ''), ('state:prevComputeBoundingBox', 'bool', 0, None, 'Value of "computeBoundingBox" input from previous run', {}, True, None, False, ''), ('state:prevImportAttributes', 'bool', 0, None, 'Value of "importAttributes" input from previous run', {}, True, None, False, ''), ('state:prevImportPath', 'bool', 0, None, 'Value of "importPath" input from previous run', {}, True, None, False, ''), ('state:prevImportPrimvarMetadata', 'bool', 0, None, 'Value of "importPrimvarMetadata" input from previous run', {}, True, None, False, ''), ('state:prevImportTime', 'bool', 0, None, 'Value of "importTime" input from previous run', {}, True, None, False, ''), ('state:prevImportTransform', 'bool', 0, None, 'Value of "importTransform" input from previous run', {}, True, None, False, ''), ('state:prevImportType', 'bool', 0, None, 'Value of "importType" input from previous run', {}, True, None, False, ''), ('state:prevInputAttrNames', 'token', 0, None, 'Value of "inputAttrNames" input from previous run', {}, True, None, False, ''), ('state:prevInvNodeTransform', 'matrix4d', 0, None, 'Inverse transform of the node prim from the previous run.', {}, True, None, False, ''), ('state:prevKeepPrimsSeparate', 'bool', 0, None, 'Value of "keepPrimsSeparate" input from previous run', {}, True, None, False, ''), ('state:prevOnlyImportSpecified', 'bool', 0, None, 'Value of "onlyImportSpecified" input from previous run', {}, True, None, False, ''), ('state:prevOutputAttrNames', 'token', 0, None, 'Value of "outputAttrNames" input from previous run', {}, True, None, False, ''), ('state:prevPaths', 'token[]', 0, None, 'Array of paths from the previous run.', {}, True, None, False, ''), ('state:prevRenameAttributes', 'bool', 0, None, 'Value of "renameAttributes" input from previous run', {}, True, None, False, ''), ('state:prevTimeVaryingAttributes', 'bool', 0, None, 'Value of "timeVaryingAttributes" input from previous run', {}, True, None, False, ''), ('state:prevTransforms', 'matrix4d[]', 0, None, 'Array of transforms from the previous run.', {}, True, None, False, ''), ('state:prevUsdTimecode', 'double', 0, None, 'Value of "usdTimecode" input from previous run', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.prim = og.AttributeRole.BUNDLE role_data.outputs.output = og.AttributeRole.BUNDLE role_data.state.prevInvNodeTransform = og.AttributeRole.MATRIX role_data.state.prevTransforms = og.AttributeRole.MATRIX return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def applySkelBinding(self): data_view = og.AttributeValueHelper(self._attributes.applySkelBinding) return data_view.get() @applySkelBinding.setter def applySkelBinding(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.applySkelBinding) data_view = og.AttributeValueHelper(self._attributes.applySkelBinding) data_view.set(value) @property def applyTransform(self): data_view = og.AttributeValueHelper(self._attributes.applyTransform) return data_view.get() @applyTransform.setter def applyTransform(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.applyTransform) data_view = og.AttributeValueHelper(self._attributes.applyTransform) data_view.set(value) @property def attrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) return data_view.get() @attrNamesToImport.setter def attrNamesToImport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrNamesToImport) data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) data_view.set(value) @property def computeBoundingBox(self): data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) return data_view.get() @computeBoundingBox.setter def computeBoundingBox(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.computeBoundingBox) data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) data_view.set(value) @property def importAttributes(self): data_view = og.AttributeValueHelper(self._attributes.importAttributes) return data_view.get() @importAttributes.setter def importAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importAttributes) data_view = og.AttributeValueHelper(self._attributes.importAttributes) data_view.set(value) @property def importPath(self): data_view = og.AttributeValueHelper(self._attributes.importPath) return data_view.get() @importPath.setter def importPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importPath) data_view = og.AttributeValueHelper(self._attributes.importPath) data_view.set(value) @property def importPrimvarMetadata(self): data_view = og.AttributeValueHelper(self._attributes.importPrimvarMetadata) return data_view.get() @importPrimvarMetadata.setter def importPrimvarMetadata(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importPrimvarMetadata) data_view = og.AttributeValueHelper(self._attributes.importPrimvarMetadata) data_view.set(value) @property def importTime(self): data_view = og.AttributeValueHelper(self._attributes.importTime) return data_view.get() @importTime.setter def importTime(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importTime) data_view = og.AttributeValueHelper(self._attributes.importTime) data_view.set(value) @property def importTransform(self): data_view = og.AttributeValueHelper(self._attributes.importTransform) return data_view.get() @importTransform.setter def importTransform(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importTransform) data_view = og.AttributeValueHelper(self._attributes.importTransform) data_view.set(value) @property def importType(self): data_view = og.AttributeValueHelper(self._attributes.importType) return data_view.get() @importType.setter def importType(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.importType) data_view = og.AttributeValueHelper(self._attributes.importType) data_view.set(value) @property def inputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) return data_view.get() @inputAttrNames.setter def inputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.inputAttrNames) data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) data_view.set(value) @property def keepPrimsSeparate(self): data_view = og.AttributeValueHelper(self._attributes.keepPrimsSeparate) return data_view.get() @keepPrimsSeparate.setter def keepPrimsSeparate(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.keepPrimsSeparate) data_view = og.AttributeValueHelper(self._attributes.keepPrimsSeparate) data_view.set(value) @property def outputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) return data_view.get() @outputAttrNames.setter def outputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.outputAttrNames) data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) data_view.set(value) @property def prim(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.prim""" return self.__bundles.prim @property def renameAttributes(self): data_view = og.AttributeValueHelper(self._attributes.renameAttributes) return data_view.get() @renameAttributes.setter def renameAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.renameAttributes) data_view = og.AttributeValueHelper(self._attributes.renameAttributes) data_view.set(value) @property def timeVaryingAttributes(self): data_view = og.AttributeValueHelper(self._attributes.timeVaryingAttributes) return data_view.get() @timeVaryingAttributes.setter def timeVaryingAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.timeVaryingAttributes) data_view = og.AttributeValueHelper(self._attributes.timeVaryingAttributes) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdTimecode) data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def output(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.output""" return self.__bundles.output @output.setter def output(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.output with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.output.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.prevPaths_size = None self.prevTransforms_size = None @property def prevApplySkelBinding(self): data_view = og.AttributeValueHelper(self._attributes.prevApplySkelBinding) return data_view.get() @prevApplySkelBinding.setter def prevApplySkelBinding(self, value): data_view = og.AttributeValueHelper(self._attributes.prevApplySkelBinding) data_view.set(value) @property def prevApplyTransform(self): data_view = og.AttributeValueHelper(self._attributes.prevApplyTransform) return data_view.get() @prevApplyTransform.setter def prevApplyTransform(self, value): data_view = og.AttributeValueHelper(self._attributes.prevApplyTransform) data_view.set(value) @property def prevAttrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.prevAttrNamesToImport) return data_view.get() @prevAttrNamesToImport.setter def prevAttrNamesToImport(self, value): data_view = og.AttributeValueHelper(self._attributes.prevAttrNamesToImport) data_view.set(value) @property def prevComputeBoundingBox(self): data_view = og.AttributeValueHelper(self._attributes.prevComputeBoundingBox) return data_view.get() @prevComputeBoundingBox.setter def prevComputeBoundingBox(self, value): data_view = og.AttributeValueHelper(self._attributes.prevComputeBoundingBox) data_view.set(value) @property def prevImportAttributes(self): data_view = og.AttributeValueHelper(self._attributes.prevImportAttributes) return data_view.get() @prevImportAttributes.setter def prevImportAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportAttributes) data_view.set(value) @property def prevImportPath(self): data_view = og.AttributeValueHelper(self._attributes.prevImportPath) return data_view.get() @prevImportPath.setter def prevImportPath(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportPath) data_view.set(value) @property def prevImportPrimvarMetadata(self): data_view = og.AttributeValueHelper(self._attributes.prevImportPrimvarMetadata) return data_view.get() @prevImportPrimvarMetadata.setter def prevImportPrimvarMetadata(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportPrimvarMetadata) data_view.set(value) @property def prevImportTime(self): data_view = og.AttributeValueHelper(self._attributes.prevImportTime) return data_view.get() @prevImportTime.setter def prevImportTime(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportTime) data_view.set(value) @property def prevImportTransform(self): data_view = og.AttributeValueHelper(self._attributes.prevImportTransform) return data_view.get() @prevImportTransform.setter def prevImportTransform(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportTransform) data_view.set(value) @property def prevImportType(self): data_view = og.AttributeValueHelper(self._attributes.prevImportType) return data_view.get() @prevImportType.setter def prevImportType(self, value): data_view = og.AttributeValueHelper(self._attributes.prevImportType) data_view.set(value) @property def prevInputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.prevInputAttrNames) return data_view.get() @prevInputAttrNames.setter def prevInputAttrNames(self, value): data_view = og.AttributeValueHelper(self._attributes.prevInputAttrNames) data_view.set(value) @property def prevInvNodeTransform(self): data_view = og.AttributeValueHelper(self._attributes.prevInvNodeTransform) return data_view.get() @prevInvNodeTransform.setter def prevInvNodeTransform(self, value): data_view = og.AttributeValueHelper(self._attributes.prevInvNodeTransform) data_view.set(value) @property def prevKeepPrimsSeparate(self): data_view = og.AttributeValueHelper(self._attributes.prevKeepPrimsSeparate) return data_view.get() @prevKeepPrimsSeparate.setter def prevKeepPrimsSeparate(self, value): data_view = og.AttributeValueHelper(self._attributes.prevKeepPrimsSeparate) data_view.set(value) @property def prevOnlyImportSpecified(self): data_view = og.AttributeValueHelper(self._attributes.prevOnlyImportSpecified) return data_view.get() @prevOnlyImportSpecified.setter def prevOnlyImportSpecified(self, value): data_view = og.AttributeValueHelper(self._attributes.prevOnlyImportSpecified) data_view.set(value) @property def prevOutputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.prevOutputAttrNames) return data_view.get() @prevOutputAttrNames.setter def prevOutputAttrNames(self, value): data_view = og.AttributeValueHelper(self._attributes.prevOutputAttrNames) data_view.set(value) @property def prevPaths(self): data_view = og.AttributeValueHelper(self._attributes.prevPaths) self.prevPaths_size = data_view.get_array_size() return data_view.get() @prevPaths.setter def prevPaths(self, value): data_view = og.AttributeValueHelper(self._attributes.prevPaths) data_view.set(value) self.prevPaths_size = data_view.get_array_size() @property def prevRenameAttributes(self): data_view = og.AttributeValueHelper(self._attributes.prevRenameAttributes) return data_view.get() @prevRenameAttributes.setter def prevRenameAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.prevRenameAttributes) data_view.set(value) @property def prevTimeVaryingAttributes(self): data_view = og.AttributeValueHelper(self._attributes.prevTimeVaryingAttributes) return data_view.get() @prevTimeVaryingAttributes.setter def prevTimeVaryingAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.prevTimeVaryingAttributes) data_view.set(value) @property def prevTransforms(self): data_view = og.AttributeValueHelper(self._attributes.prevTransforms) self.prevTransforms_size = data_view.get_array_size() return data_view.get() @prevTransforms.setter def prevTransforms(self, value): data_view = og.AttributeValueHelper(self._attributes.prevTransforms) data_view.set(value) self.prevTransforms_size = data_view.get_array_size() @property def prevUsdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.prevUsdTimecode) return data_view.get() @prevUsdTimecode.setter def prevUsdTimecode(self, value): data_view = og.AttributeValueHelper(self._attributes.prevUsdTimecode) data_view.set(value) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnImportUSDPrimDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnImportUSDPrimDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnImportUSDPrimDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/OgnExportUSDPrimDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ExportUSDPrim Exports data from an input bundle into a USD prim """ import carb import numpy import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnExportUSDPrimDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ExportUSDPrim Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.applyTransform inputs.attrNamesToExport inputs.bundle inputs.excludedAttrNames inputs.exportToRootLayer inputs.inputAttrNames inputs.layerName inputs.onlyExportToExisting inputs.outputAttrNames inputs.primPathFromBundle inputs.removeMissingAttrs inputs.renameAttributes inputs.timeVaryingAttributes inputs.usdTimecode Outputs: outputs.prim State: state.prevApplyTransform state.prevAttrNamesToExport state.prevBundleDirtyID state.prevExcludedAttrNames state.prevExportToRootLayer state.prevInputAttrNames state.prevLayerName state.prevOnlyExportToExisting state.prevOutputAttrNames state.prevPrimDirtyIDs state.prevPrimPathFromBundle state.prevRemoveMissingAttrs state.prevRenameAttributes state.prevTimeVaryingAttributes state.prevUsdTimecode Predefined Tokens: tokens.primPath tokens.primType tokens.primTime tokens.primCount tokens.transform """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:applyTransform', 'bool', 0, None, 'If true, apply the transform necessary to transform any transforming attributes from the space of the node into the space of the specified prim.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:attrNamesToExport', 'token', 0, 'Attributes To Export', 'Comma or space separated text, listing the names of attributes in the input data to be exported \nor empty to import all attributes.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:bundle', 'bundle', 0, None, 'The bundle from which data should be exported.', {}, True, None, False, ''), ('inputs:excludedAttrNames', 'token', 0, 'Attributes To Exclude', 'Attributes to be excluded from being exported', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:exportToRootLayer', 'bool', 0, 'Export to Root Layer', 'If true, prims are exported in the root layer, otherwise the layer specified by "layerName" is used.', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:inputAttrNames', 'token', 0, 'Attributes To Rename', 'Comma or space separated text, listing the names of attributes in the input data to be renamed', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:layerName', 'token', 0, 'Layer Name', 'Identifier of the layer to export to if "exportToRootLayer" is false, or leave this blank to export to the session layer', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:onlyExportToExisting', 'bool', 0, None, 'If true, only attributes that already exist in the specified output prim will have data transferred to them from the input bundle.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:outputAttrNames', 'token', 0, 'New Attribute Names', 'Comma or space separated text, listing the new names for the attributes listed in inputAttrNames', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:primPathFromBundle', 'bool', 0, None, 'When true, if there is a "primPath" token attribute inside the bundle, that will be the path of the USD prim to write to, \nelse the "outputs:prim" attribute below will be used for the USD prim path.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:removeMissingAttrs', 'bool', 0, 'Export to Root Layer', "If true, any attributes on the USD prim(s) being written to, that aren't in the input data, \nwill be removed from the USD prim(s).", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:renameAttributes', 'bool', 0, None, 'If true, attributes listed in "inputAttrNames" will be exported to attributes with the names specified in "outputAttrNames". \nNote: to avoid potential issues with redundant attributes being created while typing, keep this off until after \nspecifying all input and output attribute names.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:timeVaryingAttributes', 'bool', 0, None, 'Check whether the USD attributes should be time-varying and if so, export their data to a time sample at the time "usdTimecode".', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:usdTimecode', 'double', 0, None, 'The time at which to evaluate the transform of the USD prim for applyTransform.', {'displayGroup': 'parameters', ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:prim', 'bundle', 0, None, 'The USD prim(s) to which data should be exported if primPathFromBundle is false or if the bundle doesn\'t have a "primPath" token attribute. \nNote: this is really an input, since the node just receives the path to the prim. The node does not contain the prim.', {ogn.MetadataKeys.HIDDEN: 'true'}, False, None, False, ''), ('state:prevApplyTransform', 'bool', 0, None, 'Value of "applyTransform" input from previous run', {}, True, None, False, ''), ('state:prevAttrNamesToExport', 'token', 0, None, 'Value of "attrNamesToExport" input from previous run', {}, True, None, False, ''), ('state:prevBundleDirtyID', 'uint64', 0, None, 'Dirty ID of input bundle from previous run', {}, True, None, False, ''), ('state:prevExcludedAttrNames', 'token', 0, None, 'Value of "excludedAttrNames" input from previous run', {}, True, None, False, ''), ('state:prevExportToRootLayer', 'bool', 0, None, 'Value of "exportToRootLayer" input from previous run', {}, True, None, False, ''), ('state:prevInputAttrNames', 'token', 0, None, 'Value of "inputAttrNames" input from previous run', {}, True, None, False, ''), ('state:prevLayerName', 'token', 0, None, 'Value of "layerName" input from previous run', {}, True, None, False, ''), ('state:prevOnlyExportToExisting', 'bool', 0, None, 'Value of "onlyExportToExisting" input from previous run', {}, True, None, False, ''), ('state:prevOutputAttrNames', 'token', 0, None, 'Value of "outputAttrNames" input from previous run', {}, True, None, False, ''), ('state:prevPrimDirtyIDs', 'uint64[]', 0, None, 'Dirty IDs of input prims from previous run', {}, True, None, False, ''), ('state:prevPrimPathFromBundle', 'bool', 0, None, 'Value of "primPathFromBundle" input from previous run', {}, True, None, False, ''), ('state:prevRemoveMissingAttrs', 'bool', 0, None, 'Value of "removeMissingAttrs" input from previous run', {}, True, None, False, ''), ('state:prevRenameAttributes', 'bool', 0, None, 'Value of "renameAttributes" input from previous run', {}, True, None, False, ''), ('state:prevTimeVaryingAttributes', 'bool', 0, None, 'Value of "timeVaryingAttributes" input from previous run', {}, True, None, False, ''), ('state:prevUsdTimecode', 'double', 0, None, 'Value of "usdTimecode" input from previous run', {}, True, None, False, ''), ]) class tokens: primPath = "primPath" primType = "primType" primTime = "primTime" primCount = "primCount" transform = "transform" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.bundle = og.AttributeRole.BUNDLE role_data.outputs.prim = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def applyTransform(self): data_view = og.AttributeValueHelper(self._attributes.applyTransform) return data_view.get() @applyTransform.setter def applyTransform(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.applyTransform) data_view = og.AttributeValueHelper(self._attributes.applyTransform) data_view.set(value) @property def attrNamesToExport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) return data_view.get() @attrNamesToExport.setter def attrNamesToExport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrNamesToExport) data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) data_view.set(value) @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.bundle""" return self.__bundles.bundle @property def excludedAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.excludedAttrNames) return data_view.get() @excludedAttrNames.setter def excludedAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.excludedAttrNames) data_view = og.AttributeValueHelper(self._attributes.excludedAttrNames) data_view.set(value) @property def exportToRootLayer(self): data_view = og.AttributeValueHelper(self._attributes.exportToRootLayer) return data_view.get() @exportToRootLayer.setter def exportToRootLayer(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.exportToRootLayer) data_view = og.AttributeValueHelper(self._attributes.exportToRootLayer) data_view.set(value) @property def inputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) return data_view.get() @inputAttrNames.setter def inputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.inputAttrNames) data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) data_view.set(value) @property def layerName(self): data_view = og.AttributeValueHelper(self._attributes.layerName) return data_view.get() @layerName.setter def layerName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.layerName) data_view = og.AttributeValueHelper(self._attributes.layerName) data_view.set(value) @property def onlyExportToExisting(self): data_view = og.AttributeValueHelper(self._attributes.onlyExportToExisting) return data_view.get() @onlyExportToExisting.setter def onlyExportToExisting(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyExportToExisting) data_view = og.AttributeValueHelper(self._attributes.onlyExportToExisting) data_view.set(value) @property def outputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) return data_view.get() @outputAttrNames.setter def outputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.outputAttrNames) data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) data_view.set(value) @property def primPathFromBundle(self): data_view = og.AttributeValueHelper(self._attributes.primPathFromBundle) return data_view.get() @primPathFromBundle.setter def primPathFromBundle(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPathFromBundle) data_view = og.AttributeValueHelper(self._attributes.primPathFromBundle) data_view.set(value) @property def removeMissingAttrs(self): data_view = og.AttributeValueHelper(self._attributes.removeMissingAttrs) return data_view.get() @removeMissingAttrs.setter def removeMissingAttrs(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.removeMissingAttrs) data_view = og.AttributeValueHelper(self._attributes.removeMissingAttrs) data_view.set(value) @property def renameAttributes(self): data_view = og.AttributeValueHelper(self._attributes.renameAttributes) return data_view.get() @renameAttributes.setter def renameAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.renameAttributes) data_view = og.AttributeValueHelper(self._attributes.renameAttributes) data_view.set(value) @property def timeVaryingAttributes(self): data_view = og.AttributeValueHelper(self._attributes.timeVaryingAttributes) return data_view.get() @timeVaryingAttributes.setter def timeVaryingAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.timeVaryingAttributes) data_view = og.AttributeValueHelper(self._attributes.timeVaryingAttributes) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdTimecode) data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def prim(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.prim""" return self.__bundles.prim @prim.setter def prim(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.prim with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.prim.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.prevPrimDirtyIDs_size = None @property def prevApplyTransform(self): data_view = og.AttributeValueHelper(self._attributes.prevApplyTransform) return data_view.get() @prevApplyTransform.setter def prevApplyTransform(self, value): data_view = og.AttributeValueHelper(self._attributes.prevApplyTransform) data_view.set(value) @property def prevAttrNamesToExport(self): data_view = og.AttributeValueHelper(self._attributes.prevAttrNamesToExport) return data_view.get() @prevAttrNamesToExport.setter def prevAttrNamesToExport(self, value): data_view = og.AttributeValueHelper(self._attributes.prevAttrNamesToExport) data_view.set(value) @property def prevBundleDirtyID(self): data_view = og.AttributeValueHelper(self._attributes.prevBundleDirtyID) return data_view.get() @prevBundleDirtyID.setter def prevBundleDirtyID(self, value): data_view = og.AttributeValueHelper(self._attributes.prevBundleDirtyID) data_view.set(value) @property def prevExcludedAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.prevExcludedAttrNames) return data_view.get() @prevExcludedAttrNames.setter def prevExcludedAttrNames(self, value): data_view = og.AttributeValueHelper(self._attributes.prevExcludedAttrNames) data_view.set(value) @property def prevExportToRootLayer(self): data_view = og.AttributeValueHelper(self._attributes.prevExportToRootLayer) return data_view.get() @prevExportToRootLayer.setter def prevExportToRootLayer(self, value): data_view = og.AttributeValueHelper(self._attributes.prevExportToRootLayer) data_view.set(value) @property def prevInputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.prevInputAttrNames) return data_view.get() @prevInputAttrNames.setter def prevInputAttrNames(self, value): data_view = og.AttributeValueHelper(self._attributes.prevInputAttrNames) data_view.set(value) @property def prevLayerName(self): data_view = og.AttributeValueHelper(self._attributes.prevLayerName) return data_view.get() @prevLayerName.setter def prevLayerName(self, value): data_view = og.AttributeValueHelper(self._attributes.prevLayerName) data_view.set(value) @property def prevOnlyExportToExisting(self): data_view = og.AttributeValueHelper(self._attributes.prevOnlyExportToExisting) return data_view.get() @prevOnlyExportToExisting.setter def prevOnlyExportToExisting(self, value): data_view = og.AttributeValueHelper(self._attributes.prevOnlyExportToExisting) data_view.set(value) @property def prevOutputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.prevOutputAttrNames) return data_view.get() @prevOutputAttrNames.setter def prevOutputAttrNames(self, value): data_view = og.AttributeValueHelper(self._attributes.prevOutputAttrNames) data_view.set(value) @property def prevPrimDirtyIDs(self): data_view = og.AttributeValueHelper(self._attributes.prevPrimDirtyIDs) self.prevPrimDirtyIDs_size = data_view.get_array_size() return data_view.get() @prevPrimDirtyIDs.setter def prevPrimDirtyIDs(self, value): data_view = og.AttributeValueHelper(self._attributes.prevPrimDirtyIDs) data_view.set(value) self.prevPrimDirtyIDs_size = data_view.get_array_size() @property def prevPrimPathFromBundle(self): data_view = og.AttributeValueHelper(self._attributes.prevPrimPathFromBundle) return data_view.get() @prevPrimPathFromBundle.setter def prevPrimPathFromBundle(self, value): data_view = og.AttributeValueHelper(self._attributes.prevPrimPathFromBundle) data_view.set(value) @property def prevRemoveMissingAttrs(self): data_view = og.AttributeValueHelper(self._attributes.prevRemoveMissingAttrs) return data_view.get() @prevRemoveMissingAttrs.setter def prevRemoveMissingAttrs(self, value): data_view = og.AttributeValueHelper(self._attributes.prevRemoveMissingAttrs) data_view.set(value) @property def prevRenameAttributes(self): data_view = og.AttributeValueHelper(self._attributes.prevRenameAttributes) return data_view.get() @prevRenameAttributes.setter def prevRenameAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.prevRenameAttributes) data_view.set(value) @property def prevTimeVaryingAttributes(self): data_view = og.AttributeValueHelper(self._attributes.prevTimeVaryingAttributes) return data_view.get() @prevTimeVaryingAttributes.setter def prevTimeVaryingAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.prevTimeVaryingAttributes) data_view.set(value) @property def prevUsdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.prevUsdTimecode) return data_view.get() @prevUsdTimecode.setter def prevUsdTimecode(self, value): data_view = og.AttributeValueHelper(self._attributes.prevUsdTimecode) data_view.set(value) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnExportUSDPrimDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnExportUSDPrimDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnExportUSDPrimDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/TestOgnImportUSDPrim.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.io.ogn.OgnImportUSDPrimDatabase import OgnImportUSDPrimDatabase test_file_name = "OgnImportUSDPrimTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_ImportUSDPrim") database = OgnImportUSDPrimDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:applySkelBinding")) attribute = test_node.get_attribute("inputs:applySkelBinding") db_value = database.inputs.applySkelBinding expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:applyTransform")) attribute = test_node.get_attribute("inputs:applyTransform") db_value = database.inputs.applyTransform expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport")) attribute = test_node.get_attribute("inputs:attrNamesToImport") db_value = database.inputs.attrNamesToImport expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox")) attribute = test_node.get_attribute("inputs:computeBoundingBox") db_value = database.inputs.computeBoundingBox expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importAttributes")) attribute = test_node.get_attribute("inputs:importAttributes") db_value = database.inputs.importAttributes expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importPath")) attribute = test_node.get_attribute("inputs:importPath") db_value = database.inputs.importPath expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importPrimvarMetadata")) attribute = test_node.get_attribute("inputs:importPrimvarMetadata") db_value = database.inputs.importPrimvarMetadata expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importTime")) attribute = test_node.get_attribute("inputs:importTime") db_value = database.inputs.importTime expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importTransform")) attribute = test_node.get_attribute("inputs:importTransform") db_value = database.inputs.importTransform expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:importType")) attribute = test_node.get_attribute("inputs:importType") db_value = database.inputs.importType expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames")) attribute = test_node.get_attribute("inputs:inputAttrNames") db_value = database.inputs.inputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:keepPrimsSeparate")) attribute = test_node.get_attribute("inputs:keepPrimsSeparate") db_value = database.inputs.keepPrimsSeparate expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames")) attribute = test_node.get_attribute("inputs:outputAttrNames") db_value = database.inputs.outputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:renameAttributes")) attribute = test_node.get_attribute("inputs:renameAttributes") db_value = database.inputs.renameAttributes expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:timeVaryingAttributes")) attribute = test_node.get_attribute("inputs:timeVaryingAttributes") db_value = database.inputs.timeVaryingAttributes expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode")) attribute = test_node.get_attribute("inputs:usdTimecode") db_value = database.inputs.usdTimecode expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_output")) attribute = test_node.get_attribute("outputs_output") db_value = database.outputs.output self.assertTrue(test_node.get_attribute_exists("state:prevApplySkelBinding")) attribute = test_node.get_attribute("state:prevApplySkelBinding") db_value = database.state.prevApplySkelBinding self.assertTrue(test_node.get_attribute_exists("state:prevApplyTransform")) attribute = test_node.get_attribute("state:prevApplyTransform") db_value = database.state.prevApplyTransform self.assertTrue(test_node.get_attribute_exists("state:prevAttrNamesToImport")) attribute = test_node.get_attribute("state:prevAttrNamesToImport") db_value = database.state.prevAttrNamesToImport self.assertTrue(test_node.get_attribute_exists("state:prevComputeBoundingBox")) attribute = test_node.get_attribute("state:prevComputeBoundingBox") db_value = database.state.prevComputeBoundingBox self.assertTrue(test_node.get_attribute_exists("state:prevImportAttributes")) attribute = test_node.get_attribute("state:prevImportAttributes") db_value = database.state.prevImportAttributes self.assertTrue(test_node.get_attribute_exists("state:prevImportPath")) attribute = test_node.get_attribute("state:prevImportPath") db_value = database.state.prevImportPath self.assertTrue(test_node.get_attribute_exists("state:prevImportPrimvarMetadata")) attribute = test_node.get_attribute("state:prevImportPrimvarMetadata") db_value = database.state.prevImportPrimvarMetadata self.assertTrue(test_node.get_attribute_exists("state:prevImportTime")) attribute = test_node.get_attribute("state:prevImportTime") db_value = database.state.prevImportTime self.assertTrue(test_node.get_attribute_exists("state:prevImportTransform")) attribute = test_node.get_attribute("state:prevImportTransform") db_value = database.state.prevImportTransform self.assertTrue(test_node.get_attribute_exists("state:prevImportType")) attribute = test_node.get_attribute("state:prevImportType") db_value = database.state.prevImportType self.assertTrue(test_node.get_attribute_exists("state:prevInputAttrNames")) attribute = test_node.get_attribute("state:prevInputAttrNames") db_value = database.state.prevInputAttrNames self.assertTrue(test_node.get_attribute_exists("state:prevInvNodeTransform")) attribute = test_node.get_attribute("state:prevInvNodeTransform") db_value = database.state.prevInvNodeTransform self.assertTrue(test_node.get_attribute_exists("state:prevKeepPrimsSeparate")) attribute = test_node.get_attribute("state:prevKeepPrimsSeparate") db_value = database.state.prevKeepPrimsSeparate self.assertTrue(test_node.get_attribute_exists("state:prevOnlyImportSpecified")) attribute = test_node.get_attribute("state:prevOnlyImportSpecified") db_value = database.state.prevOnlyImportSpecified self.assertTrue(test_node.get_attribute_exists("state:prevOutputAttrNames")) attribute = test_node.get_attribute("state:prevOutputAttrNames") db_value = database.state.prevOutputAttrNames self.assertTrue(test_node.get_attribute_exists("state:prevPaths")) attribute = test_node.get_attribute("state:prevPaths") db_value = database.state.prevPaths self.assertTrue(test_node.get_attribute_exists("state:prevRenameAttributes")) attribute = test_node.get_attribute("state:prevRenameAttributes") db_value = database.state.prevRenameAttributes self.assertTrue(test_node.get_attribute_exists("state:prevTimeVaryingAttributes")) attribute = test_node.get_attribute("state:prevTimeVaryingAttributes") db_value = database.state.prevTimeVaryingAttributes self.assertTrue(test_node.get_attribute_exists("state:prevTransforms")) attribute = test_node.get_attribute("state:prevTransforms") db_value = database.state.prevTransforms self.assertTrue(test_node.get_attribute_exists("state:prevUsdTimecode")) attribute = test_node.get_attribute("state:prevUsdTimecode") db_value = database.state.prevUsdTimecode
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/__init__.py
"""====== GENERATED BY omni.graph.tools - DO NOT EDIT ======""" import omni.graph.tools._internal as ogi ogi.import_tests_in_directory(__file__, __name__)
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/TestOgnBundleToUSDA.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.io.ogn.OgnBundleToUSDADatabase import OgnBundleToUSDADatabase test_file_name = "OgnBundleToUSDATemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_BundleToUSDA") database = OgnBundleToUSDADatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:bundle")) attribute = test_node.get_attribute("inputs:bundle") db_value = database.inputs.bundle self.assertTrue(test_node.get_attribute_exists("inputs:outputAncestors")) attribute = test_node.get_attribute("inputs:outputAncestors") db_value = database.inputs.outputAncestors expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:outputValues")) attribute = test_node.get_attribute("inputs:outputValues") db_value = database.inputs.outputValues expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePrimPath")) attribute = test_node.get_attribute("inputs:usePrimPath") db_value = database.inputs.usePrimPath expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePrimType")) attribute = test_node.get_attribute("inputs:usePrimType") db_value = database.inputs.usePrimType expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usePrimvarMetadata")) attribute = test_node.get_attribute("inputs:usePrimvarMetadata") db_value = database.inputs.usePrimvarMetadata expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs:text")) attribute = test_node.get_attribute("outputs:text") db_value = database.outputs.text
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/TestOgnTransformBundle.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.io.ogn.OgnTransformBundleDatabase import OgnTransformBundleDatabase test_file_name = "OgnTransformBundleTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_TransformBundle") database = OgnTransformBundleDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:input")) attribute = test_node.get_attribute("inputs:input") db_value = database.inputs.input self.assertTrue(test_node.get_attribute_exists("inputs:transform")) attribute = test_node.get_attribute("inputs:transform") db_value = database.inputs.transform expected_value = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]] actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("outputs_output")) attribute = test_node.get_attribute("outputs_output") db_value = database.outputs.output
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/TestOgnExportUSDPrim.py
import os import omni.kit.test import omni.graph.core as og import omni.graph.core.tests as ogts from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene class TestOgn(ogts.OmniGraphTestCase): async def test_data_access(self): from omni.graph.io.ogn.OgnExportUSDPrimDatabase import OgnExportUSDPrimDatabase test_file_name = "OgnExportUSDPrimTemplate.usda" usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name) if not os.path.exists(usd_path): self.assertTrue(False, f"{usd_path} not found for loading test") (result, error) = await ogts.load_test_file(usd_path) self.assertTrue(result, f'{error} on {usd_path}') test_node = og.Controller.node("/TestGraph/Template_omni_graph_ExportUSDPrim") database = OgnExportUSDPrimDatabase(test_node) self.assertTrue(test_node.is_valid()) node_type_name = test_node.get_type_name() self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1) def _attr_error(attribute: og.Attribute, usd_test: bool) -> str: test_type = "USD Load" if usd_test else "Database Access" return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error" self.assertTrue(test_node.get_attribute_exists("inputs:applyTransform")) attribute = test_node.get_attribute("inputs:applyTransform") db_value = database.inputs.applyTransform expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToExport")) attribute = test_node.get_attribute("inputs:attrNamesToExport") db_value = database.inputs.attrNamesToExport expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:bundle")) attribute = test_node.get_attribute("inputs:bundle") db_value = database.inputs.bundle self.assertTrue(test_node.get_attribute_exists("inputs:excludedAttrNames")) attribute = test_node.get_attribute("inputs:excludedAttrNames") db_value = database.inputs.excludedAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:exportToRootLayer")) attribute = test_node.get_attribute("inputs:exportToRootLayer") db_value = database.inputs.exportToRootLayer expected_value = True actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames")) attribute = test_node.get_attribute("inputs:inputAttrNames") db_value = database.inputs.inputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:layerName")) attribute = test_node.get_attribute("inputs:layerName") db_value = database.inputs.layerName expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:onlyExportToExisting")) attribute = test_node.get_attribute("inputs:onlyExportToExisting") db_value = database.inputs.onlyExportToExisting expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames")) attribute = test_node.get_attribute("inputs:outputAttrNames") db_value = database.inputs.outputAttrNames expected_value = "" actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:primPathFromBundle")) attribute = test_node.get_attribute("inputs:primPathFromBundle") db_value = database.inputs.primPathFromBundle expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:removeMissingAttrs")) attribute = test_node.get_attribute("inputs:removeMissingAttrs") db_value = database.inputs.removeMissingAttrs expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:renameAttributes")) attribute = test_node.get_attribute("inputs:renameAttributes") db_value = database.inputs.renameAttributes expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:timeVaryingAttributes")) attribute = test_node.get_attribute("inputs:timeVaryingAttributes") db_value = database.inputs.timeVaryingAttributes expected_value = False actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode")) attribute = test_node.get_attribute("inputs:usdTimecode") db_value = database.inputs.usdTimecode expected_value = 0 actual_value = og.Controller.get(attribute) ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True)) ogts.verify_values(expected_value, db_value, _attr_error(attribute, False)) self.assertTrue(test_node.get_attribute_exists("state:prevApplyTransform")) attribute = test_node.get_attribute("state:prevApplyTransform") db_value = database.state.prevApplyTransform self.assertTrue(test_node.get_attribute_exists("state:prevAttrNamesToExport")) attribute = test_node.get_attribute("state:prevAttrNamesToExport") db_value = database.state.prevAttrNamesToExport self.assertTrue(test_node.get_attribute_exists("state:prevBundleDirtyID")) attribute = test_node.get_attribute("state:prevBundleDirtyID") db_value = database.state.prevBundleDirtyID self.assertTrue(test_node.get_attribute_exists("state:prevExcludedAttrNames")) attribute = test_node.get_attribute("state:prevExcludedAttrNames") db_value = database.state.prevExcludedAttrNames self.assertTrue(test_node.get_attribute_exists("state:prevExportToRootLayer")) attribute = test_node.get_attribute("state:prevExportToRootLayer") db_value = database.state.prevExportToRootLayer self.assertTrue(test_node.get_attribute_exists("state:prevInputAttrNames")) attribute = test_node.get_attribute("state:prevInputAttrNames") db_value = database.state.prevInputAttrNames self.assertTrue(test_node.get_attribute_exists("state:prevLayerName")) attribute = test_node.get_attribute("state:prevLayerName") db_value = database.state.prevLayerName self.assertTrue(test_node.get_attribute_exists("state:prevOnlyExportToExisting")) attribute = test_node.get_attribute("state:prevOnlyExportToExisting") db_value = database.state.prevOnlyExportToExisting self.assertTrue(test_node.get_attribute_exists("state:prevOutputAttrNames")) attribute = test_node.get_attribute("state:prevOutputAttrNames") db_value = database.state.prevOutputAttrNames self.assertTrue(test_node.get_attribute_exists("state:prevPrimDirtyIDs")) attribute = test_node.get_attribute("state:prevPrimDirtyIDs") db_value = database.state.prevPrimDirtyIDs self.assertTrue(test_node.get_attribute_exists("state:prevPrimPathFromBundle")) attribute = test_node.get_attribute("state:prevPrimPathFromBundle") db_value = database.state.prevPrimPathFromBundle self.assertTrue(test_node.get_attribute_exists("state:prevRemoveMissingAttrs")) attribute = test_node.get_attribute("state:prevRemoveMissingAttrs") db_value = database.state.prevRemoveMissingAttrs self.assertTrue(test_node.get_attribute_exists("state:prevRenameAttributes")) attribute = test_node.get_attribute("state:prevRenameAttributes") db_value = database.state.prevRenameAttributes self.assertTrue(test_node.get_attribute_exists("state:prevTimeVaryingAttributes")) attribute = test_node.get_attribute("state:prevTimeVaryingAttributes") db_value = database.state.prevTimeVaryingAttributes self.assertTrue(test_node.get_attribute_exists("state:prevUsdTimecode")) attribute = test_node.get_attribute("state:prevUsdTimecode") db_value = database.state.prevUsdTimecode
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/usd/OgnExportUSDPrimTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnExportUSDPrim.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_ExportUSDPrim" ( docs="""Exports data from an input bundle into a USD prim""" ) { token node:type = "omni.graph.ExportUSDPrim" int node:typeVersion = 1 # 14 attributes custom bool inputs:applyTransform = false ( docs="""If true, apply the transform necessary to transform any transforming attributes from the space of the node into the space of the specified prim.""" ) custom token inputs:attrNamesToExport = "" ( docs="""Comma or space separated text, listing the names of attributes in the input data to be exported or empty to import all attributes.""" ) custom rel inputs:bundle ( docs="""The bundle from which data should be exported.""" ) custom token inputs:excludedAttrNames = "" ( docs="""Attributes to be excluded from being exported""" ) custom bool inputs:exportToRootLayer = true ( docs="""If true, prims are exported in the root layer, otherwise the layer specified by "layerName" is used.""" ) custom token inputs:inputAttrNames = "" ( docs="""Comma or space separated text, listing the names of attributes in the input data to be renamed""" ) custom token inputs:layerName = "" ( docs="""Identifier of the layer to export to if "exportToRootLayer" is false, or leave this blank to export to the session layer""" ) custom bool inputs:onlyExportToExisting = false ( docs="""If true, only attributes that already exist in the specified output prim will have data transferred to them from the input bundle.""" ) custom token inputs:outputAttrNames = "" ( docs="""Comma or space separated text, listing the new names for the attributes listed in inputAttrNames""" ) custom bool inputs:primPathFromBundle = false ( docs="""When true, if there is a "primPath" token attribute inside the bundle, that will be the path of the USD prim to write to, else the "outputs:prim" attribute below will be used for the USD prim path.""" ) custom bool inputs:removeMissingAttrs = false ( docs="""If true, any attributes on the USD prim(s) being written to, that aren't in the input data, will be removed from the USD prim(s).""" ) custom bool inputs:renameAttributes = false ( docs="""If true, attributes listed in "inputAttrNames" will be exported to attributes with the names specified in "outputAttrNames". Note: to avoid potential issues with redundant attributes being created while typing, keep this off until after specifying all input and output attribute names.""" ) custom bool inputs:timeVaryingAttributes = false ( docs="""Check whether the USD attributes should be time-varying and if so, export their data to a time sample at the time "usdTimecode".""" ) custom double inputs:usdTimecode = 0 ( docs="""The time at which to evaluate the transform of the USD prim for applyTransform.""" ) # 1 attribute def Output "outputs_prim" ( docs="""The USD prim(s) to which data should be exported if primPathFromBundle is false or if the bundle doesn't have a "primPath" token attribute. Note: this is really an input, since the node just receives the path to the prim. The node does not contain the prim.""" ) { } # 15 attributes custom bool state:prevApplyTransform ( docs="""Value of "applyTransform" input from previous run""" ) custom token state:prevAttrNamesToExport ( docs="""Value of "attrNamesToExport" input from previous run""" ) custom uint64 state:prevBundleDirtyID ( docs="""Dirty ID of input bundle from previous run""" ) custom token state:prevExcludedAttrNames ( docs="""Value of "excludedAttrNames" input from previous run""" ) custom bool state:prevExportToRootLayer ( docs="""Value of "exportToRootLayer" input from previous run""" ) custom token state:prevInputAttrNames ( docs="""Value of "inputAttrNames" input from previous run""" ) custom token state:prevLayerName ( docs="""Value of "layerName" input from previous run""" ) custom bool state:prevOnlyExportToExisting ( docs="""Value of "onlyExportToExisting" input from previous run""" ) custom token state:prevOutputAttrNames ( docs="""Value of "outputAttrNames" input from previous run""" ) custom uint64[] state:prevPrimDirtyIDs ( docs="""Dirty IDs of input prims from previous run""" ) custom bool state:prevPrimPathFromBundle ( docs="""Value of "primPathFromBundle" input from previous run""" ) custom bool state:prevRemoveMissingAttrs ( docs="""Value of "removeMissingAttrs" input from previous run""" ) custom bool state:prevRenameAttributes ( docs="""Value of "renameAttributes" input from previous run""" ) custom bool state:prevTimeVaryingAttributes ( docs="""Value of "timeVaryingAttributes" input from previous run""" ) custom double state:prevUsdTimecode ( docs="""Value of "usdTimecode" input from previous run""" ) } }
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/usd/OgnImportUSDPrimTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnImportUSDPrim.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_ImportUSDPrim" ( docs="""Imports data from a USD prim into attributes in an output bundle""" ) { token node:type = "omni.graph.ImportUSDPrim" int node:typeVersion = 1 # 17 attributes custom bool inputs:applySkelBinding = true ( docs="""If the input USD prim is a Mesh, and has SkelBindingAPI schema applied, compute skinned points and normals.""" ) custom bool inputs:applyTransform = false ( docs="""If importAttributes is true, apply the transform necessary to transform any transforming attributes into the space of this node.""" ) custom token inputs:attrNamesToImport = "" ( docs="""Comma or space separated text, listing the names of attributes in the input data to be imported or empty to import all attributes.""" ) custom bool inputs:computeBoundingBox = false ( docs="""Compute and store local bounding box of a prim and its children.""" ) custom bool inputs:importAttributes = true ( docs="""Import attribute data from the USD prim.""" ) custom bool inputs:importPath = true ( docs="""Record the input USD prim's path into the output bundle in an attribute named "primPath".""" ) custom bool inputs:importPrimvarMetadata = true ( docs="""Import metadata like the interpolation type for primvars, and store it as attributes in the output bundle.""" ) custom bool inputs:importTime = true ( docs="""Record the usdTimecode above into the output bundle in an attribute named "primTime".""" ) custom bool inputs:importTransform = true ( docs="""Record the transform required to take any attributes of the input USD prim into the space of this node, i.e. the world transform of the input prim times the inverse world transform of this node, into the output bundle in an attribute named "transform".""" ) custom bool inputs:importType = true ( docs="""Record the input USD prim's type name into the output bundle in an attribute named "primType".""" ) custom token inputs:inputAttrNames = "" ( docs="""Comma or space separated text, listing the names of attributes in the input data to be renamed""" ) custom bool inputs:keepPrimsSeparate = true ( docs="""Prefix output attribute names with "prim" followed by a unique number and a colon, to keep the attributes for separate input prims separate. The prim paths will be in the "primPaths" token array attribute.""" ) custom token inputs:outputAttrNames = "" ( docs="""Comma or space separated text, listing the new names for the attributes listed in inputAttrNames""" ) custom rel inputs:prim ( docs="""The USD prim from which to import data.""" ) custom bool inputs:renameAttributes = false ( docs="""If true, attributes listed in "inputAttrNames" will be imported to attributes with the names specified in "outputAttrNames".""" ) custom bool inputs:timeVaryingAttributes = true ( docs="""Check whether the USD attributes are time-varying and if so, import their data at the time "usdTimecode".""" ) custom double inputs:usdTimecode = 0 ( docs="""The time at which to evaluate the transform of the USD prim.""" ) # 1 attribute def Output "outputs_output" ( docs="""Output bundle containing all of the imported data.""" ) { } # 20 attributes custom bool state:prevApplySkelBinding ( docs="""Value of "applySkelBinding" input from previous run""" ) custom bool state:prevApplyTransform ( docs="""Value of "applyTransform" input from previous run""" ) custom token state:prevAttrNamesToImport ( docs="""Value of "attrNamesToImport" input from previous run""" ) custom bool state:prevComputeBoundingBox ( docs="""Value of "computeBoundingBox" input from previous run""" ) custom bool state:prevImportAttributes ( docs="""Value of "importAttributes" input from previous run""" ) custom bool state:prevImportPath ( docs="""Value of "importPath" input from previous run""" ) custom bool state:prevImportPrimvarMetadata ( docs="""Value of "importPrimvarMetadata" input from previous run""" ) custom bool state:prevImportTime ( docs="""Value of "importTime" input from previous run""" ) custom bool state:prevImportTransform ( docs="""Value of "importTransform" input from previous run""" ) custom bool state:prevImportType ( docs="""Value of "importType" input from previous run""" ) custom token state:prevInputAttrNames ( docs="""Value of "inputAttrNames" input from previous run""" ) custom matrix4d state:prevInvNodeTransform ( docs="""Inverse transform of the node prim from the previous run.""" ) custom bool state:prevKeepPrimsSeparate ( docs="""Value of "keepPrimsSeparate" input from previous run""" ) custom bool state:prevOnlyImportSpecified ( docs="""Value of "onlyImportSpecified" input from previous run""" ) custom token state:prevOutputAttrNames ( docs="""Value of "outputAttrNames" input from previous run""" ) custom token[] state:prevPaths ( docs="""Array of paths from the previous run.""" ) custom bool state:prevRenameAttributes ( docs="""Value of "renameAttributes" input from previous run""" ) custom bool state:prevTimeVaryingAttributes ( docs="""Value of "timeVaryingAttributes" input from previous run""" ) custom matrix4d[] state:prevTransforms ( docs="""Array of transforms from the previous run.""" ) custom double state:prevUsdTimecode ( docs="""Value of "usdTimecode" input from previous run""" ) } }
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/usd/OgnBundleToUSDATemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnBundleToUSDA.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_BundleToUSDA" ( docs="""Outputs a represention of the content of a bundle as usda text""" ) { token node:type = "omni.graph.BundleToUSDA" int node:typeVersion = 1 # 6 attributes custom rel inputs:bundle ( docs="""The bundle to convert to usda text.""" ) custom bool inputs:outputAncestors = false ( docs="""If usePath is true and this is also true, ancestor "primPath" entries will be output.""" ) custom bool inputs:outputValues = true ( docs="""If true, the values of attributes will be output, else values will be omitted.""" ) custom bool inputs:usePrimPath = true ( docs="""Use the attribute named "primPath" for the usda prim path.""" ) custom bool inputs:usePrimType = true ( docs="""Use the attribute named "primType" for the usda prim type name.""" ) custom bool inputs:usePrimvarMetadata = true ( docs="""Identify attributes representing metadata like the interpolation type for primvars, and include them as usda metadata in the output text.""" ) # 1 attribute custom token outputs:text ( docs="""Output usda text representing the bundle contents.""" ) } }
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/ogn/tests/usd/OgnTransformBundleTemplate.usda
#usda 1.0 ( doc ="""Generated from node description file OgnTransformBundle.ogn Contains templates for node types found in that file.""" ) def OmniGraph "TestGraph" { token evaluator:type = "push" int2 fileFormatVersion = (1, 3) token flatCacheBacking = "Shared" token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "Template_omni_graph_TransformBundle" ( docs="""Applies a transform to an input bundle, storing the result in an output bundle""" ) { token node:type = "omni.graph.TransformBundle" int node:typeVersion = 1 # 2 attributes custom rel inputs:input ( docs="""Input bundle containing the attributes to be transformed.""" ) custom matrix4d inputs:transform = ((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0)) ( docs="""The transform to apply to the bundle""" ) # 1 attribute def Output "outputs_output" ( docs="""Output bundle containing all of the transformed attributes""" ) { } } }
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/_impl/extension.py
"""Support required by the Carbonite extension loader""" import omni.ext from ..bindings._omni_graph_io import acquire_interface as _acquire_interface # noqa: PLE0402 from ..bindings._omni_graph_io import release_interface as _release_interface # noqa: PLE0402 class _PublicExtension(omni.ext.IExt): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.__interface = None try: import omni.graph.ui as ogu ogu.ComputeNodeWidget.get_instance().add_template_path(__file__) except ImportError: pass def on_startup(self, ext_id): self.__interface = _acquire_interface() def on_shutdown(self): if self.__interface is not None: _release_interface(self.__interface) self.__interface = None
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/_impl/templates/template_omni.graph.ImportUSDPrim.py
from omni.kit.property.usd.custom_layout_helper import CustomLayoutFrame, CustomLayoutGroup, CustomLayoutProperty class CustomLayout: def __init__(self, compute_node_widget): # print("\nInside template_omni.genproc.ImportUSDPrim.py, CustomLayout:__init__\n"); # Enable template self.enable = True self.compute_node_widget = compute_node_widget self.compute_node_widget.get_bundles() bundle_items_iter = iter(self.compute_node_widget.bundles.items()) _ = next(bundle_items_iter)[1][0].get_attribute_names_and_types() def apply(self, props): frame = CustomLayoutFrame(hide_extra=True) with frame: with CustomLayoutGroup("Import Parameters"): CustomLayoutProperty("inputs:prim", "Prim(s) to Import") CustomLayoutProperty("inputs:usdTimecode", "Timecode") CustomLayoutProperty("inputs:keepPrimsSeparate", "Allow Multiple Prims") CustomLayoutProperty("inputs:importTransform", "Import Transforms") CustomLayoutProperty("inputs:computeBoundingBox", "Compute Bounding Boxes") CustomLayoutProperty("inputs:importType", "Import Types") CustomLayoutProperty("inputs:importPath", "Import Paths") CustomLayoutProperty("inputs:importTime", "Import Time") with CustomLayoutGroup("Attributes"): CustomLayoutProperty("inputs:importAttributes", "Import Attributes") CustomLayoutProperty("inputs:attrNamesToImport", "Attributes to Import") CustomLayoutProperty("inputs:renameAttributes", "Rename Attributes") CustomLayoutProperty("inputs:inputAttrNames", "Attributes to Rename") CustomLayoutProperty("inputs:outputAttrNames", "New Attribute Names") CustomLayoutProperty("inputs:applyTransform", "Transform Attributes") CustomLayoutProperty("inputs:timeVaryingAttributes", "Time Varying Attributes") CustomLayoutProperty("inputs:importPrimvarMetadata", "Import Metadata") CustomLayoutProperty("inputs:applySkelBinding", "Apply SkelBinding") return frame.apply(props) # print("\nIn template_omni.graph.ImportUSDPrim.py\n")
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/_impl/templates/template_omni.graph.ExportUSDPrim.py
from omni.kit.property.usd.custom_layout_helper import CustomLayoutFrame, CustomLayoutGroup, CustomLayoutProperty class CustomLayout: def __init__(self, compute_node_widget): # print("\nInside template_omni.genproc.ExportUSDPrim.py, CustomLayout:__init__\n"); # Enable template self.enable = True self.compute_node_widget = compute_node_widget self.compute_node_widget.get_bundles() bundle_items_iter = iter(self.compute_node_widget.bundles.items()) _ = next(bundle_items_iter)[1][0].get_attribute_names_and_types() def apply(self, props): frame = CustomLayoutFrame(hide_extra=True) with frame: with CustomLayoutGroup("Export Parameters"): CustomLayoutProperty("outputs:prim", "Prim(s) to Export to") CustomLayoutProperty("inputs:bundle", "Source Data") CustomLayoutProperty("inputs:primPathFromBundle", "Export to primPath from Source") CustomLayoutProperty("inputs:exportToRootLayer", "Export to Root Layer") CustomLayoutProperty("inputs:layerName", "Layer Name") with CustomLayoutGroup("Attributes"): CustomLayoutProperty("inputs:attrNamesToExport", "Attributes to Export") CustomLayoutProperty("inputs:onlyExportToExisting", "Only Export Existing") CustomLayoutProperty("inputs:removeMissingAttrs", "Remove Missing") CustomLayoutProperty("inputs:renameAttributes", "Rename Attributes") CustomLayoutProperty("inputs:inputAttrNames", "Attributes to Rename") CustomLayoutProperty("inputs:outputAttrNames", "New Attribute Names") CustomLayoutProperty("inputs:excludedAttrNames", "Attributes to Exclude") CustomLayoutProperty("inputs:applyTransform", "Transform Attributes") CustomLayoutProperty("inputs:timeVaryingAttributes", "Time-varying Attributes") CustomLayoutProperty("inputs:usdTimecode", "USD Time") return frame.apply(props) # print("\nIn template_omni.graph.ExportUSDPrim.py\n")
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/tests/test_api.py
"""Testing the stability of the API in this module""" import omni.graph.core.tests as ogts import omni.graph.io as ogio from omni.graph.tools.tests.internal_utils import _check_module_api_consistency, _check_public_api_contents # ====================================================================== class _TestOmniGraphIoApi(ogts.OmniGraphTestCase): _UNPUBLISHED = ["bindings", "ogn", "tests"] async def test_api(self): _check_module_api_consistency(ogio, self._UNPUBLISHED) # noqa: PLW0212 _check_module_api_consistency(ogio.tests, is_test_module=True) # noqa: PLW0212 async def test_api_features(self): """Test that the known public API features continue to exist""" _check_public_api_contents(ogio, [], self._UNPUBLISHED, only_expected_allowed=True) # noqa: PLW0212 _check_public_api_contents(ogio.tests, [], [], only_expected_allowed=True) # noqa: PLW0212
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/tests/__init__.py
"""There is no public API to this module.""" __all__ = [] scan_for_test_modules = True """The presence of this object causes the test runner to automatically scan the directory for unit test cases"""
omniverse-code/kit/exts/omni.graph.io/omni/graph/io/tests/test_prim_data_import_export.py
import omni.graph.core as ogc import omni.kit.test class TestPrimDataImportExport(ogc.tests.OmniGraphTestCase): """Run a unit test to validate data flow through bundles.""" TEST_GRAPH_PATH = "/TestGraph" TRANSLATE = (10.0, 20.0, 30.0) ROTATE = (90.0, 180.0, 270.0) SCALE = (400.0, 500.0, 600.0) async def setUp(self): """Set up test environment, to be torn down when done""" await super().setUp() self.controller = ogc.Controller() self.graph = self.controller.create_graph(self.TEST_GRAPH_PATH) self.context = self.graph.get_default_graph_context() # Create ImportUSDPrim and ExportUSDPrim and connect them together. (self.graph, (self.importNode, self.exportNode), _, _,) = self.controller.edit( self.TEST_GRAPH_PATH, { ogc.Controller.Keys.CREATE_NODES: [ ("import_usd_prim_data", "omni.graph.ImportUSDPrim"), ("export_usd_prim_data", "omni.graph.ExportUSDPrim"), ], ogc.Controller.Keys.CONNECT: [ ( "import_usd_prim_data.outputs_output", "export_usd_prim_data.inputs:bundle", ) ], }, ) stage = omni.usd.get_context().get_stage() # Create two Xform nodes, one as input, the other as output. self.input_prim = ogc.Controller.create_prim("/input_prim", {}, "Xform") self.output_prim = ogc.Controller.create_prim("/output_prim", {}, "Xform") omni.kit.commands.execute( "AddRelationshipTarget", relationship=stage.GetPropertyAtPath(self.TEST_GRAPH_PATH + "/import_usd_prim_data.inputs:prim"), target=self.input_prim.GetPath(), ) omni.kit.commands.execute( "AddRelationshipTarget", relationship=stage.GetPropertyAtPath(self.TEST_GRAPH_PATH + "/export_usd_prim_data.outputs:prim"), target=self.output_prim.GetPath(), ) async def test_set_attributes(self): """Test whether attribute value changes of the input prim will be synced to the output prim.""" # Assign new TRS values to the input prim. self.input_prim.GetAttribute("xformOp:translate").Set(self.TRANSLATE) self.input_prim.GetAttribute("xformOp:rotateXYZ").Set(self.ROTATE) self.input_prim.GetAttribute("xformOp:scale").Set(self.SCALE) # Before graph evaluation, the output prim is still with its default attribute values. self.assertFalse(self.output_prim.GetAttribute("xformOp:translate").Get() == self.TRANSLATE) self.assertFalse(self.output_prim.GetAttribute("xformOp:rotateXYZ").Get() == self.ROTATE) self.assertFalse(self.output_prim.GetAttribute("xformOp:scale").Get() == self.SCALE) # Trigger graph evaluation and wait for completion. await ogc.Controller.evaluate(self.graph) # After graph evaluation, the output prim has been fed with data from the input prim. self.assertTrue(self.output_prim.GetAttribute("xformOp:translate").Get() == self.TRANSLATE) self.assertTrue(self.output_prim.GetAttribute("xformOp:rotateXYZ").Get() == self.ROTATE) self.assertTrue(self.output_prim.GetAttribute("xformOp:scale").Get() == self.SCALE) async def test_bundle_attributes_and_metadata(self): """Test bundle attributes and metadata""" # Get the bundle from the import node. bundle = self.context.get_output_bundle(self.importNode, "outputs_output") self.assertTrue(bundle.is_valid()) # Attribute names and types before evaluation. attr_names, attr_types = bundle.get_attribute_names_and_types() self.assertTrue(len(attr_names) == 0) self.assertTrue(len(attr_types) == 0) # Assign new TRS values to the input prim. self.input_prim.GetAttribute("xformOp:translate").Set(self.TRANSLATE) self.input_prim.GetAttribute("xformOp:rotateXYZ").Set(self.ROTATE) self.input_prim.GetAttribute("xformOp:scale").Set(self.SCALE) # Trigger graph evaluation and wait for completion. await ogc.Controller.evaluate(self.graph) # Attribute names and types after evaluation. attr_names, attr_types = bundle.get_attribute_names_and_types() self.assertTrue(len(attr_names) != 0) self.assertTrue(len(attr_types) != 0) # Internal attributes shouldn't be exposed. metadata_names = { "interpolation", "source", "bundlePrimIndexOffset", } self.assertTrue(metadata_names.isdisjoint(set(attr_names))) # Convert bundle to IBundle2 for metadata access. factory = ogc.IBundleFactory.create() bundle = factory.get_bundle(self.context, bundle) # Test metadata names. self.assertEqual( set(bundle.get_bundle_metadata_names()), {"bundlePrimIndexOffset"}, ) async def test_bundle_dirty_id(self): """Test whether bundleDirtyID bumps after graph evaluation.""" factory = ogc.IBundleFactory.create() # Get the output bundle from the importer and convert to IBundle2. output_bundle = self.context.get_output_bundle(self.importNode, "outputs_output") output_bundle = factory.get_bundle(self.context, output_bundle) # Get the input bundle from the exporter and convert to IBundle2. input_bundle = self.context.get_input_bundle(self.exportNode, "inputs:bundle") input_bundle = factory.get_bundle(self.context, input_bundle) # Trigger graph evaluation and wait for completion. await ogc.Controller.evaluate(self.graph) dirty_id = ogc._og_unstable.IDirtyID2.create(self.context) # noqa: PLW0212 # Get dirty id. output_dirty_id = dirty_id.get([output_bundle])[0] input_dirty_id = dirty_id.get([input_bundle])[0] # Trigger graph evaluation and wait for completion. await ogc.Controller.evaluate(self.graph) # The dirty id doesn't bump because nothing gets changed. self.assertEqual(output_dirty_id, dirty_id.get([output_bundle])[0]) self.assertEqual(input_dirty_id, dirty_id.get([input_bundle])[0]) # Assign new TRS values to the input prim. self.input_prim.GetAttribute("xformOp:translate").Set(self.TRANSLATE) self.input_prim.GetAttribute("xformOp:rotateXYZ").Set(self.ROTATE) self.input_prim.GetAttribute("xformOp:scale").Set(self.SCALE) # Trigger graph evaluation and wait for completion. await ogc.Controller.evaluate(self.graph) # The dirty id bumps because of TRS value changes. self.assertNotEqual(output_dirty_id, dirty_id.get([output_bundle])[0]) self.assertNotEqual(input_dirty_id, dirty_id.get([input_bundle])[0]) async def test_child_bundle_order(self): """Test whether the order of child bundles extracted from the output bundle is consistent with that of target prims.""" graph_path = "/TestGraph2" cubes = [("/cube_1", 1.0), ("/cube_2", 2.0), ("/cube_3", 3.0), ("/cube_4", 4.0)] attr_name = "size" controller = ogc.Controller() keys = ogc.Controller.Keys (graph, (_, output_node), _, _,) = controller.edit( graph_path, { keys.CREATE_NODES: [ ("import_usd_prim_data", "omni.graph.ImportUSDPrim"), ("bundle_to_usda_text", "omni.graph.BundleToUSDA"), ], keys.CONNECT: [ ("import_usd_prim_data.outputs_output", "bundle_to_usda_text.inputs:bundle"), ], keys.SET_VALUES: ("import_usd_prim_data.inputs:attrNamesToImport", attr_name), }, ) # Create target prims and assign the size attribute with different values. for cube_path, cube_size in cubes: prim = ogc.Controller.create_prim(cube_path, {}, "Cube") prim.GetAttribute(attr_name).Set(cube_size) # Assign the target prims to the import node. stage = omni.usd.get_context().get_stage() omni.kit.commands.execute( "SetRelationshipTargets", relationship=stage.GetPropertyAtPath(graph_path + "/import_usd_prim_data.inputs:prim"), targets=[cube_path for cube_path, _ in cubes], ) await ogc.Controller.evaluate(graph) expected_result = ( 'def Cube "cube_1"\n' "{\n" " double size = 1.00000000000000000e+00\n" ' token sourcePrimPath = "/cube_1"\n' ' token sourcePrimType = "Cube"\n' "}\n" 'def Cube "cube_2"\n' "{\n" " double size = 2.00000000000000000e+00\n" ' token sourcePrimPath = "/cube_2"\n' ' token sourcePrimType = "Cube"\n' "}\n" 'def Cube "cube_3"\n' "{\n" " double size = 3.00000000000000000e+00\n" ' token sourcePrimPath = "/cube_3"\n' ' token sourcePrimType = "Cube"\n' "}\n" 'def Cube "cube_4"\n' "{\n" " double size = 4.00000000000000000e+00\n" ' token sourcePrimPath = "/cube_4"\n' ' token sourcePrimType = "Cube"\n' "}\n" ) # Change timecode to trigger recompute. Run 60 times to eliminate random factor. for timecode in range(60): self.controller.edit( self.TEST_GRAPH_PATH, {ogc.Controller.Keys.SET_VALUES: ("import_usd_prim_data.inputs:usdTimecode", timecode)}, ) await ogc.Controller.evaluate(self.graph) output_attr = output_node.get_attribute("outputs:text") self.assertTrue(output_attr is not None and output_attr.is_valid()) self.assertEqual(output_attr.get(), expected_result)
omniverse-code/kit/exts/omni.graph.io/docs/CHANGELOG.md
# CHANGELOG This document records all notable changes to ``omni.graph.io`` extension. This project adheres to `Semantic Versioning <https://semver.org/>`_. <<<<<<< HEAD ======= ## [1.2.5] - 2022-11-18 ### Changed - Allow to be used in headless mode ## [1.2.3] - 2022-08-09 ### Fixed - Applied formatting to all of the Python files ## [1.2.2] - 2022-08-09 ### Fixed - Fixed backward compatibility break for the deprecated `IDirtyID` interface. ## [1.2.1] - 2022-08-03 ### Fixed - Compilation errors related to deprecation of methods in ogn bundle. ## [1.2.0] - 2022-07-28 ### Deprecated - Deprecated `IDirtyID` interface - Deprecated `BundleAttrib` class and `BundleAttribSource` enumeration - Deprecated `BundlePrim`, `BundlePrims`, `BundlePrimIterator` and `BundlePrimAttrIterator` - Deprecated `ConstBundlePrim`, `ConstBundlePrims`, `ConstBundlePrimIterator` and `ConstBundlePrimAttrIterator` ## [1.1.0] - 2022-07-07 ### Added - Test for public API consistency - Added build handling for tests module ## [1.0.10] - 2021-11-19 - Added option on ImportUsdPrim to include local bounding box of imported prims as a common attribute. - Fixed case where Import is not re-computed when a transform is needed and an ancestor prim's transform has changed. ## [1.0.9] - 2021-11-10 - Added option on ExportUSDPrim node type to remove, from output prims, any authored attributes that aren't being exported ## [1.0.8] - 2021-10-22 - Should be identical to 1.0.7, but incrementing the version number just in case, for logistical reasons ## [1.0.7] - 2021-10-14 - Added option to export time sampled data to specified time in ExportUSDPrim node type ## [1.0.6] - 2021-10-05 - Fixed re-importing of transforming attributes in ImportUSDPrim node type when transforms change ## [1.0.5] - 2021-09-24 - Added attribute-level change tracking to ImportUSDPrim node type ## [1.0.4] - 2021-09-16 - Added "Attributes to Import" and "Attributes to Export" to corresponding nodes to reduce confusion about how to import/export a subset of attributes - Added support for importing/exporting "widths" interpolation from USD ## [1.0.3] - 2021-08-18 - Updated for an ABI break in Kit ## [1.0.2] - 2021-08-17 - Fixed crash related to ImportUSDPrim node type and breaking change in Kit from eTransform being deprecated in favour of eMatrix ## [1.0.1] - 2021-08-13 - Fixed crash related to ImportUSDPrim node type ## [1.0.0] - 2021-07-27 ### Added - Initial version. Added ImportUSDPrim, ExportUSDPrim, TransformBundle, and BundleToUSDA node types.
omniverse-code/kit/exts/omni.graph.io/docs/README.md
# OmniGraph I/O [omni.graph.io] The OmniGraph I/O extension provides OmniGraph node types for dealing with collections of USD prims. ImportUSDPrim imports data from one or more USD prims, representing the collection as a single output bundle. ExportUSDPrim takes data from such a bundle as input and exports it to one or more USD prims. TransformBundle transforms transforming attributes in a bundle. BundleToUSDA outputs text representing the input bundle in a format similar to that of usda files.
omniverse-code/kit/exts/omni.graph.io/docs/index.rst
OmniGraph I/O ############# .. tabularcolumns:: |L|R| .. csv-table:: :width: 100% **Extension**: omni.graph.io,**Documentation Generated**: |today| .. toctree:: :maxdepth: 1 CHANGELOG
omniverse-code/kit/exts/omni.graph.io/docs/Overview.md
# OmniGraph I/O ```{csv-table} **Extension**: omni.graph.io,**Documentation Generated**: {sub-ref}`today` ```
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnGetCameraTarget.rst
.. _omni_graph_ui_nodes_GetCameraTarget_2: .. _omni_graph_ui_nodes_GetCameraTarget: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Get Camera Target :keywords: lang-en omnigraph node sceneGraph:camera threadsafe ui_nodes get-camera-target Get Camera Target ================= .. <description> Gets a viewport camera's target point. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:prim", "``target``", "The camera prim, when 'usePath' is false", "None" "Camera Path (*inputs:primPath*)", "``token``", "Path of the camera, used when 'usePath' is true", "" "inputs:usePath", "``bool``", "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", "True" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Target (*outputs:target*)", "``pointd[3]``", "The target point", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.GetCameraTarget" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Get Camera Target" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnGetCameraTargetDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadWindowSize.rst
.. _omni_graph_ui_nodes_ReadWindowSize_1: .. _omni_graph_ui_nodes_ReadWindowSize: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Window Size (BETA) :keywords: lang-en omnigraph node ui ReadOnly ui_nodes read-window-size Read Window Size (BETA) ======================= .. <description> Outputs the size of a UI window. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Viewport? (*inputs:isViewport*)", "``bool``", "If true then only viewport windows will be considered.", "False" "Name (*inputs:name*)", "``token``", "Name of the window. If there are multiple windows with the same name the first one found will be used.", "None" "Widget Path (*inputs:widgetPath*)", "``token``", "Full path to a widget in the window. If specified then 'name' will be ignored and the window containing the widget will be used.", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Height (*outputs:height*)", "``float``", "Height of the window in pixels.", "None" "Width (*outputs:width*)", "``float``", "Width of the window in pixels.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadWindowSize" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Window Size (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadWindowSizeDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnNewFrame.rst
.. _omni_graph_ui_nodes_OnNewFrame_1: .. _omni_graph_ui_nodes_OnNewFrame: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On New Frame :keywords: lang-en omnigraph node graph:action,event compute-on-request ui_nodes on-new-frame On New Frame ============ .. <description> Triggers when there is a new frame available for the given viewport. Note that the graph will run asynchronously to the new frame event .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:viewport", "``token``", "Name of the viewport, or empty for the default viewport", "" "", "*displayGroup*", "parameters", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:execOut", "``execution``", "Output Execution", "None" "outputs:frameNumber", "``int``", "The number of the frame which is available", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnNewFrame" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "True" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On New Frame" "Categories", "graph:action,event" "Generated Class Name", "OgnOnNewFrameDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnWidgetValueChanged.rst
.. _omni_graph_ui_nodes_OnWidgetValueChanged_1: .. _omni_graph_ui_nodes_OnWidgetValueChanged: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Widget Value Changed (BETA) :keywords: lang-en omnigraph node graph:action,ui compute-on-request ui_nodes on-widget-value-changed On Widget Value Changed (BETA) ============================== .. <description> Event node which fires when a UI widget with the specified identifier has its value changed. This node should be used in combination with UI creation nodes such as OgnSlider. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "A unique identifier identifying the widget. This should be specified in the UI creation node such as OgnSlider.", "" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "New Value (*outputs:newValue*)", "``['bool', 'float', 'int', 'string']``", "The new value of the widget", "None" "Value Changed (*outputs:valueChanged*)", "``execution``", "Executed when the value of the widget is changed", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnWidgetValueChanged" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "True" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Widget Value Changed (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnWidgetValueChangedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnViewportDragged.rst
.. _omni_graph_ui_nodes_OnViewportDragged_1: .. _omni_graph_ui_nodes_OnViewportDragged: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Viewport Dragged (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-viewport-dragged On Viewport Dragged (BETA) ========================== .. <description> Event node which fires when a viewport drag event occurs in the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport drag events", "Left Mouse Drag" "", "*displayGroup*", "parameters", "" "", "*literalOnly*", "1", "" "", "*allowedTokens*", "Left Mouse Drag,Right Mouse Drag,Middle Mouse Drag", "" "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played", "True" "", "*literalOnly*", "1", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of 2D position outputs are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "", "*literalOnly*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for drag events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Began (*outputs:began*)", "``execution``", "Enabled when the drag begins, populating 'Initial Position' with the current mouse position", "None" "Ended (*outputs:ended*)", "``execution``", "Enabled when the drag ends, populating 'Final Position' with the current mouse position", "None" "Final Position (*outputs:finalPosition*)", "``double[2]``", "The mouse position at which the drag ended (valid when 'Ended' is enabled)", "None" "Initial Position (*outputs:initialPosition*)", "``double[2]``", "The mouse position at which the drag began (valid when either 'Began' or 'Ended' is enabled)", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnViewportDragged" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Viewport Dragged (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnViewportDraggedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnPlacer.rst
.. _omni_graph_ui_nodes_Placer_1: .. _omni_graph_ui_nodes_Placer: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Placer (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes placer Placer (BETA) ============= .. <description> Contruct a Placer widget. The Placer takes a single child and places it at a given position within it. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget.", "" "Position (*inputs:position*)", "``double[2]``", "Where to position the child widget within the Placer.", "[0.0, 0.0]" "inputs:style", "``string``", "Style to be applied to the Placer and its child. This can later be changed with the WriteWidgetStyle node.", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created Placer widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.Placer" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Placer (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnPlacerDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetActiveViewportCamera.rst
.. _omni_graph_ui_nodes_SetActiveViewportCamera_1: .. _omni_graph_ui_nodes_SetActiveViewportCamera: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Active Camera :keywords: lang-en omnigraph node sceneGraph:camera ReadOnly ui_nodes set-active-viewport-camera Set Active Camera ================= .. <description> Sets Viewport's actively bound camera to given camera at give path .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "In (*inputs:execIn*)", "``execution``", "Execution input", "None" "Camera Path (*inputs:primPath*)", "``token``", "Path of the camera to bind", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Out (*outputs:execOut*)", "``execution``", "Execution Output", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetActiveViewportCamera" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Active Camera" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnSetActiveViewportCameraDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnPicked.rst
.. _omni_graph_ui_nodes_OnPicked_3: .. _omni_graph_ui_nodes_OnPicked: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Picked (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-picked On Picked (BETA) ================ .. <description> Event node which fires when a picking event occurs in the specified viewport. Note that picking events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger a picking event", "Left Mouse Click" "", "*displayGroup*", "parameters", "" "", "*literalOnly*", "1", "" "", "*allowedTokens*", "Left Mouse Click,Right Mouse Click,Middle Mouse Click,Left Mouse Press,Right Mouse Press,Middle Mouse Press", "" "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played.", "True" "", "*literalOnly*", "1", "" "Tracked Prims (*inputs:trackedPrims*)", "``target``", "Optionally specify a set of tracked prims that will cause 'Picked' to fire when picked", "None" "", "*literalOnly*", "1", "" "", "*allowMultiInputs*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for picking events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Tracked Prim Picked (*outputs:isTrackedPrimPicked*)", "``bool``", "True if a tracked prim got picked, or if any prim got picked if no tracked prims are specified (will always be true when 'Picked' fires, and false when 'Missed' fires)", "None" "Missed (*outputs:missed*)", "``execution``", "Enabled when an attempted picking did not pick a tracked prim, or when nothing gets picked if no tracked prims are specified", "None" "Picked (*outputs:picked*)", "``execution``", "Enabled when a tracked prim is picked, or when any prim is picked if no tracked prims are specified", "None" "Picked Prim (*outputs:pickedPrim*)", "``target``", "The picked prim, or an empty target if nothing got picked", "None" "Picked Prim Path (*outputs:pickedPrimPath*)", "``token``", "The path of the picked prim, or an empty string if nothing got picked", "None" "Picked World Position (*outputs:pickedWorldPos*)", "``pointd[3]``", "The XYZ-coordinates of the point in world space at which the prim got picked, or (0,0,0) if nothing got picked", "None" "Tracked Prim Paths (*outputs:trackedPrimPaths*)", "``token[]``", "A list of the paths of the prims specified in 'Tracked Prims'", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnPicked" "Version", "3" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Picked (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnPickedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnGetCameraPosition.rst
.. _omni_graph_ui_nodes_GetCameraPosition_2: .. _omni_graph_ui_nodes_GetCameraPosition: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Get Camera Position :keywords: lang-en omnigraph node sceneGraph:camera threadsafe ui_nodes get-camera-position Get Camera Position =================== .. <description> Gets a viewport camera position .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:prim", "``target``", "The camera prim, when 'usePath' is false", "None" "Camera Path (*inputs:primPath*)", "``token``", "Path of the camera, used when 'usePath' is true", "" "inputs:usePath", "``bool``", "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", "True" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Position (*outputs:position*)", "``pointd[3]``", "The position of the camera in world space", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.GetCameraPosition" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Get Camera Position" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnGetCameraPositionDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnDrawDebugCurve.rst
.. _omni_graph_ui_nodes_DrawDebugCurve_1: .. _omni_graph_ui_nodes_DrawDebugCurve: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Draw Debug Curve :keywords: lang-en omnigraph node debug ui_nodes draw-debug-curve Draw Debug Curve ================ .. <description> Given a set of curve points, draw a curve in the viewport .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Closed (*inputs:closed*)", "``bool``", "When true, connect the last point to the first", "False" "Color (*inputs:color*)", "``colorf[3]``", "The color of the curve", "[0.0, 0.0, 0.0]" "Curve Points (*inputs:curvepoints*)", "``double[3][]``", "The curve to be drawn", "[]" "In (*inputs:execIn*)", "``execution``", "Execution input", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Out (*outputs:execOut*)", "``execution``", "Execution Output", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.DrawDebugCurve" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Draw Debug Curve" "Categories", "debug" "Generated Class Name", "OgnDrawDebugCurveDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnViewportClicked.rst
.. _omni_graph_ui_nodes_OnViewportClicked_1: .. _omni_graph_ui_nodes_OnViewportClicked: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Viewport Clicked (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-viewport-clicked On Viewport Clicked (BETA) ========================== .. <description> Event node which fires when a viewport click event occurs in the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport click events", "Left Mouse Click" "", "*displayGroup*", "parameters", "" "", "*literalOnly*", "1", "" "", "*allowedTokens*", "Left Mouse Click,Right Mouse Click,Middle Mouse Click", "" "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played", "True" "", "*literalOnly*", "1", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of the 2D position output are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "", "*literalOnly*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for click events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Clicked (*outputs:clicked*)", "``execution``", "Enabled when the specified input gesture triggers a viewport click event in the specified viewport", "None" "Position (*outputs:position*)", "``double[2]``", "The position at which the viewport click event occurred", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnViewportClicked" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Viewport Clicked (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnViewportClickedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadViewportPressState.rst
.. _omni_graph_ui_nodes_ReadViewportPressState_1: .. _omni_graph_ui_nodes_ReadViewportPressState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Viewport Press State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-viewport-press-state Read Viewport Press State (BETA) ================================ .. <description> Read the state of the last viewport press event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport press events", "Left Mouse Press" "", "*displayGroup*", "parameters", "" "", "*allowedTokens*", "Left Mouse Press,Right Mouse Press,Middle Mouse Press", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of 2D position outputs are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for press events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Pressed (*outputs:isPressed*)", "``bool``", "True if the specified viewport is currently pressed", "None" "Is Release Position Valid (*outputs:isReleasePositionValid*)", "``bool``", "True if the press was released inside of the viewport, and false otherwise", "None" "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Press Position (*outputs:pressPosition*)", "``double[2]``", "The position at which the specified viewport was last pressed", "None" "Release Position (*outputs:releasePosition*)", "``double[2]``", "The position at which the last press on the specified viewport was released, or (0,0) if the press was released outside of the viewport or the viewport is currently pressed", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadViewportPressState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Viewport Press State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadViewportPressStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnGetViewportResolution.rst
.. _omni_graph_ui_nodes_GetViewportResolution_1: .. _omni_graph_ui_nodes_GetViewportResolution: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Get Viewport Resolution :keywords: lang-en omnigraph node viewport ui_nodes get-viewport-resolution Get Viewport Resolution ======================= .. <description> Gets the resolution of the target viewport. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Resolution (*outputs:resolution*)", "``int[2]``", "The resolution of the target viewport", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.GetViewportResolution" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Get Viewport Resolution" "Categories", "viewport" "Generated Class Name", "OgnGetViewportResolutionDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetCameraPosition.rst
.. _omni_graph_ui_nodes_SetCameraPosition_2: .. _omni_graph_ui_nodes_SetCameraPosition: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Camera Position :keywords: lang-en omnigraph node sceneGraph:camera WriteOnly ui_nodes set-camera-position Set Camera Position =================== .. <description> Sets the camera's position .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "In (*inputs:execIn*)", "``execution``", "Execution input", "None" "Position (*inputs:position*)", "``pointd[3]``", "The new position", "[0.0, 0.0, 0.0]" "inputs:prim", "``target``", "The camera prim, when 'usePath' is false", "None" "Camera Path (*inputs:primPath*)", "``token``", "Path of the camera, used when 'usePath' is true", "" "Rotate (*inputs:rotate*)", "``bool``", "True to keep position but change orientation and radius (camera moves to new position while still looking at the same target). False to keep orientation and radius but change position (camera moves to look at new target).", "True" "inputs:usePath", "``bool``", "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", "True" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Out (*outputs:execOut*)", "``execution``", "Execution Output", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetCameraPosition" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Camera Position" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnSetCameraPositionDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetViewportFullscreen.rst
.. _omni_graph_ui_nodes_SetViewportFullscreen_1: .. _omni_graph_ui_nodes_SetViewportFullscreen: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Viewport Fullscreen :keywords: lang-en omnigraph node graph:action,viewport WriteOnly ui_nodes set-viewport-fullscreen Set Viewport Fullscreen ======================= .. <description> Toggles fullscreen on/off for viewport(s) and visibility on/off for all other panes. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:exec", "``execution``", "The input execution", "None" "Mode (*inputs:mode*)", "``token``", "The mode to toggle fullscreen on/off for viewport(s) and visibility on/off for all other panes: ""Default"" - Windowed viewport(s) with all other panes shown. ""Fullscreen"" - Fullscreen viewport(s) with all other panes hidden. ""Hide UI"" - Windowed viewport(s) with all other panes hidden.", "Default" "", "*allowedTokens*", "Default,Fullscreen,Hide UI", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:exec", "``execution``", "The output execution", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetViewportFullscreen" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Viewport Fullscreen" "Categories", "graph:action,viewport" "Generated Class Name", "OgnSetViewportFullscreenDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSlider.rst
.. _omni_graph_ui_nodes_Slider_1: .. _omni_graph_ui_nodes_Slider: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Slider (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes slider Slider (BETA) ============= .. <description> Create a slider widget on the Viewport .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Disable (*inputs:disable*)", "``execution``", "Disable this button so that it cannot be pressed", "None" "Enable (*inputs:enable*)", "``execution``", "Enable this button after it has been disabled", "None" "Hide (*inputs:hide*)", "``execution``", "Input execution to hide the widget and all its child widgets", "None" "Max (*inputs:max*)", "``float``", "The maximum value of the slider", "0.0" "Min (*inputs:min*)", "``float``", "The minimum value of the slider", "0.0" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget. If empty, this widget will be created as a direct child of Viewport.", "None" "Show (*inputs:show*)", "``execution``", "Input execution to show the widget and all its child widgets after they become hidden", "None" "Step (*inputs:step*)", "``float``", "The step size of the slider", "0.01" "Tear Down (*inputs:tearDown*)", "``execution``", "Input execution to tear down the widget and all its child widgets", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" "Width (*inputs:width*)", "``double``", "The width of the created slider", "100.0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.Slider" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "hidden", "True" "uiName", "Slider (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnSliderDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadMouseState.rst
.. _omni_graph_ui_nodes_ReadMouseState_1: .. _omni_graph_ui_nodes_ReadMouseState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Mouse State :keywords: lang-en omnigraph node input:mouse threadsafe ui_nodes read-mouse-state Read Mouse State ================ .. <description> Reads the current state of the mouse. You can choose which mouse element this node is associated with. When mouse element is chosen to be a button, only outputs:isPressed is meaningful. When coordinates are chosen, only outputs:coords and outputs:window are meaningful. Pixel coordinates are the position of the mouse cursor in screen pixel units with (0,0) top left. Normalized coordinates are values between 0-1 where 0 is top/left and 1 is bottom/right. By default, coordinates are relative to the application window, but if 'Use Relative Coords' is set to true, then coordinates are relative to the workspace window containing the mouse pointer. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Mouse Element (*inputs:mouseElement*)", "``token``", "The mouse input to check the state of", "Left Button" "", "*displayGroup*", "parameters", "" "", "*allowedTokens*", "Left Button,Right Button,Middle Button,Forward Button,Back Button,Normalized Mouse Coordinates,Pixel Mouse Coordinates", "" "Use Relative Coords (*inputs:useRelativeCoords*)", "``bool``", "When true, the output 'coords' is made relative to the workspace window containing the mouse pointer instead of the entire application window", "False" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:coords", "``float[2]``", "The coordinates of the mouse. If the mouse element selected is a button, this will output a zero vector.", "None" "outputs:isPressed", "``bool``", "True if the button is currently pressed, false otherwise. If the mouse element selected is a coordinate, this will output false.", "None" "outputs:window", "``token``", "The name of the workspace window containing the mouse pointer if 'Use Relative Coords' is true and the mouse element selected is a coordinate", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadMouseState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Mouse State" "Categories", "input:mouse" "Generated Class Name", "OgnReadMouseStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetCameraTarget.rst
.. _omni_graph_ui_nodes_SetCameraTarget_2: .. _omni_graph_ui_nodes_SetCameraTarget: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Camera Target :keywords: lang-en omnigraph node sceneGraph:camera WriteOnly ui_nodes set-camera-target Set Camera Target ================= .. <description> Sets the camera's target .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "In (*inputs:execIn*)", "``execution``", "Execution input", "None" "inputs:prim", "``target``", "The camera prim, when 'usePath' is false", "None" "Camera Path (*inputs:primPath*)", "``token``", "Path of the camera, used when 'usePath' is true", "" "Rotate (*inputs:rotate*)", "``bool``", "True to keep position but change orientation and radius (camera rotates to look at new target). False to keep orientation and radius but change position (camera moves to look at new target).", "True" "Target (*inputs:target*)", "``pointd[3]``", "The target point", "[0.0, 0.0, 0.0]" "inputs:usePath", "``bool``", "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", "True" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Out (*outputs:execOut*)", "``execution``", "Execution Output", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetCameraTarget" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Camera Target" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnSetCameraTargetDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetViewportMode.rst
.. _omni_graph_ui_nodes_SetViewportMode_1: .. _omni_graph_ui_nodes_SetViewportMode: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Viewport Mode (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes set-viewport-mode Set Viewport Mode (BETA) ======================== .. <description> Sets the mode of a specified viewport window to 'Scripted' mode or 'Default' mode when executed. 'Scripted' mode disables default viewport interaction and enables placing UI elements over the viewport. 'Default' mode is the default state of the viewport, and entering it will destroy any UI elements on the viewport. Executing with 'Enable Viewport Mouse Events' set to true in 'Scripted' mode is required to allow the specified viewport to be targeted by viewport mouse event nodes, including 'On Viewport Dragged' and 'Read Viewport Drag State'. Executing with 'Enable Picking' set to true in 'Scripted' mode is required to allow the specified viewport to be targeted by the 'On Picked' and 'Read Pick State' nodes. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Enable Picking (*inputs:enablePicking*)", "``bool``", "Enable/Disable picking prims in the specified viewport when in 'Scripted' mode", "False" "Enable Viewport Mouse Events (*inputs:enableViewportMouseEvents*)", "``bool``", "Enable/Disable viewport mouse events on the specified viewport when in 'Scripted' mode", "False" "inputs:execIn", "``execution``", "Input execution", "None" "Mode (*inputs:mode*)", "``int``", "The mode to set the specified viewport to when this node is executed (0: 'Default', 1: 'Scripted')", "0" "Pass Clicks Thru (*inputs:passClicksThru*)", "``bool``", "Allow mouse clicks to affect the viewport while in 'Scripted' mode. In 'Scripted' mode mouse clicks are prevented from reaching the viewport to avoid accidentally selecting prims or interacting with the viewport's own UI. Setting this attribute true will allow clicks to reach the viewport. This is in addition to interacting with the widgets created by UI nodes so if a button widget appears on top of some geometry in the viewport, clicking on the button will not only trigger the button but could also select the geometry. To avoid this, put the button inside a Stack widget and use a WriteWidgetProperty node to set the Stack's 'content_clipping' property to 1.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to set the mode of", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Default Mode (*outputs:defaultMode*)", "``execution``", "Fires when this node is successfully executed with 'Mode' set to 'Default'", "None" "Scripted Mode (*outputs:scriptedMode*)", "``execution``", "Fires when this node is successfully executed with 'Mode' set to 'Scripted'", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "When the viewport enters 'Scripted' mode, a container widget is created under which other UI may be parented. This attribute provides the absolute path to that widget, which can be used as the 'parentWidgetPath' input to various UI nodes, such as Button. When the viewport exits 'Scripted' mode, the container widget and all the UI within it will be destroyed.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetViewportMode" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Viewport Mode (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnSetViewportModeDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadViewportDragState.rst
.. _omni_graph_ui_nodes_ReadViewportDragState_1: .. _omni_graph_ui_nodes_ReadViewportDragState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Viewport Drag State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-viewport-drag-state Read Viewport Drag State (BETA) =============================== .. <description> Read the state of the last viewport drag event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport drag events", "Left Mouse Drag" "", "*displayGroup*", "parameters", "" "", "*allowedTokens*", "Left Mouse Drag,Right Mouse Drag,Middle Mouse Drag", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of 2D position and velocity outputs are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for drag events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Current Position (*outputs:currentPosition*)", "``double[2]``", "The current mouse position if a drag is in progress, or the final mouse position of the most recent drag if a drag is not in progress", "None" "Initial Position (*outputs:initialPosition*)", "``double[2]``", "The mouse position at which the most recent drag began", "None" "Is Drag In Progress (*outputs:isDragInProgress*)", "``bool``", "True if a viewport drag event is currently in progress in the specified viewport", "None" "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Velocity (*outputs:velocity*)", "``double[2]``", "A vector representing the change in position of the mouse since the previous frame if a drag is in progress, otherwise (0,0)", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadViewportDragState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Viewport Drag State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadViewportDragStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetViewportRenderer.rst
.. _omni_graph_ui_nodes_SetViewportRenderer_1: .. _omni_graph_ui_nodes_SetViewportRenderer: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Viewport Renderer :keywords: lang-en omnigraph node graph:action,viewport ui_nodes set-viewport-renderer Set Viewport Renderer ===================== .. <description> Sets renderer for the target viewport. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:exec", "``execution``", "The input execution", "None" "Renderer (*inputs:renderer*)", "``token``", "Renderer to be assigned to the target viewport", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:exec", "``execution``", "The output execution", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetViewportRenderer" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Viewport Renderer" "Categories", "graph:action,viewport" "Generated Class Name", "OgnSetViewportRendererDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnComboBox.rst
.. _omni_graph_ui_nodes_ComboBox_1: .. _omni_graph_ui_nodes_ComboBox: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Combo Box (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes combo-box Combo Box (BETA) ================ .. <description> Create a combo box widget on the Viewport .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Disable (*inputs:disable*)", "``execution``", "Disable this button so that it cannot be pressed", "None" "Enable (*inputs:enable*)", "``execution``", "Enable this button after it has been disabled", "None" "Hide (*inputs:hide*)", "``execution``", "Input execution to hide the widget and all its child widgets", "None" "Item List (*inputs:itemList*)", "``token[]``", "A list of items that appears in the drop-down list", "[]" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget. If empty, this widget will be created as a direct child of Viewport.", "None" "Show (*inputs:show*)", "``execution``", "Input execution to show the widget and all its child widgets after they become hidden", "None" "Tear Down (*inputs:tearDown*)", "``execution``", "Input execution to tear down the widget and all its child widgets", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" "Width (*inputs:width*)", "``double``", "The width of the created combo box", "100.0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ComboBox" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "hidden", "True" "uiName", "Combo Box (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnComboBoxDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSetViewportResolution.rst
.. _omni_graph_ui_nodes_SetViewportResolution_1: .. _omni_graph_ui_nodes_SetViewportResolution: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Set Viewport Resolution :keywords: lang-en omnigraph node graph:action,viewport ui_nodes set-viewport-resolution Set Viewport Resolution ======================= .. <description> Sets the resolution of the target viewport. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:exec", "``execution``", "The input execution", "None" "Resolution (*inputs:resolution*)", "``int[2]``", "The new resolution of the target viewport", "[512, 512]" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:exec", "``execution``", "The output execution", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.SetViewportResolution" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Set Viewport Resolution" "Categories", "graph:action,viewport" "Generated Class Name", "OgnSetViewportResolutionDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnGetActiveViewportCamera.rst
.. _omni_graph_ui_nodes_GetActiveViewportCamera_2: .. _omni_graph_ui_nodes_GetActiveViewportCamera: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Get Active Camera :keywords: lang-en omnigraph node sceneGraph:camera ui_nodes get-active-viewport-camera Get Active Camera ================= .. <description> Gets the path of the camera bound to a viewport .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Camera (*outputs:camera*)", "``token``", "Path of the active camera", "None" "Camera Prim (*outputs:cameraPrim*)", "``target``", "The prim of the active camera", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.GetActiveViewportCamera" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Get Active Camera" "Categories", "sceneGraph:camera" "Generated Class Name", "OgnGetActiveViewportCameraDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnSpacer.rst
.. _omni_graph_ui_nodes_Spacer_1: .. _omni_graph_ui_nodes_Spacer: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Spacer (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes spacer Spacer (BETA) ============= .. <description> A widget that leaves empty space. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Height (*inputs:height*)", "``int``", "The amount of vertical space to leave, in pixels.", "0" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget.", "" "inputs:style", "``string``", "Style to be applied to the spacer. This can later be changed with the WriteWidgetStyle node.", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" "Width (*inputs:width*)", "``int``", "The amount of horizontal space to leave, in pixels.", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.Spacer" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Spacer (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnSpacerDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadPickState.rst
.. _omni_graph_ui_nodes_ReadPickState_2: .. _omni_graph_ui_nodes_ReadPickState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Pick State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-pick-state Read Pick State (BETA) ====================== .. <description> Read the state of the last picking event from the specified viewport. Note that picking events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger a picking event", "Left Mouse Click" "", "*displayGroup*", "parameters", "" "", "*allowedTokens*", "Left Mouse Click,Right Mouse Click,Middle Mouse Click,Left Mouse Press,Right Mouse Press,Middle Mouse Press", "" "Tracked Prim Paths (*inputs:trackedPrimPaths*)", "``token[]``", "Optionally specify a set of prims (by paths) to track whether or not they got picked (only affects the value of 'Is Tracked Prim Picked')", "None" "Tracked Prims (*inputs:trackedPrims*)", "``target``", "Optionally specify a set of prims to track whether or not they got picked (only affects the value of 'Is Tracked Prim Picked')", "None" "", "*allowMultiInputs*", "1", "" "Use Paths (*inputs:usePaths*)", "``bool``", "When true, 'Tracked Prim Paths' is used, otherwise 'Tracked Prims' is used", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for picking events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Tracked Prim Picked (*outputs:isTrackedPrimPicked*)", "``bool``", "True if a tracked prim got picked in the last picking event, or if any prim got picked if no tracked prims are specified", "None" "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Picked Prim (*outputs:pickedPrim*)", "``target``", "The picked prim, or an empty target if nothing got picked", "None" "Picked Prim Path (*outputs:pickedPrimPath*)", "``token``", "The path of the prim picked in the last picking event, or an empty string if nothing got picked", "None" "Picked World Position (*outputs:pickedWorldPos*)", "``pointd[3]``", "The XYZ-coordinates of the point in world space at which the prim got picked, or (0,0,0) if nothing got picked", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadPickState" "Version", "2" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Pick State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadPickStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnButton.rst
.. _omni_graph_ui_nodes_Button_1: .. _omni_graph_ui_nodes_Button: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Button (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes button Button (BETA) ============= .. <description> Create a button widget on the Viewport .. </description> Here is an example of a button that was created using the text ``Press Me``: .. image:: ../../../../../source/extensions/omni.graph.ui_nodes/docs/PressMe.png :alt: "Press Me" Button Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget.", "" "Size (*inputs:size*)", "``double[2]``", "The width and height of the created widget. Value of 0 means the created widget will be just large enough to fit everything.", "[0.0, 0.0]" "Start Hidden (*inputs:startHidden*)", "``bool``", "Determines whether the button will initially be visible (False) or not (True).", "False" "inputs:style", "``string``", "Style to be applied to the button. This can later be changed with the WriteWidgetStyle node.", "None" "Text (*inputs:text*)", "``string``", "The text that is displayed on the button", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.Button" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Button (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnButtonDatabase" "Python Module", "omni.graph.ui_nodes" Further information on the button operation can be found in the documentation of :py:class:`omni.ui.Button`.
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnWriteWidgetProperty.rst
.. _omni_graph_ui_nodes_WriteWidgetProperty_1: .. _omni_graph_ui_nodes_WriteWidgetProperty: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Write Widget Property (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes write-widget-property Write Widget Property (BETA) ============================ .. <description> Set the value of a widget's property (height, tooltip, etc). .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Property Name (*inputs:propertyName*)", "``token``", "Name of the property to write to.", "" "Value (*inputs:value*)", "``any``", "The value to write to the property.", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "Unique identifier for the widget. This is only valid within the current graph.", "" "Widget Path (*inputs:widgetPath*)", "``token``", "Full path to the widget. If present this will be used insted of 'widgetIdentifier'. Unlike 'widgetIdentifier' this is valid across all graphs.", "" "Write (*inputs:write*)", "``execution``", "Input execution to write the value to the widget's property.", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:written", "``execution``", "Executed when the value has been successfully written.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.WriteWidgetProperty" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Write Widget Property (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnWriteWidgetPropertyDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnPrintText.rst
.. _omni_graph_ui_nodes_PrintText_1: .. _omni_graph_ui_nodes_PrintText: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Print Text :keywords: lang-en omnigraph node debug ui_nodes print-text Print Text ========== .. <description> Prints some text to the system log or to the screen .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "In (*inputs:execIn*)", "``execution``", "Execution input", "None" "Log Level (*inputs:logLevel*)", "``token``", "The logging level for the message [Info, Warning, Error]", "Info" "", "*allowedTokens*", "Info,Warning,Error", "" "Text (*inputs:text*)", "``string``", "The text to print", "" "To Screen (*inputs:toScreen*)", "``bool``", "When true, displays the text on the viewport for a few seconds, as well as the log", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport if printing to screen, or empty for the default viewport", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Out (*outputs:execOut*)", "``execution``", "Execution Output", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.PrintText" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "tags", "logging,toast,debug" "uiName", "Print Text" "Categories", "debug" "Generated Class Name", "OgnPrintTextDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnWidgetClicked.rst
.. _omni_graph_ui_nodes_OnWidgetClicked_1: .. _omni_graph_ui_nodes_OnWidgetClicked: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Widget Clicked (BETA) :keywords: lang-en omnigraph node graph:action,ui compute-on-request ui_nodes on-widget-clicked On Widget Clicked (BETA) ======================== .. <description> Event node which fires when a UI widget with the specified identifier is clicked. This node should be used in combination with UI creation nodes such as OgnButton. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "A unique identifier identifying the widget. This should be specified in the UI creation node such as OgnButton.", "" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Clicked (*outputs:clicked*)", "``execution``", "Executed when the widget is clicked", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnWidgetClicked" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "True" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Widget Clicked (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnWidgetClickedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnVStack.rst
.. _omni_graph_ui_nodes_VStack_1: .. _omni_graph_ui_nodes_VStack: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Stack (BETA) :keywords: lang-en omnigraph node graph:action,ui ui_nodes v-stack Stack (BETA) ============ .. <description> Contruct a Stack on the Viewport. All child widgets of Stack will be placed in a row, column or layer based on the direction input. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Create (*inputs:create*)", "``execution``", "Input execution to create and show the widget", "None" "Direction (*inputs:direction*)", "``token``", "The direction the widgets will be stacked.", "TOP_TO_BOTTOM" "", "*allowedTokens*", "BACK_TO_FRONT,BOTTOM_TO_TOP,FRONT_TO_BACK,LEFT_TO_RIGHT,RIGHT_TO_LEFT,TOP_TO_BOTTOM", "" "Parent Widget Path (*inputs:parentWidgetPath*)", "``token``", "The absolute path to the parent widget.", "" "inputs:style", "``string``", "Style to be applied to the stack and its children. This can later be changed with the WriteWidgetStyle node.", "None" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "An optional unique identifier for the widget. Can be used to refer to this widget in other places such as the OnWidgetClicked node.", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Created (*outputs:created*)", "``execution``", "Executed when the widget is created", "None" "Widget Path (*outputs:widgetPath*)", "``token``", "The absolute path to the created widget", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.VStack" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Stack (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnVStackDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadViewportHoverState.rst
.. _omni_graph_ui_nodes_ReadViewportHoverState_1: .. _omni_graph_ui_nodes_ReadViewportHoverState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Viewport Hover State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-viewport-hover-state Read Viewport Hover State (BETA) ================================ .. <description> Read the state of the last viewport hover event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of 2D position and velocity outputs are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for hover events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Hovered (*outputs:isHovered*)", "``bool``", "True if the specified viewport is currently hovered", "None" "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Position (*outputs:position*)", "``double[2]``", "The current mouse position if the specified viewport is currently hovered, otherwise (0,0)", "None" "Velocity (*outputs:velocity*)", "``double[2]``", "A vector representing the change in position of the mouse since the previous frame if the specified viewport is currently hovered, otherwise (0,0)", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadViewportHoverState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Viewport Hover State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadViewportHoverStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadViewportClickState.rst
.. _omni_graph_ui_nodes_ReadViewportClickState_1: .. _omni_graph_ui_nodes_ReadViewportClickState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Viewport Click State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-viewport-click-state Read Viewport Click State (BETA) ================================ .. <description> Read the state of the last viewport click event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport click events", "Left Mouse Click" "", "*displayGroup*", "parameters", "" "", "*allowedTokens*", "Left Mouse Click,Right Mouse Click,Middle Mouse Click", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of the 2D position output are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for click events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Position (*outputs:position*)", "``double[2]``", "The position at which the specified input gesture last triggered a viewport click event in the specified viewport", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadViewportClickState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Viewport Click State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadViewportClickStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnGetViewportRenderer.rst
.. _omni_graph_ui_nodes_GetViewportRenderer_1: .. _omni_graph_ui_nodes_GetViewportRenderer: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Get Viewport Renderer :keywords: lang-en omnigraph node viewport ui_nodes get-viewport-renderer Get Viewport Renderer ===================== .. <description> Gets the renderer being used by the target viewport. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Renderer (*outputs:renderer*)", "``token``", "The renderer being used by the target viewport", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.GetViewportRenderer" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Get Viewport Renderer" "Categories", "viewport" "Generated Class Name", "OgnGetViewportRendererDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnWriteWidgetStyle.rst
.. _omni_graph_ui_nodes_WriteWidgetStyle_1: .. _omni_graph_ui_nodes_WriteWidgetStyle: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Write Widget Style (BETA) :keywords: lang-en omnigraph node graph:action,ui ReadOnly ui_nodes write-widget-style Write Widget Style (BETA) ========================= .. <description> Sets a widget's style properties. This node should be used in combination with UI creation nodes such as Button. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:style", "``string``", "The style to set the widget to.", "" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "A unique identifier identifying the widget. This is only valid within the current graph. This should be specified in the UI creation node such as OgnButton.", "" "Widget Path (*inputs:widgetPath*)", "``token``", "Full path to the widget. If present this will be used insted of 'widgetIdentifier'. Unlike 'widgetIdentifier' this is valid across all graphs.", "" "inputs:write", "``execution``", "Input execution", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:written", "``execution``", "Output execution", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.WriteWidgetStyle" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Write Widget Style (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnWriteWidgetStyleDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnViewportHovered.rst
.. _omni_graph_ui_nodes_OnViewportHovered_1: .. _omni_graph_ui_nodes_OnViewportHovered: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Viewport Hovered (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-viewport-hovered On Viewport Hovered (BETA) ========================== .. <description> Event node which fires when the specified viewport is hovered over. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played", "True" "", "*literalOnly*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for hover events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Began (*outputs:began*)", "``execution``", "Enabled when the hover begins", "None" "Ended (*outputs:ended*)", "``execution``", "Enabled when the hover ends", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnViewportHovered" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Viewport Hovered (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnViewportHoveredDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnViewportScrolled.rst
.. _omni_graph_ui_nodes_OnViewportScrolled_1: .. _omni_graph_ui_nodes_OnViewportScrolled: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Viewport Scrolled (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-viewport-scrolled On Viewport Scrolled (BETA) =========================== .. <description> Event node which fires when a viewport scroll event occurs in the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played", "True" "", "*literalOnly*", "1", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of the 2D position output are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "", "*literalOnly*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for scroll events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Position (*outputs:position*)", "``double[2]``", "The position at which the viewport scroll event occurred", "None" "Scroll Value (*outputs:scrollValue*)", "``float``", "The number of mouse wheel clicks scrolled up if positive, or scrolled down if negative", "None" "Scrolled (*outputs:scrolled*)", "``execution``", "Enabled when a viewport scroll event occurs in the specified viewport", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnViewportScrolled" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Viewport Scrolled (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnViewportScrolledDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnOnViewportPressed.rst
.. _omni_graph_ui_nodes_OnViewportPressed_1: .. _omni_graph_ui_nodes_OnViewportPressed: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: On Viewport Pressed (BETA) :keywords: lang-en omnigraph node graph:action,ui threadsafe compute-on-request ui_nodes on-viewport-pressed On Viewport Pressed (BETA) ========================== .. <description> Event node which fires when the specified viewport is pressed, and when that press is released. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Gesture (*inputs:gesture*)", "``token``", "The input gesture to trigger viewport press events", "Left Mouse Press" "", "*displayGroup*", "parameters", "" "", "*literalOnly*", "1", "" "", "*allowedTokens*", "Left Mouse Press,Right Mouse Press,Middle Mouse Press", "" "Only Simulate On Play (*inputs:onlyPlayback*)", "``bool``", "When true, the node is only computed while Stage is being played", "True" "", "*literalOnly*", "1", "" "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of 2D position outputs are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "", "*literalOnly*", "1", "" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for press events", "Viewport" "", "*literalOnly*", "1", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Release Position Valid (*outputs:isReleasePositionValid*)", "``bool``", "True if the press was released inside of the viewport, and false otherwise", "None" "Press Position (*outputs:pressPosition*)", "``double[2]``", "The position at which the viewport was pressed (valid when either 'Pressed' or 'Released' is enabled)", "None" "Pressed (*outputs:pressed*)", "``execution``", "Enabled when the specified viewport is pressed, populating 'Press Position' with the current mouse position", "None" "Release Position (*outputs:releasePosition*)", "``double[2]``", "The position at which the press was released, or (0,0) if the press was released outside of the viewport or the viewport is currently pressed (valid when 'Ended' is enabled and 'Is Release Position Valid' is true)", "None" "Released (*outputs:released*)", "``execution``", "Enabled when the press is released, populating 'Release Position' with the current mouse position and setting 'Is Release Position Valid' to true if the press is released inside of the viewport. If the press is released outside of the viewport, 'Is Release Position Valid' is set to false and 'Release Position' is set to (0,0).", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.OnViewportPressed" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "On Viewport Pressed (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnOnViewportPressedDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadViewportScrollState.rst
.. _omni_graph_ui_nodes_ReadViewportScrollState_1: .. _omni_graph_ui_nodes_ReadViewportScrollState: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Viewport Scroll State (BETA) :keywords: lang-en omnigraph node ui threadsafe ui_nodes read-viewport-scroll-state Read Viewport Scroll State (BETA) ================================= .. <description> Read the state of the last viewport scroll event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Use Normalized Coords (*inputs:useNormalizedCoords*)", "``bool``", "When true, the components of the 2D position output are scaled to between 0 and 1, where 0 is top/left and 1 is bottom/right. When false, components are in viewport render resolution pixels.", "False" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport window to watch for scroll events", "Viewport" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Is Valid (*outputs:isValid*)", "``bool``", "True if a valid event state was detected and the outputs of this node are valid, and false otherwise", "None" "Position (*outputs:position*)", "``double[2]``", "The last position at which a viewport scroll event occurred in the specified viewport", "None" "Scroll Value (*outputs:scrollValue*)", "``float``", "The number of mouse wheel clicks scrolled up if positive, or scrolled down if negative", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadViewportScrollState" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Viewport Scroll State (BETA)" "Categories", "ui" "Generated Class Name", "OgnReadViewportScrollStateDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnLockViewportRender.rst
.. _omni_graph_ui_nodes_LockViewportRender_1: .. _omni_graph_ui_nodes_LockViewportRender: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Lock Viewport Render :keywords: lang-en omnigraph node graph:action,viewport ui_nodes lock-viewport-render Lock Viewport Render ==================== .. <description> Locks and unlocks viewport render. Viewport render is frozen at the frame when it is locked, while computation and UI update are still executed as normal. It fades out back to the current frame when it is unlocked, two output execution attributes - fadeStarted and fadeComplete - will be triggered separately during the fading progress. The node manages the lock state for its target viewport and takes action according to the lock state when an input execution attribute is triggered. A node is able to unlock the target viewort only if it has locked the target viewport. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Fade Time (*inputs:fadeTime*)", "``double``", "The duration of fading in time (seconds) when being unlocked", "1.0" "inputs:lock", "``execution``", "The input execution attribute for locking viewport render", "None" "inputs:unlock", "``execution``", "The input execution attribute for unlocking viewport render", "None" "Viewport (*inputs:viewport*)", "``token``", "Name of the viewport, or empty for the default viewport", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:fadeComplete", "``execution``", "Triggered when fading is complete", "None" "outputs:fadeStarted", "``execution``", "Triggered when fading is started", "None" "outputs:locked", "``execution``", "Triggered when viewport render is locked", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.LockViewportRender" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Lock Viewport Render" "Categories", "graph:action,viewport" "Generated Class Name", "OgnLockViewportRenderDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/ogn/docs/OgnReadWidgetProperty.rst
.. _omni_graph_ui_nodes_ReadWidgetProperty_1: .. _omni_graph_ui_nodes_ReadWidgetProperty: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Read Widget Property (BETA) :keywords: lang-en omnigraph node graph:action,ui WriteOnly ui_nodes read-widget-property Read Widget Property (BETA) =========================== .. <description> Read the value of a widget's property (height, tooltip, etc). .. </description> Installation ------------ To use this node enable :ref:`omni.graph.ui_nodes<ext_omni_graph_ui_nodes>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Property Name (*inputs:propertyName*)", "``token``", "Name of the property to read.", "" "Widget Identifier (*inputs:widgetIdentifier*)", "``token``", "Unique identifier for the widget. This is only valid within the current graph.", "" "Widget Path (*inputs:widgetPath*)", "``token``", "Full path to the widget. If present this will be used insted of 'widgetIdentifier'. Unlike 'widgetIdentifier' this is valid across all graphs.", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Value (*outputs:value*)", "``['bool', 'double', 'int', 'string']``", "The value of the property.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.ui_nodes.ReadWidgetProperty" "Version", "1" "Extension", "omni.graph.ui_nodes" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "tests" "uiName", "Read Widget Property (BETA)" "Categories", "graph:action,ui" "Generated Class Name", "OgnReadWidgetPropertyDatabase" "Python Module", "omni.graph.ui_nodes"
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/__init__.py
"""There is no public API to this module.""" __all__ = [] from ._impl.extension import _PublicExtension # noqa: F401
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnGetViewportResolutionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.GetViewportResolution Gets the resolution of the target viewport. """ import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetViewportResolutionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.GetViewportResolution Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.viewport Outputs: outputs.resolution """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport, or empty for the default viewport', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:resolution', 'int2', 0, 'Resolution', 'The resolution of the target viewport', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"viewport", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.viewport] self._batchedReadValues = ["Viewport"] @property def viewport(self): return self._batchedReadValues[0] @viewport.setter def viewport(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"resolution", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def resolution(self): value = self._batchedWriteValues.get(self._attributes.resolution) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.resolution) return data_view.get() @resolution.setter def resolution(self, value): self._batchedWriteValues[self._attributes.resolution] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnGetViewportResolutionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetViewportResolutionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetViewportResolutionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.GetViewportResolution' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnGetViewportResolutionDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnGetViewportResolutionDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnGetViewportResolutionDatabase(node) try: compute_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnGetViewportResolutionDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnGetViewportResolutionDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnGetViewportResolutionDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnGetViewportResolutionDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Get Viewport Resolution") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "viewport") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Gets the resolution of the target viewport.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnGetViewportResolutionDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnGetViewportResolutionDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnGetViewportResolutionDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.GetViewportResolution")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadViewportPressStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportPressState Read the state of the last viewport press event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadViewportPressStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportPressState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.useNormalizedCoords inputs.viewport Outputs: outputs.isPressed outputs.isReleasePositionValid outputs.isValid outputs.pressPosition outputs.releasePosition Predefined Tokens: tokens.LeftMouseDrag tokens.RightMouseDrag tokens.MiddleMouseDrag """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger viewport press events', {'displayGroup': 'parameters', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Press,Right Mouse Press,Middle Mouse Press', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseDrag": "Left Mouse Press", "RightMouseDrag": "Right Mouse Press", "MiddleMouseDrag": "Middle Mouse Press"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Press"'}, True, "Left Mouse Press", False, ''), ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of 2D position outputs are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for press events', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isPressed', 'bool', 0, 'Is Pressed', 'True if the specified viewport is currently pressed', {}, True, None, False, ''), ('outputs:isReleasePositionValid', 'bool', 0, 'Is Release Position Valid', 'True if the press was released inside of the viewport, and false otherwise', {}, True, None, False, ''), ('outputs:isValid', 'bool', 0, 'Is Valid', 'True if a valid event state was detected and the outputs of this node are valid, and false otherwise', {}, True, None, False, ''), ('outputs:pressPosition', 'double2', 0, 'Press Position', 'The position at which the specified viewport was last pressed', {}, True, None, False, ''), ('outputs:releasePosition', 'double2', 0, 'Release Position', 'The position at which the last press on the specified viewport was released,\nor (0,0) if the press was released outside of the viewport or the viewport is currently pressed', {}, True, None, False, ''), ]) class tokens: LeftMouseDrag = "Left Mouse Press" RightMouseDrag = "Right Mouse Press" MiddleMouseDrag = "Middle Mouse Press" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def isPressed(self): data_view = og.AttributeValueHelper(self._attributes.isPressed) return data_view.get() @isPressed.setter def isPressed(self, value): data_view = og.AttributeValueHelper(self._attributes.isPressed) data_view.set(value) @property def isReleasePositionValid(self): data_view = og.AttributeValueHelper(self._attributes.isReleasePositionValid) return data_view.get() @isReleasePositionValid.setter def isReleasePositionValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isReleasePositionValid) data_view.set(value) @property def isValid(self): data_view = og.AttributeValueHelper(self._attributes.isValid) return data_view.get() @isValid.setter def isValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isValid) data_view.set(value) @property def pressPosition(self): data_view = og.AttributeValueHelper(self._attributes.pressPosition) return data_view.get() @pressPosition.setter def pressPosition(self, value): data_view = og.AttributeValueHelper(self._attributes.pressPosition) data_view.set(value) @property def releasePosition(self): data_view = og.AttributeValueHelper(self._attributes.releasePosition) return data_view.get() @releasePosition.setter def releasePosition(self, value): data_view = og.AttributeValueHelper(self._attributes.releasePosition) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadViewportPressStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadViewportPressStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadViewportPressStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnGetCameraTargetDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.GetCameraTarget Gets a viewport camera's target point. """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetCameraTargetDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.GetCameraTarget Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.primPath inputs.usePath Outputs: outputs.target """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:prim', 'target', 0, None, "The camera prim, when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, 'Camera Path', "Path of the camera, used when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:target', 'point3d', 0, 'Target', 'The target point', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.prim = og.AttributeRole.TARGET role_data.outputs.target = og.AttributeRole.POSITION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def target(self): data_view = og.AttributeValueHelper(self._attributes.target) return data_view.get() @target.setter def target(self, value): data_view = og.AttributeValueHelper(self._attributes.target) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnGetCameraTargetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetCameraTargetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetCameraTargetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnViewportHoveredDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportHovered Event node which fires when the specified viewport is hovered over. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnViewportHoveredDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportHovered Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.onlyPlayback inputs.viewport Outputs: outputs.began outputs.ended """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:onlyPlayback', 'bool', 0, 'Only Simulate On Play', 'When true, the node is only computed while Stage is being played', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for hover events', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:began', 'execution', 0, 'Began', 'Enabled when the hover begins', {}, True, None, False, ''), ('outputs:ended', 'execution', 0, 'Ended', 'Enabled when the hover ends', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.began = og.AttributeRole.EXECUTION role_data.outputs.ended = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def onlyPlayback(self): data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) return data_view.get() @onlyPlayback.setter def onlyPlayback(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyPlayback) data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def began(self): data_view = og.AttributeValueHelper(self._attributes.began) return data_view.get() @began.setter def began(self, value): data_view = og.AttributeValueHelper(self._attributes.began) data_view.set(value) @property def ended(self): data_view = og.AttributeValueHelper(self._attributes.ended) return data_view.get() @ended.setter def ended(self, value): data_view = og.AttributeValueHelper(self._attributes.ended) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnViewportHoveredDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnViewportHoveredDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnViewportHoveredDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnViewportPressedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportPressed Event node which fires when the specified viewport is pressed, and when that press is released. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnViewportPressedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportPressed Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.onlyPlayback inputs.useNormalizedCoords inputs.viewport Outputs: outputs.isReleasePositionValid outputs.pressPosition outputs.pressed outputs.releasePosition outputs.released Predefined Tokens: tokens.LeftMouseDrag tokens.RightMouseDrag tokens.MiddleMouseDrag """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger viewport press events', {'displayGroup': 'parameters', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Press,Right Mouse Press,Middle Mouse Press', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseDrag": "Left Mouse Press", "RightMouseDrag": "Right Mouse Press", "MiddleMouseDrag": "Middle Mouse Press"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Press"'}, True, "Left Mouse Press", False, ''), ('inputs:onlyPlayback', 'bool', 0, 'Only Simulate On Play', 'When true, the node is only computed while Stage is being played', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of 2D position outputs are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for press events', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isReleasePositionValid', 'bool', 0, 'Is Release Position Valid', 'True if the press was released inside of the viewport, and false otherwise', {}, True, None, False, ''), ('outputs:pressPosition', 'double2', 0, 'Press Position', "The position at which the viewport was pressed (valid when either 'Pressed' or 'Released' is enabled)", {}, True, None, False, ''), ('outputs:pressed', 'execution', 0, 'Pressed', "Enabled when the specified viewport is pressed, populating 'Press Position' with the current mouse position", {}, True, None, False, ''), ('outputs:releasePosition', 'double2', 0, 'Release Position', "The position at which the press was released, or (0,0) if the press was released outside of the viewport\nor the viewport is currently pressed (valid when 'Ended' is enabled and 'Is Release Position Valid' is true)", {}, True, None, False, ''), ('outputs:released', 'execution', 0, 'Released', "Enabled when the press is released, populating 'Release Position' with the current mouse position\nand setting 'Is Release Position Valid' to true if the press is released inside of the viewport.\nIf the press is released outside of the viewport, 'Is Release Position Valid' is set to false\nand 'Release Position' is set to (0,0).", {}, True, None, False, ''), ]) class tokens: LeftMouseDrag = "Left Mouse Press" RightMouseDrag = "Right Mouse Press" MiddleMouseDrag = "Middle Mouse Press" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.pressed = og.AttributeRole.EXECUTION role_data.outputs.released = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def onlyPlayback(self): data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) return data_view.get() @onlyPlayback.setter def onlyPlayback(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyPlayback) data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) data_view.set(value) @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def isReleasePositionValid(self): data_view = og.AttributeValueHelper(self._attributes.isReleasePositionValid) return data_view.get() @isReleasePositionValid.setter def isReleasePositionValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isReleasePositionValid) data_view.set(value) @property def pressPosition(self): data_view = og.AttributeValueHelper(self._attributes.pressPosition) return data_view.get() @pressPosition.setter def pressPosition(self, value): data_view = og.AttributeValueHelper(self._attributes.pressPosition) data_view.set(value) @property def pressed(self): data_view = og.AttributeValueHelper(self._attributes.pressed) return data_view.get() @pressed.setter def pressed(self, value): data_view = og.AttributeValueHelper(self._attributes.pressed) data_view.set(value) @property def releasePosition(self): data_view = og.AttributeValueHelper(self._attributes.releasePosition) return data_view.get() @releasePosition.setter def releasePosition(self, value): data_view = og.AttributeValueHelper(self._attributes.releasePosition) data_view.set(value) @property def released(self): data_view = og.AttributeValueHelper(self._attributes.released) return data_view.get() @released.setter def released(self, value): data_view = og.AttributeValueHelper(self._attributes.released) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnViewportPressedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnViewportPressedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnViewportPressedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadPickStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadPickState Read the state of the last picking event from the specified viewport. Note that picking events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadPickStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadPickState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.trackedPrimPaths inputs.trackedPrims inputs.usePaths inputs.viewport Outputs: outputs.isTrackedPrimPicked outputs.isValid outputs.pickedPrim outputs.pickedPrimPath outputs.pickedWorldPos Predefined Tokens: tokens.LeftMouseClick tokens.RightMouseClick tokens.MiddleMouseClick tokens.LeftMousePress tokens.RightMousePress tokens.MiddleMousePress """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger a picking event', {'displayGroup': 'parameters', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Click,Right Mouse Click,Middle Mouse Click,Left Mouse Press,Right Mouse Press,Middle Mouse Press', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseClick": "Left Mouse Click", "RightMouseClick": "Right Mouse Click", "MiddleMouseClick": "Middle Mouse Click", "LeftMousePress": "Left Mouse Press", "RightMousePress": "Right Mouse Press", "MiddleMousePress": "Middle Mouse Press"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Click"'}, True, "Left Mouse Click", False, ''), ('inputs:trackedPrimPaths', 'token[]', 0, 'Tracked Prim Paths', "Optionally specify a set of prims (by paths) to track whether or not they got picked\n(only affects the value of 'Is Tracked Prim Picked')", {}, False, None, True, 'Use the trackedPrims input instead'), ('inputs:trackedPrims', 'target', 0, 'Tracked Prims', "Optionally specify a set of prims to track whether or not they got picked\n(only affects the value of 'Is Tracked Prim Picked')", {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, False, [], False, ''), ('inputs:usePaths', 'bool', 0, 'Use Paths', "When true, 'Tracked Prim Paths' is used, otherwise 'Tracked Prims' is used", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for picking events', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isTrackedPrimPicked', 'bool', 0, 'Is Tracked Prim Picked', 'True if a tracked prim got picked in the last picking event,\nor if any prim got picked if no tracked prims are specified', {}, True, None, False, ''), ('outputs:isValid', 'bool', 0, 'Is Valid', 'True if a valid event state was detected and the outputs of this node are valid, and false otherwise', {}, True, None, False, ''), ('outputs:pickedPrim', 'target', 0, 'Picked Prim', 'The picked prim, or an empty target if nothing got picked', {}, True, [], False, ''), ('outputs:pickedPrimPath', 'token', 0, 'Picked Prim Path', 'The path of the prim picked in the last picking event, or an empty string if nothing got picked', {}, True, None, True, 'Use the pickedPrim output instead'), ('outputs:pickedWorldPos', 'point3d', 0, 'Picked World Position', 'The XYZ-coordinates of the point in world space at which the prim got picked,\nor (0,0,0) if nothing got picked', {}, True, None, False, ''), ]) class tokens: LeftMouseClick = "Left Mouse Click" RightMouseClick = "Right Mouse Click" MiddleMouseClick = "Middle Mouse Click" LeftMousePress = "Left Mouse Press" RightMousePress = "Right Mouse Press" MiddleMousePress = "Middle Mouse Press" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.trackedPrims = og.AttributeRole.TARGET role_data.outputs.pickedPrim = og.AttributeRole.TARGET role_data.outputs.pickedWorldPos = og.AttributeRole.POSITION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def trackedPrimPaths(self): data_view = og.AttributeValueHelper(self._attributes.trackedPrimPaths) return data_view.get() @trackedPrimPaths.setter def trackedPrimPaths(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.trackedPrimPaths) data_view = og.AttributeValueHelper(self._attributes.trackedPrimPaths) data_view.set(value) self.trackedPrimPaths_size = data_view.get_array_size() @property def trackedPrims(self): data_view = og.AttributeValueHelper(self._attributes.trackedPrims) return data_view.get() @trackedPrims.setter def trackedPrims(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.trackedPrims) data_view = og.AttributeValueHelper(self._attributes.trackedPrims) data_view.set(value) self.trackedPrims_size = data_view.get_array_size() @property def usePaths(self): data_view = og.AttributeValueHelper(self._attributes.usePaths) return data_view.get() @usePaths.setter def usePaths(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePaths) data_view = og.AttributeValueHelper(self._attributes.usePaths) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.pickedPrim_size = None self._batchedWriteValues = { } @property def isTrackedPrimPicked(self): data_view = og.AttributeValueHelper(self._attributes.isTrackedPrimPicked) return data_view.get() @isTrackedPrimPicked.setter def isTrackedPrimPicked(self, value): data_view = og.AttributeValueHelper(self._attributes.isTrackedPrimPicked) data_view.set(value) @property def isValid(self): data_view = og.AttributeValueHelper(self._attributes.isValid) return data_view.get() @isValid.setter def isValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isValid) data_view.set(value) @property def pickedPrim(self): data_view = og.AttributeValueHelper(self._attributes.pickedPrim) return data_view.get(reserved_element_count=self.pickedPrim_size) @pickedPrim.setter def pickedPrim(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedPrim) data_view.set(value) self.pickedPrim_size = data_view.get_array_size() @property def pickedPrimPath(self): data_view = og.AttributeValueHelper(self._attributes.pickedPrimPath) return data_view.get() @pickedPrimPath.setter def pickedPrimPath(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedPrimPath) data_view.set(value) @property def pickedWorldPos(self): data_view = og.AttributeValueHelper(self._attributes.pickedWorldPos) return data_view.get() @pickedWorldPos.setter def pickedWorldPos(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedWorldPos) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadPickStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadPickStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadPickStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadWidgetPropertyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadWidgetProperty Read the value of a widget's property (height, tooltip, etc). """ from typing import Any import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadWidgetPropertyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadWidgetProperty Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.propertyName inputs.widgetIdentifier inputs.widgetPath Outputs: outputs.value """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:propertyName', 'token', 0, 'Property Name', 'Name of the property to read.', {}, True, "", False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'Unique identifier for the widget. This is only valid within the current graph.', {}, True, "", False, ''), ('inputs:widgetPath', 'token', 0, 'Widget Path', "Full path to the widget. If present this will be used insted of 'widgetIdentifier'.\nUnlike 'widgetIdentifier' this is valid across all graphs.", {}, True, "", False, ''), ('outputs:value', 'bool,double,int,string', 1, 'Value', 'The value of the property.', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"propertyName", "widgetIdentifier", "widgetPath", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.propertyName, self._attributes.widgetIdentifier, self._attributes.widgetPath] self._batchedReadValues = ["", "", ""] @property def propertyName(self): return self._batchedReadValues[0] @propertyName.setter def propertyName(self, value): self._batchedReadValues[0] = value @property def widgetIdentifier(self): return self._batchedReadValues[1] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[1] = value @property def widgetPath(self): return self._batchedReadValues[2] @widgetPath.setter def widgetPath(self, value): self._batchedReadValues[2] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadWidgetPropertyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadWidgetPropertyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadWidgetPropertyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.ReadWidgetProperty' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnReadWidgetPropertyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnReadWidgetPropertyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnReadWidgetPropertyDatabase(node) try: compute_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnReadWidgetPropertyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnReadWidgetPropertyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnReadWidgetPropertyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnReadWidgetPropertyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Read Widget Property (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Read the value of a widget's property (height, tooltip, etc).") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") __hints = node_type.get_scheduling_hints() if __hints is not None: __hints.set_data_access(og.eAccessLocation.E_GLOBAL, og.eAccessType.E_WRITE) OgnReadWidgetPropertyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnReadWidgetPropertyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnReadWidgetPropertyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.ReadWidgetProperty")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadWindowSizeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadWindowSize Outputs the size of a UI window. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadWindowSizeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadWindowSize Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.isViewport inputs.name inputs.widgetPath Outputs: outputs.height outputs.width """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:isViewport', 'bool', 0, 'Is Viewport?', 'If true then only viewport windows will be considered.', {ogn.MetadataKeys.DEFAULT: 'false'}, False, False, False, ''), ('inputs:name', 'token', 0, 'Name', 'Name of the window. If there are multiple windows with the same name\nthe first one found will be used.', {}, False, None, False, ''), ('inputs:widgetPath', 'token', 0, 'Widget Path', "Full path to a widget in the window. If specified then 'name' will be ignored and\nthe window containing the widget will be used.", {}, False, None, False, ''), ('outputs:height', 'float', 0, 'Height', 'Height of the window in pixels.', {}, True, None, False, ''), ('outputs:width', 'float', 0, 'Width', 'Width of the window in pixels.', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"isViewport", "name", "widgetPath", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.isViewport, self._attributes.name, self._attributes.widgetPath] self._batchedReadValues = [False, None, None] @property def isViewport(self): return self._batchedReadValues[0] @isViewport.setter def isViewport(self, value): self._batchedReadValues[0] = value @property def name(self): return self._batchedReadValues[1] @name.setter def name(self, value): self._batchedReadValues[1] = value @property def widgetPath(self): return self._batchedReadValues[2] @widgetPath.setter def widgetPath(self, value): self._batchedReadValues[2] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"height", "width", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def height(self): value = self._batchedWriteValues.get(self._attributes.height) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.height) return data_view.get() @height.setter def height(self, value): self._batchedWriteValues[self._attributes.height] = value @property def width(self): value = self._batchedWriteValues.get(self._attributes.width) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.width) return data_view.get() @width.setter def width(self, value): self._batchedWriteValues[self._attributes.width] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadWindowSizeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadWindowSizeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadWindowSizeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.ReadWindowSize' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnReadWindowSizeDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnReadWindowSizeDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnReadWindowSizeDatabase(node) try: compute_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnReadWindowSizeDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnReadWindowSizeDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnReadWindowSizeDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnReadWindowSizeDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnReadWindowSizeDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Read Window Size (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Outputs the size of a UI window.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") __hints = node_type.get_scheduling_hints() if __hints is not None: __hints.set_data_access(og.eAccessLocation.E_GLOBAL, og.eAccessType.E_READ) OgnReadWindowSizeDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnReadWindowSizeDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnReadWindowSizeDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnReadWindowSizeDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.ReadWindowSize")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnSetCameraTargetDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.SetCameraTarget Sets the camera's target """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSetCameraTargetDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.SetCameraTarget Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.prim inputs.primPath inputs.rotate inputs.target inputs.usePath Outputs: outputs.execOut """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:execIn', 'execution', 0, 'In', 'Execution input', {}, True, None, False, ''), ('inputs:prim', 'target', 0, None, "The camera prim, when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, 'Camera Path', "Path of the camera, used when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:rotate', 'bool', 0, 'Rotate', 'True to keep position but change orientation and radius (camera rotates to look at new target).\nFalse to keep orientation and radius but change position (camera moves to look at new target).', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:target', 'point3d', 0, 'Target', 'The target point', {}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:execOut', 'execution', 0, 'Out', 'Execution Output', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.execIn = og.AttributeRole.EXECUTION role_data.inputs.prim = og.AttributeRole.TARGET role_data.inputs.target = og.AttributeRole.POSITION role_data.outputs.execOut = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def rotate(self): data_view = og.AttributeValueHelper(self._attributes.rotate) return data_view.get() @rotate.setter def rotate(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.rotate) data_view = og.AttributeValueHelper(self._attributes.rotate) data_view.set(value) @property def target(self): data_view = og.AttributeValueHelper(self._attributes.target) return data_view.get() @target.setter def target(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.target) data_view = og.AttributeValueHelper(self._attributes.target) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnSetCameraTargetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSetCameraTargetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSetCameraTargetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnSetViewportFullscreenDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.SetViewportFullscreen Toggles fullscreen on/off for viewport(s) and visibility on/off for all other panes. """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSetViewportFullscreenDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.SetViewportFullscreen Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.exec inputs.mode Outputs: outputs.exec Predefined Tokens: tokens.Default tokens.Fullscreen tokens.HideUI """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:exec', 'execution', 0, None, 'The input execution', {}, True, None, False, ''), ('inputs:mode', 'token', 0, 'Mode', 'The mode to toggle fullscreen on/off for viewport(s) and visibility on/off for all other panes:\n\n"Default" - Windowed viewport(s) with all other panes shown.\n"Fullscreen" - Fullscreen viewport(s) with all other panes hidden.\n"Hide UI" - Windowed viewport(s) with all other panes hidden.', {ogn.MetadataKeys.ALLOWED_TOKENS: 'Default,Fullscreen,Hide UI', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"Default": "Default", "Fullscreen": "Fullscreen", "HideUI": "Hide UI"}', ogn.MetadataKeys.DEFAULT: '"Default"'}, True, "Default", False, ''), ('outputs:exec', 'execution', 0, None, 'The output execution', {}, True, None, False, ''), ]) class tokens: Default = "Default" Fullscreen = "Fullscreen" HideUI = "Hide UI" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.exec = og.AttributeRole.EXECUTION role_data.outputs.exec = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def exec(self): data_view = og.AttributeValueHelper(self._attributes.exec) return data_view.get() @exec.setter def exec(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.exec) data_view = og.AttributeValueHelper(self._attributes.exec) data_view.set(value) @property def mode(self): data_view = og.AttributeValueHelper(self._attributes.mode) return data_view.get() @mode.setter def mode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.mode) data_view = og.AttributeValueHelper(self._attributes.mode) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def exec(self): data_view = og.AttributeValueHelper(self._attributes.exec) return data_view.get() @exec.setter def exec(self, value): data_view = og.AttributeValueHelper(self._attributes.exec) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnSetViewportFullscreenDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSetViewportFullscreenDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSetViewportFullscreenDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnWriteWidgetPropertyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.WriteWidgetProperty Set the value of a widget's property (height, tooltip, etc). """ from typing import Any import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnWriteWidgetPropertyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.WriteWidgetProperty Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.propertyName inputs.value inputs.widgetIdentifier inputs.widgetPath inputs.write Outputs: outputs.written """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:propertyName', 'token', 0, 'Property Name', 'Name of the property to write to.', {}, True, "", False, ''), ('inputs:value', 'any', 2, 'Value', 'The value to write to the property.', {}, True, None, False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'Unique identifier for the widget. This is only valid within the current graph.', {}, True, "", False, ''), ('inputs:widgetPath', 'token', 0, 'Widget Path', "Full path to the widget. If present this will be used insted of 'widgetIdentifier'.\nUnlike 'widgetIdentifier' this is valid across all graphs.", {}, True, "", False, ''), ('inputs:write', 'execution', 0, 'Write', "Input execution to write the value to the widget's property.", {}, True, None, False, ''), ('outputs:written', 'execution', 0, None, 'Executed when the value has been successfully written.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.write = og.AttributeRole.EXECUTION role_data.outputs.written = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"propertyName", "widgetIdentifier", "widgetPath", "write", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.propertyName, self._attributes.widgetIdentifier, self._attributes.widgetPath, self._attributes.write] self._batchedReadValues = ["", "", "", None] @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.value = value_to_set @property def propertyName(self): return self._batchedReadValues[0] @propertyName.setter def propertyName(self, value): self._batchedReadValues[0] = value @property def widgetIdentifier(self): return self._batchedReadValues[1] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[1] = value @property def widgetPath(self): return self._batchedReadValues[2] @widgetPath.setter def widgetPath(self, value): self._batchedReadValues[2] = value @property def write(self): return self._batchedReadValues[3] @write.setter def write(self, value): self._batchedReadValues[3] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"written", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def written(self): value = self._batchedWriteValues.get(self._attributes.written) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.written) return data_view.get() @written.setter def written(self, value): self._batchedWriteValues[self._attributes.written] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnWriteWidgetPropertyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnWriteWidgetPropertyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnWriteWidgetPropertyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.WriteWidgetProperty' @staticmethod def compute(context, node): def database_valid(): if db.inputs.value.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:value is not resolved, compute skipped') return False return True try: per_node_data = OgnWriteWidgetPropertyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnWriteWidgetPropertyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnWriteWidgetPropertyDatabase(node) try: compute_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnWriteWidgetPropertyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnWriteWidgetPropertyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnWriteWidgetPropertyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnWriteWidgetPropertyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Write Widget Property (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Set the value of a widget's property (height, tooltip, etc).") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnWriteWidgetPropertyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnWriteWidgetPropertyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnWriteWidgetPropertyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.WriteWidgetProperty")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnLockViewportRenderDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.LockViewportRender Locks and unlocks viewport render. Viewport render is frozen at the frame when it is locked, while computation and UI update are still executed as normal. It fades out back to the current frame when it is unlocked, two output execution attributes - fadeStarted and fadeComplete - will be triggered separately during the fading progress. The node manages the lock state for its target viewport and takes action according to the lock state when an input execution attribute is triggered. A node is able to unlock the target viewort only if it has locked the target viewport. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnLockViewportRenderDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.LockViewportRender Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.fadeTime inputs.lock inputs.unlock inputs.viewport Outputs: outputs.fadeComplete outputs.fadeStarted outputs.locked """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:fadeTime', 'double', 0, 'Fade Time', 'The duration of fading in time (seconds) when being unlocked', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:lock', 'execution', 0, None, 'The input execution attribute for locking viewport render', {}, True, None, False, ''), ('inputs:unlock', 'execution', 0, None, 'The input execution attribute for unlocking viewport render', {}, True, None, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport, or empty for the default viewport', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('outputs:fadeComplete', 'execution', 0, None, 'Triggered when fading is complete', {}, True, None, False, ''), ('outputs:fadeStarted', 'execution', 0, None, 'Triggered when fading is started', {}, True, None, False, ''), ('outputs:locked', 'execution', 0, None, 'Triggered when viewport render is locked', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.lock = og.AttributeRole.EXECUTION role_data.inputs.unlock = og.AttributeRole.EXECUTION role_data.outputs.fadeComplete = og.AttributeRole.EXECUTION role_data.outputs.fadeStarted = og.AttributeRole.EXECUTION role_data.outputs.locked = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"fadeTime", "lock", "unlock", "viewport", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.fadeTime, self._attributes.lock, self._attributes.unlock, self._attributes.viewport] self._batchedReadValues = [1.0, None, None, ""] @property def fadeTime(self): return self._batchedReadValues[0] @fadeTime.setter def fadeTime(self, value): self._batchedReadValues[0] = value @property def lock(self): return self._batchedReadValues[1] @lock.setter def lock(self, value): self._batchedReadValues[1] = value @property def unlock(self): return self._batchedReadValues[2] @unlock.setter def unlock(self, value): self._batchedReadValues[2] = value @property def viewport(self): return self._batchedReadValues[3] @viewport.setter def viewport(self, value): self._batchedReadValues[3] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"fadeComplete", "fadeStarted", "locked", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def fadeComplete(self): value = self._batchedWriteValues.get(self._attributes.fadeComplete) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.fadeComplete) return data_view.get() @fadeComplete.setter def fadeComplete(self, value): self._batchedWriteValues[self._attributes.fadeComplete] = value @property def fadeStarted(self): value = self._batchedWriteValues.get(self._attributes.fadeStarted) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.fadeStarted) return data_view.get() @fadeStarted.setter def fadeStarted(self, value): self._batchedWriteValues[self._attributes.fadeStarted] = value @property def locked(self): value = self._batchedWriteValues.get(self._attributes.locked) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.locked) return data_view.get() @locked.setter def locked(self, value): self._batchedWriteValues[self._attributes.locked] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnLockViewportRenderDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnLockViewportRenderDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnLockViewportRenderDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.LockViewportRender' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnLockViewportRenderDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnLockViewportRenderDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnLockViewportRenderDatabase(node) try: compute_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnLockViewportRenderDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnLockViewportRenderDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnLockViewportRenderDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnLockViewportRenderDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnLockViewportRenderDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Lock Viewport Render") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,viewport") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Locks and unlocks viewport render. Viewport render is frozen at the frame when it is locked, while computation and UI update are still executed as normal. It fades out back to the current frame when it is unlocked, two output execution attributes - fadeStarted and fadeComplete - will be triggered separately during the fading progress. The node manages the lock state for its target viewport and takes action according to the lock state when an input execution attribute is triggered. A node is able to unlock the target viewort only if it has locked the target viewport.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnLockViewportRenderDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnLockViewportRenderDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnLockViewportRenderDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnLockViewportRenderDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.LockViewportRender")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnVStackDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.VStack Contruct a Stack on the Viewport. All child widgets of Stack will be placed in a row, column or layer based on the direction input. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnVStackDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.VStack Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.create inputs.direction inputs.parentWidgetPath inputs.style inputs.widgetIdentifier Outputs: outputs.created outputs.widgetPath Predefined Tokens: tokens.BACK_TO_FRONT tokens.BOTTOM_TO_TOP tokens.FRONT_TO_BACK tokens.LEFT_TO_RIGHT tokens.RIGHT_TO_LEFT tokens.TOP_TO_BOTTOM """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:create', 'execution', 0, 'Create', 'Input execution to create and show the widget', {}, True, None, False, ''), ('inputs:direction', 'token', 0, 'Direction', 'The direction the widgets will be stacked.', {ogn.MetadataKeys.ALLOWED_TOKENS: 'BACK_TO_FRONT,BOTTOM_TO_TOP,FRONT_TO_BACK,LEFT_TO_RIGHT,RIGHT_TO_LEFT,TOP_TO_BOTTOM', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"BACK_TO_FRONT": "BACK_TO_FRONT", "BOTTOM_TO_TOP": "BOTTOM_TO_TOP", "FRONT_TO_BACK": "FRONT_TO_BACK", "LEFT_TO_RIGHT": "LEFT_TO_RIGHT", "RIGHT_TO_LEFT": "RIGHT_TO_LEFT", "TOP_TO_BOTTOM": "TOP_TO_BOTTOM"}', ogn.MetadataKeys.DEFAULT: '"TOP_TO_BOTTOM"'}, True, "TOP_TO_BOTTOM", False, ''), ('inputs:parentWidgetPath', 'token', 0, 'Parent Widget Path', 'The absolute path to the parent widget.', {}, True, "", False, ''), ('inputs:style', 'string', 0, None, 'Style to be applied to the stack and its children. This can later be changed with the\nWriteWidgetStyle node.', {}, False, None, False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'An optional unique identifier for the widget.\nCan be used to refer to this widget in other places such as the OnWidgetClicked node.', {}, False, None, False, ''), ('outputs:created', 'execution', 0, 'Created', 'Executed when the widget is created', {}, True, None, False, ''), ('outputs:widgetPath', 'token', 0, 'Widget Path', 'The absolute path to the created widget', {}, True, None, False, ''), ]) class tokens: BACK_TO_FRONT = "BACK_TO_FRONT" BOTTOM_TO_TOP = "BOTTOM_TO_TOP" FRONT_TO_BACK = "FRONT_TO_BACK" LEFT_TO_RIGHT = "LEFT_TO_RIGHT" RIGHT_TO_LEFT = "RIGHT_TO_LEFT" TOP_TO_BOTTOM = "TOP_TO_BOTTOM" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.create = og.AttributeRole.EXECUTION role_data.inputs.style = og.AttributeRole.TEXT role_data.outputs.created = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"create", "direction", "parentWidgetPath", "style", "widgetIdentifier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.create, self._attributes.direction, self._attributes.parentWidgetPath, self._attributes.style, self._attributes.widgetIdentifier] self._batchedReadValues = [None, "TOP_TO_BOTTOM", "", None, None] @property def create(self): return self._batchedReadValues[0] @create.setter def create(self, value): self._batchedReadValues[0] = value @property def direction(self): return self._batchedReadValues[1] @direction.setter def direction(self, value): self._batchedReadValues[1] = value @property def parentWidgetPath(self): return self._batchedReadValues[2] @parentWidgetPath.setter def parentWidgetPath(self, value): self._batchedReadValues[2] = value @property def style(self): return self._batchedReadValues[3] @style.setter def style(self, value): self._batchedReadValues[3] = value @property def widgetIdentifier(self): return self._batchedReadValues[4] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[4] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"created", "widgetPath", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def created(self): value = self._batchedWriteValues.get(self._attributes.created) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.created) return data_view.get() @created.setter def created(self, value): self._batchedWriteValues[self._attributes.created] = value @property def widgetPath(self): value = self._batchedWriteValues.get(self._attributes.widgetPath) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.widgetPath) return data_view.get() @widgetPath.setter def widgetPath(self, value): self._batchedWriteValues[self._attributes.widgetPath] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnVStackDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnVStackDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnVStackDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.VStack' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnVStackDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnVStackDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnVStackDatabase(node) try: compute_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnVStackDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnVStackDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnVStackDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnVStackDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnVStackDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Stack (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Contruct a Stack on the Viewport. All child widgets of Stack will be placed in a row, column or layer based on the direction input.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnVStackDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnVStackDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnVStackDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnVStackDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.VStack")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnSetViewportRendererDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.SetViewportRenderer Sets renderer for the target viewport. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSetViewportRendererDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.SetViewportRenderer Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.exec inputs.renderer inputs.viewport Outputs: outputs.exec """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:exec', 'execution', 0, None, 'The input execution', {}, True, None, False, ''), ('inputs:renderer', 'token', 0, 'Renderer', 'Renderer to be assigned to the target viewport', {}, True, "", False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport, or empty for the default viewport', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:exec', 'execution', 0, None, 'The output execution', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.exec = og.AttributeRole.EXECUTION role_data.outputs.exec = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"exec", "renderer", "viewport", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.exec, self._attributes.renderer, self._attributes.viewport] self._batchedReadValues = [None, "", "Viewport"] @property def exec(self): return self._batchedReadValues[0] @exec.setter def exec(self, value): self._batchedReadValues[0] = value @property def renderer(self): return self._batchedReadValues[1] @renderer.setter def renderer(self, value): self._batchedReadValues[1] = value @property def viewport(self): return self._batchedReadValues[2] @viewport.setter def viewport(self, value): self._batchedReadValues[2] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"exec", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def exec(self): value = self._batchedWriteValues.get(self._attributes.exec) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.exec) return data_view.get() @exec.setter def exec(self, value): self._batchedWriteValues[self._attributes.exec] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnSetViewportRendererDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSetViewportRendererDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSetViewportRendererDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.SetViewportRenderer' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnSetViewportRendererDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnSetViewportRendererDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnSetViewportRendererDatabase(node) try: compute_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnSetViewportRendererDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnSetViewportRendererDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnSetViewportRendererDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnSetViewportRendererDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnSetViewportRendererDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Set Viewport Renderer") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,viewport") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Sets renderer for the target viewport.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnSetViewportRendererDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnSetViewportRendererDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnSetViewportRendererDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnSetViewportRendererDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.SetViewportRenderer")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnPrintTextDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.PrintText Prints some text to the system log or to the screen """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnPrintTextDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.PrintText Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.logLevel inputs.text inputs.toScreen inputs.viewport Outputs: outputs.execOut Predefined Tokens: tokens.Info tokens.Warning tokens.Error """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:execIn', 'execution', 0, 'In', 'Execution input', {}, True, None, False, ''), ('inputs:logLevel', 'token', 0, 'Log Level', 'The logging level for the message [Info, Warning, Error]', {ogn.MetadataKeys.ALLOWED_TOKENS: 'Info,Warning,Error', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["Info", "Warning", "Error"]', ogn.MetadataKeys.DEFAULT: '"Info"'}, True, "Info", False, ''), ('inputs:text', 'string', 0, 'Text', 'The text to print', {}, True, "", False, ''), ('inputs:toScreen', 'bool', 0, 'To Screen', 'When true, displays the text on the viewport for a few seconds, as well as the log', {}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport if printing to screen, or empty for the default viewport', {}, True, "", False, ''), ('outputs:execOut', 'execution', 0, 'Out', 'Execution Output', {}, True, None, False, ''), ]) class tokens: Info = "Info" Warning = "Warning" Error = "Error" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.execIn = og.AttributeRole.EXECUTION role_data.inputs.text = og.AttributeRole.TEXT role_data.outputs.execOut = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"execIn", "logLevel", "text", "toScreen", "viewport", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.execIn, self._attributes.logLevel, self._attributes.text, self._attributes.toScreen, self._attributes.viewport] self._batchedReadValues = [None, "Info", "", False, ""] @property def execIn(self): return self._batchedReadValues[0] @execIn.setter def execIn(self, value): self._batchedReadValues[0] = value @property def logLevel(self): return self._batchedReadValues[1] @logLevel.setter def logLevel(self, value): self._batchedReadValues[1] = value @property def text(self): return self._batchedReadValues[2] @text.setter def text(self, value): self._batchedReadValues[2] = value @property def toScreen(self): return self._batchedReadValues[3] @toScreen.setter def toScreen(self, value): self._batchedReadValues[3] = value @property def viewport(self): return self._batchedReadValues[4] @viewport.setter def viewport(self, value): self._batchedReadValues[4] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"execOut", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def execOut(self): value = self._batchedWriteValues.get(self._attributes.execOut) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): self._batchedWriteValues[self._attributes.execOut] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnPrintTextDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnPrintTextDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnPrintTextDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.PrintText' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnPrintTextDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnPrintTextDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnPrintTextDatabase(node) try: compute_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnPrintTextDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnPrintTextDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnPrintTextDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnPrintTextDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnPrintTextDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.TAGS, "logging,toast,debug") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Print Text") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "debug") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Prints some text to the system log or to the screen") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnPrintTextDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnPrintTextDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnPrintTextDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnPrintTextDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.PrintText")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnWidgetClickedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnWidgetClicked Event node which fires when a UI widget with the specified identifier is clicked. This node should be used in combination with UI creation nodes such as OgnButton. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnWidgetClickedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnWidgetClicked Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.widgetIdentifier Outputs: outputs.clicked """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'A unique identifier identifying the widget.\nThis should be specified in the UI creation node such as OgnButton.', {ogn.MetadataKeys.LITERAL_ONLY: '1'}, True, "", False, ''), ('outputs:clicked', 'execution', 0, 'Clicked', 'Executed when the widget is clicked', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.clicked = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"widgetIdentifier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.widgetIdentifier] self._batchedReadValues = [""] @property def widgetIdentifier(self): return self._batchedReadValues[0] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"clicked", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def clicked(self): value = self._batchedWriteValues.get(self._attributes.clicked) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.clicked) return data_view.get() @clicked.setter def clicked(self, value): self._batchedWriteValues[self._attributes.clicked] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnWidgetClickedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnWidgetClickedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnWidgetClickedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.OnWidgetClicked' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnOnWidgetClickedDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnOnWidgetClickedDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnOnWidgetClickedDatabase(node) try: compute_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnOnWidgetClickedDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnOnWidgetClickedDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnOnWidgetClickedDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnOnWidgetClickedDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "On Widget Clicked (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Event node which fires when a UI widget with the specified identifier is clicked. This node should be used in combination with UI creation nodes such as OgnButton.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") __hints = node_type.get_scheduling_hints() if __hints is not None: __hints.compute_rule = og.eComputeRule.E_ON_REQUEST OgnOnWidgetClickedDatabase.INTERFACE.add_to_node_type(node_type) node_type.set_has_state(True) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnOnWidgetClickedDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnOnWidgetClickedDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.OnWidgetClicked")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnButtonDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.Button Create a button widget on the Viewport """ import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnButtonDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.Button Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.create inputs.parentWidgetPath inputs.size inputs.startHidden inputs.style inputs.text inputs.widgetIdentifier Outputs: outputs.created outputs.widgetPath """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:create', 'execution', 0, 'Create', 'Input execution to create and show the widget', {}, True, None, False, ''), ('inputs:parentWidgetPath', 'token', 0, 'Parent Widget Path', 'The absolute path to the parent widget.', {}, True, "", False, ''), ('inputs:size', 'double2', 0, 'Size', 'The width and height of the created widget.\nValue of 0 means the created widget will be just large enough to fit everything.', {}, True, [0.0, 0.0], False, ''), ('inputs:startHidden', 'bool', 0, 'Start Hidden', 'Determines whether the button will initially be visible (False) or not (True).', {ogn.MetadataKeys.DEFAULT: 'false'}, False, False, False, ''), ('inputs:style', 'string', 0, None, 'Style to be applied to the button. This can later be changed with the WriteWidgetStyle node.', {}, False, None, False, ''), ('inputs:text', 'string', 0, 'Text', 'The text that is displayed on the button', {}, False, None, False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'An optional unique identifier for the widget.\nCan be used to refer to this widget in other places such as the OnWidgetClicked node.', {}, False, None, False, ''), ('outputs:created', 'execution', 0, 'Created', 'Executed when the widget is created', {}, True, None, False, ''), ('outputs:widgetPath', 'token', 0, 'Widget Path', 'The absolute path to the created widget', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.create = og.AttributeRole.EXECUTION role_data.inputs.style = og.AttributeRole.TEXT role_data.inputs.text = og.AttributeRole.TEXT role_data.outputs.created = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"create", "parentWidgetPath", "size", "startHidden", "style", "text", "widgetIdentifier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.create, self._attributes.parentWidgetPath, self._attributes.size, self._attributes.startHidden, self._attributes.style, self._attributes.text, self._attributes.widgetIdentifier] self._batchedReadValues = [None, "", [0.0, 0.0], False, None, None, None] @property def create(self): return self._batchedReadValues[0] @create.setter def create(self, value): self._batchedReadValues[0] = value @property def parentWidgetPath(self): return self._batchedReadValues[1] @parentWidgetPath.setter def parentWidgetPath(self, value): self._batchedReadValues[1] = value @property def size(self): return self._batchedReadValues[2] @size.setter def size(self, value): self._batchedReadValues[2] = value @property def startHidden(self): return self._batchedReadValues[3] @startHidden.setter def startHidden(self, value): self._batchedReadValues[3] = value @property def style(self): return self._batchedReadValues[4] @style.setter def style(self, value): self._batchedReadValues[4] = value @property def text(self): return self._batchedReadValues[5] @text.setter def text(self, value): self._batchedReadValues[5] = value @property def widgetIdentifier(self): return self._batchedReadValues[6] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[6] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"created", "widgetPath", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def created(self): value = self._batchedWriteValues.get(self._attributes.created) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.created) return data_view.get() @created.setter def created(self, value): self._batchedWriteValues[self._attributes.created] = value @property def widgetPath(self): value = self._batchedWriteValues.get(self._attributes.widgetPath) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.widgetPath) return data_view.get() @widgetPath.setter def widgetPath(self, value): self._batchedWriteValues[self._attributes.widgetPath] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnButtonDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnButtonDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnButtonDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.Button' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnButtonDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnButtonDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnButtonDatabase(node) try: compute_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnButtonDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnButtonDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnButtonDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnButtonDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnButtonDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Button (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Create a button widget on the Viewport") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnButtonDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnButtonDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnButtonDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnButtonDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.Button")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnSliderDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.Slider Create a slider widget on the Viewport """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSliderDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.Slider Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.create inputs.disable inputs.enable inputs.hide inputs.max inputs.min inputs.parentWidgetPath inputs.show inputs.step inputs.tearDown inputs.widgetIdentifier inputs.width Outputs: outputs.created outputs.widgetPath """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:create', 'execution', 0, 'Create', 'Input execution to create and show the widget', {}, True, None, False, ''), ('inputs:disable', 'execution', 0, 'Disable', 'Disable this button so that it cannot be pressed', {}, True, None, False, ''), ('inputs:enable', 'execution', 0, 'Enable', 'Enable this button after it has been disabled', {}, True, None, False, ''), ('inputs:hide', 'execution', 0, 'Hide', 'Input execution to hide the widget and all its child widgets', {}, True, None, False, ''), ('inputs:max', 'float', 0, 'Max', 'The maximum value of the slider', {}, True, 0.0, False, ''), ('inputs:min', 'float', 0, 'Min', 'The minimum value of the slider', {}, True, 0.0, False, ''), ('inputs:parentWidgetPath', 'token', 0, 'Parent Widget Path', 'The absolute path to the parent widget.\nIf empty, this widget will be created as a direct child of Viewport.', {}, False, None, False, ''), ('inputs:show', 'execution', 0, 'Show', 'Input execution to show the widget and all its child widgets after they become hidden', {}, True, None, False, ''), ('inputs:step', 'float', 0, 'Step', 'The step size of the slider', {ogn.MetadataKeys.DEFAULT: '0.01'}, True, 0.01, False, ''), ('inputs:tearDown', 'execution', 0, 'Tear Down', 'Input execution to tear down the widget and all its child widgets', {}, True, None, False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'An optional unique identifier for the widget.\nCan be used to refer to this widget in other places such as the OnWidgetClicked node.', {}, False, None, False, ''), ('inputs:width', 'double', 0, 'Width', 'The width of the created slider', {ogn.MetadataKeys.DEFAULT: '100.0'}, True, 100.0, False, ''), ('outputs:created', 'execution', 0, 'Created', 'Executed when the widget is created', {}, True, None, False, ''), ('outputs:widgetPath', 'token', 0, 'Widget Path', 'The absolute path to the created widget', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.create = og.AttributeRole.EXECUTION role_data.inputs.disable = og.AttributeRole.EXECUTION role_data.inputs.enable = og.AttributeRole.EXECUTION role_data.inputs.hide = og.AttributeRole.EXECUTION role_data.inputs.show = og.AttributeRole.EXECUTION role_data.inputs.tearDown = og.AttributeRole.EXECUTION role_data.outputs.created = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"create", "disable", "enable", "hide", "max", "min", "parentWidgetPath", "show", "step", "tearDown", "widgetIdentifier", "width", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.create, self._attributes.disable, self._attributes.enable, self._attributes.hide, self._attributes.max, self._attributes.min, self._attributes.parentWidgetPath, self._attributes.show, self._attributes.step, self._attributes.tearDown, self._attributes.widgetIdentifier, self._attributes.width] self._batchedReadValues = [None, None, None, None, 0.0, 0.0, None, None, 0.01, None, None, 100.0] @property def create(self): return self._batchedReadValues[0] @create.setter def create(self, value): self._batchedReadValues[0] = value @property def disable(self): return self._batchedReadValues[1] @disable.setter def disable(self, value): self._batchedReadValues[1] = value @property def enable(self): return self._batchedReadValues[2] @enable.setter def enable(self, value): self._batchedReadValues[2] = value @property def hide(self): return self._batchedReadValues[3] @hide.setter def hide(self, value): self._batchedReadValues[3] = value @property def max(self): return self._batchedReadValues[4] @max.setter def max(self, value): self._batchedReadValues[4] = value @property def min(self): return self._batchedReadValues[5] @min.setter def min(self, value): self._batchedReadValues[5] = value @property def parentWidgetPath(self): return self._batchedReadValues[6] @parentWidgetPath.setter def parentWidgetPath(self, value): self._batchedReadValues[6] = value @property def show(self): return self._batchedReadValues[7] @show.setter def show(self, value): self._batchedReadValues[7] = value @property def step(self): return self._batchedReadValues[8] @step.setter def step(self, value): self._batchedReadValues[8] = value @property def tearDown(self): return self._batchedReadValues[9] @tearDown.setter def tearDown(self, value): self._batchedReadValues[9] = value @property def widgetIdentifier(self): return self._batchedReadValues[10] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[10] = value @property def width(self): return self._batchedReadValues[11] @width.setter def width(self, value): self._batchedReadValues[11] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"created", "widgetPath", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def created(self): value = self._batchedWriteValues.get(self._attributes.created) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.created) return data_view.get() @created.setter def created(self, value): self._batchedWriteValues[self._attributes.created] = value @property def widgetPath(self): value = self._batchedWriteValues.get(self._attributes.widgetPath) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.widgetPath) return data_view.get() @widgetPath.setter def widgetPath(self, value): self._batchedWriteValues[self._attributes.widgetPath] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnSliderDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSliderDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSliderDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.Slider' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnSliderDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnSliderDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnSliderDatabase(node) try: compute_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnSliderDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnSliderDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnSliderDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnSliderDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnSliderDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.HIDDEN, "True") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Slider (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Create a slider widget on the Viewport") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnSliderDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnSliderDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnSliderDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnSliderDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.Slider")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnSetCameraPositionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.SetCameraPosition Sets the camera's position """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSetCameraPositionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.SetCameraPosition Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.position inputs.prim inputs.primPath inputs.rotate inputs.usePath Outputs: outputs.execOut """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:execIn', 'execution', 0, 'In', 'Execution input', {}, True, None, False, ''), ('inputs:position', 'point3d', 0, 'Position', 'The new position', {}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:prim', 'target', 0, None, "The camera prim, when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, 'Camera Path', "Path of the camera, used when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:rotate', 'bool', 0, 'Rotate', 'True to keep position but change orientation and radius (camera moves to new \n position while still looking at the same target).\nFalse to keep orientation and radius but change position (camera moves to look at new target).', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:execOut', 'execution', 0, 'Out', 'Execution Output', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.execIn = og.AttributeRole.EXECUTION role_data.inputs.position = og.AttributeRole.POSITION role_data.inputs.prim = og.AttributeRole.TARGET role_data.outputs.execOut = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.position) data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def rotate(self): data_view = og.AttributeValueHelper(self._attributes.rotate) return data_view.get() @rotate.setter def rotate(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.rotate) data_view = og.AttributeValueHelper(self._attributes.rotate) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnSetCameraPositionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSetCameraPositionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSetCameraPositionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnViewportClickedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportClicked Event node which fires when a viewport click event occurs in the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnViewportClickedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportClicked Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.onlyPlayback inputs.useNormalizedCoords inputs.viewport Outputs: outputs.clicked outputs.position Predefined Tokens: tokens.LeftMouseClick tokens.RightMouseClick tokens.MiddleMouseClick """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger viewport click events', {'displayGroup': 'parameters', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Click,Right Mouse Click,Middle Mouse Click', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseClick": "Left Mouse Click", "RightMouseClick": "Right Mouse Click", "MiddleMouseClick": "Middle Mouse Click"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Click"'}, True, "Left Mouse Click", False, ''), ('inputs:onlyPlayback', 'bool', 0, 'Only Simulate On Play', 'When true, the node is only computed while Stage is being played', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of the 2D position output are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for click events', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:clicked', 'execution', 0, 'Clicked', 'Enabled when the specified input gesture triggers a viewport click event in the specified viewport', {}, True, None, False, ''), ('outputs:position', 'double2', 0, 'Position', 'The position at which the viewport click event occurred', {}, True, None, False, ''), ]) class tokens: LeftMouseClick = "Left Mouse Click" RightMouseClick = "Right Mouse Click" MiddleMouseClick = "Middle Mouse Click" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.clicked = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def onlyPlayback(self): data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) return data_view.get() @onlyPlayback.setter def onlyPlayback(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyPlayback) data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) data_view.set(value) @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def clicked(self): data_view = og.AttributeValueHelper(self._attributes.clicked) return data_view.get() @clicked.setter def clicked(self, value): data_view = og.AttributeValueHelper(self._attributes.clicked) data_view.set(value) @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnViewportClickedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnViewportClickedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnViewportClickedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnViewportScrolledDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportScrolled Event node which fires when a viewport scroll event occurs in the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnViewportScrolledDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnViewportScrolled Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.onlyPlayback inputs.useNormalizedCoords inputs.viewport Outputs: outputs.position outputs.scrollValue outputs.scrolled """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:onlyPlayback', 'bool', 0, 'Only Simulate On Play', 'When true, the node is only computed while Stage is being played', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of the 2D position output are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for scroll events', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:position', 'double2', 0, 'Position', 'The position at which the viewport scroll event occurred', {}, True, None, False, ''), ('outputs:scrollValue', 'float', 0, 'Scroll Value', 'The number of mouse wheel clicks scrolled up if positive, or scrolled down if negative', {}, True, None, False, ''), ('outputs:scrolled', 'execution', 0, 'Scrolled', 'Enabled when a viewport scroll event occurs in the specified viewport', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.scrolled = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def onlyPlayback(self): data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) return data_view.get() @onlyPlayback.setter def onlyPlayback(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyPlayback) data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) data_view.set(value) @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) @property def scrollValue(self): data_view = og.AttributeValueHelper(self._attributes.scrollValue) return data_view.get() @scrollValue.setter def scrollValue(self, value): data_view = og.AttributeValueHelper(self._attributes.scrollValue) data_view.set(value) @property def scrolled(self): data_view = og.AttributeValueHelper(self._attributes.scrolled) return data_view.get() @scrolled.setter def scrolled(self, value): data_view = og.AttributeValueHelper(self._attributes.scrolled) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnViewportScrolledDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnViewportScrolledDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnViewportScrolledDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnWidgetValueChangedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnWidgetValueChanged Event node which fires when a UI widget with the specified identifier has its value changed. This node should be used in combination with UI creation nodes such as OgnSlider. """ from typing import Any import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnWidgetValueChangedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnWidgetValueChanged Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.widgetIdentifier Outputs: outputs.newValue outputs.valueChanged """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'A unique identifier identifying the widget.\nThis should be specified in the UI creation node such as OgnSlider.', {ogn.MetadataKeys.LITERAL_ONLY: '1'}, True, "", False, ''), ('outputs:newValue', 'bool,float,int,string', 1, 'New Value', 'The new value of the widget', {}, True, None, False, ''), ('outputs:valueChanged', 'execution', 0, 'Value Changed', 'Executed when the value of the widget is changed', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.valueChanged = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"widgetIdentifier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.widgetIdentifier] self._batchedReadValues = [""] @property def widgetIdentifier(self): return self._batchedReadValues[0] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"valueChanged", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def newValue(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.newValue""" return og.RuntimeAttribute(self._attributes.newValue.get_attribute_data(), self._context, False) @newValue.setter def newValue(self, value_to_set: Any): """Assign another attribute's value to outputs.newValue""" if isinstance(value_to_set, og.RuntimeAttribute): self.newValue.value = value_to_set.value else: self.newValue.value = value_to_set @property def valueChanged(self): value = self._batchedWriteValues.get(self._attributes.valueChanged) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.valueChanged) return data_view.get() @valueChanged.setter def valueChanged(self, value): self._batchedWriteValues[self._attributes.valueChanged] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnWidgetValueChangedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnWidgetValueChangedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnWidgetValueChangedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.OnWidgetValueChanged' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnOnWidgetValueChangedDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnOnWidgetValueChangedDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnOnWidgetValueChangedDatabase(node) try: compute_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnOnWidgetValueChangedDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnOnWidgetValueChangedDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnOnWidgetValueChangedDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnOnWidgetValueChangedDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "On Widget Value Changed (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Event node which fires when a UI widget with the specified identifier has its value changed. This node should be used in combination with UI creation nodes such as OgnSlider.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") __hints = node_type.get_scheduling_hints() if __hints is not None: __hints.compute_rule = og.eComputeRule.E_ON_REQUEST OgnOnWidgetValueChangedDatabase.INTERFACE.add_to_node_type(node_type) node_type.set_has_state(True) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnOnWidgetValueChangedDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnOnWidgetValueChangedDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.OnWidgetValueChanged")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadViewportScrollStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportScrollState Read the state of the last viewport scroll event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadViewportScrollStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportScrollState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.useNormalizedCoords inputs.viewport Outputs: outputs.isValid outputs.position outputs.scrollValue """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of the 2D position output are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for scroll events', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isValid', 'bool', 0, 'Is Valid', 'True if a valid event state was detected and the outputs of this node are valid, and false otherwise', {}, True, None, False, ''), ('outputs:position', 'double2', 0, 'Position', 'The last position at which a viewport scroll event occurred in the specified viewport', {}, True, None, False, ''), ('outputs:scrollValue', 'float', 0, 'Scroll Value', 'The number of mouse wheel clicks scrolled up if positive, or scrolled down if negative', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def isValid(self): data_view = og.AttributeValueHelper(self._attributes.isValid) return data_view.get() @isValid.setter def isValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isValid) data_view.set(value) @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) @property def scrollValue(self): data_view = og.AttributeValueHelper(self._attributes.scrollValue) return data_view.get() @scrollValue.setter def scrollValue(self, value): data_view = og.AttributeValueHelper(self._attributes.scrollValue) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadViewportScrollStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadViewportScrollStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadViewportScrollStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnGetCameraPositionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.GetCameraPosition Gets a viewport camera position """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetCameraPositionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.GetCameraPosition Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.primPath inputs.usePath Outputs: outputs.position """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:prim', 'target', 0, None, "The camera prim, when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, 'Camera Path', "Path of the camera, used when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:position', 'point3d', 0, 'Position', 'The position of the camera in world space', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.prim = og.AttributeRole.TARGET role_data.outputs.position = og.AttributeRole.POSITION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnGetCameraPositionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetCameraPositionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetCameraPositionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnOnPickedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.OnPicked Event node which fires when a picking event occurs in the specified viewport. Note that picking events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOnPickedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.OnPicked Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.onlyPlayback inputs.trackedPrims inputs.viewport Outputs: outputs.isTrackedPrimPicked outputs.missed outputs.picked outputs.pickedPrim outputs.pickedPrimPath outputs.pickedWorldPos outputs.trackedPrimPaths Predefined Tokens: tokens.LeftMouseClick tokens.RightMouseClick tokens.MiddleMouseClick tokens.LeftMousePress tokens.RightMousePress tokens.MiddleMousePress """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger a picking event', {'displayGroup': 'parameters', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Click,Right Mouse Click,Middle Mouse Click,Left Mouse Press,Right Mouse Press,Middle Mouse Press', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseClick": "Left Mouse Click", "RightMouseClick": "Right Mouse Click", "MiddleMouseClick": "Middle Mouse Click", "LeftMousePress": "Left Mouse Press", "RightMousePress": "Right Mouse Press", "MiddleMousePress": "Middle Mouse Press"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Click"'}, True, "Left Mouse Click", False, ''), ('inputs:onlyPlayback', 'bool', 0, 'Only Simulate On Play', 'When true, the node is only computed while Stage is being played.', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:trackedPrims', 'target', 0, 'Tracked Prims', "Optionally specify a set of tracked prims that will cause 'Picked' to fire when picked", {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, False, [], False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for picking events', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isTrackedPrimPicked', 'bool', 0, 'Is Tracked Prim Picked', "True if a tracked prim got picked, or if any prim got picked if no tracked prims are specified\n(will always be true when 'Picked' fires, and false when 'Missed' fires)", {}, True, None, False, ''), ('outputs:missed', 'execution', 0, 'Missed', 'Enabled when an attempted picking did not pick a tracked prim,\nor when nothing gets picked if no tracked prims are specified', {}, True, None, False, ''), ('outputs:picked', 'execution', 0, 'Picked', 'Enabled when a tracked prim is picked,\nor when any prim is picked if no tracked prims are specified', {}, True, None, False, ''), ('outputs:pickedPrim', 'target', 0, 'Picked Prim', 'The picked prim, or an empty target if nothing got picked', {}, True, [], False, ''), ('outputs:pickedPrimPath', 'token', 0, 'Picked Prim Path', 'The path of the picked prim, or an empty string if nothing got picked', {}, True, None, True, 'Use the pickedPrim output instead'), ('outputs:pickedWorldPos', 'point3d', 0, 'Picked World Position', 'The XYZ-coordinates of the point in world space at which the prim got picked,\nor (0,0,0) if nothing got picked', {}, True, None, False, ''), ('outputs:trackedPrimPaths', 'token[]', 0, 'Tracked Prim Paths', "A list of the paths of the prims specified in 'Tracked Prims'", {}, True, None, False, ''), ]) class tokens: LeftMouseClick = "Left Mouse Click" RightMouseClick = "Right Mouse Click" MiddleMouseClick = "Middle Mouse Click" LeftMousePress = "Left Mouse Press" RightMousePress = "Right Mouse Press" MiddleMousePress = "Middle Mouse Press" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.trackedPrims = og.AttributeRole.TARGET role_data.outputs.missed = og.AttributeRole.EXECUTION role_data.outputs.picked = og.AttributeRole.EXECUTION role_data.outputs.pickedPrim = og.AttributeRole.TARGET role_data.outputs.pickedWorldPos = og.AttributeRole.POSITION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def onlyPlayback(self): data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) return data_view.get() @onlyPlayback.setter def onlyPlayback(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.onlyPlayback) data_view = og.AttributeValueHelper(self._attributes.onlyPlayback) data_view.set(value) @property def trackedPrims(self): data_view = og.AttributeValueHelper(self._attributes.trackedPrims) return data_view.get() @trackedPrims.setter def trackedPrims(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.trackedPrims) data_view = og.AttributeValueHelper(self._attributes.trackedPrims) data_view.set(value) self.trackedPrims_size = data_view.get_array_size() @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.pickedPrim_size = None self.trackedPrimPaths_size = None self._batchedWriteValues = { } @property def isTrackedPrimPicked(self): data_view = og.AttributeValueHelper(self._attributes.isTrackedPrimPicked) return data_view.get() @isTrackedPrimPicked.setter def isTrackedPrimPicked(self, value): data_view = og.AttributeValueHelper(self._attributes.isTrackedPrimPicked) data_view.set(value) @property def missed(self): data_view = og.AttributeValueHelper(self._attributes.missed) return data_view.get() @missed.setter def missed(self, value): data_view = og.AttributeValueHelper(self._attributes.missed) data_view.set(value) @property def picked(self): data_view = og.AttributeValueHelper(self._attributes.picked) return data_view.get() @picked.setter def picked(self, value): data_view = og.AttributeValueHelper(self._attributes.picked) data_view.set(value) @property def pickedPrim(self): data_view = og.AttributeValueHelper(self._attributes.pickedPrim) return data_view.get(reserved_element_count=self.pickedPrim_size) @pickedPrim.setter def pickedPrim(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedPrim) data_view.set(value) self.pickedPrim_size = data_view.get_array_size() @property def pickedPrimPath(self): data_view = og.AttributeValueHelper(self._attributes.pickedPrimPath) return data_view.get() @pickedPrimPath.setter def pickedPrimPath(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedPrimPath) data_view.set(value) @property def pickedWorldPos(self): data_view = og.AttributeValueHelper(self._attributes.pickedWorldPos) return data_view.get() @pickedWorldPos.setter def pickedWorldPos(self, value): data_view = og.AttributeValueHelper(self._attributes.pickedWorldPos) data_view.set(value) @property def trackedPrimPaths(self): data_view = og.AttributeValueHelper(self._attributes.trackedPrimPaths) return data_view.get(reserved_element_count=self.trackedPrimPaths_size) @trackedPrimPaths.setter def trackedPrimPaths(self, value): data_view = og.AttributeValueHelper(self._attributes.trackedPrimPaths) data_view.set(value) self.trackedPrimPaths_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnOnPickedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOnPickedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOnPickedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadViewportClickStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportClickState Read the state of the last viewport click event from the specified viewport. Note that viewport mouse events must be enabled on the specified viewport using a SetViewportMode node. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadViewportClickStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadViewportClickState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gesture inputs.useNormalizedCoords inputs.viewport Outputs: outputs.isValid outputs.position Predefined Tokens: tokens.LeftMouseClick tokens.RightMouseClick tokens.MiddleMouseClick """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gesture', 'token', 0, 'Gesture', 'The input gesture to trigger viewport click events', {'displayGroup': 'parameters', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Mouse Click,Right Mouse Click,Middle Mouse Click', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftMouseClick": "Left Mouse Click", "RightMouseClick": "Right Mouse Click", "MiddleMouseClick": "Middle Mouse Click"}', ogn.MetadataKeys.DEFAULT: '"Left Mouse Click"'}, True, "Left Mouse Click", False, ''), ('inputs:useNormalizedCoords', 'bool', 0, 'Use Normalized Coords', 'When true, the components of the 2D position output are scaled to between 0 and 1,\nwhere 0 is top/left and 1 is bottom/right.\nWhen false, components are in viewport render resolution pixels.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport window to watch for click events', {ogn.MetadataKeys.DEFAULT: '"Viewport"'}, True, "Viewport", False, ''), ('outputs:isValid', 'bool', 0, 'Is Valid', 'True if a valid event state was detected and the outputs of this node are valid, and false otherwise', {}, True, None, False, ''), ('outputs:position', 'double2', 0, 'Position', 'The position at which the specified input gesture last triggered a viewport click event in the specified viewport', {}, True, None, False, ''), ]) class tokens: LeftMouseClick = "Left Mouse Click" RightMouseClick = "Right Mouse Click" MiddleMouseClick = "Middle Mouse Click" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gesture(self): data_view = og.AttributeValueHelper(self._attributes.gesture) return data_view.get() @gesture.setter def gesture(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gesture) data_view = og.AttributeValueHelper(self._attributes.gesture) data_view.set(value) @property def useNormalizedCoords(self): data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) return data_view.get() @useNormalizedCoords.setter def useNormalizedCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useNormalizedCoords) data_view = og.AttributeValueHelper(self._attributes.useNormalizedCoords) data_view.set(value) @property def viewport(self): data_view = og.AttributeValueHelper(self._attributes.viewport) return data_view.get() @viewport.setter def viewport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.viewport) data_view = og.AttributeValueHelper(self._attributes.viewport) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def isValid(self): data_view = og.AttributeValueHelper(self._attributes.isValid) return data_view.get() @isValid.setter def isValid(self, value): data_view = og.AttributeValueHelper(self._attributes.isValid) data_view.set(value) @property def position(self): data_view = og.AttributeValueHelper(self._attributes.position) return data_view.get() @position.setter def position(self, value): data_view = og.AttributeValueHelper(self._attributes.position) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadViewportClickStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadViewportClickStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadViewportClickStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnGetActiveViewportCameraDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.GetActiveViewportCamera Gets the path of the camera bound to a viewport """ import sys import traceback import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetActiveViewportCameraDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.GetActiveViewportCamera Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.viewport Outputs: outputs.camera outputs.cameraPrim """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:viewport', 'token', 0, 'Viewport', 'Name of the viewport, or empty for the default viewport', {}, True, "", False, ''), ('outputs:camera', 'token', 0, 'Camera', 'Path of the active camera', {}, True, None, False, ''), ('outputs:cameraPrim', 'target', 0, 'Camera Prim', 'The prim of the active camera', {}, True, [], False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.cameraPrim = og.AttributeRole.TARGET return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"viewport", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.viewport] self._batchedReadValues = [""] @property def viewport(self): return self._batchedReadValues[0] @viewport.setter def viewport(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"camera", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.cameraPrim_size = None self._batchedWriteValues = { } @property def cameraPrim(self): data_view = og.AttributeValueHelper(self._attributes.cameraPrim) return data_view.get(reserved_element_count=self.cameraPrim_size) @cameraPrim.setter def cameraPrim(self, value): data_view = og.AttributeValueHelper(self._attributes.cameraPrim) data_view.set(value) self.cameraPrim_size = data_view.get_array_size() @property def camera(self): value = self._batchedWriteValues.get(self._attributes.camera) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.camera) return data_view.get() @camera.setter def camera(self, value): self._batchedWriteValues[self._attributes.camera] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnGetActiveViewportCameraDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetActiveViewportCameraDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetActiveViewportCameraDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.GetActiveViewportCamera' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnGetActiveViewportCameraDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnGetActiveViewportCameraDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnGetActiveViewportCameraDatabase(node) try: compute_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnGetActiveViewportCameraDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnGetActiveViewportCameraDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnGetActiveViewportCameraDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnGetActiveViewportCameraDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Get Active Camera") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "sceneGraph:camera") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Gets the path of the camera bound to a viewport") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnGetActiveViewportCameraDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnGetActiveViewportCameraDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnGetActiveViewportCameraDatabase.abi, 2) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.GetActiveViewportCamera")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnPlacerDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.Placer Contruct a Placer widget. The Placer takes a single child and places it at a given position within it. """ import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnPlacerDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.Placer Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.create inputs.parentWidgetPath inputs.position inputs.style inputs.widgetIdentifier Outputs: outputs.created outputs.widgetPath """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:create', 'execution', 0, 'Create', 'Input execution to create and show the widget', {}, True, None, False, ''), ('inputs:parentWidgetPath', 'token', 0, 'Parent Widget Path', 'The absolute path to the parent widget.', {}, True, "", False, ''), ('inputs:position', 'double2', 0, 'Position', 'Where to position the child widget within the Placer.', {}, True, [0.0, 0.0], False, ''), ('inputs:style', 'string', 0, None, 'Style to be applied to the Placer and its child. This can later be changed with the\nWriteWidgetStyle node.', {}, False, None, False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'An optional unique identifier for the widget.\nCan be used to refer to this widget in other places such as the OnWidgetClicked node.', {}, False, None, False, ''), ('outputs:created', 'execution', 0, 'Created', 'Executed when the widget is created', {}, True, None, False, ''), ('outputs:widgetPath', 'token', 0, 'Widget Path', 'The absolute path to the created Placer widget', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.create = og.AttributeRole.EXECUTION role_data.inputs.style = og.AttributeRole.TEXT role_data.outputs.created = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"create", "parentWidgetPath", "position", "style", "widgetIdentifier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.create, self._attributes.parentWidgetPath, self._attributes.position, self._attributes.style, self._attributes.widgetIdentifier] self._batchedReadValues = [None, "", [0.0, 0.0], None, None] @property def create(self): return self._batchedReadValues[0] @create.setter def create(self, value): self._batchedReadValues[0] = value @property def parentWidgetPath(self): return self._batchedReadValues[1] @parentWidgetPath.setter def parentWidgetPath(self, value): self._batchedReadValues[1] = value @property def position(self): return self._batchedReadValues[2] @position.setter def position(self, value): self._batchedReadValues[2] = value @property def style(self): return self._batchedReadValues[3] @style.setter def style(self, value): self._batchedReadValues[3] = value @property def widgetIdentifier(self): return self._batchedReadValues[4] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[4] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"created", "widgetPath", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def created(self): value = self._batchedWriteValues.get(self._attributes.created) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.created) return data_view.get() @created.setter def created(self, value): self._batchedWriteValues[self._attributes.created] = value @property def widgetPath(self): value = self._batchedWriteValues.get(self._attributes.widgetPath) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.widgetPath) return data_view.get() @widgetPath.setter def widgetPath(self, value): self._batchedWriteValues[self._attributes.widgetPath] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnPlacerDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnPlacerDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnPlacerDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.Placer' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnPlacerDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnPlacerDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnPlacerDatabase(node) try: compute_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnPlacerDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnPlacerDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnPlacerDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnPlacerDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnPlacerDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Placer (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Contruct a Placer widget. The Placer takes a single child and places it at a given position within it.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnPlacerDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnPlacerDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnPlacerDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnPlacerDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.Placer")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnWriteWidgetStyleDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.WriteWidgetStyle Sets a widget's style properties. This node should be used in combination with UI creation nodes such as Button. """ import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnWriteWidgetStyleDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.WriteWidgetStyle Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.style inputs.widgetIdentifier inputs.widgetPath inputs.write Outputs: outputs.written """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:style', 'string', 0, None, 'The style to set the widget to.', {}, True, "", False, ''), ('inputs:widgetIdentifier', 'token', 0, 'Widget Identifier', 'A unique identifier identifying the widget. This is only valid within the current graph.\nThis should be specified in the UI creation node such as OgnButton.', {}, True, "", False, ''), ('inputs:widgetPath', 'token', 0, 'Widget Path', "Full path to the widget. If present this will be used insted of 'widgetIdentifier'.\nUnlike 'widgetIdentifier' this is valid across all graphs.", {}, True, "", False, ''), ('inputs:write', 'execution', 0, None, 'Input execution', {}, True, None, False, ''), ('outputs:written', 'execution', 0, None, 'Output execution', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.style = og.AttributeRole.TEXT role_data.inputs.write = og.AttributeRole.EXECUTION role_data.outputs.written = og.AttributeRole.EXECUTION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"style", "widgetIdentifier", "widgetPath", "write", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.style, self._attributes.widgetIdentifier, self._attributes.widgetPath, self._attributes.write] self._batchedReadValues = ["", "", "", None] @property def style(self): return self._batchedReadValues[0] @style.setter def style(self, value): self._batchedReadValues[0] = value @property def widgetIdentifier(self): return self._batchedReadValues[1] @widgetIdentifier.setter def widgetIdentifier(self, value): self._batchedReadValues[1] = value @property def widgetPath(self): return self._batchedReadValues[2] @widgetPath.setter def widgetPath(self, value): self._batchedReadValues[2] = value @property def write(self): return self._batchedReadValues[3] @write.setter def write(self, value): self._batchedReadValues[3] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"written", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def written(self): value = self._batchedWriteValues.get(self._attributes.written) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.written) return data_view.get() @written.setter def written(self, value): self._batchedWriteValues[self._attributes.written] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnWriteWidgetStyleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnWriteWidgetStyleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnWriteWidgetStyleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.ui_nodes.WriteWidgetStyle' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnWriteWidgetStyleDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnWriteWidgetStyleDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnWriteWidgetStyleDatabase(node) try: compute_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnWriteWidgetStyleDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnWriteWidgetStyleDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnWriteWidgetStyleDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnWriteWidgetStyleDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.ui_nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Write Widget Style (BETA)") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "graph:action,ui") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Sets a widget's style properties. This node should be used in combination with UI creation nodes such as Button.") node_type.set_metadata(ogn.MetadataKeys.EXCLUSIONS, "tests") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") __hints = node_type.get_scheduling_hints() if __hints is not None: __hints.set_data_access(og.eAccessLocation.E_GLOBAL, og.eAccessType.E_READ) OgnWriteWidgetStyleDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnWriteWidgetStyleDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnWriteWidgetStyleDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.ui_nodes.WriteWidgetStyle")
omniverse-code/kit/exts/omni.graph.ui_nodes/omni/graph/ui_nodes/ogn/OgnReadMouseStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.ui_nodes.ReadMouseState Reads the current state of the mouse. You can choose which mouse element this node is associated with. When mouse element is chosen to be a button, only outputs:isPressed is meaningful. When coordinates are chosen, only outputs:coords and outputs:window are meaningful. Pixel coordinates are the position of the mouse cursor in screen pixel units with (0,0) top left. Normalized coordinates are values between 0-1 where 0 is top/left and 1 is bottom/right. By default, coordinates are relative to the application window, but if 'Use Relative Coords' is set to true, then coordinates are relative to the workspace window containing the mouse pointer. """ import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadMouseStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.ui_nodes.ReadMouseState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.mouseElement inputs.useRelativeCoords Outputs: outputs.coords outputs.isPressed outputs.window Predefined Tokens: tokens.LeftButton tokens.RightButton tokens.MiddleButton tokens.ForwardButton tokens.BackButton tokens.MouseCoordsNormalized tokens.MouseCoordsPixel """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:mouseElement', 'token', 0, 'Mouse Element', 'The mouse input to check the state of', {'displayGroup': 'parameters', ogn.MetadataKeys.ALLOWED_TOKENS: 'Left Button,Right Button,Middle Button,Forward Button,Back Button,Normalized Mouse Coordinates,Pixel Mouse Coordinates', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"LeftButton": "Left Button", "RightButton": "Right Button", "MiddleButton": "Middle Button", "ForwardButton": "Forward Button", "BackButton": "Back Button", "MouseCoordsNormalized": "Normalized Mouse Coordinates", "MouseCoordsPixel": "Pixel Mouse Coordinates"}', ogn.MetadataKeys.DEFAULT: '"Left Button"'}, True, "Left Button", False, ''), ('inputs:useRelativeCoords', 'bool', 0, 'Use Relative Coords', "When true, the output 'coords' is made relative to the workspace window containing the\nmouse pointer instead of the entire application window", {}, True, False, False, ''), ('outputs:coords', 'float2', 0, None, 'The coordinates of the mouse. If the mouse element selected is a button, this will output a zero vector.', {}, True, None, False, ''), ('outputs:isPressed', 'bool', 0, None, 'True if the button is currently pressed, false otherwise. If the mouse element selected\nis a coordinate, this will output false.', {}, True, None, False, ''), ('outputs:window', 'token', 0, None, "The name of the workspace window containing the mouse pointer if 'Use Relative Coords' is true\nand the mouse element selected is a coordinate", {}, True, None, False, ''), ]) class tokens: LeftButton = "Left Button" RightButton = "Right Button" MiddleButton = "Middle Button" ForwardButton = "Forward Button" BackButton = "Back Button" MouseCoordsNormalized = "Normalized Mouse Coordinates" MouseCoordsPixel = "Pixel Mouse Coordinates" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def mouseElement(self): data_view = og.AttributeValueHelper(self._attributes.mouseElement) return data_view.get() @mouseElement.setter def mouseElement(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.mouseElement) data_view = og.AttributeValueHelper(self._attributes.mouseElement) data_view.set(value) @property def useRelativeCoords(self): data_view = og.AttributeValueHelper(self._attributes.useRelativeCoords) return data_view.get() @useRelativeCoords.setter def useRelativeCoords(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useRelativeCoords) data_view = og.AttributeValueHelper(self._attributes.useRelativeCoords) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def coords(self): data_view = og.AttributeValueHelper(self._attributes.coords) return data_view.get() @coords.setter def coords(self, value): data_view = og.AttributeValueHelper(self._attributes.coords) data_view.set(value) @property def isPressed(self): data_view = og.AttributeValueHelper(self._attributes.isPressed) return data_view.get() @isPressed.setter def isPressed(self, value): data_view = og.AttributeValueHelper(self._attributes.isPressed) data_view.set(value) @property def window(self): data_view = og.AttributeValueHelper(self._attributes.window) return data_view.get() @window.setter def window(self, value): data_view = og.AttributeValueHelper(self._attributes.window) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnReadMouseStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadMouseStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadMouseStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)