Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:20

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 
0033 class TDataStd_TreeNode;
0034 DEFINE_STANDARD_HANDLE(TDataStd_TreeNode, TDF_Attribute)
0035 
0036 //! Allows you to define an explicit tree of labels
0037 //! which you can also edit.
0038 //! Without this class, the data structure cannot be fully edited.
0039 //! This service is required if for presentation
0040 //! purposes, you want to create an application with
0041 //! a tree which allows you to organize and link data
0042 //! as a function of application features.
0043 class TDataStd_TreeNode : public TDF_Attribute
0044 {
0045 
0046 public:
0047 
0048   
0049   //! class  methods working on the node
0050   //! ===================================
0051   //! Returns true if the tree node T is found on the label L.
0052   //! Otherwise, false is returned.
0053   Standard_EXPORT static Standard_Boolean Find (const TDF_Label& L, Handle(TDataStd_TreeNode)& T);
0054   
0055   //! Finds or Creates a TreeNode attribute on the label <L>
0056   //! with  the  default tree  ID,   returned by the method
0057   //! <GetDefaultTreeID>.  Returns the created/found     TreeNode
0058   //! attribute.
0059   Standard_EXPORT static Handle(TDataStd_TreeNode) Set (const TDF_Label& L);
0060   
0061   //! Finds  or Creates a   TreeNode attribute on  the label
0062   //! <L>, with an   explicit tree ID.  <ExplicitTreeID>  is
0063   //! the  ID   returned by    <TDF_Attribute::ID>   method.
0064   //! Returns the found/created TreeNode attribute.
0065   Standard_EXPORT static Handle(TDataStd_TreeNode) Set (const TDF_Label& L, const Standard_GUID& ExplicitTreeID);
0066   
0067   //! returns a default  tree ID.  this  ID is  used by the
0068   //! <Set> method without explicit tree ID.
0069   //! Instance methods:
0070   //! ================
0071   Standard_EXPORT static const Standard_GUID& GetDefaultTreeID();
0072   
0073   Standard_EXPORT TDataStd_TreeNode();
0074   
0075   //! Insert the TreeNode <Child> as last  child of <me>. If
0076   //! the insertion is successful <me> becomes the Father of <Child>.
0077   Standard_EXPORT Standard_Boolean Append (const Handle(TDataStd_TreeNode)& Child);
0078   
0079   //! Insert the   the TreeNode <Child>  as  first child of
0080   //! <me>. If the insertion is successful <me> becomes the Father of <Child>
0081   Standard_EXPORT Standard_Boolean Prepend (const Handle(TDataStd_TreeNode)& Child);
0082   
0083   //! Inserts the TreeNode  <Node> before <me>. If insertion is successful <me>
0084   //! and <Node> belongs to the same Father.
0085   Standard_EXPORT Standard_Boolean InsertBefore (const Handle(TDataStd_TreeNode)& Node);
0086   
0087   //! Inserts the TreeNode <Node>  after <me>. If insertion is successful  <me>
0088   //! and <Node> belongs to the same Father.
0089   Standard_EXPORT Standard_Boolean InsertAfter (const Handle(TDataStd_TreeNode)& Node);
0090   
0091   //! Removes this tree node attribute from its father
0092   //! node. The result is that this attribute becomes a root node.
0093   Standard_EXPORT Standard_Boolean Remove();
0094   
0095   //! Returns the depth of this tree node in the overall tree node structure.
0096   //! In other words, the number of father tree nodes of this one is returned.
0097   Standard_EXPORT Standard_Integer Depth() const;
0098   
0099   //! Returns the number of child nodes.
0100   //! If <allLevels> is true, the method counts children of all levels
0101   //! (children of children ...)
0102   Standard_EXPORT Standard_Integer NbChildren (const Standard_Boolean allLevels = Standard_False) const;
0103   
0104   //! Returns true if this tree node attribute is an
0105   //! ascendant of of. In other words, if it is a father or
0106   //! the father of a father of of.
0107   Standard_EXPORT Standard_Boolean IsAscendant (const Handle(TDataStd_TreeNode)& of) const;
0108   
0109   //! Returns true if this tree node attribute is a
0110   //! descendant of of. In other words, if it is a child or
0111   //! the child of a child of of.
0112   Standard_EXPORT Standard_Boolean IsDescendant (const Handle(TDataStd_TreeNode)& of) const;
0113   
0114   //! Returns true if this tree node attribute is the
0115   //! ultimate father in the tree.
0116   Standard_EXPORT Standard_Boolean IsRoot() const;
0117   
0118   //! Returns the ultimate father of this tree node attribute.
0119   Standard_EXPORT Handle(TDataStd_TreeNode) Root() const;
0120   
0121   //! Returns true if this tree node attribute is a father of of.
0122   Standard_EXPORT Standard_Boolean IsFather (const Handle(TDataStd_TreeNode)& of) const;
0123   
0124   //! Returns true if this tree node attribute is a child of of.
0125   Standard_EXPORT Standard_Boolean IsChild (const Handle(TDataStd_TreeNode)& of) const;
0126   
0127   //! Returns true if this tree node attribute has a father tree node.
0128     Standard_Boolean HasFather() const;
0129   
0130   //! Returns the father TreeNode of <me>. Null if root.
0131   Standard_EXPORT Handle(TDataStd_TreeNode) Father() const;
0132   
0133   //! Returns true if this tree node attribute has a next tree node.
0134     Standard_Boolean HasNext() const;
0135   
0136   //! Returns the next tree node in this tree node attribute.
0137   //! Warning
0138   //! This tree node is null if it is the last one in this
0139   //! tree node attribute.Returns the next TreeNode of <me>. Null if last.
0140   Standard_EXPORT Handle(TDataStd_TreeNode) Next() const;
0141   
0142   //! Returns true if this tree node attribute has a previous tree node.
0143     Standard_Boolean HasPrevious() const;
0144   
0145   //! Returns the previous tree node of this tree node attribute.
0146   //! Warning
0147   //! This tree node is null if it is the first one in this tree node attribute.
0148   Standard_EXPORT Handle(TDataStd_TreeNode) Previous() const;
0149   
0150   //! Returns true if this tree node attribute has a first child tree node.
0151     Standard_Boolean HasFirst() const;
0152   
0153   //! Returns the first child tree node in this tree node object.
0154   Standard_EXPORT Handle(TDataStd_TreeNode) First() const;
0155   
0156   //! Returns true if this tree node attribute has a last child tree node.
0157     Standard_Boolean HasLast() const;
0158   
0159   //! Returns the last child tree node in this tree node object.
0160   Standard_EXPORT Handle(TDataStd_TreeNode) Last();
0161   
0162   //! Returns the last child tree node in this tree node object.
0163   //! to set fields
0164   //! =============
0165   Standard_EXPORT Handle(TDataStd_TreeNode) FindLast();
0166   
0167   Standard_EXPORT void SetTreeID (const Standard_GUID& explicitID);
0168   
0169   Standard_EXPORT void SetFather (const Handle(TDataStd_TreeNode)& F);
0170   
0171   Standard_EXPORT void SetNext (const Handle(TDataStd_TreeNode)& F);
0172   
0173   Standard_EXPORT void SetPrevious (const Handle(TDataStd_TreeNode)& F);
0174   
0175   Standard_EXPORT void SetFirst (const Handle(TDataStd_TreeNode)& F);
0176   
0177   //! TreeNode callback:
0178   //! ==================
0179   Standard_EXPORT void SetLast (const Handle(TDataStd_TreeNode)& F);
0180   
0181   //! Connect the TreeNode to its father child list
0182   Standard_EXPORT virtual void AfterAddition() Standard_OVERRIDE;
0183   
0184   //! Disconnect the TreeNode from its Father child list
0185   Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE;
0186   
0187   //! Reconnect the TreeNode to its father child list.
0188   Standard_EXPORT virtual void AfterResume() Standard_OVERRIDE;
0189   
0190   //! Disconnect the TreeNode, if necessary.
0191   Standard_EXPORT virtual Standard_Boolean BeforeUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
0192   
0193   //! Reconnect the TreeNode, if necessary.
0194   //! Implementation of Attribute methods:
0195   //! ===================================
0196   Standard_EXPORT virtual Standard_Boolean AfterUndo (const Handle(TDF_AttributeDelta)& anAttDelta, const Standard_Boolean forceIt = Standard_False) Standard_OVERRIDE;
0197   
0198   //! Returns the tree ID (default or explicit one depending on the Set method used).
0199   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0200   
0201   Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
0202   
0203   Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
0204   
0205   Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0206   
0207   Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& aDataSet) const Standard_OVERRIDE;
0208   
0209   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
0210 
0211   //! Dumps the content of me into the stream
0212   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0213 
0214 
0215 friend class TDataStd_ChildNodeIterator;
0216 
0217 
0218   DEFINE_STANDARD_RTTIEXT(TDataStd_TreeNode,TDF_Attribute)
0219 
0220 protected:
0221 
0222 
0223 
0224 
0225 private:
0226 
0227 
0228   TDataStd_PtrTreeNode myFather;
0229   TDataStd_PtrTreeNode myPrevious;
0230   TDataStd_PtrTreeNode myNext;
0231   TDataStd_PtrTreeNode myFirst;
0232   TDataStd_PtrTreeNode myLast;
0233   Standard_GUID myTreeID;
0234 
0235 
0236 };
0237 
0238 
0239 #include <TDataStd_TreeNode.lxx>
0240 
0241 
0242 
0243 
0244 
0245 #endif // _TDataStd_TreeNode_HeaderFile