SoCallbackAction Class Reference
[Actions]

Performs a generic traversal of a scene graph or path. More...

#include <Inventor/actions/SoCallbackAction.h>

Inheritance diagram for SoCallbackAction:
SoAction SoTypedObject SoSTLWriteAction SoToU3DAction SoToPDFAction

List of all members.

Public Types

enum  Response {
  CONTINUE,
  ABORT,
  PRUNE
}
typedef Response SoCallbackActionCB (void *userData, SoCallbackAction *action, const SoNode *node)

Public Member Functions

virtual SoType getTypeId () const
 SoCallbackAction ()
void addPreCallback (SoType type, SoCallbackActionCB *cb, void *data)
void addPostCallback (SoType type, SoCallbackActionCB *cb, void *data)
void addPreTailCallback (SoCallbackActionCB *cb, void *data)
void addPostTailCallback (SoCallbackActionCB *cb, void *data)
void addTriangleCallback (SoType type, SoTriangleCB *cb, void *data)
void addLineSegmentCallback (SoType type, SoLineSegmentCB *cb, void *data)
void addPointCallback (SoType type, SoPointCB *cb, void *data)
float getComplexity () const
SoComplexity::Type getComplexityType () const
int32_t getNumCoordinates () const
const SbVec3fgetCoordinate3 (int index) const
const SbVec4fgetCoordinate4 (int index) const
SoDecimationTypeElement::Type getDecimationType () const
float getDecimationPercentage () const
SoDrawStyle::Style getDrawStyle () const
u_short getLinePattern () const
int getLinePatternScaleFactor () const
float getLineWidth () const
float getPointSize () const
const SbStringgetFontName () const
float getFontSize () const
SoFont::RenderStyle getFontRenderStyle () const
SoLightModel::Model getLightModel () const
const SbVec3fgetLightAttenuation () const
void getMaterial (SbColor &ambient, SbColor &diffuse, SbColor &specular, SbColor &emission, float &shininess, float &transparency, int mtlIndex=0) const
SoMaterialBinding::Binding getMaterialBinding () const
SoGLRenderAction::TransparencyType getTransparencyType () const
int32_t getNumNormals () const
const SbVec3fgetNormal (int index) const
SoNormalBinding::Binding getNormalBinding () const
int32_t getNumProfileCoordinates () const
const SbVec2fgetProfileCoordinate2 (int index) const
const SbVec3fgetProfileCoordinate3 (int index) const
const SoNodeListgetProfile () const
SoShapeHints::VertexOrdering getVertexOrdering () const
SoShapeHints::ShapeType getShapeType () const
SoShapeHints::FaceType getFaceType () const
float getCreaseAngle () const
int32_t getNumTextureCoordinates () const
const SbVec2fgetTextureCoordinate2 (int index) const
const SbVec4fgetTextureCoordinate4 (int index) const
SoTextureCoordinateBinding::Binding getTextureCoordinateBinding () const
const SbColorgetTextureBlendColor () const
const unsigned char * getTextureImage (SbVec2i32 &size, int &numComps) const
const SbNamegetTextureFileName () const
const SbMatrixgetTextureMatrix () const
const SoTexture2TransformgetTextureTransformNode () const
SoTexture::Model getTextureModel () const
SoTexture::Wrap getTextureWrapS () const
SoTexture::Wrap getTextureWrapT () const
const SbMatrixgetModelMatrix () const
SoUnits::Units getUnits () const
float getFocalDistance () const
const SbMatrixgetProjectionMatrix () const
const SbMatrixgetViewingMatrix () const
const SbViewVolumegetViewVolume () const
SoPickStyle::Style getPickStyle () const
int32_t getSwitch () const
void setCallbackAll (SbBool flag)
SbBool isCallbackAll () const
virtual void forwardTraversal (SoNode *node)
virtual void forwardTraversal (SoPath *path)

Static Public Member Functions

static SoType getClassTypeId ()

Deprecated



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

Detailed Description

Performs a generic traversal of a scene graph or path.

Performs a generic traversal of a scene graph or path. In many cases a "custom" action can be implemented using SoCallbackAction with much less complexity than deriving a completely new action class.

The application can specify callback methods that will be called when the action traverses a node of the specified class or a derived class. For example a callback for the SoCone class will only be called for SoCone nodes, but a callback for the SoShape class will be called for any type of shape node.

This makes SoCallbackAction flexible and very convenient for "visiting" a set of nodes, especially when you only need the node itself and not a path to the node. For example, to count all the shapes in the scene graph. It is possible to get the path to the node being visited (see getCurPath() ), but SoSearchAction may be more convenient for getting a path to one or a small number of nodes.

In addition, callback methods can be registered to collect the primitives (trangles, lines and points) generated by shapes in the scene graph. These primitives are the actual geometry if the shape contains triangles, lines or points, else they represent or approximate the actual geometry. NOTE: Most, but not all, shapes can generate primitives. See below for a complete list. 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.

EXAMPLE

SEE ALSO

SoCallback, SoEventCallback, SoShape

See related examples:

AlternateRep


Member Typedef Documentation

typedef Response SoCallbackAction::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.

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.


Member Enumeration Documentation

Possible responses from a pre or post callback.

Enumerator:
CONTINUE 

Continue traversal as if nothing happened.

ABORT 

Abort traversal.

PRUNE 

Do not traverse node's children, but continue traversal.


Constructor & Destructor Documentation

SoCallbackAction::SoCallbackAction (  ) 

The constructor.


Member Function Documentation

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

Routine to add callbacks for generated primitives (line segments) for all shapes of the given type.

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

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

Routine to add callbacks for generated primitives (points) for all shapes of the given type.

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

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

Adds 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::addPostTailCallback ( SoCallbackActionCB cb,
void *  data 
)

Sets up a callback function to call when the action is applied to a path.

This function is called just after the node at the tail of the path is traversed.

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

Adds 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 
)

Sets up a callback function to call when the action is applied to a path.

This function is called just before the node at the tail of the path is traversed.

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

Routine to add callbacks for generated primitives (triangles) for all shapes of the given type.

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

virtual void SoCallbackAction::forwardTraversal ( SoPath path  )  [virtual]

Traverse a node that is not part of the current scenegraph. Like an SoNodeKit, the contents of the specified sub-scenegraph won't be visible as an SoPath. Casting the path to a SoFullPath allows access to the whole path.This method can be used to delegate an action to an internal/private scene graph. So a node can have an internal scene graph without actually being a "group" node. This is a convenient way to implement "composite" nodes that create their behavior using other Open Inventor nodes.The node parameter can be of any type. Sensors may still be attached directly to nodes and fields in the internal scene graph.This method must not be called from a node derived from SoGroup or SoBaseKit. This method should not be called on nodes that are part of the public/visible scene graph.

Note : The pre and post callbacks are not called if the traversed shape is a forward traversed shape.

Reimplemented from SoAction.

virtual void SoCallbackAction::forwardTraversal ( SoNode node  )  [virtual]

Traverse a node that is not part of the current scenegraph. Like an SoNodeKit, the contents of the specified sub-scenegraph won't be visible as an SoPath. Casting the path to a SoFullPath allows access to the whole path.This method can be used to delegate an action to an internal/private scene graph. So a node can have an internal scene graph without actually being a "group" node. This is a convenient way to implement "composite" nodes that create their behavior using other Open Inventor nodes.The node parameter can be of any type. Sensors may still be attached directly to nodes and fields in the internal scene graph.This method must not be called from a node derived from SoGroup or SoBaseKit. This method should not be called on nodes that are part of the public/visible scene graph.

Note : The pre and post callbacks are not called if the traversed shape is a forward traversed shape.

Reimplemented from SoAction.

static SoType SoCallbackAction::getClassTypeId (  )  [static]

Returns the type identifier for this class.

Reimplemented from SoAction.

Reimplemented in SoToPDFAction, SoToU3DAction, and SoSTLWriteAction.

float SoCallbackAction::getComplexity (  )  const

Returns complexity information from the state.

SoComplexity::Type SoCallbackAction::getComplexityType (  )  const

Returns complexity information from the state.

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

Returns the current coordinates from the state.

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

Returns the current coordinates from the state.

float SoCallbackAction::getCreaseAngle (  )  const

Returns the current shape hints from the state.

float SoCallbackAction::getDecimationPercentage (  )  const

Returns the current decimation percentage from the state.

SoDecimationTypeElement::Type SoCallbackAction::getDecimationType (  )  const

Returns the current decimation type from the state.

SoDrawStyle::Style SoCallbackAction::getDrawStyle (  )  const

Returns the current drawing style information from the state.

SoShapeHints::FaceType SoCallbackAction::getFaceType (  )  const

Returns the current shape hints from the state.

float SoCallbackAction::getFocalDistance (  )  const

Returns the current camera and viewing information from the state.

const SbString& SoCallbackAction::getFontName (  )  const

Returns the current font information from the state.

SoFont::RenderStyle SoCallbackAction::getFontRenderStyle (  )  const

Returns the current font information from the state.

float SoCallbackAction::getFontSize (  )  const

Returns the current font information from the state.

const SbVec3f& SoCallbackAction::getLightAttenuation (  )  const

Returns the current lighting model information from the state.

SoLightModel::Model SoCallbackAction::getLightModel (  )  const

Returns the current lighting model information from the state.

u_short SoCallbackAction::getLinePattern (  )  const

Returns the current drawing style information from the state.

int SoCallbackAction::getLinePatternScaleFactor (  )  const

Returns the current drawing style information from the state.

float SoCallbackAction::getLineWidth (  )  const

Returns the current drawing style information from the state.

void SoCallbackAction::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.

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

SoMaterialBinding::Binding SoCallbackAction::getMaterialBinding (  )  const

Returns the current material information from the state.

const SbMatrix& SoCallbackAction::getModelMatrix (  )  const

Returns the current modeling transformation from the state.

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

Returns the current normal information from the state.

SoNormalBinding::Binding SoCallbackAction::getNormalBinding (  )  const

Returns the current normal information from the state.

int32_t SoCallbackAction::getNumCoordinates (  )  const

Returns the current coordinates from the state.

int32_t SoCallbackAction::getNumNormals (  )  const

Returns the current normal information from the state.

int32_t SoCallbackAction::getNumProfileCoordinates (  )  const

Returns the current profiles and their coordinates from the state.

int32_t SoCallbackAction::getNumTextureCoordinates (  )  const

Returns texture information from the state.

getNumTextureCoordinates() returns 0 if texture coordinates are generated by a function.

SoPickStyle::Style SoCallbackAction::getPickStyle (  )  const

Returns the current picking style.

float SoCallbackAction::getPointSize (  )  const

Returns the current drawing style information from the state.

const SoNodeList& SoCallbackAction::getProfile (  )  const

Returns the current profiles and their coordinates from the state.

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

Returns the current profiles and their coordinates from the state.

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

Returns the current profiles and their coordinates from the state.

const SbMatrix& SoCallbackAction::getProjectionMatrix (  )  const

Returns the current camera and viewing information from the state.

SoShapeHints::ShapeType SoCallbackAction::getShapeType (  )  const

Returns the current shape hints from the state.

int32_t SoCallbackAction::getSwitch (  )  const

Returns the current switch value.

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

Returns texture information from the state.

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

Returns texture information from the state.

SoTextureCoordinateBinding::Binding SoCallbackAction::getTextureCoordinateBinding (  )  const

Returns texture information from the state.

const SbName& SoCallbackAction::getTextureFileName (  )  const

Returns texture information from the state.

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

Returns texture information from the state.

getTextureImage() returns NULL if no texture is enabled.

Deprecated:

Deprecated since Open Inventor 9400
Use a SbVec2i32 as the size parameter since a short can overflow.
const unsigned char* SoCallbackAction::getTextureImage ( SbVec2i32 size,
int &  numComps 
) const

Returns texture information from the state.

getTextureImage() returns NULL if no texture is enabled.

const SbMatrix& SoCallbackAction::getTextureMatrix (  )  const

Returns the current texture mapping information from the state.

SoTexture::Model SoCallbackAction::getTextureModel (  )  const

Returns the current texture mapping information from the state.

const SoTexture2Transform* SoCallbackAction::getTextureTransformNode (  )  const

Returns the current texture mapping information from the state.

SoTexture::Wrap SoCallbackAction::getTextureWrapS (  )  const

Returns the current texture mapping information from the state.

SoTexture::Wrap SoCallbackAction::getTextureWrapT (  )  const

Returns the current texture mapping information from the state.

SoGLRenderAction::TransparencyType SoCallbackAction::getTransparencyType (  )  const

Returns the current Transparency Type information from the state.

virtual SoType SoCallbackAction::getTypeId (  )  const [virtual]

Returns the type identifier for this specific instance.

Implements SoTypedObject.

Reimplemented in SoToPDFAction, SoToU3DAction, and SoSTLWriteAction.

SoUnits::Units SoCallbackAction::getUnits (  )  const

Returns the current units from the state.

SoShapeHints::VertexOrdering SoCallbackAction::getVertexOrdering (  )  const

Returns the current shape hints from the state.

const SbMatrix& SoCallbackAction::getViewingMatrix (  )  const

Returns the current camera and viewing information from the state.

const SbViewVolume& SoCallbackAction::getViewVolume (  )  const

Returns the current camera and viewing information from the state.

SbBool SoCallbackAction::isCallbackAll (  )  const [inline]

Returns whether the callback uses normal traversal (switches, etc.

) or whether it traverses every single node.

void SoCallbackAction::setCallbackAll ( SbBool  flag  )  [inline]

Sets whether the callback uses normal traversal (switches, etc.

) or whether it traverses every single node. Default is FALSE.


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

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/