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 . . .
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
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.
|
SoGLRenderAction.TransparencyTypes |
getTransparencyType()
Returns the current Transparency Type information from the state.
|
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, getDistribMode, 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, getNativeResourceHandle
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 static void enableElement(java.lang.Class<? extends Inventor> t, int stkIndex)
public SoCallbackAction.Responses getCurrentResponse()
public float getPointSize()
public SoDrawStyle.Styles getDrawStyle()
public short getLinePattern()
public int getLinePatternScaleFactor()
public boolean isCallbackAll()
public float getLineWidth()
public void setCallbackAll(boolean flag)
public float getDecimationPercentage()
public SoComplexity.Types getComplexityType()
public void invokePointCallbacks(SoShape shape, SoPrimitiveVertex[] v)
public int getNumCoordinates()
public boolean shouldGeneratePrimitives(SoShape shape)
public int getNumTextureCoordinates()
getNumTextureCoordinates()
returns 0 if texture coordinates are generated by a function.public float getComplexity()
public void invokePostCallbacks(SoNode node)
public SoDecimationTypeElement.Types getDecimationType()
public void invokePreCallbacks(SoNode node)
public SbVec4f getCoordinate4(int index)
public void invokeLineSegmentCallbacks(SoShape shape, SoPrimitiveVertex[] v1, SoPrimitiveVertex[] v2)
public SbVec3f getCoordinate3(int index)
public void invokeTriangleCallbacks(SoShape shape, SoPrimitiveVertex[] v1, SoPrimitiveVertex[] v2, SoPrimitiveVertex[] v3)
public SbVec2f getProfileCoordinate2(int index)
public SbMatrix getTextureMatrix()
public SbVec3f getProfileCoordinate3(int index)
public java.lang.String getTextureFileName()
public int getNumProfileCoordinates()
public SoTexture.Models getTextureModel()
public SbVec3f getNormal(int index)
public SoTexture2Transform getTextureTransformNode()
public SoNormalBinding.Bindings getNormalBinding()
public SoCallbackAction.TextureImage getTextureImage()
getTextureImage()
returns NULL if no texture is enabled.public SoShapeHints.FaceTypes getFaceType()
public SbVec4f getTextureCoordinate4(int index)
public float getCreaseAngle()
public SbVec2f getTextureCoordinate2(int index)
public SoShapeHints.ShapeTypes getShapeType()
public SbColor getTextureBlendColor()
public java.util.Vector<SoNode> getProfile()
public SoTextureCoordinateBinding.Bindings getTextureCoordinateBinding()
public SoShapeHints.VertexOrderings getVertexOrdering()
public SbMatrix getViewingMatrix()
public SoFont.RenderStyles getFontRenderStyle()
public SbMatrix getProjectionMatrix()
public SoLightModel.Models getLightModel()
public SbViewVolume getViewVolume()
public java.lang.String getFontName()
public int getSwitch()
public float getFontSize()
public SoPickStyle.Styles getPickStyle()
public SbVec3f getLightAttenuation()
public SoTexture.WrapType getTextureWrapT()
public SoGLRenderAction.TransparencyTypes getTransparencyType()
public SoTexture.WrapType getTextureWrapS()
public int getNumNormals()
public SbMatrix getModelMatrix()
public SoCallbackAction.Material getMaterial(int mtlIndex)
public float getFocalDistance()
public SoMaterialBinding.Bindings getMaterialBinding()
public SoUnits.UnitsType getUnits()
Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com