Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

SoAction.h

00001 /**************************************************************************\ 00002 * 00003 * This file is part of the Coin 3D visualization library. 00004 * Copyright (C) 1998-2003 by Systems in Motion. All rights reserved. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * version 2.1 as published by the Free Software Foundation. See the 00009 * file LICENSE.LGPL at the root directory of the distribution for 00010 * more details. 00011 * 00012 * If you want to use Coin for applications not compatible with the 00013 * LGPL, please contact SIM to acquire a Professional Edition license. 00014 * 00015 * Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY 00016 * http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097 00017 * 00018 \**************************************************************************/ 00019 00020 #ifndef COIN_SOACTION_H 00021 #define COIN_SOACTION_H 00022 00023 #include <Inventor/SbBasic.h> 00024 #include <Inventor/SoType.h> 00025 #include <Inventor/misc/SoTempPath.h> 00026 #include <Inventor/lists/SbList.h> 00027 00028 // Include instead of using forward declarations to be compatible with 00029 // Open Inventor (and besides, all the other action class definitions 00030 // needs to know about these lists). 00031 #include <Inventor/lists/SoActionMethodList.h> 00032 #include <Inventor/lists/SoEnabledElementsList.h> 00033 00034 // defined in Inventor/SbBasic.h 00035 #ifdef COIN_UNDEF_IN_PATH_HACK 00036 #include <sys/unistd.h> 00037 #undef IN_PATH 00038 // Avoid problem with HPUX 10.20 C library API headers, which defines IN_PATH 00039 // in <sys/unistd.h>. That define destroys the SoAction::PathCode enum, and 00040 // the preprocessor is so broken that we can't store/restore the define for 00041 // the duration of this header file. 00042 #endif 00043 00044 00049 #define SO_ENABLE(action, element) \ 00050 do { \ 00051 assert(!element::getClassTypeId().isBad()); \ 00052 action::enableElement(element::getClassTypeId(), \ 00053 element::getClassStackIndex()); \ 00054 } while (0) 00055 00056 00057 class SoEnabledElementsList; 00058 class SoNode; 00059 class SoPath; 00060 class SoPathList; 00061 class SoState; 00062 00063 00064 class COIN_DLL_API SoAction { 00065 public: 00066 enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }; 00067 enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }; 00068 00069 virtual ~SoAction(); 00070 00071 static void initClass(void); 00072 static void initClasses(void); 00073 00074 static SoType getClassTypeId(void); 00075 virtual SoType getTypeId(void) const = 0; 00076 virtual SbBool isOfType(SoType type) const; 00077 00078 00079 virtual void apply(SoNode * root); 00080 virtual void apply(SoPath * path); 00081 virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE); 00082 virtual void invalidateState(void); 00083 00084 static void nullAction(SoAction * action, SoNode * node); 00085 00086 AppliedCode getWhatAppliedTo(void) const; 00087 SoNode * getNodeAppliedTo(void) const; 00088 SoPath * getPathAppliedTo(void) const; 00089 const SoPathList * getPathListAppliedTo(void) const; 00090 const SoPathList * getOriginalPathListAppliedTo(void) const; 00091 00092 SbBool isLastPathListAppliedTo(void) const; 00093 00094 PathCode getPathCode(int & numindices, const int * & indices); 00095 00096 void traverse(SoNode * const node); 00097 SbBool hasTerminated(void) const; 00098 00099 const SoPath * getCurPath(void); 00100 SoState * getState(void) const; 00101 00102 PathCode getCurPathCode(void) const; 00103 virtual SoNode * getCurPathTail(void); 00104 void usePathCode(int & numindices, const int * & indices); 00105 00106 void pushCurPath(const int childindex, SoNode * node = NULL); 00107 void popCurPath(const PathCode prevpathcode); 00108 void pushCurPath(void); 00109 00110 void popPushCurPath(const int childindex, SoNode * node = NULL); 00111 void popCurPath(void); 00112 00113 public: 00114 void switchToPathTraversal(SoPath * path); 00115 void switchToNodeTraversal(SoNode * node); 00116 00117 00118 protected: 00119 SoAction(void); 00120 00121 virtual void beginTraversal(SoNode * node); 00122 virtual void endTraversal(SoNode * node); 00123 void setTerminated(const SbBool flag); 00124 00125 virtual const SoEnabledElementsList & getEnabledElements(void) const; 00126 virtual SbBool shouldCompactPathList(void) const; 00127 00128 SoState * state; 00129 SoActionMethodList * traversalMethods; 00130 00131 /* These two methods are not available in the original OIV API. The 00132 reason they have been added is explained in SoSubAction.h for the 00133 SO_ACTION_HEADER macro. */ 00134 static SoEnabledElementsList * getClassEnabledElements(void); 00135 static SoActionMethodList * getClassActionMethods(void); 00136 00137 private: 00138 static SoType classTypeId; 00139 /* The enabledElements and methods variables are protected in the 00140 original OIV API. This is not such a good idea, see the comments 00141 in SoSubAction.h for SO_ACTION_HEADER. */ 00142 static SoEnabledElementsList * enabledElements; 00143 static SoActionMethodList * methods; 00144 00145 AppliedCode appliedcode; 00146 00147 // FIXME: this is to avoid a complaint from Doxygen, which has a bug 00148 // that makes it spit out a warning on undocumented nested *private* 00149 // structs. Bug not reported yet. Found with Doxygen version 00150 // 1.2.18. 20020919 mortene. 00151 #ifndef DOXYGEN_SKIP_THIS 00152 union AppliedData { 00153 SoNode * node; 00154 SoPath * path; 00155 struct { 00156 const SoPathList * pathlist; 00157 const SoPathList * origpathlist; 00158 } pathlistdata; 00159 } applieddata; 00160 #endif // DOXYGEN_SKIP_THIS 00161 00162 SoTempPath currentpath; 00163 SbBool terminated; 00164 PathCode currentpathcode; 00165 SbList <SbList<int> *> pathcodearray; 00166 }; 00167 00168 // inline methods 00169 00170 inline SoAction::PathCode 00171 SoAction::getCurPathCode(void) const 00172 { 00173 return this->currentpathcode; 00174 } 00175 00176 inline void 00177 SoAction::popCurPath(const PathCode prevpathcode) 00178 { 00179 this->currentpath.pop(); 00180 this->currentpathcode = prevpathcode; 00181 } 00182 00183 00184 #endif // !COIN_SOACTION_H

Generated on Tue Jul 27 23:53:00 2004 for Coin by doxygen 1.3.7