![]() |
http://www.sim.no/ http://www.coin3d.org/ |
00001 #ifndef COIN_SOACTION_H 00002 #define COIN_SOACTION_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2008 by Kongsberg SIM. All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * ("GPL") version 2 as published by the Free Software Foundation. 00012 * See the file LICENSE.GPL at the root directory of this source 00013 * distribution for additional information about the GNU GPL. 00014 * 00015 * For using Coin with software that can not be combined with the GNU 00016 * GPL, and for taking advantage of the additional benefits of our 00017 * support services, please contact Kongsberg SIM about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Kongsberg SIM, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. 00023 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org 00024 * 00025 \**************************************************************************/ 00026 00027 #include <Inventor/SbBasic.h> 00028 #include <Inventor/SoType.h> 00029 #include <Inventor/misc/SoTempPath.h> 00030 #include <Inventor/tools/SbPimplPtr.h> 00031 00032 // Include instead of using forward declarations to be compatible with 00033 // Open Inventor (and besides, all the other action class definitions 00034 // needs to know about these lists). 00035 #include <Inventor/lists/SoActionMethodList.h> 00036 #include <Inventor/lists/SoEnabledElementsList.h> 00037 00038 // defined in Inventor/SbBasic.h 00039 #ifdef COIN_UNDEF_IN_PATH_HACK 00040 #include <sys/unistd.h> 00041 #undef IN_PATH 00042 // Avoid problem with HPUX 10.20 C library API headers, which defines IN_PATH 00043 // in <sys/unistd.h>. That define destroys the SoAction::PathCode enum, and 00044 // the preprocessor is so broken that we can't store/restore the define for 00045 // the duration of this header file. 00046 #endif // COIN_UNDEF_IN_PATH_HACK 00047 00048 00053 #define SO_ENABLE(action, element) \ 00054 do { \ 00055 assert(!element::getClassTypeId().isBad()); \ 00056 action::enableElement(element::getClassTypeId(), \ 00057 element::getClassStackIndex()); \ 00058 } while (0) 00059 00060 00061 class SoEnabledElementsList; 00062 class SoNode; 00063 class SoPath; 00064 class SoPathList; 00065 class SoState; 00066 class SoActionP; 00067 00068 class COIN_DLL_API SoAction { 00069 public: 00070 static void initClass(void); 00071 static void initClasses(void); 00072 00073 enum AppliedCode { NODE = 0, PATH = 1, PATH_LIST = 2 }; 00074 enum PathCode { NO_PATH = 0, IN_PATH = 1, BELOW_PATH = 2, OFF_PATH = 3 }; 00075 00076 virtual ~SoAction(void); 00077 00078 static SoType getClassTypeId(void); 00079 virtual SoType getTypeId(void) const = 0; 00080 virtual SbBool isOfType(SoType type) const; 00081 00082 virtual void apply(SoNode * root); 00083 virtual void apply(SoPath * path); 00084 virtual void apply(const SoPathList & pathlist, SbBool obeysrules = FALSE); 00085 void apply(SoAction * beingApplied); 00086 virtual void invalidateState(void); 00087 00088 static void nullAction(SoAction * action, SoNode * node); 00089 00090 AppliedCode getWhatAppliedTo(void) const; 00091 SoNode * getNodeAppliedTo(void) const; 00092 SoPath * getPathAppliedTo(void) const; 00093 const SoPathList * getPathListAppliedTo(void) const; 00094 const SoPathList * getOriginalPathListAppliedTo(void) const; 00095 00096 SbBool isLastPathListAppliedTo(void) const; 00097 00098 PathCode getPathCode(int & numindices, const int * & indices); 00099 00100 void traverse(SoNode * const node); 00101 SbBool hasTerminated(void) const; 00102 00103 const SoPath * getCurPath(void); 00104 SoState * getState(void) const; 00105 00106 PathCode getCurPathCode(void) const; 00107 virtual SoNode * getCurPathTail(void); 00108 void usePathCode(int & numindices, const int * & indices); 00109 00110 void pushCurPath(const int childindex, SoNode * node = NULL); 00111 void popCurPath(const PathCode prevpathcode); 00112 void pushCurPath(void); 00113 00114 void popPushCurPath(const int childindex, SoNode * node = NULL); 00115 void popCurPath(void); 00116 00117 public: 00118 void switchToPathTraversal(SoPath * path); 00119 void switchToNodeTraversal(SoNode * node); 00120 00121 protected: 00122 SoAction(void); 00123 00124 virtual void beginTraversal(SoNode * node); 00125 virtual void endTraversal(SoNode * node); 00126 void setTerminated(const SbBool flag); 00127 00128 virtual const SoEnabledElementsList & getEnabledElements(void) const; 00129 virtual SbBool shouldCompactPathList(void) const; 00130 00131 SoState * state; 00132 SoActionMethodList * traversalMethods; 00133 00134 /* These two methods are not available in the original OIV API. The 00135 reason they have been added is explained in SoSubAction.h for the 00136 SO_ACTION_HEADER macro. */ 00137 static SoEnabledElementsList * getClassEnabledElements(void); 00138 static SoActionMethodList * getClassActionMethods(void); 00139 00140 private: 00141 static SoType classTypeId; 00142 /* The enabledElements and methods variables are protected in the 00143 original OIV API. This is not such a good idea, see the comments 00144 in SoSubAction.h for SO_ACTION_HEADER. */ 00145 00146 static void atexit_cleanup(void); 00147 static SoEnabledElementsList * enabledElements; 00148 static SoActionMethodList * methods; 00149 SoTempPath currentpath; 00150 PathCode currentpathcode; 00151 00152 private: 00153 SbPimplPtr<SoActionP> pimpl; 00154 00155 // NOT IMPLEMENTED: 00156 SoAction(const SoAction & rhs); 00157 SoAction & operator = (const SoAction & rhs); 00158 }; // SoAction 00159 00160 // inline methods 00161 00162 inline SoAction::PathCode 00163 SoAction::getCurPathCode(void) const 00164 { 00165 return this->currentpathcode; 00166 } 00167 00168 #endif // !COIN_SOACTION_H
Copyright © 1998-2008 by Kongsberg SIM. All rights reserved.
Generated on Tue May 5 02:52:04 2009 for Coin by Doxygen 1.5.5.