b311480e |
1 | // Created on: 2000-08-11 |
2 | // Created by: Andrey BETENEV |
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 | #include <XCAFPrs_Style.ixx> |
22 | |
23 | //======================================================================= |
24 | //function : XCAFPrs_Style |
25 | //purpose : |
26 | //======================================================================= |
27 | |
28 | XCAFPrs_Style::XCAFPrs_Style () : |
29 | defColorSurf(Standard_False), |
30 | defColorCurv(Standard_False), |
31 | myVisibility(Standard_True) |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : IsSetColorSurf |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Standard_Boolean XCAFPrs_Style::IsSetColorSurf () const |
41 | { |
42 | return defColorSurf; |
43 | } |
44 | |
45 | //======================================================================= |
46 | //function : GetColorSurf |
47 | //purpose : |
48 | //======================================================================= |
49 | |
50 | Quantity_Color XCAFPrs_Style::GetColorSurf () const |
51 | { |
52 | return myColorSurf; |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : SetColorSurf |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | void XCAFPrs_Style::SetColorSurf (const Quantity_Color &col) |
61 | { |
62 | myColorSurf = col; |
63 | defColorSurf = Standard_True; |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : UnSetColorSurf |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | void XCAFPrs_Style::UnSetColorSurf () |
72 | { |
73 | defColorSurf = Standard_False; |
74 | myColorSurf.SetValues ( Quantity_NOC_YELLOW ); |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : IsSetColorCurv |
79 | //purpose : |
80 | //======================================================================= |
81 | |
82 | Standard_Boolean XCAFPrs_Style::IsSetColorCurv () const |
83 | { |
84 | return defColorCurv; |
85 | } |
86 | |
87 | //======================================================================= |
88 | //function : GetColorCurv |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | Quantity_Color XCAFPrs_Style::GetColorCurv () const |
93 | { |
94 | return myColorCurv; |
95 | } |
96 | |
97 | //======================================================================= |
98 | //function : SetColorCurv |
99 | //purpose : |
100 | //======================================================================= |
101 | |
102 | void XCAFPrs_Style::SetColorCurv (const Quantity_Color &col) |
103 | { |
104 | myColorCurv = col; |
105 | defColorCurv = Standard_True; |
106 | } |
107 | |
108 | //======================================================================= |
109 | //function : UnSetColorCurv |
110 | //purpose : |
111 | //======================================================================= |
112 | |
113 | void XCAFPrs_Style::UnSetColorCurv () |
114 | { |
115 | defColorCurv = Standard_False; |
116 | myColorCurv.SetValues ( Quantity_NOC_YELLOW ); |
117 | } |
118 | |
119 | //======================================================================= |
120 | //function : SetVisibility |
121 | //purpose : |
122 | //======================================================================= |
123 | |
124 | void XCAFPrs_Style::SetVisibility (const Standard_Boolean visibility) |
125 | { |
126 | myVisibility = visibility; |
127 | if ( ! visibility ) { UnSetColorSurf(); UnSetColorCurv(); } // for hash codes |
128 | } |
129 | |
130 | //======================================================================= |
131 | //function : IsVisible |
132 | //purpose : |
133 | //======================================================================= |
134 | |
135 | Standard_Boolean XCAFPrs_Style::IsVisible () const |
136 | { |
137 | return myVisibility; |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : IsEqual |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | Standard_Boolean XCAFPrs_Style::IsEqual (const XCAFPrs_Style &other) const |
146 | { |
147 | return myVisibility == other.myVisibility && |
148 | ( ! myVisibility || |
149 | ( defColorSurf == other.defColorSurf && |
150 | defColorCurv == other.defColorCurv && |
151 | ( ! defColorSurf || myColorSurf == other.myColorSurf ) && |
152 | ( ! defColorCurv || myColorCurv == other.myColorCurv ) ) ); |
153 | } |
154 | |
155 | //======================================================================= |
156 | //function : HashCode |
157 | //purpose : |
158 | //======================================================================= |
159 | |
160 | Standard_Integer XCAFPrs_Style::HashCode (const XCAFPrs_Style& S, const Standard_Integer Upper) |
161 | { |
162 | int *meintPtr = (int*)&S; |
163 | Standard_Integer aHashCode=0, i, aSize = sizeof(S) / sizeof(int); |
164 | |
165 | for (i = 0; i < aSize; i++, meintPtr++) { |
166 | aHashCode = aHashCode ^ *meintPtr; |
167 | } |
168 | return ::HashCode( aHashCode, Upper); |
169 | } |
170 | |
171 | //======================================================================= |
172 | //function : IsEqual |
173 | //purpose : |
174 | //======================================================================= |
175 | |
176 | Standard_Boolean XCAFPrs_Style::IsEqual (const XCAFPrs_Style& S1, const XCAFPrs_Style& S2) |
177 | { |
178 | return S1.IsEqual(S2); |
179 | } |