0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TDataStd / TDataStd_TreeNode.hxx
CommitLineData
42cf5bc1 1// Created on: 1999-06-10
2// Created by: Vladislav ROMASHKO
3// Copyright (c) 1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _TDataStd_TreeNode_HeaderFile
18#define _TDataStd_TreeNode_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TDataStd_PtrTreeNode.hxx>
24#include <Standard_GUID.hxx>
25#include <TDF_Attribute.hxx>
26#include <Standard_Boolean.hxx>
27#include <Standard_Integer.hxx>
28#include <Standard_OStream.hxx>
29class TDataStd_ChildNodeIterator;
30class TDF_Label;
31class Standard_GUID;
32class TDF_AttributeDelta;
33class TDF_Attribute;
34class TDF_RelocationTable;
35class TDF_DataSet;
36
37
38class TDataStd_TreeNode;
39DEFINE_STANDARD_HANDLE(TDataStd_TreeNode, TDF_Attribute)
40
41//! Allows you to define an explicit tree of labels
42//! which you can also edit.
43//! Without this class, the data structure cannot be fully edited.
44//! This service is required if for presentation
45//! purposes, you want to create an application with
46//! a tree which allows you to organize and link data
47//! as a function of application features.
48class TDataStd_TreeNode : public TDF_Attribute
49{
50
51public:
52
53
54 //! class methods working on the node
55 //! ===================================
56 //! Returns true if the tree node T is found on the label L.
57 //! Otherwise, false is returned.
58 Standard_EXPORT static Standard_Boolean Find (const TDF_Label& L, Handle(TDataStd_TreeNode)& T);
59
60 //! Finds or Creates a TreeNode attribute on the label <L>
61 //! with the default tree ID, returned by the method
62 //! <GetDefaultTreeID>. Returns the created/found TreeNode
63 //! attribute.
64 Standard_EXPORT static Handle(TDataStd_TreeNode) Set (const TDF_Label& L);
65
66 //! Finds or Creates a TreeNode attribute on the label
67 //! <L>, with an explicit tree ID. <ExplicitTreeID> is
68 //! the ID returned by <TDF_Attribute::ID> method.
69 //! Returns the found/created TreeNode attribute.
70 Standard_EXPORT static Handle(TDataStd_TreeNode) Set (const TDF_Label& L, const Standard_GUID& ExplicitTreeID);
71
72 //! returns a default tree ID. this ID is used by the
73 //! <Set> method without explicit tree ID.
74 //! Instance methods:
75 //! ================
76 Standard_EXPORT static const Standard_GUID& GetDefaultTreeID();
77
78 Standard_EXPORT TDataStd_TreeNode();
79
80 //! Insert the TreeNode <Child> as last child of <me>. If
81 //! the insertion is successful <me> becomes the Father of <Child>.
82 Standard_EXPORT Standard_Boolean Append (const Handle(TDataStd_TreeNode)& Child);
83
84 //! Insert the the TreeNode <Child> as first child of
85 //! <me>. If the insertion is successful <me> becomes the Father of <Child>
86 Standard_EXPORT Standard_Boolean Prepend (const Handle(TDataStd_TreeNode)& Child);
87
88 //! Inserts the TreeNode <Node> before <me>. If insertion is successful <me>
89 //! and <Node> belongs to the same Father.
90 Standard_EXPORT Standard_Boolean InsertBefore (const Handle(TDataStd_TreeNode)& Node);
91
92 //! Inserts the TreeNode <Node> after <me>. If insertion is successful <me>
93 //! and <Node> belongs to the same Father.
94 Standard_EXPORT Standard_Boolean InsertAfter (const Handle(TDataStd_TreeNode)& Node);
95
96 //! Removes this tree node attribute from its father
97 //! node. The result is that this attribute becomes a root node.
98 Standard_EXPORT Standard_Boolean Remove();
99
100 //! Returns the depth of this tree node in the overall tree node structure.
101 //! In other words, the number of father tree nodes of this one is returned.
102 Standard_EXPORT Standard_Integer Depth() const;
103
104 //! Returns the number of child nodes.
105 //! If <allLevels> is true, the method counts children of all levels
106 //! (children of children ...)
107 Standard_EXPORT Standard_Integer NbChildren (const Standard_Boolean allLevels = Standard_False) const;
108
109 //! Returns true if this tree node attribute is an
110 //! ascendant of of. In other words, if it is a father or
111 //! the father of a father of of.
112 Standard_EXPORT Standard_Boolean IsAscendant (const Handle(TDataStd_TreeNode)& of) const;
113
114 //! Returns true if this tree node attribute is a
115 //! descendant of of. In other words, if it is a child or
116 //! the child of a child of of.
117 Standard_EXPORT Standard_Boolean IsDescendant (const Handle(TDataStd_TreeNode)& of) const;
118
119 //! Returns true if this tree node attribute is the
120 //! ultimate father in the tree.
121 Standard_EXPORT Standard_Boolean IsRoot() const;
122
123 //! Returns the ultimate father of this tree node attribute.
124 Standard_EXPORT Handle(TDataStd_TreeNode) Root() const;
125
126 //! Returns true if this tree node attribute is a father of of.
127 Standard_EXPORT Standard_Boolean IsFather (const Handle(TDataStd_TreeNode)& of) const;
128
129 //! Returns true if this tree node attribute is a child of of.
130 Standard_EXPORT Standard_Boolean IsChild (const Handle(TDataStd_TreeNode)& of) const;
131
132 //! Returns true if this tree node attribute has a father tree node.
133 Standard_Boolean HasFather() const;
134
135 //! Returns the father TreeNode of <me>. Null if root.
136 Standard_EXPORT Handle(TDataStd_TreeNode) Father() const;
137
138 //! Returns true if this tree node attribute has a next tree node.
139 Standard_Boolean HasNext() const;
140
141 //! Returns the next tree node in this tree node attribute.
142 //! Warning
143 //! This tree node is null if it is the last one in this
144 //! tree node attribute.Returns the next TreeNode of <me>. Null if last.
145 Standard_EXPORT Handle(TDataStd_TreeNode) Next() const;
146
147 //! Returns true if this tree node attribute has a previous tree node.
148 Standard_Boolean HasPrevious() const;
149
150 //! Returns the previous tree node of this tree node attribute.
151 //! Warning
152 //! This tree node is null if it is the first one in this tree node attribute.
153 Standard_EXPORT Handle(TDataStd_TreeNode) Previous() const;
154
155 //! Returns true if this tree node attribute has a first child tree node.
156 Standard_Boolean HasFirst() const;
157
158 //! Returns the first child tree node in this tree node object.
159 Standard_EXPORT Handle(TDataStd_TreeNode) First() const;
160
161 //! Returns true if this tree node attribute has a last child tree node.
162 Standard_Boolean HasLast() const;
163
164 //! Returns the last child tree node in this tree node object.
165 Standard_EXPORT Handle(TDataStd_TreeNode) Last();
166
167 //! Returns the last child tree node in this tree node object.
168 //! to set fields
169 //! =============
170 Standard_EXPORT Handle(TDataStd_TreeNode) FindLast();
171
172 Standard_EXPORT void SetTreeID (const Standard_GUID& explicitID);
173
174 Standard_EXPORT void SetFather (const Handle(TDataStd_TreeNode)& F);
175
176 Standard_EXPORT void SetNext (const Handle(TDataStd_TreeNode)& F);
177
178 Standard_EXPORT void SetPrevious (const Handle(TDataStd_TreeNode)& F);
179
180 Standard_EXPORT void SetFirst (const Handle(TDataStd_TreeNode)& F);
181
182 //! TreeNode callback:
183 //! ==================
184 Standard_EXPORT void SetLast (const Handle(TDataStd_TreeNode)& F);
185
186 //! Connect the TreeNode to its father child list
187 Standard_EXPORT virtual void AfterAddition() Standard_OVERRIDE;
188
189 //! Disconnect the TreeNode from its Father child list
190 Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE;
191
192 //! Reconnect the TreeNode to its father child list.
193 Standard_EXPORT virtual void AfterResume() Standard_OVERRIDE;
194
195 //! Disconnect the TreeNode, if necessary.
196 Standard_EXPORT virtual Standard_Boolean BeforeUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
197
198 //! Reconnect the TreeNode, if necessary.
199 //! Implementation of Attribute methods:
200 //! ===================================
201 Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
202
203 //! Returns the tree ID (default or explicit one depending
204 //! onthe Set method used).
79104795 205 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
42cf5bc1 206
79104795 207 Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
42cf5bc1 208
79104795 209 Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
42cf5bc1 210
211 Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
212
213 Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& aDataSet) const Standard_OVERRIDE;
214
215 Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
216
bc73b006 217 //! Dumps the content of me into the stream
218 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
219
42cf5bc1 220
221friend class TDataStd_ChildNodeIterator;
222
223
92efcf78 224 DEFINE_STANDARD_RTTIEXT(TDataStd_TreeNode,TDF_Attribute)
42cf5bc1 225
226protected:
227
228
229
230
231private:
232
233
234 TDataStd_PtrTreeNode myFather;
235 TDataStd_PtrTreeNode myPrevious;
236 TDataStd_PtrTreeNode myNext;
237 TDataStd_PtrTreeNode myFirst;
238 TDataStd_PtrTreeNode myLast;
239 Standard_GUID myTreeID;
240
241
242};
243
244
245#include <TDataStd_TreeNode.lxx>
246
247
248
249
250
251#endif // _TDataStd_TreeNode_HeaderFile