Open Inventor Reference
SoState.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | This file defines the SoState class.
48  |
49  | Author(s) : Paul S. Strauss
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_STATE_
56 #define _SO_STATE_
57 
73 
74 #define SO_STATE_GET_CONST_ELEMENT(stackIndex)\
75  return stack[stackIndex];
76 
77 #include <Inventor/SoLists.h>
78 
79 class SoAction;
80 class SoElement;
81 
83 
84  public:
87  SoState(SoAction *action, const SoTypeList &enabledElements);
88 
91 
93  SoAction * getAction() const { return action; }
94 
97  SoElement * getElement(int stackIndex);
98 
100  const SoElement * getConstElement(int stackIndex) const
101  { return stack[stackIndex]; }
102 
108  void push()
109  { depth++; }
110 
112  void pop();
113 
115  void print(FILE *fp);
116 
117  SoINTERNAL public:
119  bool isElementEnabled(int stackIndex) const
120  { return (stack[stackIndex] != NULL); }
121 
123  int getDepth() const { return depth; }
124 
128  void setCacheOpen(bool flag) { cacheOpen = flag; }
129  bool isCacheOpen() const { return cacheOpen; }
130 
135  SoElement * getElementNoPush(int stackIndex) const
136  { return stack[stackIndex]; }
137 
138  private:
139  SoAction *action;
140  int depth;
141  SoElement **stack;
142  int numStacks;
143  SoElement * topElement;
144 
145  bool cacheOpen;
146 };
147 
148 #endif /* _SO_STATE_ */
149 
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
Abstract base class for all actions.
Definition: SoAction.h:179
This is the abstract base class for all state elements.
Definition: SoElement.h:96
An SoState collects and holds state while traversing a scene graph.
Definition: SoState.h:82
int getDepth() const
Returns current depth of state.
Definition: SoState.h:123
SoElement * getElementNoPush(int stackIndex) const
Internal-only, dangerous method that returns a writeable element without checking for state depth and...
Definition: SoState.h:135
const SoElement * getConstElement(int stackIndex) const
Returns the top (read-only) instance of the given element stack.
Definition: SoState.h:100
void push()
Pushes (saves) the current state until a pop() restores it.
Definition: SoState.h:108
void setCacheOpen(bool flag)
Sets/returns flag that indicates whether a cache is open.
Definition: SoState.h:128
SoElement * getElement(int stackIndex)
Returns a writable instance of the element on the top of the stack with the given index.
bool isElementEnabled(int stackIndex) const
Returns TRUE if element with given stack index is enabled in state.
Definition: SoState.h:119
void print(FILE *fp)
Prints state to file (for debugging)
~SoState()
Destructor.
SoAction * getAction() const
Returns the action instance the state is part of.
Definition: SoState.h:93
SoState(SoAction *action, const SoTypeList &enabledElements)
Constructor.
void pop()
Pops the state, restoring the state to just before the last push().
bool isCacheOpen() const
Definition: SoState.h:129
Maintains a list of SoTypes.
Definition: SoLists.h:295