0026911: Configuration, CMake - strips symbol information from the binary in release...
[occt.git] / src / XCAFDoc / XCAFDoc_ColorTool.hxx
CommitLineData
42cf5bc1 1// Created on: 2000-05-11
2// Created by: Edward AGAPOV
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_ColorTool_HeaderFile
17#define _XCAFDoc_ColorTool_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 <XCAFDoc_ColorType.hxx>
26class XCAFDoc_ShapeTool;
27class TDF_Label;
28class Standard_GUID;
29class Quantity_Color;
30class TopoDS_Shape;
31class TDF_Attribute;
32class TDF_RelocationTable;
33
34
35class XCAFDoc_ColorTool;
36DEFINE_STANDARD_HANDLE(XCAFDoc_ColorTool, TDF_Attribute)
37
38//! Provides tools to store and retrieve attributes (colors)
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 Colors section of document.
43class XCAFDoc_ColorTool : public TDF_Attribute
44{
45
46public:
47
48
49 Standard_EXPORT XCAFDoc_ColorTool();
50
51 //! Creates (if not exist) ColorTool.
52 Standard_EXPORT static Handle(XCAFDoc_ColorTool) Set (const TDF_Label& L);
53
54 Standard_EXPORT static const Standard_GUID& GetID();
55
56 //! returns the label under which colors 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 colortable and
63 //! is a color definition
64 Standard_EXPORT Standard_Boolean IsColor (const TDF_Label& lab) const;
65
66 //! Returns color defined by label lab
67 //! Returns False if the label is not in colortable
68 //! or does not define a color
69 Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& lab, Quantity_Color& col) const;
70
71 //! Finds a color definition in a colortable and returns
72 //! its label if found
73 //! Returns False if color is not found in colortable
74 Standard_EXPORT Standard_Boolean FindColor (const Quantity_Color& col, TDF_Label& lab) const;
75
76 //! Finds a color definition in a colortable and returns
77 //! its label if found (or Null label else)
78 Standard_EXPORT TDF_Label FindColor (const Quantity_Color& col) const;
79
80 //! Adds a color definition to a colortable and returns
81 //! its label (returns existing label if the same color
82 //! is already defined)
83 Standard_EXPORT TDF_Label AddColor (const Quantity_Color& col) const;
84
85 //! Removes color from the colortable
86 Standard_EXPORT void RemoveColor (const TDF_Label& lab) const;
87
88 //! Returns a sequence of colors currently stored
89 //! in the colortable
90 Standard_EXPORT void GetColors (TDF_LabelSequence& Labels) const;
91
92 //! Sets a link with GUID defined by <type> (see
93 //! XCAFDoc::ColorRefGUID()) from label <L> to color
94 //! defined by <colorL>. Color of shape is defined following way
95 //! in dependance with type of color.
96 //! If type of color is XCAFDoc_ColorGen - then this color
97 //! defines default color for surfaces and curves.
98 //! If for shape color with types XCAFDoc_ColorSurf or XCAFDoc_ColorCurv is specified
99 //! then such color overrides generic color.
100 Standard_EXPORT void SetColor (const TDF_Label& L, const TDF_Label& colorL, const XCAFDoc_ColorType type) const;
101
102 //! Sets a link with GUID defined by <type> (see
103 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
104 //! in the colortable
105 //! Adds a color as necessary
106 Standard_EXPORT void SetColor (const TDF_Label& L, const Quantity_Color& Color, const XCAFDoc_ColorType type) const;
107
108 //! Removes a link with GUID defined by <type> (see
109 //! XCAFDoc::ColorRefGUID()) from label <L> to color
110 Standard_EXPORT void UnSetColor (const TDF_Label& L, const XCAFDoc_ColorType type) const;
111
112 //! Returns True if label <L> has a color assignment
113 //! of the type <type>
114 Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L, const XCAFDoc_ColorType type) const;
115
116 //! Returns label with color assigned to <L> as <type>
117 //! Returns False if no such color is assigned
118 Standard_EXPORT static Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, TDF_Label& colorL);
119
120 //! Returns color assigned to <L> as <type>
121 //! Returns False if no such color is assigned
122 Standard_EXPORT Standard_Boolean GetColor (const TDF_Label& L, const XCAFDoc_ColorType type, Quantity_Color& color);
123
124 //! Sets a link with GUID defined by <type> (see
125 //! XCAFDoc::ColorRefGUID()) from label <L> to color
126 //! defined by <colorL>
127 //! Returns False if cannot find a label for shape S
128 Standard_EXPORT Standard_Boolean SetColor (const TopoDS_Shape& S, const TDF_Label& colorL, const XCAFDoc_ColorType type);
129
130 //! Sets a link with GUID defined by <type> (see
131 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
132 //! in the colortable
133 //! Adds a color as necessary
134 //! Returns False if cannot find a label for shape S
135 Standard_EXPORT Standard_Boolean SetColor (const TopoDS_Shape& S, const Quantity_Color& Color, const XCAFDoc_ColorType type);
136
137 //! Removes a link with GUID defined by <type> (see
138 //! XCAFDoc::ColorRefGUID()) from label <L> to color
139 //! Returns True if such link existed
140 Standard_EXPORT Standard_Boolean UnSetColor (const TopoDS_Shape& S, const XCAFDoc_ColorType type);
141
142 //! Returns True if label <L> has a color assignment
143 //! of the type <type>
144 Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& S, const XCAFDoc_ColorType type);
145
146 //! Returns label with color assigned to <L> as <type>
147 //! Returns False if no such color is assigned
148 Standard_EXPORT Standard_Boolean GetColor (const TopoDS_Shape& S, const XCAFDoc_ColorType type, TDF_Label& colorL);
149
150 //! Returns color assigned to <L> as <type>
151 //! Returns False if no such color is assigned
152 Standard_EXPORT Standard_Boolean GetColor (const TopoDS_Shape& S, const XCAFDoc_ColorType type, Quantity_Color& color);
153
154 //! Return TRUE if object on this label is visible, FALSE if invisible.
155 Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& L) const;
156
157 //! Set the visibility of object on label. Do nothing if there no any object.
158 //! Set UAttribute with corresponding GUID.
159 Standard_EXPORT void SetVisibility (const TDF_Label& shapeLabel, const Standard_Boolean isvisible = Standard_True);
160
161 //! Sets the color of component that styled with SHUO structure
162 //! Returns FALSE if no sush component found
163 //! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
164 Standard_EXPORT Standard_Boolean SetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, const Quantity_Color& color, const Standard_Boolean isCreateSHUO = Standard_True);
165
166 //! Gets the color of component that styled with SHUO structure
167 //! Returns FALSE if no sush component or color type
168 Standard_EXPORT Standard_Boolean GetInstanceColor (const TopoDS_Shape& theShape, const XCAFDoc_ColorType type, Quantity_Color& color);
169
170 //! Gets the visibility status of component that styled with SHUO structure
171 //! Returns FALSE if no sush component
172 Standard_EXPORT Standard_Boolean IsInstanceVisible (const TopoDS_Shape& theShape);
173
174 //! Reverses order in chains of TreeNodes (from Last to First) under
175 //! each Color Label since we became to use function ::Prepend()
176 //! instead of ::Append() in method SetColor() for acceleration
177 Standard_EXPORT Standard_Boolean ReverseChainsOfTreeNodes();
178
179 Standard_EXPORT const Standard_GUID& ID() const;
180
181 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with);
182
183 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const;
184
185 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const;
186
187
188
189
190 DEFINE_STANDARD_RTTI(XCAFDoc_ColorTool,TDF_Attribute)
191
192protected:
193
194
195
196
197private:
198
199
200 Handle(XCAFDoc_ShapeTool) myShapeTool;
201
202
203};
204
205
206
207
208
209
210
211#endif // _XCAFDoc_ColorTool_HeaderFile