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