0024162: Eliminate CLang compiler warning
[occt.git] / src / V3d / V3d_View_1.cxx
1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
2 //
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
7 //
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10 //
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
17
18 /***********************************************************************/
19
20 /*     FUNCTION :
21      ----------
22         File V3d_View_1.cxx :     */
23
24
25 /*----------------------------------------------------------------------*/
26 /*
27  * Includes
28  */ 
29
30 #include <V3d_View.jxx>
31
32 /*----------------------------------------------------------------------*/
33
34 void V3d_View::SetAntialiasingOn() {
35   MyViewContext.SetAliasingOn() ;
36   MyView->SetContext(MyViewContext) ;
37 }
38
39 void V3d_View::SetAntialiasingOff() {
40   MyViewContext.SetAliasingOff() ;
41   MyView->SetContext(MyViewContext) ;
42 }
43
44 /*----------------------------------------------------------------------*/
45
46 void V3d_View::SetZClippingDepth(const Standard_Real Depth) {
47   Standard_Real Front,Back,Width ;
48
49   Front = MyViewContext.ZClippingFrontPlane() ;
50   Back = MyViewContext.ZClippingBackPlane() ;
51   Width = Front - Back ;
52   Front = Depth + Width/2. ;
53   Back = Depth - Width/2. ;
54   MyViewContext.SetZClippingBackPlane(Back) ;
55   MyViewContext.SetZClippingFrontPlane(Front) ;
56   MyView->SetContext(MyViewContext) ;
57 }
58
59 /*----------------------------------------------------------------------*/
60
61 void V3d_View::SetZClippingWidth(const Standard_Real Width) {
62   Standard_Real Front,Back,Depth ;
63   V3d_BadValue_Raise_if( Width <= 0.,"V3d_View::SetZClippingWidth, bad width");
64
65   Front = MyViewContext.ZClippingFrontPlane() ;
66   Back = MyViewContext.ZClippingBackPlane() ;
67   Depth = (Front + Back)/2. ;
68   Front = Depth + Width/2. ;
69   Back = Depth - Width/2. ;
70   MyViewContext.SetZClippingBackPlane(Back) ;
71   MyViewContext.SetZClippingFrontPlane(Front) ;
72   MyView->SetContext(MyViewContext) ;
73 }
74
75 /*----------------------------------------------------------------------*/
76
77 void V3d_View::SetZClippingType(const V3d_TypeOfZclipping Type) {
78
79   switch (Type) {
80   case V3d_OFF :
81     MyViewContext.SetZClippingOff() ;
82     break ;
83   case V3d_BACK :
84     MyViewContext.SetBackZClippingOn() ;
85     MyViewContext.SetFrontZClippingOff() ;
86     break ;
87   case V3d_FRONT :
88     MyViewContext.SetFrontZClippingOn() ;
89     MyViewContext.SetBackZClippingOff() ;
90     break ;
91   case V3d_SLICE :
92     MyViewContext.SetZClippingOn() ;
93     break ;
94   }
95   MyView->SetContext(MyViewContext) ;
96 }
97
98 /*----------------------------------------------------------------------*/
99
100 V3d_TypeOfZclipping V3d_View::ZClipping(Standard_Real& Depth, Standard_Real& Width) const {
101   V3d_TypeOfZclipping T = V3d_OFF ;
102   Standard_Real Front,Back ;
103   Standard_Boolean Aback,Afront ;
104
105   Back = MyViewContext.ZClippingBackPlane() ;
106   Front = MyViewContext.ZClippingFrontPlane() ;
107   Aback = MyViewContext.BackZClippingIsOn() ;
108   Afront = MyViewContext.FrontZClippingIsOn() ;
109   Width = Front - Back ;
110   Depth = (Front + Back)/2. ;
111   if( Aback ) {
112     if( Afront ) T = V3d_SLICE ;
113     else         T = V3d_BACK ;
114   } else if( Afront ) T = V3d_FRONT ;
115
116   return T ;
117 }
118
119
120 /*----------------------------------------------------------------------*/
121
122 void V3d_View::SetZCueingDepth(const Standard_Real Depth) {
123   Standard_Real Front,Back,Width ;
124
125   Front = MyViewContext.DepthCueingFrontPlane() ;
126   Back = MyViewContext.DepthCueingBackPlane() ;
127   Width = Front - Back ;
128   Front = Depth + Width/2. ;
129   Back = Depth - Width/2. ;
130   MyViewContext.SetDepthCueingBackPlane(Back) ;
131   MyViewContext.SetDepthCueingFrontPlane(Front) ;
132   MyView->SetContext(MyViewContext) ;
133 }
134
135 /*----------------------------------------------------------------------*/
136
137 void V3d_View::SetZCueingWidth(const Standard_Real Width) {
138   Standard_Real Front,Back,Depth ;
139   V3d_BadValue_Raise_if( Width <= 0.,"V3d_View::SetZCueingWidth, bad width");
140
141   Front = MyViewContext.DepthCueingFrontPlane() ;
142   Back = MyViewContext.DepthCueingBackPlane() ;
143   Depth = (Front + Back)/2. ;
144   Front = Depth + Width/2. ;
145   Back = Depth - Width/2. ;
146   MyViewContext.SetDepthCueingBackPlane(Back) ;
147   MyViewContext.SetDepthCueingFrontPlane(Front) ;
148   MyView->SetContext(MyViewContext) ;
149 }
150
151 /*----------------------------------------------------------------------*/
152
153 void V3d_View::SetZCueingOn() {
154
155   MyViewContext.SetDepthCueingOn() ;
156   MyView->SetContext(MyViewContext) ;
157 }
158
159 /*----------------------------------------------------------------------*/
160
161 void V3d_View::SetZCueingOff() {
162
163   MyViewContext.SetDepthCueingOff() ;
164   MyView->SetContext(MyViewContext) ;
165 }
166
167 /*----------------------------------------------------------------------*/
168
169 Standard_Boolean V3d_View::ZCueing(Standard_Real& Depth, Standard_Real& Width)const  {
170   Standard_Boolean Z = MyViewContext.DepthCueingIsOn() ;
171   Standard_Real Front,Back ;
172
173 Back = MyViewContext.DepthCueingBackPlane() ;
174   Front = MyViewContext.DepthCueingFrontPlane() ;
175   Width = Front - Back ;
176   Depth = (Front + Back)/2. ;
177
178   return Z ;
179 }
180
181 /*----------------------------------------------------------------------*/