Open Inventor Reference
SoCallbackAction.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | Defines the SoCallbackAction class
48  |
49  | Author(s) : Dave Immel, Thad Beier
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_CALLBACK_ACTION_
56 #define _SO_CALLBACK_ACTION_
57 
59 #include <Inventor/SbBox.h>
70 #include <Inventor/nodes/SoUnits.h>
71 
72 class SoPrimitiveVertex;
73 class SoShape;
74 
79 
80 typedef void SoTriangleCB(void *userData,
81  SoCallbackAction *action,
82  const SoPrimitiveVertex *v1,
83  const SoPrimitiveVertex *v2,
84  const SoPrimitiveVertex *v3);
85 
86 typedef void SoLineSegmentCB(void *userData, SoCallbackAction *action,
87  const SoPrimitiveVertex *v1,
88  const SoPrimitiveVertex *v2);
89 
90 typedef void SoPointCB(void *userData, SoCallbackAction *action,
91  const SoPrimitiveVertex *v);
92 
93 
96 
125 
127 
129 
130  public:
131 
133  enum Response {
136  PRUNE
137  };
138 
145  typedef Response SoCallbackActionCB(void *userData,
146  SoCallbackAction *action,
147  const SoNode *node);
148 
151 
153  virtual ~SoCallbackAction();
154 
159 
165  void addPreCallback(SoType type, SoCallbackActionCB *cb, void *data);
167  void addPostCallback(SoType type, SoCallbackActionCB *cb, void *data);
168 
172  void addPreTailCallback(SoCallbackActionCB *cb, void *data);
176  void addPostTailCallback(SoCallbackActionCB *cb, void *data);
177 
182  void addTriangleCallback(SoType type, SoTriangleCB *cb, void *data);
184  void addLineSegmentCallback(SoType type, SoLineSegmentCB *cb, void *data);
186  void addPointCallback(SoType type, SoPointCB *cb, void *data);
187 
188 
194 
196 
198  float getComplexity() const;
200 
202 
206  const SbVec3f & getCoordinate3(int index) const;
208  const SbVec4f & getCoordinate4(int index) const;
209 
211 
214  u_short getLinePattern() const;
216  float getLineWidth() const;
218  float getPointSize() const;
219 
221 
223  const SbName & getFontName() const;
225  float getFontSize() const;
226 
228 
231  const SbVec3f & getLightAttenuation() const;
232 
234 
237  void getMaterial(SbColor &ambient,
238  SbColor &diffuse,
239  SbColor &specular,
240  SbColor &emission,
241  float &shininess,
242  float &transparency,
243  int mtlIndex = 0) const;
245 
247 
251  const SbVec3f & getNormal(int index) const;
253 
255 
259  const SbVec2f & getProfileCoordinate2(int index) const;
261  const SbVec3f & getProfileCoordinate3(int index) const;
263  const SoNodeList & getProfile() const;
264 
266 
271  float getCreaseAngle() const;
272 
274 
278  const SbVec2f & getTextureCoordinate2(int index) const;
280  const SbVec4f & getTextureCoordinate4(int index) const;
283  const SbColor & getTextureBlendColor() const;
284 
287  const unsigned char * getTextureImage(SbVec2s &size,
288  int &numComps) const;
290  const SbMatrix & getTextureMatrix() const;
294 
296 
299  const SbMatrix & getModelMatrix() const;
301 
303 
305  float getFocalDistance() const;
307  const SbMatrix & getProjectionMatrix() const;
309  const SbMatrix & getViewingMatrix() const;
311  const SbViewVolume & getViewVolume() const;
312 
314 
318 
319  SoEXTENDER public:
321  Response getCurrentResponse() const { return response; }
322 
324  void invokePreCallbacks(const SoNode *node);
325  void invokePostCallbacks(const SoNode *node);
326 
328  void invokeTriangleCallbacks(const SoShape *shape,
329  const SoPrimitiveVertex *v1,
330  const SoPrimitiveVertex *v2,
331  const SoPrimitiveVertex *v3);
333  const SoPrimitiveVertex *v1,
334  const SoPrimitiveVertex *v2);
335  void invokePointCallbacks(const SoShape *shape,
336  const SoPrimitiveVertex *v);
337 
339  bool shouldGeneratePrimitives(const SoShape *shape) const;
340 
341  SoINTERNAL public:
342  static void initClass();
343 
345  virtual SoNode * getCurPathTail();
346 
348  void setCurrentNode(SoNode *node)
349  { currentNode = node;}
350 
351  protected:
353  virtual void beginTraversal(SoNode *node);
354 
355  private:
357  SbPList preCallbackList;
358  SbPList postCallbackList;
359 
360  SbPList preTailCallbackList;
361  SbPList postTailCallbackList;
362 
363  SbPList triangleCallbackList;
364  SbPList lineSegmentCallbackList;
365  SbPList pointCallbackList;
366 
368  Response response;
369 
371  SoNode * currentNode;
372 };
373 
374 #endif /* _SO_CALLBACK_ACTION_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
signed int int32_t
Definition: SbTypeDefs.h:43
void SoTriangleCB(void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)
Typedefs for callback routines used with the callbacks for generating primitives.
void SoLineSegmentCB(void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2)
void SoPointCB(void *userData, SoCallbackAction *action, const SoPrimitiveVertex *v)
#define SO_ACTION_HEADER(className)
Macros to be called within the class definition header for an action subclass:
Definition: SoSubAction.h:87
Color vector class.
Definition: SbColor.h:84
4x4 matrix class.
Definition: SbLinear.h:823
Character string stored in a hash table.
Definition: SbString.h:264
List of generic (void *) pointers.
Definition: SbPList.h:78
2D vector class.
Definition: SbLinear.h:246
2D vector class.
Definition: SbLinear.h:354
3D vector class.
Definition: SbLinear.h:120
4D vector class.
Definition: SbLinear.h:559
3D viewing volume class.
Definition: SbLinear.h:1058
Abstract base class for all actions.
Definition: SoAction.h:179
Performs a generic traversal of the scene graph.
float getFocalDistance() const
Returns the current camera and viewing information from the state.
Response
Possible responses from a pre or post callback.
@ CONTINUE
Continue as usual.
@ ABORT
Stop traversing the rest of the graph.
static void initClass()
const SbVec3f & getNormal(int index) const
Returns the current normal information from the state.
bool shouldGeneratePrimitives(const SoShape *shape) const
Should primitives be generated for this shape?
const unsigned char * getTextureImage(SbVec2s &size, int &numComps) const
Returns texture information from the state.
const SbMatrix & getViewingMatrix() const
Returns the current camera and viewing information from the state.
SoDrawStyle::Style getDrawStyle() const
const SbVec4f & getCoordinate4(int index) const
Returns the current coordinates from the state.
float getCreaseAngle() const
Returns the current shape hints from the state.
void invokeTriangleCallbacks(const SoShape *shape, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2, const SoPrimitiveVertex *v3)
Call the primitive callbacks.
void invokePreCallbacks(const SoNode *node)
Call the pre-callbacks and post-callbacks.
Response getCurrentResponse() const
Returns the current response.
virtual ~SoCallbackAction()
Destructor.
SoUnits::Units getUnits() const
void invokeLineSegmentCallbacks(const SoShape *shape, const SoPrimitiveVertex *v1, const SoPrimitiveVertex *v2)
int32_t getNumNormals() const
Returns the current normal information from the state.
float getFontSize() const
Returns the current font information from the state.
void addPreTailCallback(SoCallbackActionCB *cb, void *data)
These can be used to set up callback functions to call when the action is applied to a path.
void getMaterial(SbColor &ambient, SbColor &diffuse, SbColor &specular, SbColor &emission, float &shininess, float &transparency, int mtlIndex=0) const
Returns the current material information from the state.
const SbVec4f & getTextureCoordinate4(int index) const
Returns texture information from the state.
u_short getLinePattern() const
Returns the current drawing style information from the state.
void addPostTailCallback(SoCallbackActionCB *cb, void *data)
These can be used to set up callback functions to call when the action is applied to a path.
float getPointSize() const
Returns the current drawing style information from the state.
SoMaterialBinding::Binding getMaterialBinding() const
const SbColor & getTextureBlendColor() const
Returns texture information from the state.
SoShapeHints::ShapeType getShapeType() const
int32_t getNumProfileCoordinates() const
Returns the current profiles and their coordinates from the state.
int32_t getNumCoordinates() const
Returns the current coordinates from the state.
int32_t getNumTextureCoordinates() const
Returns 0 if texture coordinates are generated by a function.
float getComplexity() const
Accessing state information from callbacks.
void addPointCallback(SoType type, SoPointCB *cb, void *data)
SoTextureCoordinateBinding::Binding getTextureCoordinateBinding() const
float getLineWidth() const
Returns the current drawing style information from the state.
const SbMatrix & getTextureMatrix() const
Returns the current texture mapping information from the state.
SoLightModel::Model getLightModel() const
const SbMatrix & getModelMatrix() const
Returns the current modeling transformation and the current units from the state.
Response SoCallbackActionCB(void *userData, SoCallbackAction *action, const SoNode *node)
The SoCallbackActionCB typedef is defined within the class, since it needs to refer to the Response e...
void addTriangleCallback(SoType type, SoTriangleCB *cb, void *data)
Routines to add callbacks for generated primitives (triangles, line segments, and points) for all sha...
virtual SoNode * getCurPathTail()
Returns the node that caused the callback:
SoPickStyle::Style getPickStyle() const
const SbVec3f & getLightAttenuation() const
Returns the current lighting model information from the state.
void invokePostCallbacks(const SoNode *node)
void addPreCallback(SoType type, SoCallbackActionCB *cb, void *data)
Adding callback functions:
const SoNodeList & getProfile() const
Returns the current profiles and their coordinates from the state.
const SbVec2f & getProfileCoordinate2(int index) const
Returns the current profiles and their coordinates from the state.
virtual void beginTraversal(SoNode *node)
Initiates action on graph.
void addLineSegmentCallback(SoType type, SoLineSegmentCB *cb, void *data)
void setCurrentNode(SoNode *node)
Set the current node during traversal:
const SbVec3f & getCoordinate3(int index) const
Returns the current coordinates from the state.
SoTexture2::Wrap getTextureWrapS() const
const SbVec3f & getProfileCoordinate3(int index) const
Returns the current profiles and their coordinates from the state.
SoTexture2::Wrap getTextureWrapT() const
void addPostCallback(SoType type, SoCallbackActionCB *cb, void *data)
SoShapeHints::VertexOrdering getVertexOrdering() const
const SbViewVolume & getViewVolume() const
Returns the current camera and viewing information from the state.
const SbVec2f & getTextureCoordinate2(int index) const
Returns texture information from the state.
SoCallbackAction()
The constructor.
const SbMatrix & getProjectionMatrix() const
Returns the current camera and viewing information from the state.
SoComplexity::Type getComplexityType() const
const SbName & getFontName() const
Returns the current font information from the state.
SoTexture2::Model getTextureModel() const
SoShapeHints::FaceType getFaceType() const
void invokePointCallbacks(const SoShape *shape, const SoPrimitiveVertex *v)
int32_t getSwitch() const
Returns the current switch value.
SoNormalBinding::Binding getNormalBinding() const
Model
Lighting model:
Definition: SoLightModel.h:98
Maintains a list of pointers to nodes.
Definition: SoLists.h:177
Abstract base class for all database nodes.
Definition: SoNode.h:103
Style
Picking style:
Definition: SoPickStyle.h:102
Represents a vertex of a generated primitive.
FaceType
Hints about faces of shape: if all faces are known to be convex or not.
Definition: SoShapeHints.h:146
VertexOrdering
Hints about ordering of face vertices: if ordering of all vertices of all faces is known to be consis...
Definition: SoShapeHints.h:131
ShapeType
Hints about entire shape: if shape is known to be a solid object, as opposed to a surface.
Definition: SoShapeHints.h:139
Abstract base class for all shape nodes.
Definition: SoShape.h:101
Wrap
Texture wrap type.
Definition: SoTexture2.h:156
Model
Texture model.
Definition: SoTexture2.h:149
SoType has no virtual functions to keep it small...
Definition: SoType.h:103