summaryrefslogtreecommitdiff
path: root/src/XCAFDoc/XCAFDoc_Color.cxx
blob: ac9befa6c662e0b6579a20d18ff27f271897a901 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// File:	XCAFDoc_Color.cxx
// Created:	Wed Aug 16 11:52:13 2000
// Author:	data exchange team
//		<det@strelox.nnov.matra-dtv.fr>


#include <TDF_RelocationTable.hxx>
#include <XCAFDoc_Color.ixx>

//=======================================================================
//function : Constructor
//purpose  : 
//=======================================================================

XCAFDoc_Color::XCAFDoc_Color()
{
}

//=======================================================================
//function : GetID
//purpose  : 
//=======================================================================

const Standard_GUID& XCAFDoc_Color::GetID() 
{
  static Standard_GUID ColorID ("efd212f0-6dfd-11d4-b9c8-0060b0ee281b");
  return ColorID; 
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
					  const Quantity_Color& C) 
{
  Handle(XCAFDoc_Color) A;
  if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
    A = new XCAFDoc_Color ();
    L.AddAttribute(A);
  }
  A->Set (C); 
  return A;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

 Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
					  const Quantity_NameOfColor C) 
{
  Handle(XCAFDoc_Color) A;
  if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
    A = new XCAFDoc_Color ();
    L.AddAttribute(A);
  }
  A->Set (C); 
  return A;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
						     const Standard_Real R,
						     const Standard_Real G,
						     const Standard_Real B) 
{
  Handle(XCAFDoc_Color) A;
  if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
    A = new XCAFDoc_Color ();
    L.AddAttribute(A);
  }
  A->Set (R,G,B); 
  return A;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

void XCAFDoc_Color::Set(const Quantity_Color& C) 
{
  Backup();
  myColor = C;
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

 void XCAFDoc_Color::Set(const Quantity_NameOfColor C) 
{
  Backup();
  myColor.SetValues(C);
}

//=======================================================================
//function : Set
//purpose  : 
//=======================================================================

 void XCAFDoc_Color::Set(const Standard_Real R,
			       const Standard_Real G,
			       const Standard_Real B) 
{
  Backup();
  myColor.SetValues(R,G,B, Quantity_TOC_RGB);
}

//=======================================================================
//function : GetColor
//purpose  : 
//=======================================================================

 Quantity_Color XCAFDoc_Color::GetColor() const
{
  return myColor;
}

//=======================================================================
//function : GetNOC
//purpose  : 
//=======================================================================

 Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
{
  return myColor.Name();
}

//=======================================================================
//function : GetRGB
//purpose  : 
//=======================================================================

 void XCAFDoc_Color::GetRGB(Standard_Real& R,
				  Standard_Real& G,
				  Standard_Real& B) const
{
  myColor.Values(R,G,B, Quantity_TOC_RGB);
}
//=======================================================================
//function : ID
//purpose  : 
//=======================================================================

const Standard_GUID& XCAFDoc_Color::ID() const
{
  return GetID();
}

//=======================================================================
//function : Restore
//purpose  : 
//=======================================================================

 void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With) 
{
  myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColor();
}

//=======================================================================
//function : NewEmpty
//purpose  : 
//=======================================================================

 Handle(TDF_Attribute) XCAFDoc_Color::NewEmpty() const
{
  return new XCAFDoc_Color();
}

//=======================================================================
//function : Paste
//purpose  : 
//=======================================================================

 void XCAFDoc_Color::Paste(const Handle(TDF_Attribute)& Into,
				 const Handle(TDF_RelocationTable)& /* RT */) const
{
  Handle(XCAFDoc_Color)::DownCast(Into)->Set(myColor);
}