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 | |
c99ad5d7 |
22 | #include <TDataStd_GenericEmpty.hxx> |
42cf5bc1 |
23 | #include <Standard_Boolean.hxx> |
24 | #include <TDF_LabelSequence.hxx> |
25 | #include <TColStd_HSequenceOfExtendedString.hxx> |
26 | class XCAFDoc_ShapeTool; |
27 | class TDF_Label; |
28 | class Standard_GUID; |
29 | class TCollection_ExtendedString; |
30 | class TopoDS_Shape; |
31 | class TDF_Attribute; |
32 | class TDF_RelocationTable; |
33 | |
34 | |
35 | class XCAFDoc_LayerTool; |
c99ad5d7 |
36 | DEFINE_STANDARD_HANDLE(XCAFDoc_LayerTool, TDataStd_GenericEmpty) |
42cf5bc1 |
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. |
c99ad5d7 |
43 | class XCAFDoc_LayerTool : public TDataStd_GenericEmpty |
42cf5bc1 |
44 | { |
45 | |
46 | public: |
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; |
c99ad5d7 |
187 | |
bc73b006 |
188 | //! Dumps the content of me into the stream |
189 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
42cf5bc1 |
190 | |
191 | |
c99ad5d7 |
192 | DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_LayerTool,TDataStd_GenericEmpty) |
42cf5bc1 |
193 | |
194 | |
195 | private: |
196 | |
197 | |
198 | Handle(XCAFDoc_ShapeTool) myShapeTool; |
199 | |
200 | |
201 | }; |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | #endif // _XCAFDoc_LayerTool_HeaderFile |