b311480e |
1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
973c2be1 |
6 | // This library is free software; you can redistribute it and / or modify it |
7 | // under the terms of the GNU Lesser General Public version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | #include <Aspect_ColorMapEntry.ixx> |
16 | |
17 | Aspect_ColorMapEntry::Aspect_ColorMapEntry() { |
18 | |
19 | myColorIsDef = Standard_True; |
20 | myIndexIsDef = Standard_True; |
21 | allocated = myColorIsDef && myIndexIsDef; |
22 | myindex = 0; |
23 | mycolor.SetValues (0., 0., 0., Quantity_TOC_RGB); |
24 | |
25 | } |
26 | |
27 | Aspect_ColorMapEntry::Aspect_ColorMapEntry (const Standard_Integer index, const Quantity_Color &color) { |
28 | |
29 | myColorIsDef = Standard_True; |
30 | myIndexIsDef = Standard_True; |
31 | allocated = myColorIsDef && myIndexIsDef; |
32 | myindex = index; |
33 | mycolor = color; |
34 | |
35 | } |
36 | |
37 | Aspect_ColorMapEntry::Aspect_ColorMapEntry (const Aspect_ColorMapEntry& entry) { |
38 | |
39 | if (entry.allocated == Standard_False) { |
40 | Aspect_BadAccess::Raise |
41 | ("Aspect_ColorMapEntry::Aspect_ColorMapEntry Unallocated ColorMapEntry"); |
42 | } |
43 | else { |
44 | myColorIsDef = Standard_True; |
45 | myIndexIsDef = Standard_True; |
46 | allocated = myColorIsDef && myIndexIsDef; |
47 | myindex = entry.myindex; |
48 | mycolor = entry.mycolor; |
49 | } |
50 | } |
51 | |
52 | void Aspect_ColorMapEntry::SetValue (const Standard_Integer index, const Quantity_Color &color) { |
53 | |
54 | myColorIsDef = Standard_True; |
55 | myIndexIsDef = Standard_True; |
56 | allocated = myColorIsDef && myIndexIsDef; |
57 | myindex = index; |
58 | mycolor = color; |
59 | |
60 | } |
61 | |
62 | void Aspect_ColorMapEntry::SetValue (const Aspect_ColorMapEntry& entry) { |
63 | |
64 | if (entry.allocated == Standard_False) { |
65 | Aspect_BadAccess::Raise |
66 | ("Aspect_ColorMapEntry::Aspect_ColorMapEntry Unallocated ColorMapEntry"); |
67 | } |
68 | else { |
69 | myColorIsDef = Standard_True; |
70 | myIndexIsDef = Standard_True; |
71 | allocated = myColorIsDef && myIndexIsDef; |
72 | myindex = entry.myindex; |
73 | mycolor = entry.mycolor; |
74 | } |
75 | |
76 | } |
77 | |
78 | void Aspect_ColorMapEntry::SetColor (const Quantity_Color &color) { |
79 | |
80 | myColorIsDef = Standard_True; |
81 | allocated = myColorIsDef && myIndexIsDef; |
82 | mycolor = color; |
83 | |
84 | } |
85 | |
86 | const Quantity_Color& Aspect_ColorMapEntry::Color () const { |
87 | |
88 | if (allocated == Standard_False) |
89 | Aspect_BadAccess::Raise |
90 | ("Aspect_ColorMapEntry::Color Unallocated ColorMapEntry"); |
91 | |
92 | return mycolor; |
93 | |
94 | } |
95 | |
96 | void Aspect_ColorMapEntry::SetIndex (const Standard_Integer index) { |
97 | |
98 | myColorIsDef = Standard_True; |
99 | allocated = myColorIsDef && myIndexIsDef; |
100 | myindex = index; |
101 | |
102 | } |
103 | |
104 | Standard_Integer Aspect_ColorMapEntry::Index () const { |
105 | |
106 | if (allocated == Standard_False) |
107 | Aspect_BadAccess::Raise |
108 | ("Aspect_ColorMapEntry::Index Unallocated ColorMapEntry"); |
109 | |
110 | return myindex; |
111 | |
112 | } |
113 | |
114 | Standard_Boolean Aspect_ColorMapEntry::IsAllocated () const { |
115 | |
116 | return allocated; |
117 | |
118 | } |
119 | |
120 | void Aspect_ColorMapEntry::Free () { |
121 | |
122 | myColorIsDef = Standard_False; |
123 | myIndexIsDef = Standard_False; |
124 | allocated = myColorIsDef && myIndexIsDef; |
125 | |
126 | } |
127 | |
128 | void Aspect_ColorMapEntry::Dump () const { |
129 | |
130 | Standard_Real r,g,b ; |
131 | |
132 | mycolor.Values( r,g,b, Quantity_TOC_RGB ) ; |
133 | |
134 | cout << flush; |
135 | cout << "myColorIsDef : " << (myColorIsDef ? "True " : "False") << " , " |
136 | << "myIndexIsDef : " << (myIndexIsDef ? "True " : "False") << " , " |
137 | << "allocated : " << (allocated ? "True " : "False") << "\n"; |
138 | cout << "myindex : " << myindex << " myColor : ( " |
139 | << r << ", " << g << ", " << g << " )\n"; |
140 | cout << flush; |
141 | } |