Traversal state. More...
#include <Inventor/misc/SoState.h>
Classes | |
class | PushPop |
Push SoState in constructor and pop it in destructor. | |
Public Member Functions | |
SoState (SoAction *action, const SoTypeList &enabledElements) | |
~SoState () | |
SoAction * | getAction () const |
template<typename T > | |
T * | getElement () |
SoElement * | getElement (const SoType &type, const int stackIndex) |
template<typename T > | |
const T * | getConstElement () const |
const SoElement * | getConstElement (const SoType &type, const int stackIndex) const |
void | push () |
void | pop () |
void | print (FILE *fp) |
Deprecated | |
| |
SoDEPRECATED SoElement * | getElement (const int stackIndex) |
SoDEPRECATED const SoElement * | getConstElement (const int stackIndex) const |
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.
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 | ( | ) |
Destructor.
SoAction* SoState::getAction | ( | ) | const [inline] |
Returns the action instance the state is part of.
SoDEPRECATED const SoElement* SoState::getConstElement | ( | const int | stackIndex | ) | const |
Returns the top (read-only) instance of the given element stack.
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.
const T* SoState::getConstElement | ( | ) | const [inline] |
Returns the top (read-only) instance of the given element.
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.
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.
T* SoState::getElement | ( | ) | [inline] |
Returns a writable instance of the element on the top of the stack with the given type.
void SoState::pop | ( | ) |
Pops the state, restoring the state to just before the last push().
void SoState::print | ( | FILE * | fp | ) |
Prints state to file (for debugging).
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.