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/nodes/SoUnits.h>
00067 #include <Inventor/elements/SoDecimationTypeElement.h>
00068 #include <Inventor/actions/SoGLRenderAction.h>
00069
00070 class SoPrimitiveVertex;
00071 class SoShape;
00072 class SoTexture2Transform;
00073
00074
00075
00076
00077
00082 typedef void SoTriangleCB(void *userData,
00083 SoCallbackAction *action,
00084 const SoPrimitiveVertex *v1,
00085 const SoPrimitiveVertex *v2,
00086 const SoPrimitiveVertex *v3);
00091 typedef void SoLineSegmentCB(void *userData,
00092 SoCallbackAction *action,
00093 const SoPrimitiveVertex *v1,
00094 const SoPrimitiveVertex *v2);
00099 typedef void SoPointCB(void *userData,
00100 SoCallbackAction *action,
00101 const SoPrimitiveVertex *v);
00102
00103 #ifdef _WIN32
00104
00105
00106 typedef int SoCallbackActionCB2(void *userData,
00107 SoCallbackAction *action,
00108 const SoNode *node);
00109 #endif
00111 //
00112
00113
00114
00115
00116
00117
00119
00297 class SoCallbackAction : public SoAction {
00298
00299 SO_ACTION_HEADER(SoCallbackAction);
00300
00301 public:
00302
00304 enum Response {
00308 CONTINUE,
00312 ABORT,
00316 PRUNE
00317 };
00318
00327 typedef Response SoCallbackActionCB(void *userData,
00328 SoCallbackAction *action,
00329 const SoNode *node);
00330
00334 SoCallbackAction();
00335
00336
00337 #ifndef HIDDEN_FROM_DOC
00338 virtual ~SoCallbackAction();
00339 #endif // HIDDEN_FROM_DOC
00340
00342
00343
00344
00345
00353 void addPreCallback(SoType type, SoCallbackActionCB *cb, void *data);
00354
00362 void addPostCallback(SoType type, SoCallbackActionCB *cb, void *data);
00363
00370 void addPreTailCallback(SoCallbackActionCB *cb, void *data);
00371
00378 void addPostTailCallback(SoCallbackActionCB *cb, void *data);
00379
00385 void addTriangleCallback(SoType type, SoTriangleCB *cb, void *data);
00386
00393 void addLineSegmentCallback(SoType type, SoLineSegmentCB *cb, void *data);
00394
00400 void addPointCallback(SoType type, SoPointCB *cb, void *data);
00401
00403
00404
00405
00406
00407
00409
00412 float getComplexity() const;
00413
00417 SoComplexity::Type getComplexityType() const;
00418
00420
00423 int32_t getNumCoordinates() const;
00424
00428 const SbVec3f &getCoordinate3(int index) const;
00429
00433 const SbVec4f &getCoordinate4(int index) const;
00434
00438 SoDecimationTypeElement::Type getDecimationType() const;
00439
00443 float getDecimationPercentage() const;
00444
00448 SoDrawStyle::Style getDrawStyle() const;
00449
00453 u_short getLinePattern() const;
00454
00458 int getLinePatternScaleFactor() const;
00459
00463 float getLineWidth() const;
00464
00468 float getPointSize() const;
00469
00471
00475 const SbString & getFontName() const;
00476
00480 float getFontSize() const;
00481
00485 SoFont::RenderStyle getFontRenderStyle() const;
00486
00488
00491 SoLightModel::Model getLightModel() const;
00492
00496 const SbVec3f &getLightAttenuation() const;
00497
00499
00504 void getMaterial(SbColor &ambient,
00505 SbColor &diffuse,
00506 SbColor &specular,
00507 SbColor &emission,
00508 float &shininess,
00509 float &transparency,
00510 int mtlIndex = 0) const;
00511
00515 SoMaterialBinding::Binding getMaterialBinding() const;
00516
00517
00521 SoGLRenderAction::TransparencyType getTransparencyType() const;
00522
00524
00527 int32_t getNumNormals() const;
00528
00532 const SbVec3f & getNormal(int index) const;
00533
00537 SoNormalBinding::Binding getNormalBinding() const;
00538
00540
00543 int32_t getNumProfileCoordinates() const;
00544
00548 const SbVec2f &getProfileCoordinate2(int index) const;
00549
00553 const SbVec3f &getProfileCoordinate3(int index) const;
00554
00558 const SoNodeList & getProfile() const;
00559
00561
00564 SoShapeHints::VertexOrdering getVertexOrdering() const;
00565
00569 SoShapeHints::ShapeType getShapeType() const;
00570
00574 SoShapeHints::FaceType getFaceType() const;
00575
00579 float getCreaseAngle() const;
00580
00582
00586 int32_t getNumTextureCoordinates() const;
00587
00591 const SbVec2f &getTextureCoordinate2(int index) const;
00592
00596 const SbVec4f &getTextureCoordinate4(int index) const;
00597
00601 SoTextureCoordinateBinding::Binding getTextureCoordinateBinding() const;
00602
00603 #ifdef _WIN32
00604
00607 const SbColor getTextureBlendColor() const;
00608 #else
00609 const SbColor &getTextureBlendColor() const;
00610 #endif
00611
00618 const unsigned char *getTextureImage(SbVec2i32 &size, int &numComps) const;
00619
00623 const SbName &getTextureFileName() const;
00624
00628 const SbMatrix &getTextureMatrix() const;
00629
00633 const SoTexture2Transform *getTextureTransformNode() const;
00634
00638 SoTexture::Model getTextureModel() const;
00639
00643 SoTexture::Wrap getTextureWrapS() const;
00647 SoTexture::Wrap getTextureWrapT() const;
00648
00650
00653 const SbMatrix & getModelMatrix() const;
00654
00658 SoUnits::Units getUnits() const;
00659
00661
00664 float getFocalDistance() const;
00665
00669 const SbMatrix &getProjectionMatrix() const;
00670
00674 const SbMatrix &getViewingMatrix() const;
00675
00679 const SbViewVolume &getViewVolume() const;
00680
00682
00685 SoPickStyle::Style getPickStyle() const;
00686
00690 int32_t getSwitch() const;
00691
00696 void setCallbackAll(SbBool flag) { callbackAll = flag; }
00697
00702 SbBool isCallbackAll() const { return callbackAll; }
00703
00710 virtual void forwardTraversal( SoNode* node );
00711
00718 virtual void forwardTraversal( SoPath* path );
00719
00720 #if 1 SoDEPRECATED
00728 const unsigned char *getTextureImage(SbVec2s &size, int &numComps) const;
00729
00730 #endif
00732 private:
00733 #ifdef _WIN32
00734 void addPreCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00735 void addPostCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00736 void addPreTailCallback(SoCallbackActionCB2 *cb, void *data);
00737 void addPostTailCallback(SoCallbackActionCB2 *cb, void *data);
00738 #endif
00739
00740
00741 Response getCurrentResponse() const { return response; }
00742
00743
00744 virtual void invokePreCallbacks(const SoNode *node);
00745 virtual void invokePostCallbacks(const SoNode *node);
00746
00747
00748 virtual void invokeTriangleCallbacks(const SoShape *shape,
00749 const SoPrimitiveVertex *v1,
00750 const SoPrimitiveVertex *v2,
00751 const SoPrimitiveVertex *v3);
00752 virtual void invokeLineSegmentCallbacks(const SoShape *shape,
00753 const SoPrimitiveVertex *v1,
00754 const SoPrimitiveVertex *v2);
00755 virtual void invokePointCallbacks(const SoShape *shape,
00756 const SoPrimitiveVertex *v);
00757
00758
00759 virtual SbBool shouldGeneratePrimitives(const SoShape *shape) const;
00760
00761 private:
00762
00763
00764
00765
00766 static SbBool duringCallbackAll;
00767 static void initClass();
00768 static void exitClass();
00769
00770
00771 virtual SoNode *getCurPathTail();
00772
00773
00774 void setCurrentNode(SoNode *node)
00775 { currentNode = node;}
00776
00777 void setStartTransparencyType( SoGLRenderAction::TransparencyType type) {
00778 transpType = type;
00779 };
00780
00788 bool removeTriangleCallback(SoType type, SoTriangleCB *cb);
00789
00797 bool removeLineSegmentCallback(SoType type, SoLineSegmentCB *cb);
00798
00806 bool removePointCallback(SoType type, SoPointCB *cb);
00807
00816 bool removePostCallback(SoType type, SoCallbackActionCB *cb);
00817
00826 bool removePreCallback(SoType type, SoCallbackActionCB *cb);
00827
00828 enum CBFuncTypes
00829 {
00830 NONE=0,
00831 PRE =1,
00832 POST=2,
00833 PRE_TAIL=4,
00834 POST_TAIL=8,
00835 ANY=PRE|POST|PRE_TAIL|POST_TAIL,
00836 };
00837
00838
00839
00840 template< class T, int N >
00841 SbPList& getCallbackList( );
00842
00843 private:
00844
00845 virtual void beginTraversal(SoNode *node);
00846
00847
00848
00849 void transformForwardTraversedVertices(const SbMatrix& model, size_t numVertices, SoPrimitiveVertex** vertices);
00850
00851
00852 Response response;
00853
00854 private:
00855 SbBool callbackAll;
00856
00857
00858 SbPList preCallbackList;
00859 SbPList postCallbackList;
00860
00861 SbPList preTailCallbackList;
00862 SbPList postTailCallbackList;
00863
00864 SbPList triangleCallbackList;
00865 SbPList lineSegmentCallbackList;
00866 SbPList pointCallbackList;
00867
00868
00869 SoNode *currentNode;
00870
00871 SoGLRenderAction::TransparencyType transpType;
00872
00873
00874
00875 bool m_stopPrePostCallback;
00876 };
00877
00878 #endif
00879
00880