Warnings on vc14 were eliminated
[occt.git] / src / XCAFDoc / XCAFDoc_Color.cxx
CommitLineData
b311480e 1// Created on: 2000-08-16
2// Created by: data exchange team
973c2be1 3// Copyright (c) 2000-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
42cf5bc1 16
17#include <Quantity_Color.hxx>
18#include <Standard_GUID.hxx>
19#include <Standard_Type.hxx>
20#include <TDF_Attribute.hxx>
21#include <TDF_Label.hxx>
7fd59977 22#include <TDF_RelocationTable.hxx>
42cf5bc1 23#include <XCAFDoc_Color.hxx>
7fd59977 24
92efcf78 25IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Color,TDF_Attribute)
26
7fd59977 27//=======================================================================
28//function : Constructor
29//purpose :
30//=======================================================================
7fd59977 31XCAFDoc_Color::XCAFDoc_Color()
32{
33}
34
35//=======================================================================
36//function : GetID
37//purpose :
38//=======================================================================
39
40const Standard_GUID& XCAFDoc_Color::GetID()
41{
42 static Standard_GUID ColorID ("efd212f0-6dfd-11d4-b9c8-0060b0ee281b");
43 return ColorID;
44}
45
46//=======================================================================
47//function : Set
48//purpose :
49//=======================================================================
50
51 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
52 const Quantity_Color& C)
53{
54 Handle(XCAFDoc_Color) A;
55 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
56 A = new XCAFDoc_Color ();
57 L.AddAttribute(A);
58 }
59 A->Set (C);
60 return A;
61}
62
63//=======================================================================
64//function : Set
65//purpose :
66//=======================================================================
67
68 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
69 const Quantity_NameOfColor C)
70{
71 Handle(XCAFDoc_Color) A;
72 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
73 A = new XCAFDoc_Color ();
74 L.AddAttribute(A);
75 }
76 A->Set (C);
77 return A;
78}
79
80//=======================================================================
81//function : Set
82//purpose :
83//=======================================================================
84
85Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
86 const Standard_Real R,
87 const Standard_Real G,
88 const Standard_Real B)
89{
90 Handle(XCAFDoc_Color) A;
91 if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
92 A = new XCAFDoc_Color ();
93 L.AddAttribute(A);
94 }
95 A->Set (R,G,B);
96 return A;
97}
98
99//=======================================================================
100//function : Set
101//purpose :
102//=======================================================================
103
104void XCAFDoc_Color::Set(const Quantity_Color& C)
105{
106 Backup();
107 myColor = C;
108}
109
110//=======================================================================
111//function : Set
112//purpose :
113//=======================================================================
114
115 void XCAFDoc_Color::Set(const Quantity_NameOfColor C)
116{
117 Backup();
118 myColor.SetValues(C);
119}
120
121//=======================================================================
122//function : Set
123//purpose :
124//=======================================================================
125
126 void XCAFDoc_Color::Set(const Standard_Real R,
127 const Standard_Real G,
128 const Standard_Real B)
129{
130 Backup();
131 myColor.SetValues(R,G,B, Quantity_TOC_RGB);
132}
133
134//=======================================================================
135//function : GetColor
136//purpose :
137//=======================================================================
138
d97f89db 139const Quantity_Color& XCAFDoc_Color::GetColor() const
7fd59977 140{
141 return myColor;
142}
143
144//=======================================================================
145//function : GetNOC
146//purpose :
147//=======================================================================
148
149 Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
150{
151 return myColor.Name();
152}
153
154//=======================================================================
155//function : GetRGB
156//purpose :
157//=======================================================================
158
159 void XCAFDoc_Color::GetRGB(Standard_Real& R,
160 Standard_Real& G,
161 Standard_Real& B) const
162{
163 myColor.Values(R,G,B, Quantity_TOC_RGB);
164}
165//=======================================================================
166//function : ID
167//purpose :
168//=======================================================================
169
170const Standard_GUID& XCAFDoc_Color::ID() const
171{
172 return GetID();
173}
174
175//=======================================================================
176//function : Restore
177//purpose :
178//=======================================================================
179
180 void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With)
181{
182 myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColor();
183}
184
185//=======================================================================
186//function : NewEmpty
187//purpose :
188//=======================================================================
189
190 Handle(TDF_Attribute) XCAFDoc_Color::NewEmpty() const
191{
192 return new XCAFDoc_Color();
193}
194
195//=======================================================================
196//function : Paste
197//purpose :
198//=======================================================================
199
200 void XCAFDoc_Color::Paste(const Handle(TDF_Attribute)& Into,
201 const Handle(TDF_RelocationTable)& /* RT */) const
202{
203 Handle(XCAFDoc_Color)::DownCast(Into)->Set(myColor);
204}
205