Open Inventor Reference
|
Performs a generic traversal of the scene graph. More...
#include <Inventor/actions/SoCallbackAction.h>
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... | |
![]() | |
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 SbVec3f & | getCoordinate3 (int index) const |
Returns the current coordinates from the state. More... | |
const SbVec4f & | getCoordinate4 (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 SbName & | getFontName () 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 SbVec3f & | getLightAttenuation () 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 SbVec3f & | getNormal (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 SbVec2f & | getProfileCoordinate2 (int index) const |
Returns the current profiles and their coordinates from the state. More... | |
const SbVec3f & | getProfileCoordinate3 (int index) const |
Returns the current profiles and their coordinates from the state. More... | |
const SoNodeList & | getProfile () 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 SbVec2f & | getTextureCoordinate2 (int index) const |
Returns texture information from the state. More... | |
const SbVec4f & | getTextureCoordinate4 (int index) const |
Returns texture information from the state. More... | |
SoTextureCoordinateBinding::Binding | getTextureCoordinateBinding () const |
const SbColor & | getTextureBlendColor () 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 SbMatrix & | getTextureMatrix () const |
Returns the current texture mapping information from the state. More... | |
SoTexture2::Model | getTextureModel () const |
SoTexture2::Wrap | getTextureWrapS () const |
SoTexture2::Wrap | getTextureWrapT () const |
const SbMatrix & | getModelMatrix () 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 SbMatrix & | getProjectionMatrix () const |
Returns the current camera and viewing information from the state. More... | |
const SbMatrix & | getViewingMatrix () const |
Returns the current camera and viewing information from the state. More... | |
const SbViewVolume & | getViewVolume () 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 SoNode * | getCurPathTail () |
Returns the node that caused the callback: More... | |
void | setCurrentNode (SoNode *node) |
Set the current node during traversal: More... | |
![]() | |
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... | |
SoNode * | getNodeAppliedTo () const |
These returns a pointer to the node, path, or path list the action is being applied to. More... | |
SoPath * | getPathAppliedTo () const |
const SoPathList * | getPathListAppliedTo () const |
A single path list may be split into several, one for each different head node. More... | |
const SoPathList * | getOriginalPathListAppliedTo () 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 SoPath * | getCurPath () |
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... | |
SoState * | getState () 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 SoLightweightPath & | getCurrentLightweightPath () 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 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... | |
![]() | |
SoAction () | |
Constructor. More... | |
virtual const SoEnabledElementsList & | getEnabledElements () 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 | |
![]() | |
SoState * | state |
Traversal state. More... | |
SoActionMethodList * | traversalMethods |
The list of what to do when. More... | |
![]() | |
static SoEnabledElementsList * | enabledElements |
Holds list of enabled elements for the SoAction class. More... | |
static SoActionMethodList * | methods |
... and the methods More... | |
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.
Definition at line 126 of file SoCallbackAction.h.
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.
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.
SoCallbackAction::SoCallbackAction | ( | ) |
|
virtual |
void SoCallbackAction::addLineSegmentCallback | ( | SoType | type, |
SoLineSegmentCB * | cb, | ||
void * | data | ||
) |
void SoCallbackAction::addPostCallback | ( | SoType | type, |
SoCallbackActionCB * | cb, | ||
void * | data | ||
) |
void SoCallbackAction::addPostTailCallback | ( | SoCallbackActionCB * | cb, |
void * | data | ||
) |
The functions are called just after the node at the tail of the path is traversed.
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.
void SoCallbackAction::addPreTailCallback | ( | SoCallbackActionCB * | cb, |
void * | data | ||
) |
The functions are called just before the node at the tail of the path is traversed.
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.
|
protectedvirtual |
Reimplemented from SoAction.
float SoCallbackAction::getComplexity | ( | ) | const |
Non-obvious return values are documented. Returns complexity information from the state.
SoComplexity::Type SoCallbackAction::getComplexityType | ( | ) | const |
const SbVec3f& SoCallbackAction::getCoordinate3 | ( | int | index | ) | const |
const SbVec4f& SoCallbackAction::getCoordinate4 | ( | int | index | ) | const |
float SoCallbackAction::getCreaseAngle | ( | ) | const |
|
inline |
Definition at line 321 of file SoCallbackAction.h.
SoDrawStyle::Style SoCallbackAction::getDrawStyle | ( | ) | const |
SoShapeHints::FaceType SoCallbackAction::getFaceType | ( | ) | const |
float SoCallbackAction::getFocalDistance | ( | ) | const |
const SbName& SoCallbackAction::getFontName | ( | ) | const |
float SoCallbackAction::getFontSize | ( | ) | const |
const SbVec3f& SoCallbackAction::getLightAttenuation | ( | ) | const |
SoLightModel::Model SoCallbackAction::getLightModel | ( | ) | const |
u_short SoCallbackAction::getLinePattern | ( | ) | const |
float SoCallbackAction::getLineWidth | ( | ) | const |
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.
SoMaterialBinding::Binding SoCallbackAction::getMaterialBinding | ( | ) | const |
const SbMatrix& SoCallbackAction::getModelMatrix | ( | ) | const |
const SbVec3f& SoCallbackAction::getNormal | ( | int | index | ) | const |
SoNormalBinding::Binding SoCallbackAction::getNormalBinding | ( | ) | const |
int32_t SoCallbackAction::getNumCoordinates | ( | ) | const |
int32_t SoCallbackAction::getNumNormals | ( | ) | const |
int32_t SoCallbackAction::getNumProfileCoordinates | ( | ) | const |
int32_t SoCallbackAction::getNumTextureCoordinates | ( | ) | const |
SoPickStyle::Style SoCallbackAction::getPickStyle | ( | ) | const |
float SoCallbackAction::getPointSize | ( | ) | const |
const SoNodeList& SoCallbackAction::getProfile | ( | ) | const |
const SbVec2f& SoCallbackAction::getProfileCoordinate2 | ( | int | index | ) | const |
const SbVec3f& SoCallbackAction::getProfileCoordinate3 | ( | int | index | ) | const |
const SbMatrix& SoCallbackAction::getProjectionMatrix | ( | ) | const |
SoShapeHints::ShapeType SoCallbackAction::getShapeType | ( | ) | const |
int32_t SoCallbackAction::getSwitch | ( | ) | const |
const SbColor& SoCallbackAction::getTextureBlendColor | ( | ) | const |
const SbVec2f& SoCallbackAction::getTextureCoordinate2 | ( | int | index | ) | const |
const SbVec4f& SoCallbackAction::getTextureCoordinate4 | ( | int | index | ) | const |
SoTextureCoordinateBinding::Binding SoCallbackAction::getTextureCoordinateBinding | ( | ) | const |
const unsigned char* SoCallbackAction::getTextureImage | ( | SbVec2s & | size, |
int & | numComps | ||
) | const |
returns NULL if no texture is enabled.
const SbMatrix& SoCallbackAction::getTextureMatrix | ( | ) | const |
SoTexture2::Model SoCallbackAction::getTextureModel | ( | ) | const |
SoTexture2::Wrap SoCallbackAction::getTextureWrapS | ( | ) | const |
SoTexture2::Wrap SoCallbackAction::getTextureWrapT | ( | ) | const |
SoUnits::Units SoCallbackAction::getUnits | ( | ) | const |
SoShapeHints::VertexOrdering SoCallbackAction::getVertexOrdering | ( | ) | const |
const SbMatrix& SoCallbackAction::getViewingMatrix | ( | ) | const |
const SbViewVolume& SoCallbackAction::getViewVolume | ( | ) | const |
|
static |
void SoCallbackAction::invokeLineSegmentCallbacks | ( | const SoShape * | shape, |
const SoPrimitiveVertex * | v1, | ||
const SoPrimitiveVertex * | v2 | ||
) |
void SoCallbackAction::invokePointCallbacks | ( | const SoShape * | shape, |
const SoPrimitiveVertex * | v | ||
) |
void SoCallbackAction::invokePostCallbacks | ( | const SoNode * | node | ) |
void SoCallbackAction::invokePreCallbacks | ( | const SoNode * | node | ) |
void SoCallbackAction::invokeTriangleCallbacks | ( | const SoShape * | shape, |
const SoPrimitiveVertex * | v1, | ||
const SoPrimitiveVertex * | v2, | ||
const SoPrimitiveVertex * | v3 | ||
) |
|
inline |
Definition at line 348 of file SoCallbackAction.h.
bool SoCallbackAction::shouldGeneratePrimitives | ( | const SoShape * | shape | ) | const |