0030675: Visualization - remove redundant proxy classes in hierarchy of PrsMgr_Presen...
[occt.git] / src / XCAFDoc / XCAFDoc_LayerTool.hxx
CommitLineData
42cf5bc1 1// Created on: 2000-09-26
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_LayerTool_HeaderFile
17#define _XCAFDoc_LayerTool_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Type.hxx>
21
22#include <TDF_Attribute.hxx>
23#include <Standard_Boolean.hxx>
24#include <TDF_LabelSequence.hxx>
25#include <TColStd_HSequenceOfExtendedString.hxx>
26class XCAFDoc_ShapeTool;
27class TDF_Label;
28class Standard_GUID;
29class TCollection_ExtendedString;
30class TopoDS_Shape;
31class TDF_Attribute;
32class TDF_RelocationTable;
33
34
35class XCAFDoc_LayerTool;
36DEFINE_STANDARD_HANDLE(XCAFDoc_LayerTool, TDF_Attribute)
37
38//! Provides tools to store and retrieve attributes (Layers)
39//! of TopoDS_Shape in and from TDocStd_Document
40//! A Document is intended to hold different
41//! attributes of ONE shape and it's sub-shapes
42//! Provide tools for management of Layers section of document.
43class XCAFDoc_LayerTool : public TDF_Attribute
44{
45
46public:
47
48
49 Standard_EXPORT XCAFDoc_LayerTool();
50
51 //! Creates (if not exist) LayerTool.
52 Standard_EXPORT static Handle(XCAFDoc_LayerTool) Set (const TDF_Label& L);
53
54 Standard_EXPORT static const Standard_GUID& GetID();
55
56 //! returns the label under which Layers are stored
57 Standard_EXPORT TDF_Label BaseLabel() const;
58
59 //! Returns internal XCAFDoc_ShapeTool tool
60 Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
61
62 //! Returns True if label belongs to a Layertable and
63 //! is a Layer definition
64 Standard_EXPORT Standard_Boolean IsLayer (const TDF_Label& lab) const;
65
66 //! Returns Layer defined by label lab
67 //! Returns False if the label is not in Layertable
68 //! or does not define a Layer
69 Standard_EXPORT Standard_Boolean GetLayer (const TDF_Label& lab, TCollection_ExtendedString& aLayer) const;
70
71 //! Finds a Layer definition in a Layertable and returns
72 //! its label if found
73 //! Returns False if Layer is not found in Layertable
74 Standard_EXPORT Standard_Boolean FindLayer (const TCollection_ExtendedString& aLayer, TDF_Label& lab) const;
75
76 //! Finds a Layer definition in a Layertable and returns
77 //! its label if found (or Null label else)
78 Standard_EXPORT TDF_Label FindLayer (const TCollection_ExtendedString& aLayer) const;
79
80 //! Adds a Layer definition to a Layertable and returns
81 //! its label (returns existing label if the same Layer
82 //! is already defined)
83 Standard_EXPORT TDF_Label AddLayer (const TCollection_ExtendedString& aLayer) const;
84
85 //! Removes Layer from the Layertable
86 Standard_EXPORT void RemoveLayer (const TDF_Label& lab) const;
87
88 //! Returns a sequence of Layers currently stored
89 //! in the Layertable
90 Standard_EXPORT void GetLayerLabels (TDF_LabelSequence& Labels) const;
91
92 //! Sets a link from label <L> to Layer
93 //! defined by <LayerL>
94 //! optional parametr <shapeInOneLayer> show could shape be
95 //! in number of layers or only in one.
96 Standard_EXPORT void SetLayer (const TDF_Label& L, const TDF_Label& LayerL, const Standard_Boolean shapeInOneLayer = Standard_False) const;
97
98 //! Sets a link from label <L> to Layer <aLayer>
99 //! in the Layertable
100 //! Adds a Layer as necessary
101 //! optional parametr <shapeInOneLayer> show could shape be
102 //! in number of layers or only in one.
103 Standard_EXPORT void SetLayer (const TDF_Label& L, const TCollection_ExtendedString& aLayer, const Standard_Boolean shapeInOneLayer = Standard_False) const;
104
105 //! Removes a link from label <L> to all layers
106 Standard_EXPORT void UnSetLayers (const TDF_Label& L) const;
107
108 //! Remove link from label <L> and Layer <aLayer>.
109 //! returns FALSE if no such layer.
110 Standard_EXPORT Standard_Boolean UnSetOneLayer (const TDF_Label& L, const TCollection_ExtendedString& aLayer) const;
111
112 //! Remove link from label <L> and Layer <aLayerL>.
113 //! returns FALSE if <aLayerL> is not a layer label.
114 Standard_EXPORT Standard_Boolean UnSetOneLayer (const TDF_Label& L, const TDF_Label& aLayerL) const;
115
116 //! Returns True if label <L> has a Layer assosiated
117 //! with the <aLayer>.
118 Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L, const TCollection_ExtendedString& aLayer) const;
119
120 //! Returns True if label <L> has a Layer assosiated
121 //! with the <aLayerL> label.
122 Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L, const TDF_Label& aLayerL) const;
123
124 //! Return sequence of strings <aLayerS> that assosiated with label <L>.
125 Standard_EXPORT Standard_Boolean GetLayers (const TDF_Label& L, Handle(TColStd_HSequenceOfExtendedString)& aLayerS);
126
127 //! Return sequence of labels <aLayerSL> that assosiated with label <L>.
128 Standard_EXPORT Standard_Boolean GetLayers (const TDF_Label& L, TDF_LabelSequence& aLayerLS);
129
130 //! Return sequence of strings that assosiated with label <L>.
131 Standard_EXPORT Handle(TColStd_HSequenceOfExtendedString) GetLayers (const TDF_Label& L);
132
133 //! Return sequanese of shape labels that assigned with layers to <ShLabels>.
134 Standard_EXPORT void GetShapesOfLayer (const TDF_Label& layerL, TDF_LabelSequence& ShLabels) const;
135
136 //! Return TRUE if layer is visible, FALSE if invisible.
137 Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& layerL) const;
138
139 //! Set the visibility of layer. If layer is invisible when on it's layer
140 //! will set UAttribute with corresponding GUID.
141 Standard_EXPORT void SetVisibility (const TDF_Label& layerL, const Standard_Boolean isvisible = Standard_True) const;
142
143 //! Sets a link from label that containig shape <Sh>
144 //! with layer that situated at label <LayerL>.
145 //! optional parametr <shapeInOneLayer> show could shape be
146 //! in number of layers or only in one.
147 //! return FALSE if no such shape <Sh> or label <LayerL>
148 Standard_EXPORT Standard_Boolean SetLayer (const TopoDS_Shape& Sh, const TDF_Label& LayerL, const Standard_Boolean shapeInOneLayer = Standard_False);
149
150 //! Sets a link from label that containig shape <Sh>
151 //! with layer <aLayer>. Add <aLayer> to LayerTable if nessesery.
152 //! optional parametr <shapeInOneLayer> show could shape be
153 //! in number of layers or only in one.
154 //! return FALSE if no such shape <Sh>.
155 Standard_EXPORT Standard_Boolean SetLayer (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer, const Standard_Boolean shapeInOneLayer = Standard_False);
156
157 //! Remove link between shape <Sh> and all Layers at LayerTable.
158 //! return FALSE if no such shape <Sh> in XCAF Document.
159 Standard_EXPORT Standard_Boolean UnSetLayers (const TopoDS_Shape& Sh);
160
161 //! Remove link between shape <Sh> and layer <aLayer>.
162 //! returns FALSE if no such layer <aLayer> or shape <Sh>.
163 Standard_EXPORT Standard_Boolean UnSetOneLayer (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer);
164
165 //! Remove link between shape <Sh> and layer <aLayerL>.
166 //! returns FALSE if no such layer <aLayerL> or shape <Sh>.
167 Standard_EXPORT Standard_Boolean UnSetOneLayer (const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
168
169 //! Returns True if shape <Sh> has a Layer assosiated
170 //! with the <aLayer>.
171 Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer);
172
173 //! Returns True if shape <Sh> has a Layer assosiated
174 //! with the <aLayerL>.
175 Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
176
177 //! Return sequence of strings <aLayerS> that assosiated with shape <Sh>.
178 Standard_EXPORT Standard_Boolean GetLayers (const TopoDS_Shape& Sh, Handle(TColStd_HSequenceOfExtendedString)& aLayerS);
179
180 //! Return sequence of labels <aLayerLS> that assosiated with shape <Sh>.
181 Standard_EXPORT Standard_Boolean GetLayers (const TopoDS_Shape& Sh, TDF_LabelSequence& aLayerLS);
182
183 //! Return sequence of strings that assosiated with shape <Sh>.
184 Standard_EXPORT Handle(TColStd_HSequenceOfExtendedString) GetLayers (const TopoDS_Shape& Sh);
185
79104795 186 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
42cf5bc1 187
79104795 188 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
42cf5bc1 189
79104795 190 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
42cf5bc1 191
79104795 192 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
42cf5bc1 193
194
195
196
92efcf78 197 DEFINE_STANDARD_RTTIEXT(XCAFDoc_LayerTool,TDF_Attribute)
42cf5bc1 198
199protected:
200
201
202
203
204private:
205
206
207 Handle(XCAFDoc_ShapeTool) myShapeTool;
208
209
210};
211
212
213
214
215
216
217
218#endif // _XCAFDoc_LayerTool_HeaderFile