Open Inventor Reference
SoState Class Reference

An SoState collects and holds state while traversing a scene graph. More...

#include <Inventor/misc/SoState.h>

List of all members.

Public Member Functions

 SoState (SoAction *action, const SoTypeList &enabledElements)
 Constructor.
 ~SoState ()
 Destructor.
SoActiongetAction () const
 Returns the action instance the state is part of.
SoElementgetElement (int stackIndex)
 Returns a writable instance of the element on the top of the stack with the given index.
const SoElementgetConstElement (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)
SbBool isElementEnabled (int stackIndex) const
 Returns TRUE if element with given stack index is enabled in state.
int getDepth () const
 Returns current depth of state.
void setCacheOpen (SbBool flag)
 Sets/returns flag that indicates whether a cache is open.
SbBool isCacheOpen () const
SoElementgetElementNoPush (int stackIndex) const
 Internal-only, dangerous method that returns a writeable element without checking for state depth and doing a push.

Detailed Description

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 82 of file SoState.h.


Constructor & Destructor Documentation

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

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

SoState::~SoState ( )

Member Function Documentation

SoAction* SoState::getAction ( ) const [inline]

Definition at line 93 of file SoState.h.

const SoElement* SoState::getConstElement ( int  stackIndex) const [inline]
int SoState::getDepth ( ) const [inline]

Definition at line 123 of file SoState.h.

SoElement* SoState::getElement ( int  stackIndex)
SoElement* SoState::getElementNoPush ( int  stackIndex) const [inline]

Be very careful and consider the caching implications before using this method!

Definition at line 135 of file SoState.h.

Referenced by SoCacheElement::getCurrentCache(), SoLazyElement::getInstance(), SoGLCacheContextElement::resetAutoCacheBits(), SoGLCacheContextElement::setAutoCacheBits(), and SoGLCacheContextElement::shouldAutoCache().

SbBool SoState::isElementEnabled ( int  stackIndex) const [inline]

Definition at line 119 of file SoState.h.

void SoState::pop ( )
void SoState::print ( FILE *  fp)
void SoState::push ( ) [inline]

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.

Definition at line 108 of file SoState.h.

void SoState::setCacheOpen ( SbBool  flag) [inline]

This flag lets us optimize element capturing; we don't need to try to capture elements if the flag is FALSE.

Definition at line 128 of file SoState.h.


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