"""Support for simplified access to data on nodes of type omni.graph.nodes.CurveTubeST

Compute curve tube ST values
"""

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 OgnCurveTubeSTDatabase(og.Database):
    """Helper class providing simplified access to data on nodes of type omni.graph.nodes.CurveTubeST

    Class Members:
        node: Node being evaluated

    Attribute Value Properties:
        Inputs:
            inputs.cols
            inputs.curveVertexCounts
            inputs.curveVertexStarts
            inputs.scaleTLikeS
            inputs.t
            inputs.tubeQuadStarts
            inputs.tubeSTStarts
            inputs.width
        Outputs:
            outputs.primvars_st
            outputs.primvars_st_indices
    """

    # 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:cols', 'int[]', 0, 'Columns', 'Columns of the tubes', {}, True, [], False, ''),
        ('inputs:curveVertexCounts', 'int[]', 0, 'Curve Vertex Counts', 'Vertex counts for the curve points', {}, True, [], False, ''),
        ('inputs:curveVertexStarts', 'int[]', 0, 'Curve Vertex Starts', 'Vertex starting points', {}, True, [], False, ''),
        ('inputs:scaleTLikeS', 'bool', 0, 'Scale T Like S', 'If true then scale T the same as S', {}, True, False, False, ''),
        ('inputs:t', 'float[]', 0, 'T Values', 'T values of the tubes', {}, True, [], False, ''),
        ('inputs:tubeQuadStarts', 'int[]', 0, 'Tube Quad Starts', 'Vertex index values for the tube quad starting points', {}, True, [], False, ''),
        ('inputs:tubeSTStarts', 'int[]', 0, 'Tube ST Starts', 'Vertex index values for the tube ST starting points', {}, True, [], False, ''),
        ('inputs:width', 'float[]', 0, 'Tube Widths', 'Width of tube positions, if scaling T like S', {}, True, [], False, ''),
        ('outputs:primvars:st', 'float2[]', 0, 'ST Values', 'Array of computed ST values', {}, True, None, False, ''),
        ('outputs:primvars:st:indices', 'int[]', 0, 'ST Indices', 'Array of computed ST indices', {}, 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 cols(self):
            data_view = og.AttributeValueHelper(self._attributes.cols)
            return data_view.get()

        @cols.setter
        def cols(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.cols)
            data_view = og.AttributeValueHelper(self._attributes.cols)
            data_view.set(value)
            self.cols_size = data_view.get_array_size()

        @property
        def curveVertexCounts(self):
            data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
            return data_view.get()

        @curveVertexCounts.setter
        def curveVertexCounts(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.curveVertexCounts)
            data_view = og.AttributeValueHelper(self._attributes.curveVertexCounts)
            data_view.set(value)
            self.curveVertexCounts_size = data_view.get_array_size()

        @property
        def curveVertexStarts(self):
            data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
            return data_view.get()

        @curveVertexStarts.setter
        def curveVertexStarts(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.curveVertexStarts)
            data_view = og.AttributeValueHelper(self._attributes.curveVertexStarts)
            data_view.set(value)
            self.curveVertexStarts_size = data_view.get_array_size()

        @property
        def scaleTLikeS(self):
            data_view = og.AttributeValueHelper(self._attributes.scaleTLikeS)
            return data_view.get()

        @scaleTLikeS.setter
        def scaleTLikeS(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.scaleTLikeS)
            data_view = og.AttributeValueHelper(self._attributes.scaleTLikeS)
            data_view.set(value)

        @property
        def t(self):
            data_view = og.AttributeValueHelper(self._attributes.t)
            return data_view.get()

        @t.setter
        def t(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.t)
            data_view = og.AttributeValueHelper(self._attributes.t)
            data_view.set(value)
            self.t_size = data_view.get_array_size()

        @property
        def tubeQuadStarts(self):
            data_view = og.AttributeValueHelper(self._attributes.tubeQuadStarts)
            return data_view.get()

        @tubeQuadStarts.setter
        def tubeQuadStarts(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.tubeQuadStarts)
            data_view = og.AttributeValueHelper(self._attributes.tubeQuadStarts)
            data_view.set(value)
            self.tubeQuadStarts_size = data_view.get_array_size()

        @property
        def tubeSTStarts(self):
            data_view = og.AttributeValueHelper(self._attributes.tubeSTStarts)
            return data_view.get()

        @tubeSTStarts.setter
        def tubeSTStarts(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.tubeSTStarts)
            data_view = og.AttributeValueHelper(self._attributes.tubeSTStarts)
            data_view.set(value)
            self.tubeSTStarts_size = data_view.get_array_size()

        @property
        def width(self):
            data_view = og.AttributeValueHelper(self._attributes.width)
            return data_view.get()

        @width.setter
        def width(self, value):
            if self._setting_locked:
                raise og.ReadOnlyError(self._attributes.width)
            data_view = og.AttributeValueHelper(self._attributes.width)
            data_view.set(value)
            self.width_size = data_view.get_array_size()

        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.primvars_st_size = None
            self.primvars_st_indices_size = None
            self._batchedWriteValues = { }

        @property
        def primvars_st(self):
            data_view = og.AttributeValueHelper(self._attributes.primvars_st)
            return data_view.get(reserved_element_count=self.primvars_st_size)

        @primvars_st.setter
        def primvars_st(self, value):
            data_view = og.AttributeValueHelper(self._attributes.primvars_st)
            data_view.set(value)
            self.primvars_st_size = data_view.get_array_size()

        @property
        def primvars_st_indices(self):
            data_view = og.AttributeValueHelper(self._attributes.primvars_st_indices)
            return data_view.get(reserved_element_count=self.primvars_st_indices_size)

        @primvars_st_indices.setter
        def primvars_st_indices(self, value):
            data_view = og.AttributeValueHelper(self._attributes.primvars_st_indices)
            data_view.set(value)
            self.primvars_st_indices_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 = OgnCurveTubeSTDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT)
        self.outputs = OgnCurveTubeSTDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes)
        dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE)
        self.state = OgnCurveTubeSTDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
