Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoState Class Reference

Traversal state. More...

#include <Inventor/misc/SoState.h>

Public Member Functions

 SoState (SoAction *action, const SoTypeList &enabledElements)
 Constructor.
 
 ~SoState ()
 Destructor.
 
SoActiongetAction () const
 Returns the action instance the state is part of.
 
template<typename T >
T * getElement ()
 Returns a writable instance of the element on the top of the stack with the given type.
 
SoElementgetElement (const SoType &type, const int stackIndex)
 Returns a writable instance of the element on the top of the stack with the given index and type.
 
template<typename T >
const T * getConstElement () const
 Returns the top (read-only) instance of the given element.
 
const SoElementgetConstElement (const SoType &type, const int stackIndex) const
 Returns the top (read-only) instance of the given element stack.
 
void push ()
 Pushes (saves) the current state until a pop() restores it.
 
void pop ()
 Pops the state, restoring the state to just before the last push().
 
void print (FILE *fp)
 Prints state to file (for debugging)
 

Deprecated

SoDEPRECATED SoElementgetElement (const int stackIndex)
 Returns a writable instance of the element on the top of the stack with the given stack index.
 
SoDEPRECATED const SoElementgetConstElement (const int stackIndex) const
 Returns the top (read-only) instance of the given element stack.
 

Detailed Description

Traversal state.

An SoState collects and holds state while traversing a scene graph. A state is composed of a variety of elements, each of which holds some specific information, such as coordinates or diffuse color of the surface material.

Each element is stored in its own stack so that save and restore can be implemented as push and pop. These stack operations are performed lazily, so that pushing of a value occurs only when the value would be overwritten, for efficiency.

Definition at line 74 of file SoState.h.

Constructor & Destructor Documentation

◆ SoState()

SoState::SoState ( SoAction action,
const SoTypeList enabledElements 
)

Constructor.

Takes pointer to action instance this state is part of and a list of type-ids of elements that are enabled.

◆ ~SoState()

SoState::~SoState ( )

Destructor.

Member Function Documentation

◆ getAction()

SoAction * SoState::getAction ( ) const
inline

Returns the action instance the state is part of.

Definition at line 87 of file SoState.h.

◆ getConstElement() [1/3]

template<typename T >
const T * SoState::getConstElement ( ) const
inline

Returns the top (read-only) instance of the given element.

Warning
This method doesn't capture dependency on current cache

Definition at line 112 of file SoState.h.

◆ getConstElement() [2/3]

SoDEPRECATED const SoElement * SoState::getConstElement ( const int  stackIndex) const

Returns the top (read-only) instance of the given element stack.

◆ getConstElement() [3/3]

const SoElement * SoState::getConstElement ( const SoType type,
const int  stackIndex 
) const
inline

Returns the top (read-only) instance of the given element stack.


We recommend using the templated type safe version.

Definition at line 121 of file SoState.h.

◆ getElement() [1/3]

template<typename T >
T * SoState::getElement ( )
inline

Returns a writable instance of the element on the top of the stack with the given type.

Definition at line 95 of file SoState.h.

◆ getElement() [2/3]

SoDEPRECATED SoElement * SoState::getElement ( const int  stackIndex)

Returns a writable instance of the element on the top of the stack with the given stack index.

◆ getElement() [3/3]

SoElement * SoState::getElement ( const SoType type,
const int  stackIndex 
)

Returns a writable instance of the element on the top of the stack with the given index and type.


We recommend using the templated type safe version.

◆ pop()

void SoState::pop ( )

Pops the state, restoring the state to just before the last push().

◆ print()

void SoState::print ( FILE *  fp)

Prints state to file (for debugging)

◆ push()

void SoState::push ( )

Pushes (saves) the current state until a pop() restores it.

The push is done lazily: this just increments the depth in the state. When an element is accessed with getElement() and its depth is less than the current depth, it is then pushed individually.


The documentation for this class was generated from the following file: