public class SoCallbackAction extends SoAction
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.
Apply a callback action to visit all shape nodes.
This method will be called for each shape node in the scene graph.SoCallbackAction action = new SoCallbackAction(); action.addPreCallback ( SoShape.class, new NodeCallback(), null ); action.addTriangleCallback( SoShape.class, new TriangleCallback(), null ); action.apply( root );
This method will be called for each triangle in the shape node.class NodeCallback extends SoCallbackActionCB { @Override public int invoke( SoCallbackAction s, SoNode node ) { // Print node's name (if any) and class name System.out.println( "Shape \"" + node.getName() + "\": " + node.getClass().getName() ); return SoCallbackAction.Responses.CONTINUE.getValue(); } }
class TriangleCallback extends SoTriangleCB { @Override public void invoke( SoCallbackAction action, SoPrimitiveVertex v1, SoPrimitiveVertex v2, SoPrimitiveVertex v3 ) { System.out.println(" Triangle:"); printVertex(v1, "1"); printVertex(v2, "2"); printVertex(v3, "3"); } private void printVertex(SoPrimitiveVertex vertex, String label) { SbVec3f point = vertex.getPoint(); System.out.println(" Vert" + label + " = " + point.getX() + ", " + point.getY() + ", " + point.getZ()); } }
Example output:
Shape "": SoCone Triangle: Vert1 = 0.0, -1.0, -1.0 Vert2 = 0.0, 1.0, -0.0 Vert3 = 0.38268346, -1.0, -0.9238795 Triangle: Vert1 = 0.38268346, -1.0, -0.9238795 Vert2 = 0.0, 1.0, -0.0 Vert3 = 0.0, 1.0, -0.0 . . .
List of shapes supporting primitive generation:
SoAlgebraicShape
SoAnnoText3
SoAsciiText
SoBufferedShape
SoCircularExtrusion
SoCone
SoCSGShape
SoCube
SoCylinder
SoExtrusion
SoFaceSet
SoFenceSlice
SoHeightFieldRender
SoIndexedFaceSet
SoIndexedLineSet
SoIndexedMarkerSet
SoIndexedNurbsCurve
SoIndexedNurbsSurface
SoIndexedPointSet
SoIndexedQuadMesh
SoIndexedTriangleFanSet
SoIndexedTriangleSet
SoIndexedTriangleStripSet
SoLineSet
SoMarkerSet
SoNurbsCurve
SoNurbsSurface
SoObliqueSlice
SoOrthoSlice
SoPointSet
SoQuadMesh
SoSphere
SoText2
SoText3
SoTriangleSet
SoTriangleStripSet
SoVolumeRender
SoVolumeSkin
SoVRMLArc2D
SoVRMLArcClose2D
SoVRMLBox
SoVRMLCircle2D
SoVRMLCone
SoVRMLCylinder
SoVRMLDisk2D
SoVRMLElevationGrid
SoVRMLExtrusion
SoVRMLGeoElevationGrid
SoVRMLIndexedFaceSet
SoVRMLIndexedLineSet
SoVRMLIndexedTriangleFanSet
SoVRMLIndexedTriangleSet
SoVRMLIndexedTriangleStripSet
SoVRMLLineSet
SoVRMLPointSet
SoVRMLPolyline2D
SoVRMLPolypoint2D
SoVRMLRectangle2D
SoVRMLSphere
SoVRMLText
SoVRMLTriangleFanSet
SoVRMLTriangleSet
SoVRMLTriangleSet2D
SoVRMLTriangleStripSet
See also:
Modifier and Type | Class and Description |
---|---|
static class |
SoCallbackAction.Material |
static class |
SoCallbackAction.Responses
Possible responses from a pre or post callback.
|
static class |
SoCallbackAction.TextureImage |
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndices
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
ABORT
Deprecated.
Use
SoCallbackAction.Responses.ABORT instead. |
static int |
CONTINUE
Deprecated.
Use
SoCallbackAction.Responses.CONTINUE instead. |
static int |
PRUNE
Deprecated.
Use
SoCallbackAction.Responses.PRUNE instead. |
ALL, BELOW_PATH, CLUSTER_ONLY, IN_PATH, LOCAL_ONLY, NO_PATH, NODE, OFF_PATH, PATH, PATH_LIST
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoCallbackAction()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addLineSegmentCallback(java.lang.Class<? extends SoNode> nodeClass,
SoLineSegmentCB cb,
java.lang.Object userData) |
void |
addPointCallback(java.lang.Class<? extends SoNode> nodeClass,
SoPointCB cb,
java.lang.Object userData) |
void |
addPostCallback(java.lang.Class<? extends SoNode> nodeClass,
SoCallbackActionCB cb,
java.lang.Object userData) |
void |
addPostTailCallback(SoCallbackActionCB cb,
java.lang.Object userData) |
void |
addPreCallback(java.lang.Class<? extends SoNode> nodeClass,
SoCallbackActionCB cb,
java.lang.Object userData) |
void |
addPreTailCallback(SoCallbackActionCB cb,
java.lang.Object userData) |
void |
addTriangleCallback(java.lang.Class<? extends SoNode> nodeClass,
SoTriangleCB cb,
java.lang.Object userData) |
static void |
enableElement(java.lang.Class<? extends Inventor> t,
int stkIndex) |
float |
getComplexity()
Returns complexity information from the state.
|
SoComplexity.Types |
getComplexityType()
Returns complexity information from the state.
|
SbVec3f |
getCoordinate3(int index)
Returns the current coordinates from the state.
|
SbVec4f |
getCoordinate4(int index)
Returns the current coordinates from the state.
|
float |
getCreaseAngle()
Returns the current shape hints from the state.
|
SoCallbackAction.Responses |
getCurrentResponse() |
float |
getDecimationPercentage()
Returns the current decimation percentage from the state.
|
SoDecimationTypeElement.Types |
getDecimationType()
Returns the current decimation type from the state.
|
SoDrawStyle.Styles |
getDrawStyle()
Returns the current drawing style information from the state.
|
SoShapeHints.FaceTypes |
getFaceType()
Returns the current shape hints from the state.
|
float |
getFocalDistance()
Returns the current camera and viewing information from the state.
|
java.lang.String |
getFontName()
Returns the current font information from the state.
|
SoFont.RenderStyles |
getFontRenderStyle()
Returns the current font information from the state.
|
float |
getFontSize()
Returns the current font information from the state.
|
SbVec3f |
getLightAttenuation()
Returns the current lighting model information from the state.
|
SoLightModel.Models |
getLightModel()
Returns the current lighting model information from the state.
|
short |
getLinePattern()
Returns the current drawing style information from the state.
|
int |
getLinePatternScaleFactor()
Returns the current drawing style information from the state.
|
float |
getLineWidth()
Returns the current drawing style information from the state.
|
SoCallbackAction.Material |
getMaterial()
Calls getMaterial((int)0).
|
SoCallbackAction.Material |
getMaterial(int mtlIndex)
Returns the current material information from the state.
|
SoMaterialBinding.Bindings |
getMaterialBinding()
Returns the current material information from the state.
|
SbMatrix |
getModelMatrix()
Returns the current modeling transformation from the state.
|
SbVec3f |
getNormal(int index)
Returns the current normal information from the state.
|
SoNormalBinding.Bindings |
getNormalBinding()
Returns the current normal information from the state.
|
int |
getNumCoordinates()
Returns the current coordinates from the state.
|
int |
getNumNormals()
Returns the current normal information from the state.
|
int |
getNumProfileCoordinates()
Returns the current profiles and their coordinates from the state.
|
int |
getNumTextureCoordinates()
Returns texture information from the state.
|
SoPickStyle.Styles |
getPickStyle()
Returns the current picking style.
|
float |
getPointSize()
Returns the current drawing style information from the state.
|
java.util.Vector<SoNode> |
getProfile()
Returns the current profiles and their coordinates from the state.
|
SbVec2f |
getProfileCoordinate2(int index)
Returns the current profiles and their coordinates from the state.
|
SbVec3f |
getProfileCoordinate3(int index)
Returns the current profiles and their coordinates from the state.
|
SbMatrix |
getProjectionMatrix()
Returns the current camera and viewing information from the state.
|
SoShapeHints.ShapeTypes |
getShapeType()
Returns the current shape hints from the state.
|
int |
getSwitch()
Returns the current switch value.
|
SbColor |
getTextureBlendColor()
Returns texture information from the state.
|
SbVec2f |
getTextureCoordinate2(int index)
Returns texture information from the state.
|
SbVec4f |
getTextureCoordinate4(int index)
Returns texture information from the state.
|
SoTextureCoordinateBinding.Bindings |
getTextureCoordinateBinding()
Returns texture information from the state.
|
java.lang.String |
getTextureFileName()
Returns texture information from the state.
|
SoCallbackAction.TextureImage |
getTextureImage()
Returns texture information from the state.
|
SbMatrix |
getTextureMatrix()
Returns the current texture mapping information from the state.
|
SoTexture.Models |
getTextureModel()
Returns the current texture mapping information from the state.
|
SoTexture2Transform |
getTextureTransformNode()
Returns the current texture mapping information from the state.
|
SoTexture.WrapType |
getTextureWrapS()
Returns the current texture mapping information from the state.
|
SoTexture.WrapType |
getTextureWrapT()
Returns the current texture mapping information from the state.
|
SoTransparencyType.TransparencyTypes |
getTransparencyType()
Deprecated.
As of Open Inventor 9630 See documentation for more details
|
SoUnits.UnitsType |
getUnits()
Returns the current units from the state.
|
SoShapeHints.VertexOrderings |
getVertexOrdering()
Returns the current shape hints from the state.
|
SbMatrix |
getViewingMatrix()
Returns the current camera and viewing information from the state.
|
SbViewVolume |
getViewVolume()
Returns the current camera and viewing information from the state.
|
void |
invokeLineSegmentCallbacks(SoShape shape,
SoPrimitiveVertex[] v1,
SoPrimitiveVertex[] v2) |
void |
invokePointCallbacks(SoShape shape,
SoPrimitiveVertex[] v) |
void |
invokePostCallbacks(SoNode node) |
void |
invokePreCallbacks(SoNode node) |
void |
invokeTriangleCallbacks(SoShape shape,
SoPrimitiveVertex[] v1,
SoPrimitiveVertex[] v2,
SoPrimitiveVertex[] v3) |
boolean |
isCallbackAll()
Returns whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node.
|
void |
setCallbackAll(boolean flag)
Sets whether the callback uses normal traversal (switches, etc.) or whether it traverses every single node.
|
boolean |
shouldGeneratePrimitives(SoShape shape) |
apply, apply, clearApplyResult, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRep
dispose, getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int CONTINUE
SoCallbackAction.Responses.CONTINUE
instead.@Deprecated public static final int ABORT
SoCallbackAction.Responses.ABORT
instead.@Deprecated public static final int PRUNE
SoCallbackAction.Responses.PRUNE
instead.public void addPreTailCallback(SoCallbackActionCB cb, java.lang.Object userData)
public void addPostTailCallback(SoCallbackActionCB cb, java.lang.Object userData)
public void addPreCallback(java.lang.Class<? extends SoNode> nodeClass, SoCallbackActionCB cb, java.lang.Object userData)
public void addPostCallback(java.lang.Class<? extends SoNode> nodeClass, SoCallbackActionCB cb, java.lang.Object userData)
public void addTriangleCallback(java.lang.Class<? extends SoNode> nodeClass, SoTriangleCB cb, java.lang.Object userData)
public void addLineSegmentCallback(java.lang.Class<? extends SoNode> nodeClass, SoLineSegmentCB cb, java.lang.Object userData)
public void addPointCallback(java.lang.Class<? extends SoNode> nodeClass, SoPointCB cb, java.lang.Object userData)
public SoCallbackAction.Material getMaterial()
public void invokePreCallbacks(SoNode node)
public void invokePostCallbacks(SoNode node)
public float getFontSize()
public float getPointSize()
public void invokeLineSegmentCallbacks(SoShape shape, SoPrimitiveVertex[] v1, SoPrimitiveVertex[] v2)
public java.lang.String getFontName()
public void invokeTriangleCallbacks(SoShape shape, SoPrimitiveVertex[] v1, SoPrimitiveVertex[] v2, SoPrimitiveVertex[] v3)
public SoFont.RenderStyles getFontRenderStyle()
public SoCallbackAction.Material getMaterial(int mtlIndex)
public SoMaterialBinding.Bindings getMaterialBinding()
@Deprecated public SoTransparencyType.TransparencyTypes getTransparencyType()
SoTransparencyType
. public static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
public SoCallbackAction.Responses getCurrentResponse()
public SoLightModel.Models getLightModel()
public SbVec3f getLightAttenuation()
public int getNumCoordinates()
public SbVec3f getCoordinate3(int index)
public SbVec4f getCoordinate4(int index)
public SoComplexity.Types getComplexityType()
public SbVec4f getTextureCoordinate4(int index)
public float getComplexity()
public SoDecimationTypeElement.Types getDecimationType()
public int getLinePatternScaleFactor()
public void invokePointCallbacks(SoShape shape, SoPrimitiveVertex[] v)
public float getLineWidth()
public boolean shouldGeneratePrimitives(SoShape shape)
public float getDecimationPercentage()
public SoDrawStyle.Styles getDrawStyle()
public short getLinePattern()
public SoTexture.WrapType getTextureWrapT()
public float getCreaseAngle()
public SoTexture.WrapType getTextureWrapS()
public int getNumTextureCoordinates()
getNumTextureCoordinates()
returns 0 if texture coordinates are generated by a function.public SoUnits.UnitsType getUnits()
public SoShapeHints.ShapeTypes getShapeType()
public SbMatrix getModelMatrix()
public SoShapeHints.FaceTypes getFaceType()
public SbColor getTextureBlendColor()
public SbMatrix getTextureMatrix()
public SoCallbackAction.TextureImage getTextureImage()
getTextureImage()
returns NULL if no texture is enabled.public java.lang.String getTextureFileName()
public SoTexture.Models getTextureModel()
public SbVec2f getTextureCoordinate2(int index)
public SoTextureCoordinateBinding.Bindings getTextureCoordinateBinding()
public SoTexture2Transform getTextureTransformNode()
public int getSwitch()
public SoNormalBinding.Bindings getNormalBinding()
public SoPickStyle.Styles getPickStyle()
public int getNumProfileCoordinates()
public boolean isCallbackAll()
public int getNumNormals()
public void setCallbackAll(boolean flag)
public SbVec3f getNormal(int index)
public SbMatrix getProjectionMatrix()
public java.util.Vector<SoNode> getProfile()
public float getFocalDistance()
public SoShapeHints.VertexOrderings getVertexOrdering()
public SbViewVolume getViewVolume()
public SbVec2f getProfileCoordinate2(int index)
public SbMatrix getViewingMatrix()
public SbVec3f getProfileCoordinate3(int index)
Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com