973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
258ff83b |
14 | /***********************************************************************/ |
258ff83b |
15 | /* FUNCTION : |
7fd59977 |
16 | ---------- |
258ff83b |
17 | File V3d_View_1.cxx : */ |
7fd59977 |
18 | /*----------------------------------------------------------------------*/ |
19 | /* |
20 | * Includes |
42cf5bc1 |
21 | */ |
22 | |
42cf5bc1 |
23 | #include <Aspect_GradientBackground.hxx> |
24 | #include <Aspect_Grid.hxx> |
25 | #include <Aspect_Window.hxx> |
26 | #include <Bnd_Box.hxx> |
27 | #include <gp_Ax3.hxx> |
28 | #include <gp_Dir.hxx> |
29 | #include <Graphic3d_Group.hxx> |
30 | #include <Graphic3d_Structure.hxx> |
31 | #include <Graphic3d_TextureEnv.hxx> |
32 | #include <Graphic3d_Vector.hxx> |
33 | #include <Quantity_Color.hxx> |
34 | #include <Standard_MultiplyDefined.hxx> |
35 | #include <Standard_TypeMismatch.hxx> |
36 | #include <V3d_BadValue.hxx> |
42cf5bc1 |
37 | #include <V3d_Light.hxx> |
38 | #include <V3d_UnMapped.hxx> |
39 | #include <V3d_View.hxx> |
40 | #include <V3d_Viewer.hxx> |
7fd59977 |
41 | |
c357e426 |
42 | // ======================================================================= |
43 | // function : SetAntialiasingOn |
44 | // purpose : |
45 | // ======================================================================= |
46 | void V3d_View::SetAntialiasingOn() |
47 | { |
48 | myView->SetAntialiasingEnabled (Standard_True); |
7fd59977 |
49 | } |
50 | |
c357e426 |
51 | // ======================================================================= |
52 | // function : SetAntialiasingOff |
53 | // purpose : |
54 | // ======================================================================= |
55 | void V3d_View::SetAntialiasingOff() |
56 | { |
57 | myView->SetAntialiasingEnabled (Standard_False); |
7fd59977 |
58 | } |
59 | |
c357e426 |
60 | //============================================================================= |
61 | //function : SetZClippingDepth |
62 | //purpose : |
63 | //============================================================================= |
64 | void V3d_View::SetZClippingDepth (const Standard_Real theDepth) |
65 | { |
66 | Standard_Real aFront = 0., aBack = 0., aWidth = 0.; |
67 | |
68 | aFront = myView->ZClippingFrontPlane(); |
69 | aBack = myView->ZClippingBackPlane(); |
70 | aWidth = aFront - aBack; |
71 | aFront = theDepth + aWidth / 2.; |
72 | aBack = theDepth - aWidth / 2.; |
73 | myView->SetZClippingBackPlane (aBack); |
74 | myView->SetZClippingFrontPlane (aFront); |
7fd59977 |
75 | } |
76 | |
c357e426 |
77 | //============================================================================= |
78 | //function : SetZClippingWidth |
79 | //purpose : |
80 | //============================================================================= |
81 | void V3d_View::SetZClippingWidth (const Standard_Real theWidth) |
82 | { |
83 | Standard_Real aFront = 0., aBack = 0., aDepth = 0.; |
84 | V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZClippingWidth, bad width"); |
85 | |
86 | aFront = myView->ZClippingFrontPlane(); |
87 | aBack = myView->ZClippingBackPlane(); |
88 | aDepth = (aFront + aBack) / 2.; |
89 | aFront = aDepth + theWidth / 2.; |
90 | aBack = aDepth - theWidth / 2.; |
91 | myView->SetZClippingBackPlane (aBack); |
92 | myView->SetZClippingFrontPlane (aFront); |
7fd59977 |
93 | } |
94 | |
c357e426 |
95 | //============================================================================= |
96 | //function : SetZClippingType |
97 | //purpose : |
98 | //============================================================================= |
99 | void V3d_View::SetZClippingType (const V3d_TypeOfZclipping theType) |
100 | { |
101 | switch (theType) |
102 | { |
103 | case V3d_OFF : |
104 | myView->SetFrontZClippingOn (Standard_False); |
105 | myView->SetBackZClippingOn (Standard_False); |
106 | break; |
107 | |
108 | case V3d_BACK : |
109 | myView->SetBackZClippingOn (Standard_True); |
110 | myView->SetFrontZClippingOn (Standard_False); |
111 | break; |
112 | |
113 | case V3d_FRONT : |
114 | myView->SetFrontZClippingOn (Standard_True); |
115 | myView->SetBackZClippingOn (Standard_False); |
116 | break; |
117 | |
118 | case V3d_SLICE : |
119 | myView->SetFrontZClippingOn (Standard_False); |
120 | myView->SetBackZClippingOn (Standard_False); |
121 | break; |
7fd59977 |
122 | } |
7fd59977 |
123 | } |
124 | |
c357e426 |
125 | //============================================================================= |
126 | //function : ZClipping |
127 | //purpose : |
128 | //============================================================================= |
129 | V3d_TypeOfZclipping V3d_View::ZClipping (Standard_Real& theDepth, Standard_Real& theWidth) const |
130 | { |
131 | V3d_TypeOfZclipping aType = V3d_OFF; |
132 | |
133 | Standard_Real aBack = myView->ZClippingBackPlane(); |
134 | Standard_Real aFront = myView->ZClippingFrontPlane(); |
135 | Standard_Boolean isBackOn = myView->BackZClippingIsOn(); |
136 | Standard_Boolean isFrontOn = myView->FrontZClippingIsOn(); |
137 | |
138 | theWidth = aFront - aBack ; |
139 | theDepth = (aFront + aBack) / 2.0; |
140 | if (isBackOn) |
141 | { |
142 | if (isFrontOn) |
143 | { |
144 | aType = V3d_SLICE; |
145 | } |
146 | else |
147 | { |
148 | aType = V3d_BACK; |
149 | } |
150 | } |
151 | else if (isFrontOn) |
152 | { |
153 | aType = V3d_FRONT; |
154 | } |
7fd59977 |
155 | |
c357e426 |
156 | return aType; |
7fd59977 |
157 | } |
158 | |
c357e426 |
159 | //============================================================================= |
160 | //function : SetZCueingDepth |
161 | //purpose : |
162 | //============================================================================= |
163 | void V3d_View::SetZCueingDepth (const Standard_Real theDepth) |
164 | { |
165 | Standard_Real aFront = myView->DepthCueingFrontPlane(); |
166 | Standard_Real aBack = myView->DepthCueingBackPlane(); |
167 | Standard_Real aWidth = aFront - aBack; |
168 | aFront = theDepth + aWidth / 2.; |
169 | aBack = theDepth - aWidth / 2.; |
170 | myView->SetDepthCueingBackPlane (aBack); |
171 | myView->SetDepthCueingFrontPlane (aFront); |
7fd59977 |
172 | } |
173 | |
c357e426 |
174 | //============================================================================= |
175 | //function : SetZCueingWidth |
176 | //purpose : |
177 | //============================================================================= |
178 | void V3d_View::SetZCueingWidth (const Standard_Real theWidth) |
179 | { |
180 | V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZCueingWidth, bad width"); |
181 | |
182 | Standard_Real aFront = myView->DepthCueingFrontPlane(); |
183 | Standard_Real aBack = myView->DepthCueingBackPlane(); |
184 | Standard_Real aDepth = (aFront + aBack) / 2.0; |
185 | aFront = aDepth + theWidth / 2.0; |
186 | aBack = aDepth - theWidth / 2.0; |
187 | myView->SetDepthCueingBackPlane (aBack); |
188 | myView->SetDepthCueingFrontPlane (aFront); |
7fd59977 |
189 | } |
190 | |
c357e426 |
191 | //============================================================================= |
192 | //function : SetZCueingOn |
193 | //purpose : |
194 | //============================================================================= |
195 | void V3d_View::SetZCueingOn() |
196 | { |
197 | myView->SetDepthCueingOn (Standard_True); |
7fd59977 |
198 | } |
199 | |
c357e426 |
200 | //============================================================================= |
201 | //function : SetZCueingOff |
202 | //purpose : |
203 | //============================================================================= |
204 | void V3d_View::SetZCueingOff() |
205 | { |
206 | myView->SetDepthCueingOn (Standard_False); |
7fd59977 |
207 | } |
208 | |
c357e426 |
209 | //============================================================================= |
210 | //function : ZCueing |
211 | //purpose : |
212 | //============================================================================= |
213 | Standard_Boolean V3d_View::ZCueing (Standard_Real& theDepth, Standard_Real& theWidth) const |
214 | { |
215 | Standard_Boolean isOn = myView->DepthCueingIsOn(); |
216 | Standard_Real aFront = myView->DepthCueingFrontPlane(); |
217 | Standard_Real aBack = myView->DepthCueingBackPlane(); |
7fd59977 |
218 | |
c357e426 |
219 | theWidth = aFront - aBack ; |
220 | theDepth = (aFront + aBack) / 2.; |
7fd59977 |
221 | |
c357e426 |
222 | return isOn; |
7fd59977 |
223 | } |