Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | Defines the SoCallbackAction class 00048 | 00049 | Author(s) : Dave Immel, Thad Beier 00050 | 00051 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00052 _______________________________________________________________________ 00053 */ 00054 00055 #ifndef _SO_CALLBACK_ACTION_ 00056 #define _SO_CALLBACK_ACTION_ 00057 00058 #include <Inventor/system/SbSystem.h> 00059 #include <Inventor/SbBox.h> 00060 #include <Inventor/actions/SoSubAction.h> 00061 #include <Inventor/nodes/SoComplexity.h> 00062 #include <Inventor/nodes/SoDrawStyle.h> 00063 #include <Inventor/nodes/SoLightModel.h> 00064 #include <Inventor/nodes/SoMaterialBinding.h> 00065 #include <Inventor/nodes/SoNormalBinding.h> 00066 #include <Inventor/nodes/SoPickStyle.h> 00067 #include <Inventor/nodes/SoShapeHints.h> 00068 #include <Inventor/nodes/SoTexture2.h> 00069 #include <Inventor/nodes/SoTextureCoordinateBinding.h> 00070 #include <Inventor/nodes/SoUnits.h> 00071 00072 class SoPrimitiveVertex; 00073 class SoShape; 00074 00079 00080 typedef void SoTriangleCB(void *userData, 00081 SoCallbackAction *action, 00082 const SoPrimitiveVertex *v1, 00083 const SoPrimitiveVertex *v2, 00084 const SoPrimitiveVertex *v3); 00085 00086 typedef void SoLineSegmentCB(void *userData, SoCallbackAction *action, 00087 const SoPrimitiveVertex *v1, 00088 const SoPrimitiveVertex *v2); 00089 00090 typedef void SoPointCB(void *userData, SoCallbackAction *action, 00091 const SoPrimitiveVertex *v); 00092 00093 00096 00124 00125 00126 class INVENTOR_API SoCallbackAction : public SoAction { 00127 00128 SO_ACTION_HEADER(SoCallbackAction); 00129 00130 public: 00131 00133 enum Response { 00134 CONTINUE, 00135 ABORT, 00136 PRUNE 00137 }; 00138 00145 typedef Response SoCallbackActionCB(void *userData, 00146 SoCallbackAction *action, 00147 const SoNode *node); 00148 00150 SoCallbackAction(); 00151 00153 virtual ~SoCallbackAction(); 00154 00159 00165 void addPreCallback(SoType type, SoCallbackActionCB *cb, void *data); 00167 void addPostCallback(SoType type, SoCallbackActionCB *cb, void *data); 00168 00172 void addPreTailCallback(SoCallbackActionCB *cb, void *data); 00176 void addPostTailCallback(SoCallbackActionCB *cb, void *data); 00177 00182 void addTriangleCallback(SoType type, SoTriangleCB *cb, void *data); 00184 void addLineSegmentCallback(SoType type, SoLineSegmentCB *cb, void *data); 00186 void addPointCallback(SoType type, SoPointCB *cb, void *data); 00187 00188 00194 00196 00198 float getComplexity() const; 00199 SoComplexity::Type getComplexityType() const; 00200 00202 00204 int32_t getNumCoordinates() const; 00206 const SbVec3f & getCoordinate3(int index) const; 00208 const SbVec4f & getCoordinate4(int index) const; 00209 00211 00212 SoDrawStyle::Style getDrawStyle() const; 00214 u_short getLinePattern() const; 00216 float getLineWidth() const; 00218 float getPointSize() const; 00219 00221 00223 const SbName & getFontName() const; 00225 float getFontSize() const; 00226 00228 00229 SoLightModel::Model getLightModel() const; 00231 const SbVec3f & getLightAttenuation() const; 00232 00234 00237 void getMaterial(SbColor &ambient, 00238 SbColor &diffuse, 00239 SbColor &specular, 00240 SbColor &emission, 00241 float &shininess, 00242 float &transparency, 00243 int mtlIndex = 0) const; 00244 SoMaterialBinding::Binding getMaterialBinding() const; 00245 00247 00249 int32_t getNumNormals() const; 00251 const SbVec3f & getNormal(int index) const; 00252 SoNormalBinding::Binding getNormalBinding() const; 00253 00255 00257 int32_t getNumProfileCoordinates() const; 00259 const SbVec2f & getProfileCoordinate2(int index) const; 00261 const SbVec3f & getProfileCoordinate3(int index) const; 00263 const SoNodeList & getProfile() const; 00264 00266 00267 SoShapeHints::VertexOrdering getVertexOrdering() const; 00268 SoShapeHints::ShapeType getShapeType() const; 00269 SoShapeHints::FaceType getFaceType() const; 00271 float getCreaseAngle() const; 00272 00274 00276 int32_t getNumTextureCoordinates() const; 00278 const SbVec2f & getTextureCoordinate2(int index) const; 00280 const SbVec4f & getTextureCoordinate4(int index) const; 00281 SoTextureCoordinateBinding::Binding getTextureCoordinateBinding() const; 00283 const SbColor & getTextureBlendColor() const; 00284 00287 const unsigned char * getTextureImage(SbVec2s &size, 00288 int &numComps) const; 00290 const SbMatrix & getTextureMatrix() const; 00291 SoTexture2::Model getTextureModel() const; 00292 SoTexture2::Wrap getTextureWrapS() const; 00293 SoTexture2::Wrap getTextureWrapT() const; 00294 00296 00299 const SbMatrix & getModelMatrix() const; 00300 SoUnits::Units getUnits() const; 00301 00303 00305 float getFocalDistance() const; 00307 const SbMatrix & getProjectionMatrix() const; 00309 const SbMatrix & getViewingMatrix() const; 00311 const SbViewVolume & getViewVolume() const; 00312 00314 00315 SoPickStyle::Style getPickStyle() const; 00317 int32_t getSwitch() const; 00318 00319 SoEXTENDER public: 00321 Response getCurrentResponse() const { return response; } 00322 00324 void invokePreCallbacks(const SoNode *node); 00325 void invokePostCallbacks(const SoNode *node); 00326 00328 void invokeTriangleCallbacks(const SoShape *shape, 00329 const SoPrimitiveVertex *v1, 00330 const SoPrimitiveVertex *v2, 00331 const SoPrimitiveVertex *v3); 00332 void invokeLineSegmentCallbacks(const SoShape *shape, 00333 const SoPrimitiveVertex *v1, 00334 const SoPrimitiveVertex *v2); 00335 void invokePointCallbacks(const SoShape *shape, 00336 const SoPrimitiveVertex *v); 00337 00339 SbBool shouldGeneratePrimitives(const SoShape *shape) const; 00340 00341 SoINTERNAL public: 00342 static void initClass(); 00343 00345 virtual SoNode * getCurPathTail(); 00346 00348 void setCurrentNode(SoNode *node) 00349 { currentNode = node;} 00350 00351 protected: 00353 virtual void beginTraversal(SoNode *node); 00354 00355 private: 00357 SbPList preCallbackList; 00358 SbPList postCallbackList; 00359 00360 SbPList preTailCallbackList; 00361 SbPList postTailCallbackList; 00362 00363 SbPList triangleCallbackList; 00364 SbPList lineSegmentCallbackList; 00365 SbPList pointCallbackList; 00366 00368 Response response; 00369 00371 SoNode * currentNode; 00372 }; 00373 00374 #endif /* _SO_CALLBACK_ACTION_ */