summaryrefslogtreecommitdiff
path: root/src/XCAFPrs/XCAFPrs_Style.cxx
blob: fc501476628d818387e335ce6f336cf07ca86b6e (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
// File:	XCAFPrs_Style.cxx
// Created:	Fri Aug 11 19:36:48 2000
// Author:	Andrey BETENEV
//		<abv@doomox.nnov.matra-dtv.fr>

#include <XCAFPrs_Style.ixx>

//=======================================================================
//function : XCAFPrs_Style
//purpose  : 
//=======================================================================

XCAFPrs_Style::XCAFPrs_Style () : 
       defColorSurf(Standard_False),
       defColorCurv(Standard_False),
       myVisibility(Standard_True)
{
}

//=======================================================================
//function : IsSetColorSurf
//purpose  : 
//=======================================================================

Standard_Boolean XCAFPrs_Style::IsSetColorSurf () const
{
  return defColorSurf;
}

//=======================================================================
//function : GetColorSurf
//purpose  : 
//=======================================================================

Quantity_Color XCAFPrs_Style::GetColorSurf () const
{
  return myColorSurf;
}

//=======================================================================
//function : SetColorSurf
//purpose  : 
//=======================================================================

void XCAFPrs_Style::SetColorSurf (const Quantity_Color &col) 
{
  myColorSurf = col;
  defColorSurf = Standard_True;
}

//=======================================================================
//function : UnSetColorSurf
//purpose  : 
//=======================================================================

void XCAFPrs_Style::UnSetColorSurf () 
{
  defColorSurf = Standard_False;
  myColorSurf.SetValues ( Quantity_NOC_YELLOW );
}

//=======================================================================
//function : IsSetColorCurv
//purpose  : 
//=======================================================================

Standard_Boolean XCAFPrs_Style::IsSetColorCurv () const
{
  return defColorCurv;
}

//=======================================================================
//function : GetColorCurv
//purpose  : 
//=======================================================================

Quantity_Color XCAFPrs_Style::GetColorCurv () const
{
  return myColorCurv;
}

//=======================================================================
//function : SetColorCurv
//purpose  : 
//=======================================================================

void XCAFPrs_Style::SetColorCurv (const Quantity_Color &col) 
{
  myColorCurv = col;
  defColorCurv = Standard_True;
}

//=======================================================================
//function : UnSetColorCurv
//purpose  : 
//=======================================================================

void XCAFPrs_Style::UnSetColorCurv () 
{
  defColorCurv = Standard_False;
  myColorCurv.SetValues ( Quantity_NOC_YELLOW );
}

//=======================================================================
//function : SetVisibility
//purpose  : 
//=======================================================================

void XCAFPrs_Style::SetVisibility (const Standard_Boolean visibility)
{
  myVisibility = visibility;
  if ( ! visibility ) { UnSetColorSurf(); UnSetColorCurv(); } // for hash codes
}

//=======================================================================
//function : IsVisible
//purpose  : 
//=======================================================================

Standard_Boolean XCAFPrs_Style::IsVisible () const
{
  return myVisibility;
}

//=======================================================================
//function : IsEqual
//purpose  : 
//=======================================================================

Standard_Boolean XCAFPrs_Style::IsEqual (const XCAFPrs_Style &other) const
{
  return myVisibility == other.myVisibility &&
         ( ! myVisibility || 
	   ( defColorSurf == other.defColorSurf &&
	     defColorCurv == other.defColorCurv &&
             ( ! defColorSurf || myColorSurf == other.myColorSurf ) &&
             ( ! defColorCurv || myColorCurv == other.myColorCurv ) ) );
}

//=======================================================================
//function : HashCode
//purpose  : 
//=======================================================================

Standard_Integer XCAFPrs_Style::HashCode (const XCAFPrs_Style& S, const Standard_Integer Upper)
{
  int  *meintPtr  = (int*)&S;
  Standard_Integer aHashCode=0, i, aSize = sizeof(S) / sizeof(int);
  
  for (i = 0;  i < aSize; i++, meintPtr++) {
    aHashCode = aHashCode ^ *meintPtr;
  }
  return ::HashCode( aHashCode, Upper);
}

//=======================================================================
//function : IsEqual
//purpose  : 
//=======================================================================

Standard_Boolean XCAFPrs_Style::IsEqual (const XCAFPrs_Style& S1, const XCAFPrs_Style& S2)
{
  return S1.IsEqual(S2);
}