0023690: Miscellaneous minor enhancements in OCAF/XDE
[occt.git] / src / XCAFDoc / XCAFDoc_Color.cxx
CommitLineData
b311480e 1// Created on: 2000-08-16
2// Created by: data exchange team
3// Copyright (c) 2000-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
21
22#include <TDF_RelocationTable.hxx>
23#include <XCAFDoc_Color.ixx>
24
25//=======================================================================
26//function : Constructor
27//purpose :
28//=======================================================================
29
30XCAFDoc_Color::XCAFDoc_Color()
31{
32}
33
34//=======================================================================
35//function : GetID
36//purpose :
37//=======================================================================
38
39const Standard_GUID& XCAFDoc_Color::GetID()
40{
41 static Standard_GUID ColorID ("efd212f0-6dfd-11d4-b9c8-0060b0ee281b");
42 return ColorID;
43}
44
45//=======================================================================
46//function : Set
47//purpose :
48//=======================================================================
49
50 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
51 const Quantity_Color& C)
52{
53 Handle(XCAFDoc_Color) A;
54 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
55 A = new XCAFDoc_Color ();
56 L.AddAttribute(A);
57 }
58 A->Set (C);
59 return A;
60}
61
62//=======================================================================
63//function : Set
64//purpose :
65//=======================================================================
66
67 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
68 const Quantity_NameOfColor C)
69{
70 Handle(XCAFDoc_Color) A;
71 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
72 A = new XCAFDoc_Color ();
73 L.AddAttribute(A);
74 }
75 A->Set (C);
76 return A;
77}
78
79//=======================================================================
80//function : Set
81//purpose :
82//=======================================================================
83
84Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
85 const Standard_Real R,
86 const Standard_Real G,
87 const Standard_Real B)
88{
89 Handle(XCAFDoc_Color) A;
90 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
91 A = new XCAFDoc_Color ();
92 L.AddAttribute(A);
93 }
94 A->Set (R,G,B);
95 return A;
96}
97
98//=======================================================================
99//function : Set
100//purpose :
101//=======================================================================
102
103void XCAFDoc_Color::Set(const Quantity_Color& C)
104{
105 Backup();
106 myColor = C;
107}
108
109//=======================================================================
110//function : Set
111//purpose :
112//=======================================================================
113
114 void XCAFDoc_Color::Set(const Quantity_NameOfColor C)
115{
116 Backup();
117 myColor.SetValues(C);
118}
119
120//=======================================================================
121//function : Set
122//purpose :
123//=======================================================================
124
125 void XCAFDoc_Color::Set(const Standard_Real R,
126 const Standard_Real G,
127 const Standard_Real B)
128{
129 Backup();
130 myColor.SetValues(R,G,B, Quantity_TOC_RGB);
131}
132
133//=======================================================================
134//function : GetColor
135//purpose :
136//=======================================================================
137
d97f89db 138const Quantity_Color& XCAFDoc_Color::GetColor() const
7fd59977 139{
140 return myColor;
141}
142
143//=======================================================================
144//function : GetNOC
145//purpose :
146//=======================================================================
147
148 Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
149{
150 return myColor.Name();
151}
152
153//=======================================================================
154//function : GetRGB
155//purpose :
156//=======================================================================
157
158 void XCAFDoc_Color::GetRGB(Standard_Real& R,
159 Standard_Real& G,
160 Standard_Real& B) const
161{
162 myColor.Values(R,G,B, Quantity_TOC_RGB);
163}
164//=======================================================================
165//function : ID
166//purpose :
167//=======================================================================
168
169const Standard_GUID& XCAFDoc_Color::ID() const
170{
171 return GetID();
172}
173
174//=======================================================================
175//function : Restore
176//purpose :
177//=======================================================================
178
179 void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With)
180{
181 myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColor();
182}
183
184//=======================================================================
185//function : NewEmpty
186//purpose :
187//=======================================================================
188
189 Handle(TDF_Attribute) XCAFDoc_Color::NewEmpty() const
190{
191 return new XCAFDoc_Color();
192}
193
194//=======================================================================
195//function : Paste
196//purpose :
197//=======================================================================
198
199 void XCAFDoc_Color::Paste(const Handle(TDF_Attribute)& Into,
200 const Handle(TDF_RelocationTable)& /* RT */) const
201{
202 Handle(XCAFDoc_Color)::DownCast(Into)->Set(myColor);
203}
204