![]() |
http://www.sim.no http://www.coin3d.org |
00001 #ifndef COIN_SOELEMENT_H 00002 #define COIN_SOELEMENT_H 00003 00004 /**************************************************************************\ 00005 * 00006 * This file is part of the Coin 3D visualization library. 00007 * Copyright (C) 1998-2007 by Systems in Motion. 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 Systems in Motion about acquiring 00018 * a Coin Professional Edition License. 00019 * 00020 * See http://www.coin3d.org/ for more information. 00021 * 00022 * Systems in Motion, 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/SoState.h> 00030 #include <stdio.h> 00031 00032 class SoNode; 00033 00034 class COIN_DLL_API SoElement { 00035 public: 00036 static void initClass(void); 00037 00038 static SoType getClassTypeId(void); 00039 static int getClassStackIndex(void); 00040 const SoType getTypeId(void) const; 00041 int getStackIndex(void) const; 00042 00043 virtual void init(SoState * state); 00044 00045 virtual void push(SoState * state); 00046 virtual void pop(SoState * state, const SoElement * prevTopElement); 00047 00048 virtual SbBool matches(const SoElement * element) const = 0; 00049 virtual SoElement * copyMatchInfo(void) const = 0; 00050 00051 static void initElements(void); // only for base class (SoElement) 00052 00053 static int getNumStackIndices(void); 00054 static SoType getIdFromStackIndex(const int stackIndex); 00055 00056 void setDepth(const int depth); 00057 00058 int getDepth(void) const; 00059 00060 virtual void print(FILE * file = stdout) const; 00061 virtual ~SoElement(); 00062 00063 protected: 00064 SoElement(void); 00065 static int classStackIndex; 00066 00067 static SoElement * getElement(SoState * const state, const int stackIndex); 00068 static const SoElement * getConstElement(SoState * const state, const int stackIndex); 00069 00070 void capture(SoState * const state) const; 00071 00072 virtual void captureThis(SoState * state) const; 00073 00074 void setTypeId(const SoType typeId); 00075 void setStackIndex(const int index); 00076 00077 SoType typeId; 00078 int stackIndex; 00079 00080 static int createStackIndex(const SoType id); 00081 static SoTypeList * stackToType; 00082 00083 int depth; 00084 00085 SoElement * getNextInStack(void) const; 00086 SoElement * getNextFree(void) const; 00087 00088 private: 00089 00090 static SoType classTypeId; 00091 00092 friend class SoState; // FIXME: bad design. 19990629 mortene. 00093 static void cleanup(void); 00094 SoElement * nextup; 00095 SoElement * nextdown; 00096 }; 00097 00098 // inlined methods 00099 00100 inline SoElement * 00101 SoElement::getElement(SoState * const state, 00102 const int stackIndex) 00103 { 00104 return state->getElement(stackIndex); 00105 } 00106 00107 inline void 00108 SoElement::capture(SoState * const state) const 00109 { 00110 if (state->isCacheOpen()) this->captureThis(state); 00111 } 00112 00113 inline const SoElement * 00114 SoElement::getConstElement(SoState * const state, 00115 const int stackIndex) 00116 { 00117 const SoElement * element = state->getConstElement(stackIndex); 00118 element->capture(state); 00119 return element; 00120 } 00121 00122 #endif // !COIN_SOELEMENT_H
Copyright © 1998-2007 by Systems in Motion AS. All rights reserved.
Generated on Mon Feb 28 2011 10:11:54 for Coin by Doxygen. 1.7.3