Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoCallbackAction.h
Go to the documentation of this file.
1 #ifndef COIN_SOCALLBACKACTION_H
2 #define COIN_SOCALLBACKACTION_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 // FIXME: Support getTextureFilename[s]() ? (kintel 20011205)
37 
38 #include <Inventor/actions/SoAction.h>
39 #include <Inventor/actions/SoSubAction.h>
40 #include <Inventor/elements/SoDecimationTypeElement.h>
41 #include <Inventor/lists/SbList.h>
42 #include <Inventor/nodes/SoComplexity.h>
43 #include <Inventor/nodes/SoDrawStyle.h>
44 #include <Inventor/nodes/SoLightModel.h>
45 #include <Inventor/nodes/SoMaterialBinding.h>
46 #include <Inventor/nodes/SoNormalBinding.h>
47 #include <Inventor/nodes/SoPickStyle.h>
48 #include <Inventor/nodes/SoShapeHints.h>
49 #include <Inventor/nodes/SoTexture2.h>
50 #include <Inventor/nodes/SoTextureCoordinateBinding.h>
51 #include <Inventor/nodes/SoUnits.h>
52 
53 class SbColor;
54 class SbMatrix;
55 class SbVec2f;
56 class SbVec2s;
57 class SbVec3f;
58 class SbVec4f;
59 class SbViewVolume;
60 class SoCallbackAction;
61 class SoCallbackActionP;
62 class SoCallbackData;
63 class SoPrimitiveVertex;
64 class SoShape;
65 class SbViewportRegion;
66 
67 typedef void SoTriangleCB(void * userdata, SoCallbackAction * action,
68  const SoPrimitiveVertex * v1,
69  const SoPrimitiveVertex * v2,
70  const SoPrimitiveVertex * v3);
71 
72 typedef void SoLineSegmentCB(void * userdata, SoCallbackAction * action,
73  const SoPrimitiveVertex * v1,
74  const SoPrimitiveVertex * v2);
75 
76 typedef void SoPointCB(void * userdata, SoCallbackAction * action,
77  const SoPrimitiveVertex * v);
78 
79 
80 class COIN_DLL_API SoCallbackAction : public SoAction {
81  typedef SoAction inherited;
82 
83  SO_ACTION_HEADER(SoCallbackAction);
84 
85 public:
86  static void initClass(void);
87 
88  SoCallbackAction(void);
90  virtual ~SoCallbackAction(void);
91 
92  void setViewportRegion(const SbViewportRegion & vp);
93 
94  enum Response { CONTINUE, ABORT, PRUNE };
95 
96  typedef Response SoCallbackActionCB(void * userdata,
97  SoCallbackAction * action,
98  const SoNode * node);
99 
100  void addPreCallback(const SoType type, SoCallbackActionCB * cb, void * userdata);
101  void addPostCallback(const SoType type, SoCallbackActionCB * cb, void * userdata);
102 
103  void addPreTailCallback(SoCallbackActionCB * cb, void * userdata);
104  void addPostTailCallback(SoCallbackActionCB * cb, void * userdata);
105 
106  void addTriangleCallback(const SoType type, SoTriangleCB * cb, void * userdata);
107  void addLineSegmentCallback(const SoType type, SoLineSegmentCB * cb, void * userdata);
108  void addPointCallback(const SoType type, SoPointCB * cb, void * userdata);
109 
110  SoDecimationTypeElement::Type getDecimationType(void) const;
111  float getDecimationPercentage(void) const;
112  float getComplexity(void) const;
113  SoComplexity::Type getComplexityType(void) const;
114  int32_t getNumCoordinates(void) const;
115  const SbVec3f & getCoordinate3(const int index) const;
116  const SbVec4f & getCoordinate4(const int index) const;
117  SoDrawStyle::Style getDrawStyle(void) const;
118  unsigned short getLinePattern(void) const;
119  float getLineWidth(void) const;
120  float getPointSize(void) const;
121  const SbName & getFontName(void) const;
122  float getFontSize(void) const;
123  SoLightModel::Model getLightModel(void) const;
124  const SbVec3f & getLightAttenuation(void) const;
125  void getMaterial(SbColor & ambient, SbColor & diffuse,
126  SbColor & specular, SbColor & emission,
127  float & shininess, float & transparency,
128  const int index = 0) const;
129  SoMaterialBinding::Binding getMaterialBinding(void) const;
130  uint32_t getNumNormals(void) const;
131  const SbVec3f & getNormal(const int index) const;
132  SoNormalBinding::Binding getNormalBinding(void) const;
133  int32_t getNumProfileCoordinates(void) const;
134  const SbVec2f & getProfileCoordinate2(const int index) const;
135  const SbVec3f & getProfileCoordinate3(const int index) const;
136  const SoNodeList & getProfile(void) const;
137  SoShapeHints::VertexOrdering getVertexOrdering(void) const;
138  SoShapeHints::ShapeType getShapeType(void) const;
139  SoShapeHints::FaceType getFaceType(void) const;
140  float getCreaseAngle(void) const;
141  int32_t getNumTextureCoordinates(void) const;
142  const SbVec2f & getTextureCoordinate2(const int index) const;
143  const SbVec3f & getTextureCoordinate3(const int index) const;
144  const SbVec4f & getTextureCoordinate4(const int index) const;
145  SoTextureCoordinateBinding::Binding getTextureCoordinateBinding(void) const;
146  const SbColor & getTextureBlendColor(void) const;
147  const unsigned char * getTextureImage(SbVec2s & size, int & numcomps) const;
148  const unsigned char * getTextureImage(SbVec3s & size, int & numcomps) const;
149  const SbMatrix & getTextureMatrix(void) const;
150  SoTexture2::Model getTextureModel(void) const;
151  SoTexture2::Wrap getTextureWrapS(void) const;
152  SoTexture2::Wrap getTextureWrapT(void) const;
153  SoTexture2::Wrap getTextureWrapR(void) const;
154  const SbMatrix & getModelMatrix(void) const;
155  SoUnits::Units getUnits(void) const;
156  float getFocalDistance(void) const;
157  const SbMatrix & getProjectionMatrix(void) const;
158  const SbMatrix & getViewingMatrix(void) const;
159  const SbViewVolume & getViewVolume(void) const;
160  const SbViewportRegion & getViewportRegion(void) const;
161  SoPickStyle::Style getPickStyle(void) const;
162  int32_t getSwitch(void) const;
163 
164  Response getCurrentResponse(void) const;
165  void invokePreCallbacks(const SoNode * const node);
166  void invokePostCallbacks(const SoNode * const node);
167  void invokeTriangleCallbacks(const SoShape * const shape,
168  const SoPrimitiveVertex * const v1,
169  const SoPrimitiveVertex * const v2,
170  const SoPrimitiveVertex * const v3);
171  void invokeLineSegmentCallbacks(const SoShape * const shape,
172  const SoPrimitiveVertex * const v1,
173  const SoPrimitiveVertex * const v2);
174  void invokePointCallbacks(const SoShape * const shape,
175  const SoPrimitiveVertex * const v);
176 
177  SbBool shouldGeneratePrimitives(const SoShape * shape) const;
178 
179  virtual SoNode * getCurPathTail(void);
180  void setCurrentNode(SoNode * const node);
181 
182  void setCallbackAll(SbBool callbackall);
183  SbBool isCallbackAll(void) const;
184 
185 protected:
186  virtual void beginTraversal(SoNode * node);
187 
188 private:
189  void commonConstructor(void);
190 
191 private:
193  friend class SoCallbackActionP;
194 
195  SoCallbackAction(const SoCallbackAction & rhs);
196  SoCallbackAction & operator = (const SoCallbackAction & rhs);
197 }; // SoCallbackAction
198 
199 #endif // !COIN_SOCALLBACKACTION_H
The SbVec2f class is a 2 dimensional vector with floating point coordinates.
Definition: SbVec2f.h:49
The SbColor class contains the red, green and blue components which make up a color value...
Definition: SbColor.h:39
static void initClass(void)
Definition: SoAction.cpp:370
FaceType
Definition: SoShapeHints.h:62
The SoPrimitiveVertex class represents a single vertex of a generated primitive.
Definition: SoPrimitiveVertex.h:43
The SbVec4f class is a 4 dimensional vector with floating point coordinates.
Definition: SbVec4f.h:49
ShapeType
Definition: SoShapeHints.h:57
Units
Definition: SoUnits.h:51
VertexOrdering
Definition: SoShapeHints.h:51
void SoPointCB(void *userdata, SoCallbackAction *action, const SoPrimitiveVertex *v)
Definition: SoCallbackAction.h:76
Style
Definition: SoDrawStyle.h:52
Type
Definition: SoComplexity.h:50
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
virtual SoNode * getCurPathTail(void)
Definition: SoAction.cpp:1118
The SbVec3s class is a 3 dimensional vector with short integer coordinates.
Definition: SbVec3s.h:51
The SoAction class is the base class for all traversal actions.
Definition: SoAction.h:77
Binding
Definition: SoTextureCoordinateBinding.h:49
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition: SbVec3f.h:51
Wrap
Definition: SoTexture2.h:65
Response
Definition: SoCallbackAction.h:94
Model
Definition: SoLightModel.h:49
Model
Definition: SoTexture2.h:58
Type
Definition: SoDecimationTypeElement.h:48
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
void SoTriangleCB(void *userdata, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)
Definition: SoCallbackAction.h:67
Response SoCallbackActionCB(void *userdata, SoCallbackAction *action, const SoNode *node)
Definition: SoCallbackAction.h:96
void SoLineSegmentCB(void *userdata, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2)
Definition: SoCallbackAction.h:72
The SbViewVolume class is a viewing volume in 3D space.
Definition: SbViewVolume.h:50
The SoCallbackAction class invokes callbacks at specific nodes.
Definition: SoCallbackAction.h:80
The SoNodeList class is a container for pointers to SoNode objects.
Definition: SoNodeList.h:40
virtual void beginTraversal(SoNode *node)
Definition: SoAction.cpp:1270
Style
Definition: SoPickStyle.h:49
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
The SoShape class is the superclass for geometry shapes.
Definition: SoShape.h:52
Binding
Definition: SoNormalBinding.h:49
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition: SbVec2s.h:51
The SoType class is the basis for the run-time type system in Coin.
Definition: SoType.h:59
The SbName class stores strings by reference.
Definition: SbName.h:40
Binding
Definition: SoMaterialBinding.h:49