00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef COIN_SOCALLBACKACTION_H
00021 #define COIN_SOCALLBACKACTION_H
00022
00023 #include <Inventor/actions/SoAction.h>
00024 #include <Inventor/actions/SoSubAction.h>
00025 #include <Inventor/elements/SoDecimationTypeElement.h>
00026 #include <Inventor/lists/SbList.h>
00027 #include <Inventor/nodes/SoComplexity.h>
00028 #include <Inventor/nodes/SoDrawStyle.h>
00029 #include <Inventor/nodes/SoLightModel.h>
00030 #include <Inventor/nodes/SoMaterialBinding.h>
00031 #include <Inventor/nodes/SoNormalBinding.h>
00032 #include <Inventor/nodes/SoPickStyle.h>
00033 #include <Inventor/nodes/SoShapeHints.h>
00034 #include <Inventor/nodes/SoTexture2.h>
00035 #include <Inventor/nodes/SoTextureCoordinateBinding.h>
00036 #include <Inventor/nodes/SoUnits.h>
00037
00038 class SbColor;
00039 class SbMatrix;
00040 class SbVec2f;
00041 class SbVec2s;
00042 class SbVec3f;
00043 class SbVec4f;
00044 class SbViewVolume;
00045 class SoCallbackAction;
00046 class SoCallbackData;
00047 class SoPrimitiveVertex;
00048 class SoShape;
00049 class SbViewportRegion;
00050
00051 typedef void SoTriangleCB(void * userdata, SoCallbackAction * action,
00052 const SoPrimitiveVertex * v1,
00053 const SoPrimitiveVertex * v2,
00054 const SoPrimitiveVertex * v3);
00055
00056 typedef void SoLineSegmentCB(void * userdata, SoCallbackAction * action,
00057 const SoPrimitiveVertex * v1,
00058 const SoPrimitiveVertex * v2);
00059
00060 typedef void SoPointCB(void * userdata, SoCallbackAction * action,
00061 const SoPrimitiveVertex * v);
00062
00063
00064 class COIN_DLL_API SoCallbackAction : public SoAction {
00065 typedef SoAction inherited;
00066
00067 SO_ACTION_HEADER(SoCallbackAction);
00068
00069 public:
00070 SoCallbackAction(void);
00071 SoCallbackAction(const SbViewportRegion & vp);
00072
00073 virtual ~SoCallbackAction();
00074
00075 static void initClass(void);
00076
00077 void setViewportRegion(const SbViewportRegion & vp);
00078
00079 enum Response { CONTINUE, ABORT, PRUNE };
00080
00081 typedef Response SoCallbackActionCB(void * userdata,
00082 SoCallbackAction * action,
00083 const SoNode * node);
00084
00085 void addPreCallback(const SoType type, SoCallbackActionCB * cb, void * userdata);
00086 void addPostCallback(const SoType type, SoCallbackActionCB * cb, void * userdata);
00087
00088 void addPreTailCallback(SoCallbackActionCB * cb, void * userdata);
00089 void addPostTailCallback(SoCallbackActionCB * cb, void * userdata);
00090
00091 void addTriangleCallback(const SoType type, SoTriangleCB * cb, void * userdata);
00092 void addLineSegmentCallback(const SoType type, SoLineSegmentCB * cb, void * userdata);
00093 void addPointCallback(const SoType type, SoPointCB * cb, void * userdata);
00094
00095 SoDecimationTypeElement::Type getDecimationType(void) const;
00096 float getDecimationPercentage(void) const;
00097 float getComplexity(void) const;
00098 SoComplexity::Type getComplexityType(void) const;
00099 int32_t getNumCoordinates(void) const;
00100 const SbVec3f & getCoordinate3(const int index) const;
00101 const SbVec4f & getCoordinate4(const int index) const;
00102 SoDrawStyle::Style getDrawStyle(void) const;
00103 unsigned short getLinePattern(void) const;
00104 float getLineWidth(void) const;
00105 float getPointSize(void) const;
00106 const SbName & getFontName(void) const;
00107 float getFontSize(void) const;
00108 SoLightModel::Model getLightModel(void) const;
00109 const SbVec3f & getLightAttenuation(void) const;
00110 void getMaterial(SbColor & ambient, SbColor & diffuse,
00111 SbColor & specular, SbColor & emission,
00112 float & shininess, float & transparency,
00113 const int index = 0) const;
00114 SoMaterialBinding::Binding getMaterialBinding(void) const;
00115 uint32_t getNumNormals(void) const;
00116 const SbVec3f & getNormal(const int index) const;
00117 SoNormalBinding::Binding getNormalBinding(void) const;
00118 int32_t getNumProfileCoordinates(void) const;
00119 const SbVec2f & getProfileCoordinate2(const int index) const;
00120 const SbVec3f & getProfileCoordinate3(const int index) const;
00121 const SoNodeList & getProfile(void) const;
00122 SoShapeHints::VertexOrdering getVertexOrdering(void) const;
00123 SoShapeHints::ShapeType getShapeType(void) const;
00124 SoShapeHints::FaceType getFaceType(void) const;
00125 float getCreaseAngle(void) const;
00126 int32_t getNumTextureCoordinates(void) const;
00127 const SbVec2f & getTextureCoordinate2(const int index) const;
00128 const SbVec4f & getTextureCoordinate4(const int index) const;
00129 SoTextureCoordinateBinding::Binding getTextureCoordinateBinding(void) const;
00130 const SbColor & getTextureBlendColor(void) const;
00131 const unsigned char * getTextureImage(SbVec2s & size, int & numcomps) const;
00132 const SbMatrix & getTextureMatrix(void) const;
00133 SoTexture2::Model getTextureModel(void) const;
00134 SoTexture2::Wrap getTextureWrapS(void) const;
00135 SoTexture2::Wrap getTextureWrapT(void) const;
00136 const SbMatrix & getModelMatrix(void) const;
00137 SoUnits::Units getUnits(void) const;
00138 float getFocalDistance(void) const;
00139 const SbMatrix & getProjectionMatrix(void) const;
00140 const SbMatrix & getViewingMatrix(void) const;
00141 const SbViewVolume & getViewVolume(void) const;
00142 const SbViewportRegion & getViewportRegion(void) const;
00143 SoPickStyle::Style getPickStyle(void) const;
00144 int32_t getSwitch(void) const;
00145
00146 Response getCurrentResponse(void) const;
00147 void invokePreCallbacks(const SoNode * const node);
00148 void invokePostCallbacks(const SoNode * const node);
00149 void invokeTriangleCallbacks(const SoShape * const shape,
00150 const SoPrimitiveVertex * const v1,
00151 const SoPrimitiveVertex * const v2,
00152 const SoPrimitiveVertex * const v3);
00153 void invokeLineSegmentCallbacks(const SoShape * const shape,
00154 const SoPrimitiveVertex * const v1,
00155 const SoPrimitiveVertex * const v2);
00156 void invokePointCallbacks(const SoShape * const shape,
00157 const SoPrimitiveVertex * const v);
00158
00159 SbBool shouldGeneratePrimitives(const SoShape * shape) const;
00160
00161 virtual SoNode * getCurPathTail(void);
00162 void setCurrentNode(SoNode * const node);
00163
00164 protected:
00165 virtual void beginTraversal(SoNode * node);
00166
00167 private:
00168 void commonConstructor(void);
00169 class SoCallbackActionP * pimpl;
00170 friend class SoCallbackActionP;
00171 };
00172
00173
00174
00175 #endif // !COIN_SOCALLBACKACTION_H