0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / XCAFDoc / XCAFDoc_GraphNode.hxx
CommitLineData
42cf5bc1 1// Created on: 2000-09-27
2// Created by: Pavel TELKOV.
3// Copyright (c) 2000-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _XCAFDoc_GraphNode_HeaderFile
17#define _XCAFDoc_GraphNode_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Type.hxx>
21
22#include <XCAFDoc_GraphNodeSequence.hxx>
23#include <Standard_GUID.hxx>
24#include <TDF_Attribute.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_Integer.hxx>
27#include <Standard_OStream.hxx>
28class TDF_Label;
29class Standard_GUID;
30class TDF_Attribute;
31class TDF_RelocationTable;
32class TDF_DataSet;
33
34
35class XCAFDoc_GraphNode;
36DEFINE_STANDARD_HANDLE(XCAFDoc_GraphNode, TDF_Attribute)
37
38//! This attribute allow user multirelation tree of labels.
39//! This GraphNode is experimental Graph that not control looping and redundance.
40//! Attribute containg sequence of father's and child's labels.
41//! Provide create and work with Graph in XCAFDocument.
42class XCAFDoc_GraphNode : public TDF_Attribute
43{
44
45public:
46
47
48 //! class methods working on the node
49 //! ===================================
50 //! Shortcut to search a Graph node attribute with default
51 //! GraphID. Returns true if found.
52 Standard_EXPORT static Standard_Boolean Find (const TDF_Label& L, Handle(XCAFDoc_GraphNode)& G);
53
54 //! Finds or Creates a GraphNode attribute on the label <L>
55 //! with the default Graph ID, returned by the method
56 //! <GetDefaultGraphID>. Returns the created/found GraphNode
57 //! attribute.
58 Standard_EXPORT static Handle(XCAFDoc_GraphNode) Set (const TDF_Label& L);
59
60 //! Finds or Creates a GraphNode attribute on the label
61 //! <L>, with an explicit tree ID. <ExplicitGraphID> is
62 //! the ID returned by <TDF_Attribute::ID> method.
63 //! Returns the found/created GraphNode attribute.
64 Standard_EXPORT static Handle(XCAFDoc_GraphNode) Set (const TDF_Label& L, const Standard_GUID& ExplicitGraphID);
65
66 //! returns a default Graph ID. this ID is used by the
67 //! <Set> method without explicit tree ID.
68 //! Instance methods:
69 //! ================
70 Standard_EXPORT static const Standard_GUID& GetDefaultGraphID();
71
72 Standard_EXPORT XCAFDoc_GraphNode();
73
74 Standard_EXPORT void SetGraphID (const Standard_GUID& explicitID);
75
76 //! Set GraphNode <F> as father of me and returns index of <F>
77 //! in Sequence that containing Fathers GraphNodes.
78 //! return index of <F> from GraphNodeSequnece
79 Standard_EXPORT Standard_Integer SetFather (const Handle(XCAFDoc_GraphNode)& F);
80
81 //! Set GraphNode <Ch> as child of me and returns index of <Ch>
82 //! in Sequence that containing Children GraphNodes.
83 //! return index of <Ch> from GraphNodeSequnece
84 Standard_EXPORT Standard_Integer SetChild (const Handle(XCAFDoc_GraphNode)& Ch);
85
86 //! Remove <F> from Fathers GraphNodeSequence.
87 //! and remove link between father and child.
88 Standard_EXPORT void UnSetFather (const Handle(XCAFDoc_GraphNode)& F);
89
90 //! Remove Father GraphNode by index from Fathers GraphNodeSequence.
91 //! and remove link between father and child.
92 Standard_EXPORT void UnSetFather (const Standard_Integer Findex);
93
94 //! Remove <Ch> from GraphNodeSequence.
95 //! and remove link between father and child.
96 Standard_EXPORT void UnSetChild (const Handle(XCAFDoc_GraphNode)& Ch);
97
98 //! Remove Child GraphNode by index from Children GraphNodeSequence.
99 //! and remove link between father and child.
100 Standard_EXPORT void UnSetChild (const Standard_Integer Chindex);
101
102 //! Return GraphNode by index from GraphNodeSequence.
103 Standard_EXPORT Handle(XCAFDoc_GraphNode) GetFather (const Standard_Integer Findex) const;
104
105 //! Return GraphNode by index from GraphNodeSequence.
106 Standard_EXPORT Handle(XCAFDoc_GraphNode) GetChild (const Standard_Integer Chindex) const;
107
108 //! Return index of <F>, or zero if there is no such Graphnode.
109 Standard_EXPORT Standard_Integer FatherIndex (const Handle(XCAFDoc_GraphNode)& F) const;
110
111 //! Return index of <Ch>, or zero if there is no such Graphnode.
112 Standard_EXPORT Standard_Integer ChildIndex (const Handle(XCAFDoc_GraphNode)& Ch) const;
113
114 //! returns TRUE if <me> is father of <Ch>.
115 Standard_EXPORT Standard_Boolean IsFather (const Handle(XCAFDoc_GraphNode)& Ch) const;
116
117 //! returns TRUE if <me> is child of <F>.
118 Standard_EXPORT Standard_Boolean IsChild (const Handle(XCAFDoc_GraphNode)& F) const;
119
120 //! return Number of Fathers GraphNodes.
121 Standard_EXPORT Standard_Integer NbFathers() const;
122
123 //! return Number of Childrens GraphNodes.
124 //! Implementation of Attribute methods:
125 //! ===================================
126 Standard_EXPORT Standard_Integer NbChildren() const;
127
128 //! Returns the Graph ID (default or explicit one depending
129 //! onthe Set method used).
79104795 130 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
42cf5bc1 131
79104795 132 Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
42cf5bc1 133
79104795 134 Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
42cf5bc1 135
136 Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
137
138 Standard_EXPORT virtual void References (const Handle(TDF_DataSet)& aDataSet) const Standard_OVERRIDE;
139
140 Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
141
142 Standard_EXPORT virtual void BeforeForget() Standard_OVERRIDE;
143
144
145
146
92efcf78 147 DEFINE_STANDARD_RTTIEXT(XCAFDoc_GraphNode,TDF_Attribute)
42cf5bc1 148
149protected:
150
151
152
153
154private:
155
156
157 //! remove link between father and child.
158 Standard_EXPORT void UnSetFatherlink (const Handle(XCAFDoc_GraphNode)& F);
159
160 //! remove link between father and child.
161 Standard_EXPORT void UnSetChildlink (const Handle(XCAFDoc_GraphNode)& C);
162
163 XCAFDoc_GraphNodeSequence myFathers;
164 XCAFDoc_GraphNodeSequence myChildren;
165 Standard_GUID myGraphID;
166
167
168};
169
170
171
172
173
174
175
176#endif // _XCAFDoc_GraphNode_HeaderFile