Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:29:39

0001 // Created on: 1999-06-10
0002 // Created by: Vladislav ROMASHKO
0003 // Copyright (c) 1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TDataStd_TreeNode_HeaderFile
0018 #define _TDataStd_TreeNode_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <TDataStd_PtrTreeNode.hxx>
0023 #include <Standard_GUID.hxx>
0024 #include <TDF_Attribute.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_OStream.hxx>
0027 class TDF_Label;
0028 class TDF_AttributeDelta;
0029 class TDF_RelocationTable;
0030 class TDF_DataSet;
0031 
0032 //! Allows you to define an explicit tree of labels
0033 //! which you can also edit.
0034 //! Without this class, the data structure cannot be fully edited.
0035 //! This service is required if for presentation
0036 //! purposes, you want to create an application with
0037 //! a tree which allows you to organize and link data
0038 //! as a function of application features.
0039 class TDataStd_TreeNode : public TDF_Attribute
0040 {
0041 
0042 public:
0043   //! class methods working on the node
0044   //! =================================
0045   //! Returns true if the tree node T is found on the label L.
0046   //! Otherwise, false is returned.
0047   Standard_EXPORT static bool Find(const TDF_Label& L, occ::handle<TDataStd_TreeNode>& T);
0048 
0049   //! Finds or Creates a TreeNode attribute on the label <L>
0050   //! with the default tree ID, returned by the method
0051   //! <GetDefaultTreeID>. Returns the created/found TreeNode
0052   //! attribute.
0053   Standard_EXPORT static occ::handle<TDataStd_TreeNode> Set(const TDF_Label& L);
0054 
0055   //! Finds or Creates a TreeNode attribute on the label
0056   //! <L>, with an explicit tree ID. <ExplicitTreeID> is
0057   //! the ID returned by <TDF_Attribute::ID> method.
0058   //! Returns the found/created TreeNode attribute.
0059   Standard_EXPORT static occ::handle<TDataStd_TreeNode> Set(const TDF_Label&     L,
0060                                                             const Standard_GUID& ExplicitTreeID);
0061 
0062   //! returns a default tree ID. this ID is used by the
0063   //! <Set> method without explicit tree ID.
0064   //! Instance methods:
0065   //! ================
0066   Standard_EXPORT static const Standard_GUID& GetDefaultTreeID();
0067 
0068   Standard_EXPORT TDataStd_TreeNode();
0069 
0070   //! Insert the TreeNode <Child> as last child of <me>. If
0071   //! the insertion is successful <me> becomes the Father of <Child>.
0072   Standard_EXPORT bool Append(const occ::handle<TDataStd_TreeNode>& Child);
0073 
0074   //! Insert the the TreeNode <Child> as first child of
0075   //! <me>. If the insertion is successful <me> becomes the Father of <Child>
0076   Standard_EXPORT bool Prepend(const occ::handle<TDataStd_TreeNode>& Child);
0077 
0078   //! Inserts the TreeNode <Node> before <me>. If insertion is successful <me>
0079   //! and <Node> belongs to the same Father.
0080   Standard_EXPORT bool InsertBefore(const occ::handle<TDataStd_TreeNode>& Node);
0081 
0082   //! Inserts the TreeNode <Node> after <me>. If insertion is successful <me>
0083   //! and <Node> belongs to the same Father.
0084   Standard_EXPORT bool InsertAfter(const occ::handle<TDataStd_TreeNode>& Node);
0085 
0086   //! Removes this tree node attribute from its father
0087   //! node. The result is that this attribute becomes a root node.
0088   Standard_EXPORT bool Remove();
0089 
0090   //! Returns the depth of this tree node in the overall tree node structure.
0091   //! In other words, the number of father tree nodes of this one is returned.
0092   Standard_EXPORT int Depth() const;
0093 
0094   //! Returns the number of child nodes.
0095   //! If <allLevels> is true, the method counts children of all levels
0096   //! (children of children ...)
0097   Standard_EXPORT int NbChildren(const bool allLevels = false) const;
0098 
0099   //! Returns true if this tree node attribute is an
0100   //! ascendant of of. In other words, if it is a father or
0101   //! the father of a father of of.
0102   Standard_EXPORT bool IsAscendant(const occ::handle<TDataStd_TreeNode>& of) const;
0103 
0104   //! Returns true if this tree node attribute is a
0105   //! descendant of of. In other words, if it is a child or
0106   //! the child of a child of of.
0107   Standard_EXPORT bool IsDescendant(const occ::handle<TDataStd_TreeNode>& of) const;
0108 
0109   //! Returns true if this tree node attribute is the
0110   //! ultimate father in the tree.
0111   Standard_EXPORT bool IsRoot() const;
0112 
0113   //! Returns the ultimate father of this tree node attribute.
0114   Standard_EXPORT occ::handle<TDataStd_TreeNode> Root() const;
0115 
0116   //! Returns true if this tree node attribute is a father of of.
0117   Standard_EXPORT bool IsFather(const occ::handle<TDataStd_TreeNode>& of) const;
0118 
0119   //! Returns true if this tree node attribute is a child of of.
0120   Standard_EXPORT bool IsChild(const occ::handle<TDataStd_TreeNode>& of) const;
0121 
0122   //! Returns true if this tree node attribute has a father tree node.
0123   bool HasFather() const;
0124 
0125   //! Returns the father TreeNode of <me>. Null if root.
0126   Standard_EXPORT occ::handle<TDataStd_TreeNode> Father() const;
0127 
0128   //! Returns true if this tree node attribute has a next tree node.
0129   bool HasNext() const;
0130 
0131   //! Returns the next tree node in this tree node attribute.
0132   //! Warning
0133   //! This tree node is null if it is the last one in this
0134   //! tree node attribute.Returns the next TreeNode of <me>. Null if last.
0135   Standard_EXPORT occ::handle<TDataStd_TreeNode> Next() const;
0136 
0137   //! Returns true if this tree node attribute has a previous tree node.
0138   bool HasPrevious() const;
0139 
0140   //! Returns the previous tree node of this tree node attribute.
0141   //! Warning
0142   //! This tree node is null if it is the first one in this tree node attribute.
0143   Standard_EXPORT occ::handle<TDataStd_TreeNode> Previous() const;
0144 
0145   //! Returns true if this tree node attribute has a first child tree node.
0146   bool HasFirst() const;
0147 
0148   //! Returns the first child tree node in this tree node object.
0149   Standard_EXPORT occ::handle<TDataStd_TreeNode> First() const;
0150 
0151   //! Returns true if this tree node attribute has a last child tree node.
0152   bool HasLast() const;
0153 
0154   //! Returns the last child tree node in this tree node object.
0155   Standard_EXPORT occ::handle<TDataStd_TreeNode> Last();
0156 
0157   //! Returns the last child tree node in this tree node object.
0158   //! to set fields
0159   //! =============
0160   Standard_EXPORT occ::handle<TDataStd_TreeNode> FindLast();
0161 
0162   Standard_EXPORT void SetTreeID(const Standard_GUID& explicitID);
0163 
0164   Standard_EXPORT void SetFather(const occ::handle<TDataStd_TreeNode>& F);
0165 
0166   Standard_EXPORT void SetNext(const occ::handle<TDataStd_TreeNode>& F);
0167 
0168   Standard_EXPORT void SetPrevious(const occ::handle<TDataStd_TreeNode>& F);
0169 
0170   Standard_EXPORT void SetFirst(const occ::handle<TDataStd_TreeNode>& F);
0171 
0172   //! TreeNode callback:
0173   //! ==================
0174   Standard_EXPORT void SetLast(const occ::handle<TDataStd_TreeNode>& F);
0175 
0176   //! Connect the TreeNode to its father child list
0177   Standard_EXPORT void AfterAddition() override;
0178 
0179   //! Disconnect the TreeNode from its Father child list
0180   Standard_EXPORT void BeforeForget() override;
0181 
0182   //! Reconnect the TreeNode to its father child list.
0183   Standard_EXPORT void AfterResume() override;
0184 
0185   //! Disconnect the TreeNode, if necessary.
0186   Standard_EXPORT bool BeforeUndo(const occ::handle<TDF_AttributeDelta>& anAttDelta,
0187                                   const bool                             forceIt = false) override;
0188 
0189   //! Reconnect the TreeNode, if necessary.
0190   //! Implementation of Attribute methods:
0191   //! ===================================
0192   Standard_EXPORT bool AfterUndo(const occ::handle<TDF_AttributeDelta>& anAttDelta,
0193                                  const bool                             forceIt = false) override;
0194 
0195   //! Returns the tree ID (default or explicit one depending on the Set method used).
0196   Standard_EXPORT const Standard_GUID& ID() const override;
0197 
0198   Standard_EXPORT void Restore(const occ::handle<TDF_Attribute>& with) override;
0199 
0200   Standard_EXPORT void Paste(const occ::handle<TDF_Attribute>&       into,
0201                              const occ::handle<TDF_RelocationTable>& RT) const override;
0202 
0203   Standard_EXPORT occ::handle<TDF_Attribute> NewEmpty() const override;
0204 
0205   Standard_EXPORT void References(const occ::handle<TDF_DataSet>& aDataSet) const override;
0206 
0207   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& anOS) const override;
0208 
0209   //! Dumps the content of me into the stream
0210   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0211 
0212   friend class TDataStd_ChildNodeIterator;
0213 
0214   DEFINE_STANDARD_RTTIEXT(TDataStd_TreeNode, TDF_Attribute)
0215 
0216 private:
0217   TDataStd_PtrTreeNode myFather;
0218   TDataStd_PtrTreeNode myPrevious;
0219   TDataStd_PtrTreeNode myNext;
0220   TDataStd_PtrTreeNode myFirst;
0221   TDataStd_PtrTreeNode myLast;
0222   Standard_GUID        myTreeID;
0223 };
0224 
0225 #include <TDataStd_TreeNode.lxx>
0226 
0227 #endif // _TDataStd_TreeNode_HeaderFile