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
00712 #if 1 SoDEPRECATED
00720 const unsigned char *getTextureImage(SbVec2s &size, int &numComps) const;
00721
00722 #endif
00724 private:
00725 #ifdef _WIN32
00726 void addPreCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00727 void addPostCallback(SoType type, SoCallbackActionCB2 *cb, void *data);
00728 void addPreTailCallback(SoCallbackActionCB2 *cb, void *data);
00729 void addPostTailCallback(SoCallbackActionCB2 *cb, void *data);
00730 #endif
00731
00732
00733 Response getCurrentResponse() const { return response; }
00734
00735
00736 virtual void invokePreCallbacks(const SoNode *node);
00737 virtual void invokePostCallbacks(const SoNode *node);
00738
00739
00740 virtual void invokeTriangleCallbacks(const SoShape *shape,
00741 const SoPrimitiveVertex *v1,
00742 const SoPrimitiveVertex *v2,
00743 const SoPrimitiveVertex *v3);
00744 virtual void invokeLineSegmentCallbacks(const SoShape *shape,
00745 const SoPrimitiveVertex *v1,
00746 const SoPrimitiveVertex *v2);
00747 virtual void invokePointCallbacks(const SoShape *shape,
00748 const SoPrimitiveVertex *v);
00749
00750
00751 virtual SbBool shouldGeneratePrimitives(const SoShape *shape) const;
00752
00753 private:
00754
00755
00756
00757
00758 static SbBool duringCallbackAll;
00759 static void initClass();
00760 static void exitClass();
00761
00762
00763 virtual SoNode *getCurPathTail();
00764
00765
00766 void setCurrentNode(SoNode *node)
00767 { currentNode = node;}
00768
00769 void setStartTransparencyType( SoGLRenderAction::TransparencyType type) {
00770 transpType = type;
00771 };
00772
00780 bool removeTriangleCallback(SoType type, SoTriangleCB *cb);
00781
00789 bool removeLineSegmentCallback(SoType type, SoLineSegmentCB *cb);
00790
00798 bool removePointCallback(SoType type, SoPointCB *cb);
00799
00808 bool removePostCallback(SoType type, SoCallbackActionCB *cb);
00809
00818 bool removePreCallback(SoType type, SoCallbackActionCB *cb);
00819
00820 enum CBFuncTypes
00821 {
00822 NONE=0,
00823 PRE =1,
00824 POST=2,
00825 PRE_TAIL=4,
00826 POST_TAIL=8,
00827 ANY=PRE|POST|PRE_TAIL|POST_TAIL,
00828 };
00829
00830
00831
00832 template< class T, int N >
00833 SbPList& getCallbackList( );
00834
00835 private:
00836
00837 virtual void beginTraversal(SoNode *node);
00838
00839
00840
00841 void transformForwardTraversedVertices(const SbMatrix& model, size_t numVertices, SoPrimitiveVertex** vertices);
00842
00843
00844 Response response;
00845
00846 private:
00847 SbBool callbackAll;
00848
00849
00850 SbPList preCallbackList;
00851 SbPList postCallbackList;
00852
00853 SbPList preTailCallbackList;
00854 SbPList postTailCallbackList;
00855
00856 SbPList triangleCallbackList;
00857 SbPList lineSegmentCallbackList;
00858 SbPList pointCallbackList;
00859
00860
00861 SoNode *currentNode;
00862
00863 SoGLRenderAction::TransparencyType transpType;
00864
00865
00866
00867 bool m_stopPrePostCallback;
00868 };
00869
00870 #endif
00871
00872