![]() |
http://www.sim.no http://www.coin3d.org |
The SoCallbackAction class invokes callbacks at specific nodes.This action has mechanisms for tracking traversal position and traversal state. In combination with the ability to pass geometry primitives to callback actions set by the user, this does for instance make it rather straightforward to extract the geometry of a scene graph. More...
#include <Inventor/actions/SoCallbackAction.h>
Public Types | |
enum | Response { CONTINUE, ABORT, PRUNE } |
typedef Response | SoCallbackActionCB(void *userdata, SoCallbackAction *action, const SoNode *node) |
![]() | |
enum | AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 } |
enum | PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 } |
Public Member Functions | |
virtual SoType | getTypeId (void) const |
SoCallbackAction (void) | |
SoCallbackAction (const SbViewportRegion &vp) | |
virtual | ~SoCallbackAction () |
void | setViewportRegion (const SbViewportRegion &vp) |
void | addPreCallback (const SoType type, SoCallbackActionCB *cb, void *userdata) |
void | addPostCallback (const SoType type, SoCallbackActionCB *cb, void *userdata) |
void | addPreTailCallback (SoCallbackActionCB *cb, void *userdata) |
void | addPostTailCallback (SoCallbackActionCB *cb, void *userdata) |
void | addTriangleCallback (const SoType type, SoTriangleCB *cb, void *userdata) |
void | addLineSegmentCallback (const SoType type, SoLineSegmentCB *cb, void *userdata) |
void | addPointCallback (const SoType type, SoPointCB *cb, void *userdata) |
SoDecimationTypeElement::Type | getDecimationType (void) const |
float | getDecimationPercentage (void) const |
float | getComplexity (void) const |
SoComplexity::Type | getComplexityType (void) const |
int32_t | getNumCoordinates (void) const |
const SbVec3f & | getCoordinate3 (const int index) const |
const SbVec4f & | getCoordinate4 (const int index) const |
SoDrawStyle::Style | getDrawStyle (void) const |
unsigned short | getLinePattern (void) const |
float | getLineWidth (void) const |
float | getPointSize (void) const |
const SbName & | getFontName (void) const |
float | getFontSize (void) const |
SoLightModel::Model | getLightModel (void) const |
const SbVec3f & | getLightAttenuation (void) const |
void | getMaterial (SbColor &ambient, SbColor &diffuse, SbColor &specular, SbColor &emission, float &shininess, float &transparency, const int index=0) const |
SoMaterialBinding::Binding | getMaterialBinding (void) const |
uint32_t | getNumNormals (void) const |
const SbVec3f & | getNormal (const int index) const |
SoNormalBinding::Binding | getNormalBinding (void) const |
int32_t | getNumProfileCoordinates (void) const |
const SbVec2f & | getProfileCoordinate2 (const int index) const |
const SbVec3f & | getProfileCoordinate3 (const int index) const |
const SoNodeList & | getProfile (void) const |
SoShapeHints::VertexOrdering | getVertexOrdering (void) const |
SoShapeHints::ShapeType | getShapeType (void) const |
SoShapeHints::FaceType | getFaceType (void) const |
float | getCreaseAngle (void) const |
int32_t | getNumTextureCoordinates (void) const |
const SbVec2f & | getTextureCoordinate2 (const int index) const |
const SbVec3f & | getTextureCoordinate3 (const int index) const |
const SbVec4f & | getTextureCoordinate4 (const int index) const |
SoTextureCoordinateBinding::Binding | getTextureCoordinateBinding (void) const |
const SbColor & | getTextureBlendColor (void) const |
const unsigned char * | getTextureImage (SbVec2s &size, int &numcomps) const |
const unsigned char * | getTextureImage (SbVec3s &size, int &numcomps) const |
const SbMatrix & | getTextureMatrix (void) const |
SoTexture2::Model | getTextureModel (void) const |
SoTexture2::Wrap | getTextureWrapS (void) const |
SoTexture2::Wrap | getTextureWrapT (void) const |
SoTexture2::Wrap | getTextureWrapR (void) const |
const SbMatrix & | getModelMatrix (void) const |
SoUnits::Units | getUnits (void) const |
float | getFocalDistance (void) const |
const SbMatrix & | getProjectionMatrix (void) const |
const SbMatrix & | getViewingMatrix (void) const |
const SbViewVolume & | getViewVolume (void) const |
const SbViewportRegion & | getViewportRegion (void) const |
SoPickStyle::Style | getPickStyle (void) const |
int32_t | getSwitch (void) const |
Response | getCurrentResponse (void) const |
void | invokePreCallbacks (const SoNode *const node) |
void | invokePostCallbacks (const SoNode *const node) |
void | invokeTriangleCallbacks (const SoShape *const shape, const SoPrimitiveVertex *const v1, const SoPrimitiveVertex *const v2, const SoPrimitiveVertex *const v3) |
void | invokeLineSegmentCallbacks (const SoShape *const shape, const SoPrimitiveVertex *const v1, const SoPrimitiveVertex *const v2) |
void | invokePointCallbacks (const SoShape *const shape, const SoPrimitiveVertex *const v) |
SbBool | shouldGeneratePrimitives (const SoShape *shape) const |
virtual SoNode * | getCurPathTail (void) |
void | setCurrentNode (SoNode *const node) |
![]() | |
virtual | ~SoAction () |
virtual SbBool | isOfType (SoType type) const |
virtual void | apply (SoNode *root) |
virtual void | apply (SoPath *path) |
virtual void | apply (const SoPathList &pathlist, SbBool obeysrules=0) |
void | apply (SoAction *beingApplied) |
virtual void | invalidateState (void) |
AppliedCode | getWhatAppliedTo (void) const |
SoNode * | getNodeAppliedTo (void) const |
SoPath * | getPathAppliedTo (void) const |
const SoPathList * | getPathListAppliedTo (void) const |
const SoPathList * | getOriginalPathListAppliedTo (void) const |
SbBool | isLastPathListAppliedTo (void) const |
PathCode | getPathCode (int &numindices, const int *&indices) |
void | traverse (SoNode *const node) |
SbBool | hasTerminated (void) const |
const SoPath * | getCurPath (void) |
SoState * | getState (void) const |
PathCode | getCurPathCode (void) const |
void | usePathCode (int &numindices, const int *&indices) |
void | pushCurPath (const int childindex, SoNode *node=NULL) |
void | popCurPath (const PathCode prevpathcode) |
void | pushCurPath (void) |
void | popPushCurPath (const int childindex, SoNode *node=NULL) |
void | popCurPath (void) |
void | switchToPathTraversal (SoPath *path) |
void | switchToNodeTraversal (SoNode *node) |
Static Public Member Functions | |
static SoType | getClassTypeId (void) |
static void | addMethod (const SoType type, SoActionMethod method) |
static void | enableElement (const SoType type, const int stackindex) |
static void | initClass (void) |
![]() | |
static void | initClass (void) |
static void | initClasses (void) |
static SoType | getClassTypeId (void) |
static void | nullAction (SoAction *action, SoNode *node) |
Protected Member Functions | |
virtual const SoEnabledElementsList & | getEnabledElements (void) const |
virtual void | beginTraversal (SoNode *node) |
![]() | |
SoAction (void) | |
virtual void | endTraversal (SoNode *node) |
void | setTerminated (const SbBool flag) |
virtual SbBool | shouldCompactPathList (void) const |
Static Protected Member Functions | |
static SoEnabledElementsList * | getClassEnabledElements (void) |
static SoActionMethodList * | getClassActionMethods (void) |
![]() | |
static SoEnabledElementsList * | getClassEnabledElements (void) |
static SoActionMethodList * | getClassActionMethods (void) |
Friends | |
class | SoCallbackActionP |
Additional Inherited Members | |
![]() | |
SoState * | state |
SoActionMethodList * | traversalMethods |
The SoCallbackAction class invokes callbacks at specific nodes.
This action has mechanisms for tracking traversal position and traversal state. In combination with the ability to pass geometry primitives to callback actions set by the user, this does for instance make it rather straightforward to extract the geometry of a scene graph.
You should be able to use this action for most of your "simple" traversal needs, instead of cooking up your own code, as the SoCallbackAction is rather flexible.
A common use of this action is to extract geometry of non-primitive shapes as triangles. A full-fledged example that demonstrates this on a scenegraph with two spheres follows:
Response SoCallbackAction::SoCallbackActionCB |
Callback functions need to be of this type. node is at the current traversal point in the scene graph.
Response values for callback function.
SoCallbackAction::SoCallbackAction | ( | void | ) |
Default constructor. Will set the viewport to a standard viewport with size 640x512.
SoCallbackAction::SoCallbackAction | ( | const SbViewportRegion & | vp | ) |
Constructor which lets you specify the viewport.
This constructor is an extension versus the Open Inventor API.
|
virtual |
Destructor.
References SbList< Type >::append(), SoType::getAllDerivedFrom(), and SbList< Type >::getLength().
|
virtual |
Returns the type identification of an action derived from a class inheriting SoAction. This is used for run-time type checking and "downward" casting.
Usage example:
For application programmers wanting to extend the library with new actions: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through Inventor/nodes/SoSubAction.h: SO_ACTION_SOURCE, SO_ACTION_INIT_CLASS and SO_ACTION_CONSTRUCTOR.
For more information on writing Coin extensions, see the SoAction class documentation.
Returns the actual type id of an object derived from a class inheriting SoAction. Needs to be overridden in all subclasses.
Implements SoAction.
Reimplemented in SoVectorizeAction, and SoVectorizePSAction.
|
static |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Referenced by SoNode::setCompatibilityTypes().
|
static |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
|
protectedvirtual |
Returns a list of the elements used by action instances of this class upon traversal operations.
Reimplemented from SoAction.
Reimplemented in SoVectorizeAction, and SoVectorizePSAction.
void SoCallbackAction::setViewportRegion | ( | const SbViewportRegion & | vp | ) |
Sets the viewport region for this action. When set, the viewport element is initialized right before a traversal starts, making it the current viewport.
This method is an extension versus the Open Inventor API.
References SbList< Type >::getLength().
Referenced by SoVectorizeAction::beginPage(), SoVectorizeAction::beginViewport(), and SoExtSelection::wasShiftDown().
void SoCallbackAction::addPreCallback | ( | const SoType | type, |
SoCallbackActionCB * | cb, | ||
void * | userdata | ||
) |
Set a function cb to call before every node of type is traversed. cb will be called with userdata.
Referenced by SoIntersectionDetectionAction::apply().
void SoCallbackAction::addPostCallback | ( | const SoType | type, |
SoCallbackActionCB * | cb, | ||
void * | userdata | ||
) |
Set a function cb to call after every node of type has been traversed. cb will be called with userdata.
void SoCallbackAction::addPreTailCallback | ( | SoCallbackActionCB * | cb, |
void * | userdata | ||
) |
Set a function cb to call before the tail of a path is traversed. cb will be called with userdata.
void SoCallbackAction::addPostTailCallback | ( | SoCallbackActionCB * | cb, |
void * | userdata | ||
) |
Set a function cb to call after the tail of a path has been traversed. cb will be called with userdata.
void SoCallbackAction::addTriangleCallback | ( | const SoType | type, |
SoTriangleCB * | cb, | ||
void * | userdata | ||
) |
Set a function cb to call when traversing a node of type which generates triangle primitives for rendering. cb will be called with userdata.
Referenced by SoIntersectionDetectionAction::apply().
void SoCallbackAction::addLineSegmentCallback | ( | const SoType | type, |
SoLineSegmentCB * | cb, | ||
void * | userdata | ||
) |
Set a function cb to call when traversing a node of type which generates line primitives for rendering. cb will be called with userdata.
void SoCallbackAction::addPointCallback | ( | const SoType | type, |
SoPointCB * | cb, | ||
void * | userdata | ||
) |
Set a function cb to call when traversing a node of type which generates single point primitives for rendering. cb will be called with userdata.
SoDecimationTypeElement::Type SoCallbackAction::getDecimationType | ( | void | ) | const |
Returns current decimation type setting.
float SoCallbackAction::getDecimationPercentage | ( | void | ) | const |
Returns current decimation percentage setting.
float SoCallbackAction::getComplexity | ( | void | ) | const |
Returns current complexity setting.
SoComplexity::Type SoCallbackAction::getComplexityType | ( | void | ) | const |
Returns current complexity type setting.
int32_t SoCallbackAction::getNumCoordinates | ( | void | ) | const |
Returns current number of coordinates in the state.
const SbVec3f & SoCallbackAction::getCoordinate3 | ( | const int | index | ) | const |
Returns a coordinate triplet from the current state pool of coordinates.
const SbVec4f & SoCallbackAction::getCoordinate4 | ( | const int | index | ) | const |
Returns a coordinate quartuplet from the current state pool of coordinates.
SoDrawStyle::Style SoCallbackAction::getDrawStyle | ( | void | ) | const |
Returns current draw style setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
unsigned short SoCallbackAction::getLinePattern | ( | void | ) | const |
Returns current line pattern setting.
float SoCallbackAction::getLineWidth | ( | void | ) | const |
Returns current line width setting.
References SoLineWidthElement::get().
float SoCallbackAction::getPointSize | ( | void | ) | const |
Returns current point size setting.
References SoPointSizeElement::get().
const SbName & SoCallbackAction::getFontName | ( | void | ) | const |
Returns current fontname setting.
float SoCallbackAction::getFontSize | ( | void | ) | const |
Returns current fontsize setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
SoLightModel::Model SoCallbackAction::getLightModel | ( | void | ) | const |
Returns current lightmodel setting.
const SbVec3f & SoCallbackAction::getLightAttenuation | ( | void | ) | const |
Returns current light attenuation setting.
void SoCallbackAction::getMaterial | ( | SbColor & | ambient, |
SbColor & | diffuse, | ||
SbColor & | specular, | ||
SbColor & | emission, | ||
float & | shininess, | ||
float & | transparency, | ||
const int | index = 0 |
||
) | const |
Returns current material settings.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
SoMaterialBinding::Binding SoCallbackAction::getMaterialBinding | ( | void | ) | const |
Returns current materialbinding setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
uint32_t SoCallbackAction::getNumNormals | ( | void | ) | const |
Returns current number of normals in the state.
const SbVec3f & SoCallbackAction::getNormal | ( | const int | index | ) | const |
Returns the normal vectors at index from the current state.
SoNormalBinding::Binding SoCallbackAction::getNormalBinding | ( | void | ) | const |
Returns current normalbinding setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
int32_t SoCallbackAction::getNumProfileCoordinates | ( | void | ) | const |
Returns current number of profile coordinates in the state.
const SbVec2f & SoCallbackAction::getProfileCoordinate2 | ( | const int | index | ) | const |
Returns current number of SbVec2f profile coordinates in the state.
const SbVec3f & SoCallbackAction::getProfileCoordinate3 | ( | const int | index | ) | const |
Returns current number of SbVec3f profile coordinates in the state.
const SoNodeList & SoCallbackAction::getProfile | ( | void | ) | const |
Returns current list of profile nodes.
SoShapeHints::VertexOrdering SoCallbackAction::getVertexOrdering | ( | void | ) | const |
Returns current vertexordering shapehint setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
SoShapeHints::ShapeType SoCallbackAction::getShapeType | ( | void | ) | const |
Returns current shapetype hint setting.
SoShapeHints::FaceType SoCallbackAction::getFaceType | ( | void | ) | const |
Returns current facetype hint setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
float SoCallbackAction::getCreaseAngle | ( | void | ) | const |
Returns current creaseangle setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
int32_t SoCallbackAction::getNumTextureCoordinates | ( | void | ) | const |
Returns current number of texture coordinates in the traversal state.
const SbVec2f & SoCallbackAction::getTextureCoordinate2 | ( | const int | index | ) | const |
Returns SbVec2f texture coordinate at index from the texture coordinate pool of the traversal state.
const SbVec3f & SoCallbackAction::getTextureCoordinate3 | ( | const int | index | ) | const |
Returns SbVec3f texture coordinate at index from the texture coordinate pool of the traversal state.
This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
const SbVec4f & SoCallbackAction::getTextureCoordinate4 | ( | const int | index | ) | const |
Returns SbVec4f texture coordinate at index from the texture coordinate pool of the traversal state.
SoTextureCoordinateBinding::Binding SoCallbackAction::getTextureCoordinateBinding | ( | void | ) | const |
Returns current texturecoordinate binding setting.
const SbColor & SoCallbackAction::getTextureBlendColor | ( | void | ) | const |
Returns current texture blend color setting.
const unsigned char * SoCallbackAction::getTextureImage | ( | SbVec2s & | size, |
int & | numcomps | ||
) | const |
Returns current texture image settings.
const unsigned char * SoCallbackAction::getTextureImage | ( | SbVec3s & | size, |
int & | numcomps | ||
) | const |
Returns current 3D texture image settings.
This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
const SbMatrix & SoCallbackAction::getTextureMatrix | ( | void | ) | const |
Returns current texture transformation matrix setting.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
SoTexture2::Model SoCallbackAction::getTextureModel | ( | void | ) | const |
Returns current texturemapping model setting.
SoTexture2::Wrap SoCallbackAction::getTextureWrapS | ( | void | ) | const |
Returns current texture wrapping setting for the S
coordinate.
SoTexture2::Wrap SoCallbackAction::getTextureWrapT | ( | void | ) | const |
Returns current texture wrapping setting for the T
coordinate.
SoTexture2::Wrap SoCallbackAction::getTextureWrapR | ( | void | ) | const |
Returns current texture wrapping setting for the R
coordinate.
This function is an extension for Coin, and it is not available in the original SGI Open Inventor v2.1 API.
const SbMatrix & SoCallbackAction::getModelMatrix | ( | void | ) | const |
Returns current model matrix.
Referenced by SoIntersectionDetectionAction::apply().
SoUnits::Units SoCallbackAction::getUnits | ( | void | ) | const |
Returns current units setting.
float SoCallbackAction::getFocalDistance | ( | void | ) | const |
Returns current camera focal distance setting.
const SbMatrix & SoCallbackAction::getProjectionMatrix | ( | void | ) | const |
Returns current projection matrix.
const SbMatrix & SoCallbackAction::getViewingMatrix | ( | void | ) | const |
Returns current viewing matrix.
const SbViewVolume & SoCallbackAction::getViewVolume | ( | void | ) | const |
Returns current view volume setting.
const SbViewportRegion & SoCallbackAction::getViewportRegion | ( | void | ) | const |
Returns current viewport region setting.
This method is an extension versus the Open Inventor API.
SoPickStyle::Style SoCallbackAction::getPickStyle | ( | void | ) | const |
Returns current pickstyle setting.
int32_t SoCallbackAction::getSwitch | ( | void | ) | const |
Returns last SoSwitch::whichChild setting during the traversal.
Referenced by SoToVRML2Action::doReuseGeometryNodes().
SoCallbackAction::Response SoCallbackAction::getCurrentResponse | ( | void | ) | const |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Referenced by SoNode::callbackS().
void SoCallbackAction::invokePreCallbacks | ( | const SoNode *const | node | ) |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Invoke all "pre traversal" callbacks.
References ABORT, SoType::getData(), and SoBase::getTypeId().
Referenced by SoNode::callbackS().
void SoCallbackAction::invokePostCallbacks | ( | const SoNode *const | node | ) |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Invoke all "post traversal" callbacks.
References ABORT, SoType::getData(), and SoBase::getTypeId().
Referenced by SoNode::callbackS().
void SoCallbackAction::invokeTriangleCallbacks | ( | const SoShape *const | shape, |
const SoPrimitiveVertex *const | v1, | ||
const SoPrimitiveVertex *const | v2, | ||
const SoPrimitiveVertex *const | v3 | ||
) |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Invoke all "triangle generation" callbacks.
References SoType::getData(), and SoShape::getTypeId().
Referenced by SoShape::invokeTriangleCallbacks().
void SoCallbackAction::invokeLineSegmentCallbacks | ( | const SoShape *const | shape, |
const SoPrimitiveVertex *const | v1, | ||
const SoPrimitiveVertex *const | v2 | ||
) |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Invoke all "line segment generation" callbacks.
References SoType::getData(), and SoShape::getTypeId().
Referenced by SoShape::invokeLineSegmentCallbacks().
void SoCallbackAction::invokePointCallbacks | ( | const SoShape *const | shape, |
const SoPrimitiveVertex *const | v | ||
) |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Invoke all "point" callbacks.
References SoType::getData(), and SoShape::getTypeId().
Referenced by SoShape::invokePointCallbacks().
SbBool SoCallbackAction::shouldGeneratePrimitives | ( | const SoShape * | shape | ) | const |
This API member is considered internal to the library, as it is not likely to be of interest to the application programmer.
Check from the shape nodes whether or not to generate primitives from the complex shapes. If there are no callbacks attached to the node types, making the primitives would only be a waste of CPU.
References SoType::getData(), and SoShape::getTypeId().
Referenced by SoShape::callback().
|
virtual |
Returns the current tail of the traversal path for the callback action.
Reimplemented from SoAction.
void SoCallbackAction::setCurrentNode | ( | SoNode *const | node | ) |
Used from nodes during traversal to keep a current node pointer in the action.
Referenced by SoNode::callbackS().
|
protectedvirtual |
This virtual method is called from SoAction::apply(), and is the entry point for the actual scenegraph traversal.
It can be overridden to initialize the action at traversal start, for specific initializations in the action subclasses inheriting SoAction.
Default method just calls traverse(), which any overridden implementation of the method must do too (or call SoAction::beginTraversal()) to trigger the scenegraph traversal.
Reimplemented from SoAction.
References CONTINUE.
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Fri Feb 17 2017 for Coin by Doxygen. 1.8.13