.. role:: ts-api-decorator

#####
State
#####

.. js:module:: cee.usg
   :noindex:

.. container:: ts-api-section

   .. js:class:: State

      A state connects a geometry to the results (scalar, vector, displacement and transformations) for a given
      time, frequency, load case etc.

      A model can have an arbitrary number of states, but only one can be shown at any given time.

      To create an animation you can create multiple states, and then only change the 
      ``UnstructGridModel.currentStateIndex`` property to advance the animation.

      A state must have one and only one geometry.

      The state can also have a scalar, vector, displacement and transformation result.

      For the results, you only have to specify the results for the parts that have results. Results
      are mapped to part via the zero based part index.



.. container:: api-index-section

   .. rubric:: Accessors

   .. rst-class:: api-index-list-item api-kind-accessor api-parent-kind-class

   * :js:attr:`~cee.usg.State.geometry`
   * :js:attr:`~cee.usg.State.name`
   * :js:attr:`~cee.usg.State.referenceValue`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.usg.State.getBoundingBox`
   * :js:meth:`~cee.usg.State.getFringesResultRange`
   * :js:meth:`~cee.usg.State.getPartDisplacementsAt`
   * :js:meth:`~cee.usg.State.getPartFringesAt`
   * :js:meth:`~cee.usg.State.getPartTransformationAt`
   * :js:meth:`~cee.usg.State.getPartVectorsAt`
   * :js:meth:`~cee.usg.State.getVectorLengthRange`
   * :js:meth:`~cee.usg.State.removeAllPartDisplacements`
   * :js:meth:`~cee.usg.State.removeAllPartFringes`
   * :js:meth:`~cee.usg.State.removeAllPartTransformations`
   * :js:meth:`~cee.usg.State.removeAllPartVectors`
   * :js:meth:`~cee.usg.State.setPartDisplacementsAt`
   * :js:meth:`~cee.usg.State.setPartFringesAt`
   * :js:meth:`~cee.usg.State.setPartTransformationAt`
   * :js:meth:`~cee.usg.State.setPartVectorsAt`





------------

Accessors
=========

.. container:: ts-api-section

   .. js:function:: State.geometry()



      The one and only geometry in this state


      :rtype: Geometry

   .. js:function:: State.geometry( geometry)

      :param geometry: None
      :type geometry: Geometry


      :rtype: void



.. container:: ts-api-section

   .. js:function:: State.name()



      The user defined name of the state


      :rtype: string

   .. js:function:: State.name( name)

      :param name: None
      :type name: string


      :rtype: void



.. container:: ts-api-section

   .. js:function:: State.referenceValue()



      The user defined reference value of the state (time, frequency, load case index, etc)


      :rtype: number

   .. js:function:: State.referenceValue( value)

      :param value: None
      :type value: number


      :rtype: void



Methods
=======

.. rst-class:: ts-api-section

getBoundingBox
--------------

.. js:method:: State.getBoundingBox()



   Returns the ``BoundingBox`` (in world coordinates) of the model.


   :rtype: BoundingBox

.. rst-class:: ts-api-section

getFringesResultRange
---------------------

.. js:method:: State.getFringesResultRange()



   Get the min/max value of the scalar result in this part.


   :rtype: Range

.. rst-class:: ts-api-section

getPartDisplacementsAt
----------------------

.. js:method:: State.getPartDisplacementsAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Get the displacement result at the given zero based index, otherwise null.


   :rtype: PartDisplacements

.. rst-class:: ts-api-section

getPartFringesAt
----------------

.. js:method:: State.getPartFringesAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Returns the ``PartScalars`` defining the fringes result shown on the given part. Null when none is specified.


   :rtype: PartScalars

.. rst-class:: ts-api-section

getPartTransformationAt
-----------------------

.. js:method:: State.getPartTransformationAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Get the transformation matrix for the given part in this state, null if none is specified.


   :rtype: Mat4

.. rst-class:: ts-api-section

getPartVectorsAt
----------------

.. js:method:: State.getPartVectorsAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Returns the ``PartVectors`` defining the vector result shown on the given part. Null if not specified.


   :rtype: PartVectors

.. rst-class:: ts-api-section

getVectorLengthRange
--------------------

.. js:method:: State.getVectorLengthRange()



   The range (min/max) of the vector lengths in all parts


   :rtype: Range

.. rst-class:: ts-api-section

removeAllPartDisplacements
--------------------------

.. js:method:: State.removeAllPartDisplacements()



   Remove all displacement results in this state


   :rtype: void

.. rst-class:: ts-api-section

removeAllPartFringes
--------------------

.. js:method:: State.removeAllPartFringes()



   Remove all scalar fringes results from this state


   :rtype: void

.. rst-class:: ts-api-section

removeAllPartTransformations
----------------------------

.. js:method:: State.removeAllPartTransformations()



   Remove the transformation matrices for all parts in this state


   :rtype: void

.. rst-class:: ts-api-section

removeAllPartVectors
--------------------

.. js:method:: State.removeAllPartVectors()



   Remove all vector results for all parts in this state


   :rtype: void

.. rst-class:: ts-api-section

setPartDisplacementsAt
----------------------

.. js:method:: State.setPartDisplacementsAt( partIndex, partDisplacements)

   :param partIndex: None
   :type partIndex: number
   :param partDisplacements: None
   :type partDisplacements: PartDisplacements


   Set the displacement result for the given part in this state

   Note: The ``PartSettings.displacementVisible`` property must be true to show the result (default true)


   :rtype: void

.. rst-class:: ts-api-section

setPartFringesAt
----------------

.. js:method:: State.setPartFringesAt( partIndex, partFringes)

   :param partIndex: None
   :type partIndex: number
   :param partFringes: None
   :type partFringes: PartScalars


   Set the scalar result that should be shown as fringes for the given part in this state.

   Note: The ``PartSettings.fringesVisible`` property must be true to show the result (default true)


   :rtype: void

.. rst-class:: ts-api-section

setPartTransformationAt
-----------------------

.. js:method:: State.setPartTransformationAt( partIndex, partTransformationMatrix)

   :param partIndex: None
   :type partIndex: number
   :param partTransformationMatrix: None
   :type partTransformationMatrix: Mat4


   Set the transformation result (matrix) for the given part in this state.


   :rtype: void

.. rst-class:: ts-api-section

setPartVectorsAt
----------------

.. js:method:: State.setPartVectorsAt( partIndex, partVectors)

   :param partIndex: None
   :type partIndex: number
   :param partVectors: None
   :type partVectors: PartVectors


   Set the vector result that should be shown as vector arrows for the given part in this state.

   Note: The ``PartSettings.vectorsVisible`` property must be true to show the result (default true)


   :rtype: void

