Open Inventor Reference
SoCallbackAction Class Reference

Performs a generic traversal of the scene graph. More...

#include <Inventor/actions/SoCallbackAction.h>

Inheritance diagram for SoCallbackAction:
SoAction

Public Types

enum  Response { CONTINUE , ABORT , PRUNE }
 Possible responses from a pre or post callback. More...
 
typedef Response SoCallbackActionCB(void *userData, SoCallbackAction *action, const SoNode *node)
 The SoCallbackActionCB typedef is defined within the class, since it needs to refer to the Response enumerated type. More...
 
- Public Types inherited from SoAction
enum  AppliedCode { NODE , PATH , PATH_LIST }
 This enum is used to determine what the action is being applied to. More...
 
enum  PathCode { NO_PATH , IN_PATH , BELOW_PATH , OFF_PATH }
 This enum may be used during traversal of nodes to indicate where the node is with respect to the path being traversed. More...
 

Public Member Functions

 SoCallbackAction ()
 The constructor. More...
 
virtual ~SoCallbackAction ()
 Destructor. More...
 
void addPreCallback (SoType type, SoCallbackActionCB *cb, void *data)
 Adding callback functions: More...
 
void addPostCallback (SoType type, SoCallbackActionCB *cb, void *data)
 
void addPreTailCallback (SoCallbackActionCB *cb, void *data)
 These can be used to set up callback functions to call when the action is applied to a path. More...
 
void addPostTailCallback (SoCallbackActionCB *cb, void *data)
 These can be used to set up callback functions to call when the action is applied to a path. More...
 
void addTriangleCallback (SoType type, SoTriangleCB *cb, void *data)
 Routines to add callbacks for generated primitives (triangles, line segments, and points) for all shapes of the given type. More...
 
void addLineSegmentCallback (SoType type, SoLineSegmentCB *cb, void *data)
 
void addPointCallback (SoType type, SoPointCB *cb, void *data)
 
float getComplexity () const
 Accessing state information from callbacks. More...
 
SoComplexity::Type getComplexityType () const
 
int32_t getNumCoordinates () const
 Returns the current coordinates from the state. More...
 
const SbVec3fgetCoordinate3 (int index) const
 Returns the current coordinates from the state. More...
 
const SbVec4fgetCoordinate4 (int index) const
 Returns the current coordinates from the state. More...
 
SoDrawStyle::Style getDrawStyle () const
 
u_short getLinePattern () const
 Returns the current drawing style information from the state. More...
 
float getLineWidth () const
 Returns the current drawing style information from the state. More...
 
float getPointSize () const
 Returns the current drawing style information from the state. More...
 
const SbNamegetFontName () const
 Returns the current font information from the state. More...
 
float getFontSize () const
 Returns the current font information from the state. More...
 
SoLightModel::Model getLightModel () const
 
const SbVec3fgetLightAttenuation () const
 Returns the current lighting model information from the state. More...
 
void getMaterial (SbColor &ambient, SbColor &diffuse, SbColor &specular, SbColor &emission, float &shininess, float &transparency, int mtlIndex=0) const
 Returns the current material information from the state. More...
 
SoMaterialBinding::Binding getMaterialBinding () const
 
int32_t getNumNormals () const
 Returns the current normal information from the state. More...
 
const SbVec3fgetNormal (int index) const
 Returns the current normal information from the state. More...
 
SoNormalBinding::Binding getNormalBinding () const
 
int32_t getNumProfileCoordinates () const
 Returns the current profiles and their coordinates from the state. More...
 
const SbVec2fgetProfileCoordinate2 (int index) const
 Returns the current profiles and their coordinates from the state. More...
 
const SbVec3fgetProfileCoordinate3 (int index) const
 Returns the current profiles and their coordinates from the state. More...
 
const SoNodeListgetProfile () const
 Returns the current profiles and their coordinates from the state. More...
 
SoShapeHints::VertexOrdering getVertexOrdering () const
 
SoShapeHints::ShapeType getShapeType () const
 
SoShapeHints::FaceType getFaceType () const
 
float getCreaseAngle () const
 Returns the current shape hints from the state. More...
 
int32_t getNumTextureCoordinates () const
 Returns 0 if texture coordinates are generated by a function. More...
 
const SbVec2fgetTextureCoordinate2 (int index) const
 Returns texture information from the state. More...
 
const SbVec4fgetTextureCoordinate4 (int index) const
 Returns texture information from the state. More...
 
SoTextureCoordinateBinding::Binding getTextureCoordinateBinding () const
 
const SbColorgetTextureBlendColor () const
 Returns texture information from the state. More...
 
const unsigned char * getTextureImage (SbVec2s &size, int &numComps) const
 Returns texture information from the state. More...
 
const SbMatrixgetTextureMatrix () const
 Returns the current texture mapping information from the state. More...
 
SoTexture2::Model getTextureModel () const
 
SoTexture2::Wrap getTextureWrapS () const
 
SoTexture2::Wrap getTextureWrapT () const
 
const SbMatrixgetModelMatrix () const
 Returns the current modeling transformation and the current units from the state. More...
 
SoUnits::Units getUnits () const
 
float getFocalDistance () const
 Returns the current camera and viewing information from the state. More...
 
const SbMatrixgetProjectionMatrix () const
 Returns the current camera and viewing information from the state. More...
 
const SbMatrixgetViewingMatrix () const
 Returns the current camera and viewing information from the state. More...
 
const SbViewVolumegetViewVolume () const
 Returns the current camera and viewing information from the state. More...
 
SoPickStyle::Style getPickStyle () const
 
int32_t getSwitch () const
 Returns the current switch value. More...
 
Response getCurrentResponse () const
 Returns the current response. More...
 
void invokePreCallbacks (const SoNode *node)
 Call the pre-callbacks and post-callbacks. More...
 
void invokePostCallbacks (const SoNode *node)
 
void invokeTriangleCallbacks (const SoShape *shape, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)
 Call the primitive callbacks. More...
 
void invokeLineSegmentCallbacks (const SoShape *shape, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2)
 
void invokePointCallbacks (const SoShape *shape, const SoPrimitiveVertex *v)
 
bool shouldGeneratePrimitives (const SoShape *shape) const
 Should primitives be generated for this shape? More...
 
virtual SoNodegetCurPathTail ()
 Returns the node that caused the callback: More...
 
void setCurrentNode (SoNode *node)
 Set the current node during traversal: More...
 
- Public Member Functions inherited from SoAction
virtual ~SoAction ()
 Destructor. More...
 
virtual SoType getTypeId () const =0
 Returns the type identifier for a specific instance. More...
 
bool isOfType (SoType type) const
 Returns TRUE if this instance is of the type specified in type or is derived from that type. More...
 
virtual void apply (SoNode *node)
 
virtual void apply (SoPath *path)
 
virtual void apply (const SoPathList &pathList, bool obeysRules=FALSE)
 Initiates an action on the graph defined either by a node, path, or list of paths. More...
 
virtual void invalidateState ()
 Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied. More...
 
AppliedCode getWhatAppliedTo () const
 Returns code indicating what action is being applied to. More...
 
SoNodegetNodeAppliedTo () const
 These returns a pointer to the node, path, or path list the action is being applied to. More...
 
SoPathgetPathAppliedTo () const
 
const SoPathListgetPathListAppliedTo () const
 A single path list may be split into several, one for each different head node. More...
 
const SoPathListgetOriginalPathListAppliedTo () const
 
bool isLastPathListAppliedTo () const
 
PathCode getPathCode (int &numIndices, const int *&indices)
 Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to. More...
 
void traverse (SoNode *node)
 Does traversal of a graph rooted by a node. More...
 
bool hasTerminated () const
 Returns TRUE if the traversal has reached a termination condition. More...
 
const SoPathgetCurPath ()
 Returns a pointer to the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed. More...
 
SoStategetState () const
 Get the state from the action. More...
 
PathCode getCurPathCode () const
 These methods maintain the current path accumulated so far during traversal. More...
 
void pushCurPath (int childIndex)
 
void popCurPath (PathCode prevPathCode)
 
void usePathCode (int &numIndices, const int *&indices)
 called by inline getPathCode: More...
 
void pushCurPath ()
 Optimized versions of push/pop when we know path codes won't change: More...
 
void popPushCurPath (int childIndex)
 
void popCurPath ()
 
const SoLightweightPathgetCurrentLightweightPath () const
 Returns the current "light" path. More...
 
void setCurrentLightweightPath (const SoLightweightPath &path)
 Sets the current "light" path. More...
 

Static Public Member Functions

static void initClass ()
 
- Static Public Member Functions inherited from SoAction
static SoType getClassTypeId ()
 Returns the type identifier for this class. More...
 
static void nullAction (SoAction *, SoNode *)
 Null action method that can be stored in lookup table when desired. More...
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor action classes. More...
 

Protected Member Functions

virtual void beginTraversal (SoNode *node)
 Initiates action on graph. More...
 
- Protected Member Functions inherited from SoAction
 SoAction ()
 Constructor. More...
 
virtual const SoEnabledElementsListgetEnabledElements () const
 Returns the list of enabled elements for a given action subclass. More...
 
void setTerminated (bool flag)
 Allows subclass instance to indicate that traversal has reached a termination condition. More...
 
virtual bool shouldCompactPathLists () const
 This method is used when applying an action to an SoPathList. More...
 

Additional Inherited Members

- Protected Attributes inherited from SoAction
SoStatestate
 Traversal state. More...
 
SoActionMethodListtraversalMethods
 The list of what to do when. More...
 
- Static Protected Attributes inherited from SoAction
static SoEnabledElementsListenabledElements
 Holds list of enabled elements for the SoAction class. More...
 
static SoActionMethodListmethods
 ... and the methods More...
 

Detailed Description

This action defines a generic traversal of the scene graph. The user can specify callback functions for node types or paths; when those node types or paths are encountered during traversal, the user's callback function is called.

In addition, callback functions can be registered for primitives generated by shapes in the scene graph. Most shape types can generate primitives that represent or approximate their geometries. Triangle primitives are used for all surfaces (such as cubes, face sets, or 3D text), line segment primitives are used for line shapes, and point primitives are used for point shapes. Note that the type of primitives generated for a shape is the same, regardless of drawing style or other properties.

Most of the methods on this class access information from the traversal state. They should be called only by callback functions that are invoked during traversal, so there is a valid state to work with.

See Also
SoCallback, SoEventCallback, SoShape

Definition at line 126 of file SoCallbackAction.h.

Member Typedef Documentation

◆ SoCallbackActionCB

typedef Response SoCallbackAction::SoCallbackActionCB(void *userData, SoCallbackAction *action, const SoNode *node)

The first argument is the data pointer that the user supplied when the callback was registered. The second argument is the action, from which the state can be extracted. The third argument is the node that the callback is called from.

Definition at line 145 of file SoCallbackAction.h.

Member Enumeration Documentation

◆ Response

Enumerator
CONTINUE 

Continue as usual.

ABORT 

Stop traversing the rest of the graph.

PRUNE 

Do not traverse children of this node.

Definition at line 133 of file SoCallbackAction.h.

Constructor & Destructor Documentation

◆ SoCallbackAction()

SoCallbackAction::SoCallbackAction ( )

◆ ~SoCallbackAction()

virtual SoCallbackAction::~SoCallbackAction ( )
virtual

Member Function Documentation

◆ addLineSegmentCallback()

void SoCallbackAction::addLineSegmentCallback ( SoType  type,
SoLineSegmentCB cb,
void *  data 
)

◆ addPointCallback()

void SoCallbackAction::addPointCallback ( SoType  type,
SoPointCB cb,
void *  data 
)

◆ addPostCallback()

void SoCallbackAction::addPostCallback ( SoType  type,
SoCallbackActionCB cb,
void *  data 
)

◆ addPostTailCallback()

void SoCallbackAction::addPostTailCallback ( SoCallbackActionCB cb,
void *  data 
)

The functions are called just after the node at the tail of the path is traversed.

◆ addPreCallback()

void SoCallbackAction::addPreCallback ( SoType  type,
SoCallbackActionCB cb,
void *  data 
)

These add a callback function to call when a node of the given type is encountered during traversal. The PreCallback is called just before the node is traversed, and the PostCallback is called just after. The value returned by a callback function indicates whether the action should continue with the traversal.

◆ addPreTailCallback()

void SoCallbackAction::addPreTailCallback ( SoCallbackActionCB cb,
void *  data 
)

The functions are called just before the node at the tail of the path is traversed.

◆ addTriangleCallback()

void SoCallbackAction::addTriangleCallback ( SoType  type,
SoTriangleCB cb,
void *  data 
)

The callback function will be called for each primitive generated for all shapes of or derived from that type.

◆ beginTraversal()

virtual void SoCallbackAction::beginTraversal ( SoNode node)
protectedvirtual

Reimplemented from SoAction.

◆ getComplexity()

float SoCallbackAction::getComplexity ( ) const

Non-obvious return values are documented. Returns complexity information from the state.

◆ getComplexityType()

SoComplexity::Type SoCallbackAction::getComplexityType ( ) const

◆ getCoordinate3()

const SbVec3f& SoCallbackAction::getCoordinate3 ( int  index) const

◆ getCoordinate4()

const SbVec4f& SoCallbackAction::getCoordinate4 ( int  index) const

◆ getCreaseAngle()

float SoCallbackAction::getCreaseAngle ( ) const

◆ getCurPathTail()

virtual SoNode* SoCallbackAction::getCurPathTail ( )
virtual

Reimplemented from SoAction.

◆ getCurrentResponse()

Response SoCallbackAction::getCurrentResponse ( ) const
inline

Definition at line 321 of file SoCallbackAction.h.

◆ getDrawStyle()

SoDrawStyle::Style SoCallbackAction::getDrawStyle ( ) const

◆ getFaceType()

SoShapeHints::FaceType SoCallbackAction::getFaceType ( ) const

◆ getFocalDistance()

float SoCallbackAction::getFocalDistance ( ) const

◆ getFontName()

const SbName& SoCallbackAction::getFontName ( ) const

◆ getFontSize()

float SoCallbackAction::getFontSize ( ) const

◆ getLightAttenuation()

const SbVec3f& SoCallbackAction::getLightAttenuation ( ) const

◆ getLightModel()

SoLightModel::Model SoCallbackAction::getLightModel ( ) const

◆ getLinePattern()

u_short SoCallbackAction::getLinePattern ( ) const

◆ getLineWidth()

float SoCallbackAction::getLineWidth ( ) const

◆ getMaterial()

void SoCallbackAction::getMaterial ( SbColor ambient,
SbColor diffuse,
SbColor specular,
SbColor emission,
float &  shininess,
float &  transparency,
int  mtlIndex = 0 
) const

Providing a mtlIndex will return the material defined for that index.

◆ getMaterialBinding()

SoMaterialBinding::Binding SoCallbackAction::getMaterialBinding ( ) const

◆ getModelMatrix()

const SbMatrix& SoCallbackAction::getModelMatrix ( ) const

◆ getNormal()

const SbVec3f& SoCallbackAction::getNormal ( int  index) const

◆ getNormalBinding()

SoNormalBinding::Binding SoCallbackAction::getNormalBinding ( ) const

◆ getNumCoordinates()

int32_t SoCallbackAction::getNumCoordinates ( ) const

◆ getNumNormals()

int32_t SoCallbackAction::getNumNormals ( ) const

◆ getNumProfileCoordinates()

int32_t SoCallbackAction::getNumProfileCoordinates ( ) const

◆ getNumTextureCoordinates()

int32_t SoCallbackAction::getNumTextureCoordinates ( ) const

◆ getPickStyle()

SoPickStyle::Style SoCallbackAction::getPickStyle ( ) const

◆ getPointSize()

float SoCallbackAction::getPointSize ( ) const

◆ getProfile()

const SoNodeList& SoCallbackAction::getProfile ( ) const

◆ getProfileCoordinate2()

const SbVec2f& SoCallbackAction::getProfileCoordinate2 ( int  index) const

◆ getProfileCoordinate3()

const SbVec3f& SoCallbackAction::getProfileCoordinate3 ( int  index) const

◆ getProjectionMatrix()

const SbMatrix& SoCallbackAction::getProjectionMatrix ( ) const

◆ getShapeType()

SoShapeHints::ShapeType SoCallbackAction::getShapeType ( ) const

◆ getSwitch()

int32_t SoCallbackAction::getSwitch ( ) const

◆ getTextureBlendColor()

const SbColor& SoCallbackAction::getTextureBlendColor ( ) const

◆ getTextureCoordinate2()

const SbVec2f& SoCallbackAction::getTextureCoordinate2 ( int  index) const

◆ getTextureCoordinate4()

const SbVec4f& SoCallbackAction::getTextureCoordinate4 ( int  index) const

◆ getTextureCoordinateBinding()

SoTextureCoordinateBinding::Binding SoCallbackAction::getTextureCoordinateBinding ( ) const

◆ getTextureImage()

const unsigned char* SoCallbackAction::getTextureImage ( SbVec2s size,
int &  numComps 
) const

returns NULL if no texture is enabled.

◆ getTextureMatrix()

const SbMatrix& SoCallbackAction::getTextureMatrix ( ) const

◆ getTextureModel()

SoTexture2::Model SoCallbackAction::getTextureModel ( ) const

◆ getTextureWrapS()

SoTexture2::Wrap SoCallbackAction::getTextureWrapS ( ) const

◆ getTextureWrapT()

SoTexture2::Wrap SoCallbackAction::getTextureWrapT ( ) const

◆ getUnits()

SoUnits::Units SoCallbackAction::getUnits ( ) const

◆ getVertexOrdering()

SoShapeHints::VertexOrdering SoCallbackAction::getVertexOrdering ( ) const

◆ getViewingMatrix()

const SbMatrix& SoCallbackAction::getViewingMatrix ( ) const

◆ getViewVolume()

const SbViewVolume& SoCallbackAction::getViewVolume ( ) const

◆ initClass()

static void SoCallbackAction::initClass ( )
static

◆ invokeLineSegmentCallbacks()

void SoCallbackAction::invokeLineSegmentCallbacks ( const SoShape shape,
const SoPrimitiveVertex v1,
const SoPrimitiveVertex v2 
)

◆ invokePointCallbacks()

void SoCallbackAction::invokePointCallbacks ( const SoShape shape,
const SoPrimitiveVertex v 
)

◆ invokePostCallbacks()

void SoCallbackAction::invokePostCallbacks ( const SoNode node)

◆ invokePreCallbacks()

void SoCallbackAction::invokePreCallbacks ( const SoNode node)

◆ invokeTriangleCallbacks()

void SoCallbackAction::invokeTriangleCallbacks ( const SoShape shape,
const SoPrimitiveVertex v1,
const SoPrimitiveVertex v2,
const SoPrimitiveVertex v3 
)

◆ setCurrentNode()

void SoCallbackAction::setCurrentNode ( SoNode node)
inline

Definition at line 348 of file SoCallbackAction.h.

◆ shouldGeneratePrimitives()

bool SoCallbackAction::shouldGeneratePrimitives ( const SoShape shape) const

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