Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoChildList.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifndef _SO_CHILD_LIST_
51#define _SO_CHILD_LIST_
52
53#include <Inventor/SoLists.h>
56
57
59//
60// Class: SoChildList
61//
62// This class maintains a list of child nodes for any node. It allows
63// children to be added, removed, replaced, and accessed. The SoGroup
64// class has an instance of this class and provides public methods
65// for dealing with children. Other classes can also have an instance
66// of this class and may choose to publicize whatever methods they
67// wish for dealing with them. The SoNode::getChildren() method
68// returns the child list for any node class.
69//
70// SoChildList automatically maintains the auditor list for parent
71// nodes. That is, when a child is added to the list, the parent node
72// is automatically added as a parent auditor of the child. To make
73// this possible, the parent node must be passed in to the
74// constructors of the SoChildList class.
75//
77
78class SoAction;
79class AuditorsContainer;
84{
85 public:
86 // Constructors and destructor.
87 SoChildList(SoNode *parentNode);
88 SoChildList(SoNode *parentNode, int size);
89 SoChildList(SoNode *parentNode, const SoChildList &l);
90 virtual ~SoChildList();
91
92 // All of these override the standard SoBaseList methods so they
93 // can maintain auditors correctly.
94 void append(SoNode * child);
95 void insert(SoNode *child, int addBefore);
96 void remove(int which);
97 void truncate(int start);
98 void copy(const SoChildList &l);
99 void set(int i, SoNode *child);
100
101 // Traverses all children to apply action. Stops if action's
102 // termination condition is reached
103 void traverse(SoAction *action);
104
105 // Traverses just one child
106 void traverse(SoAction *action, int childIndex)
107 { traverse(action, childIndex, childIndex); }
108
109 // Traverses all children between two indices, inclusive. Stops if
110 // action's termination condition is reached.
111 void traverse(SoAction *action, int firstChild, int lastChild);
112
113 // Traverses just one node
114 void traverse(SoAction *action, SoNode *node);
115
116 // multi-instance traversals
117 // Traverses all children to apply action. Stops if action's
118 // termination condition is reached for one instance
119 void traverseMI(SoAction *action, int instanceIndex);
120
121 // Traverses just one child with multi instancing
122 void traverseMI( SoAction *action, int childIndex, int numInstances )
123 { traverseMI(action, childIndex, childIndex, numInstances); }
124
125 // Traverses all children between two indices, inclusive. Stops if
126 // action's termination condition is reached.
127 void traverseMI(SoAction *action, int firstChild, int lastChild, int instanceIndex );
128
129 // Traverses just one node
130 void traverseMI(SoAction *action, SoNode *node, int instanceIndex );
131
132 private:
133 // SoPath calls these to be notified of changes in scene graph
134 // topology:
135 // moved to the .cxx
136 void addPathAuditor(SoPath *p);
137 void removePathAuditor(SoPath *p);
138 void removeAllPathAuditor();
139 static void exitClass();
140
141private:
142
143 // Inner clas that describes current notification info details.
144 class SoChildNotificationInfo
145 {
146 public:
147 // Constructor.
148 SoChildNotificationInfo()
149 {
150 reset();
151 }
152 // reset current notification details.
153 inline void reset()
154 {
155 m_changedChild = NULL;
156 m_changedIndex = -1;
157 m_changeType = SoDataSensor::UNSPECIFIED;
158 }
159 // set current notification infos.
160 inline void set(SoNode* changedChild, const int changedIndex, const SoDataSensor::ChangeType changeType)
161 {
162 m_changedChild = changedChild;
163 m_changedIndex = changedIndex;
164 m_changeType = changeType;
165 }
166 // Basic accessors
167 inline SoNode* getChangedChild() const
168 { return m_changedChild; }
169 int getChangedIndex() const
170 { return m_changedIndex; }
171 SoDataSensor::ChangeType getChangeType() const
172 { return m_changeType;}
173
174 private:
175 // pointer on the changed child
176 SoNode* m_changedChild;
177 // index of the changed child
178 int m_changedIndex;
179 // current type of changed
180 SoDataSensor::ChangeType m_changeType;
181 };
182
183 SoNode* parent;
184 // This is a container of SoPath* and not a PathList because PathList ref()s the
185 // paths it contains, and that screws up Path reference counting.
186 AuditorsContainer *m_auditors;
187
188 // Returns details of change (only valid during notification)
189 const SoChildNotificationInfo& getChildNotificationInfo() const
190 { return m_childNotificationInfo; }
191
192 // keep track of last change during notification process
193 SoChildNotificationInfo m_childNotificationInfo;
194
196 friend class SoNode;
197 friend class SoDataSensor;
199};
200
201#endif /* _SO_CHILD_LIST_ */
202
203
void set(int32_t numNormals, const SbVec3f *normals, const SoNormalBindingElement::Binding binding, const int startIndex=0)
void start()
Abstract base class for all actions.
Definition SoAction.h:132
Abstract base class for sensors attached to parts of a scene.
ChangeType
Change type.
@ UNSPECIFIED
Unspecified.
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
size_t size() const
void set(int i, SoNode *child)
void truncate(int start)
void traverse(SoAction *action)
void remove(int which)
virtual ~SoChildList()
void append(SoNode *child)
void copy(const SoChildList &l)
void traverseMI(SoAction *action, int instanceIndex)
SoChildList(SoNode *parentNode, int size)
void insert(SoNode *child, int addBefore)
void reset()