00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_CALLBACK_ACTION_
00052 #define _SO_CALLBACK_ACTION_
00053
00054 #include <Inventor/SbBox.h>
00055 #include <Inventor/actions/SoSubAction.h>
00056 #include <Inventor/nodes/SoComplexity.h>
00057 #include <Inventor/nodes/SoDrawStyle.h>
00058 #include <Inventor/nodes/SoFont.h>
00059 #include <Inventor/nodes/SoLightModel.h>
00060 #include <Inventor/nodes/SoMaterialBinding.h>
00061 #include <Inventor/nodes/SoNormalBinding.h>
00062 #include <Inventor/nodes/SoPickStyle.h>
00063 #include <Inventor/nodes/SoShapeHints.h>
00064 #include <Inventor/nodes/SoTexture.h>
00065 #include <Inventor/nodes/SoTextureCoordinateBinding.h>
00066 #include <Inventor/actions/SoGLRenderAction.h>
00067 #include <Inventor/nodes/SoUnits.h>
00068 #include <Inventor/nodes/SoTransparencyType.h>
00069 #include <Inventor/elements/SoDecimationTypeElement.h>
00070
00071 class SoPrimitiveVertex;
00072 class SoShape;
00073 class SoTexture2Transform;
00074
00075
00076
00077
00078
00083 typedef void SoTriangleCB(void *userData,
00084 SoCallbackAction *action,
00085 const SoPrimitiveVertex *v1,
00086 const SoPrimitiveVertex *v2,
00087 const SoPrimitiveVertex *v3);
00092 typedef void SoLineSegmentCB(void *userData,
00093 SoCallbackAction *action,
00094 const SoPrimitiveVertex *v1,
00095 const SoPrimitiveVertex *v2);
00100 typedef void SoPointCB(void *userData,
00101 SoCallbackAction *action,
00102 const SoPrimitiveVertex *v);
00103
00104 #ifdef _WIN32
00105
00106
00107 typedef int SoCallbackActionCB2(void *userData,
00108 SoCallbackAction *action,
00109 const SoNode *node);
00110 #endif
00112 //
00113
00114
00115
00116
00117
00118
00120
00367 class SoCallbackAction : public SoAction {
00368
00369 SO_ACTION_HEADER(SoCallbackAction);
00370
00371 public:
00372
00374 enum Response {
00378 CONTINUE,
00382 ABORT,
00386 PRUNE
00387 };
00388
00397 typedef Response SoCallbackActionCB(void *userData,
00398 SoCallbackAction *action,
00399 const SoNode *node);
00400
00404 SoCallbackAction();
00405
00406
00407 #ifndef HIDDEN_FROM_DOC
00408 virtual ~SoCallbackAction();
00409 #endif // HIDDEN_FROM_DOC
00410
00412
00413
00414
00415
00423 void addPreCallback(SoType type, SoCallbackActionCB *cb, void *data);
00424
00432 void addPostCallback(SoType type, SoCallbackActionCB *cb, void *data);
00433
00440 void addPreTailCallback(SoCallbackActionCB *cb, void *data);
00441
00448 void addPostTailCallback(SoCallbackActionCB *cb, void *data);
00449
00455 void addTriangleCallback(SoType type, SoTriangleCB *cb, void *data);
00456
00463 void addLineSegmentCallback(SoType type, SoLineSegmentCB *cb, void *data);
00464
00470 void addPointCallback(SoType type, SoPointCB *cb, void *data);
00471
00473
00474
00475
00476
00477
00479
00482 float getComplexity() const;
00483
00487 SoComplexity::Type getComplexityType() const;
00488
00490
00493 int32_t getNumCoordinates() const;
00494
00498 const SbVec3f &getCoordinate3(int index) const;
00499
00503 const SbVec4f &getCoordinate4(int index) const;
00504
00508 SoDecimationTypeElement::Type getDecimationType() const;
00509
00513 float getDecimationPercentage() const;
00514
00518 SoDrawStyle::Style getDrawStyle() const;
00519
00523 u_short getLinePattern() const;
00524
00528 int getLinePatternScaleFactor() const;
00529
00533 float getLineWidth() const;
00534
00538 float getPointSize() const;
00539
00541
00545 const SbString & getFontName() const;
00546
00550 float getFontSize() const;
00551
00555 SoFont::RenderStyle getFontRenderStyle() const;
00556
00558
00561 SoLightModel::Model getLightModel() const;
00562
00566 const SbVec3f &getLightAttenuation() const;
00567
00569
00574 void getMaterial(SbColor &ambient,
00575 SbColor &diffuse,
00576 SbColor &specular,
00577 SbColor &emission,
00578 float &shininess,
00579 float &transparency,
00580 int mtlIndex = 0) const;
00581
00585 SoMaterialBinding::Binding getMaterialBinding() const;
00586
00587 SoDEPRECATED
00592 SoTransparencyType::TransparencyType getTransparencyType() const;
00593
00595
00598 int32_t getNumNormals() const;
00599
00603 const SbVec3f & getNormal(int index) const;
00604
00608 SoNormalBinding::Binding getNormalBinding() const;
00609
00611
00614 int32_t getNumProfileCoordinates() const;
00615
00619 const SbVec2f &getProfileCoordinate2(int index) const;
00620
00624 const SbVec3f &getProfileCoordinate3(int index) const;
00625
00629 const SoNodeList & getProfile() const;
00630
00632
00635 SoShapeHints::VertexOrdering getVertexOrdering() const;
00636
00640 SoShapeHints::ShapeType getShapeType() const;
00641
00645 SoShapeHints::FaceType getFaceType() const;
00646
00650 float getCreaseAngle() const;
00651
00653
00657 int32_t getNumTextureCoordinates() const;
00658
00662 const SbVec2f &getTextureCoordinate2(int index) const;
00663
00667 const SbVec4f &getTextureCoordinate4(int index) const;
00668
00672 SoTextureCoordinateBinding::Binding getTextureCoordinateBinding() const;
00673
00674 #ifdef _WIN32
00675
00678 const SbColor getTextureBlendColor() const;
00679 #else
00680 const SbColor &getTextureBlendColor() const;
00681 #endif
00682
00689 const unsigned char *getTextureImage(SbVec2i32 &size,
00690 int &numComps) const;
00691
00695 const SbName &getTextureFileName() const;
00696
00700 const SbMatrix &getTextureMatrix() const;
00701
00705 const SoTexture2Transform *getTextureTransformNode() const;
00706
00710 SoTexture::Model getTextureModel() const;
00711
00715 SoTexture::Wrap getTextureWrapS() const;
00719 SoTexture::Wrap getTextureWrapT() const;
00720
00722
00725 const SbMatrix & getModelMatrix() const;
00726
00730 SoUnits::Units getUnits() const;
00731
00733
00736 float getFocalDistance() const;
00737
00741 const SbMatrix &getProjectionMatrix() const;
00742
00746 const SbMatrix &getViewingMatrix() const;
00747
00751 const SbViewVolume &getViewVolume() const;
00752
00754
00757 SoPickStyle::Style getPickStyle() const;
00758
00762 int32_t getSwitch() const;
00763
00768 void setCallbackAll(SbBool flag) { callbackAll = flag; }
00769
00774 SbBool isCallbackAll() const { return callbackAll; }
00775
00782 virtual void forwardTraversal( SoNode* node );
00783
00784 #if 1 SoDEPRECATED
00792 const unsigned char *getTextureImage(SbVec2s &size,
00793 int &numComps) const;
00794
00795 #endif
00797 private:
00798 #ifdef _WIN32
00799 void addPreCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00800 void addPostCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00801 void addPreTailCallback(SoCallbackActionCB2 *cb, void *data);
00802 void addPostTailCallback(SoCallbackActionCB2 *cb, void *data);
00803 #endif
00804
00805
00806 Response getCurrentResponse() const { return response; }
00807
00808
00809 virtual void invokePreCallbacks(const SoNode *node);
00810 virtual void invokePostCallbacks(const SoNode *node);
00811
00812
00813 virtual void invokeTriangleCallbacks(const SoShape *shape,
00814 const SoPrimitiveVertex *v1,
00815 const SoPrimitiveVertex *v2,
00816 const SoPrimitiveVertex *v3);
00817 virtual void invokeLineSegmentCallbacks(const SoShape *shape,
00818 const SoPrimitiveVertex *v1,
00819 const SoPrimitiveVertex *v2);
00820 virtual void invokePointCallbacks(const SoShape *shape,
00821 const SoPrimitiveVertex *v);
00822
00823
00824 virtual SbBool shouldGeneratePrimitives(const SoShape *shape) const;
00825
00826 private:
00827
00828
00829
00830
00831 static SbBool duringCallbackAll;
00832 static void initClass();
00833 static void exitClass();
00834
00835
00836 virtual SoNode *getCurPathTail();
00837
00838
00839 void setCurrentNode(SoNode *node)
00840 { currentNode = node;}
00841
00842 void setStartTransparencyType( SoGLRenderAction::TransparencyType type) {
00843 transpType = type;
00844 };
00845
00853 bool removeTriangleCallback(SoType type, SoTriangleCB *cb);
00854
00862 bool removeLineSegmentCallback(SoType type, SoLineSegmentCB *cb);
00863
00871 bool removePointCallback(SoType type, SoPointCB *cb);
00872
00881 bool removePostCallback(SoType type, SoCallbackActionCB *cb);
00882
00891 bool removePreCallback(SoType type, SoCallbackActionCB *cb);
00892
00893 enum CBFuncTypes
00894 {
00895 NONE=0,
00896 PRE =1,
00897 POST=2,
00898 PRE_TAIL=4,
00899 POST_TAIL=8,
00900 ANY=PRE|POST|PRE_TAIL|POST_TAIL,
00901 };
00902
00903
00904
00905 template< class T, int N >
00906 SbPList& getCallbackList( );
00907
00908 private:
00909
00910 virtual void beginTraversal(SoNode *node);
00911
00912
00913
00914 void transformForwardTraversedVertices(const SbMatrix& model, size_t numVertices, SoPrimitiveVertex** vertices);
00915
00916
00917 Response response;
00918
00919 private:
00920 SbBool callbackAll;
00921
00922
00923 SbPList preCallbackList;
00924 SbPList postCallbackList;
00925
00926 SbPList preTailCallbackList;
00927 SbPList postTailCallbackList;
00928
00929 SbPList triangleCallbackList;
00930 SbPList lineSegmentCallbackList;
00931 SbPList pointCallbackList;
00932
00933
00934 SoNode *currentNode;
00935
00936 SoGLRenderAction::TransparencyType transpType;
00937
00938
00939
00940 bool m_stopPrePostCallback;
00941 };
00942
00943 #endif
00944
00945