Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoElement.h
1 #ifndef COIN_SOELEMENT_H
2 #define COIN_SOELEMENT_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) by Kongsberg Oil & Gas Technologies.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Kongsberg Oil & Gas Technologies
18  * about acquiring a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/SbBasic.h>
28 #include <Inventor/SoType.h>
29 #include <Inventor/misc/SoState.h>
30 #include <stdio.h>
31 
32 class SoNode;
33 
34 class COIN_DLL_API SoElement {
35 public:
36  static void initClass(void);
37 
38  static SoType getClassTypeId(void);
39  static int getClassStackIndex(void);
40  const SoType getTypeId(void) const;
41  int getStackIndex(void) const;
42 
43  virtual void init(SoState * state);
44 
45  virtual void push(SoState * state);
46  virtual void pop(SoState * state, const SoElement * prevTopElement);
47 
48  virtual SbBool matches(const SoElement * element) const = 0;
49  virtual SoElement * copyMatchInfo(void) const = 0;
50 
51  static void initElements(void); // only for base class (SoElement)
52 
53  static int getNumStackIndices(void);
54  static SoType getIdFromStackIndex(const int stackIndex);
55 
56  void setDepth(const int depth);
57 
58  int getDepth(void) const;
59 
60  virtual void print(FILE * file = stdout) const;
61  virtual ~SoElement();
62 
63 protected:
64  SoElement(void);
65  static int classStackIndex;
66 
67  static SoElement * getElement(SoState * const state, const int stackIndex);
68  static const SoElement * getConstElement(SoState * const state, const int stackIndex);
69 
70  void capture(SoState * const state) const;
71 
72  virtual void captureThis(SoState * state) const;
73 
74  void setTypeId(const SoType typeId);
75  void setStackIndex(const int index);
76 
79 
80  static int createStackIndex(const SoType id);
82 
83  int depth;
84 
85  SoElement * getNextInStack(void) const;
86  SoElement * getNextFree(void) const;
87 
88 private:
89 
90  static SoType classTypeId;
91 
92  friend class SoState; // FIXME: bad design. 19990629 mortene.
93  static void cleanup(void);
94  SoElement * nextup;
95  SoElement * nextdown;
96 };
97 
98 // inlined methods
99 
100 inline SoElement *
102  const int stackIndex)
103 {
104  return state->getElement(stackIndex);
105 }
106 
107 inline void
108 SoElement::capture(SoState * const state) const
109 {
110  if (state->isCacheOpen()) this->captureThis(state);
111 }
112 
113 inline const SoElement *
115  const int stackIndex)
116 {
117  const SoElement * element = state->getConstElement(stackIndex);
118  element->capture(state);
119  return element;
120 }
121 
122 #endif // !COIN_SOELEMENT_H
virtual void captureThis(SoState *state) const
Definition: SoElement.cpp:688
const SoElement * getConstElement(const int stackindex) const
Definition: SoState.h:76
static const SoElement * getConstElement(SoState *const state, const int stackIndex)
Definition: SoElement.h:114
static SoElement * getElement(SoState *const state, const int stackIndex)
Definition: SoElement.h:101
The SoNode class is the base class for nodes used in scene graphs.Coin is a retained mode 3D visualiz...
Definition: SoNode.h:47
SoElement is the abstract base class for all elements.
Definition: SoElement.h:34
SoType typeId
Definition: SoElement.h:77
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:35
The SoTypeList class is a container class for arrays of SoType objects.
Definition: SoTypeList.h:30
int stackIndex
Definition: SoElement.h:78
SoElement * getElement(const int stackindex)
Definition: SoState.cpp:218
static SoTypeList * stackToType
Definition: SoElement.h:81
void capture(SoState *const state) const
Definition: SoElement.h:108
int depth
Definition: SoElement.h:83
SbBool isCacheOpen(void) const
Definition: SoState.h:83
static int classStackIndex
Definition: SoElement.h:65
The SoType class is the basis for the run-time type system in Coin.Many of the classes in the Coin li...
Definition: SoType.h:50

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Fri Sep 9 2016 for Coin by Doxygen 1.8.5.