1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 /***********************************************************************/
17 File V3d_View_1.cxx : */
18 /*----------------------------------------------------------------------*/
23 #include <Aspect_GradientBackground.hxx>
24 #include <Aspect_Grid.hxx>
25 #include <Aspect_Window.hxx>
26 #include <Bnd_Box.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>
37 #include <V3d_Light.hxx>
38 #include <V3d_UnMapped.hxx>
39 #include <V3d_View.hxx>
40 #include <V3d_Viewer.hxx>
42 //=============================================================================
43 //function : SetZClippingDepth
45 //=============================================================================
46 void V3d_View::SetZClippingDepth (const Standard_Real theDepth)
48 Standard_Real aFront = 0., aBack = 0., aWidth = 0.;
50 aFront = myView->ZClippingFrontPlane();
51 aBack = myView->ZClippingBackPlane();
52 aWidth = aFront - aBack;
53 aFront = theDepth + aWidth / 2.;
54 aBack = theDepth - aWidth / 2.;
55 myView->SetZClippingBackPlane (aBack);
56 myView->SetZClippingFrontPlane (aFront);
59 //=============================================================================
60 //function : SetZClippingWidth
62 //=============================================================================
63 void V3d_View::SetZClippingWidth (const Standard_Real theWidth)
65 Standard_Real aFront = 0., aBack = 0., aDepth = 0.;
66 V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZClippingWidth, bad width");
68 aFront = myView->ZClippingFrontPlane();
69 aBack = myView->ZClippingBackPlane();
70 aDepth = (aFront + aBack) / 2.;
71 aFront = aDepth + theWidth / 2.;
72 aBack = aDepth - theWidth / 2.;
73 myView->SetZClippingBackPlane (aBack);
74 myView->SetZClippingFrontPlane (aFront);
77 //=============================================================================
78 //function : SetZClippingType
80 //=============================================================================
81 void V3d_View::SetZClippingType (const V3d_TypeOfZclipping theType)
86 myView->SetFrontZClippingOn (Standard_False);
87 myView->SetBackZClippingOn (Standard_False);
91 myView->SetBackZClippingOn (Standard_True);
92 myView->SetFrontZClippingOn (Standard_False);
96 myView->SetFrontZClippingOn (Standard_True);
97 myView->SetBackZClippingOn (Standard_False);
101 myView->SetFrontZClippingOn (Standard_False);
102 myView->SetBackZClippingOn (Standard_False);
107 //=============================================================================
108 //function : ZClipping
110 //=============================================================================
111 V3d_TypeOfZclipping V3d_View::ZClipping (Standard_Real& theDepth, Standard_Real& theWidth) const
113 V3d_TypeOfZclipping aType = V3d_OFF;
115 Standard_Real aBack = myView->ZClippingBackPlane();
116 Standard_Real aFront = myView->ZClippingFrontPlane();
117 Standard_Boolean isBackOn = myView->BackZClippingIsOn();
118 Standard_Boolean isFrontOn = myView->FrontZClippingIsOn();
120 theWidth = aFront - aBack ;
121 theDepth = (aFront + aBack) / 2.0;
141 //=============================================================================
142 //function : SetZCueingDepth
144 //=============================================================================
145 void V3d_View::SetZCueingDepth (const Standard_Real theDepth)
147 Standard_Real aFront = myView->DepthCueingFrontPlane();
148 Standard_Real aBack = myView->DepthCueingBackPlane();
149 Standard_Real aWidth = aFront - aBack;
150 aFront = theDepth + aWidth / 2.;
151 aBack = theDepth - aWidth / 2.;
152 myView->SetDepthCueingBackPlane (aBack);
153 myView->SetDepthCueingFrontPlane (aFront);
156 //=============================================================================
157 //function : SetZCueingWidth
159 //=============================================================================
160 void V3d_View::SetZCueingWidth (const Standard_Real theWidth)
162 V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZCueingWidth, bad width");
164 Standard_Real aFront = myView->DepthCueingFrontPlane();
165 Standard_Real aBack = myView->DepthCueingBackPlane();
166 Standard_Real aDepth = (aFront + aBack) / 2.0;
167 aFront = aDepth + theWidth / 2.0;
168 aBack = aDepth - theWidth / 2.0;
169 myView->SetDepthCueingBackPlane (aBack);
170 myView->SetDepthCueingFrontPlane (aFront);
173 //=============================================================================
174 //function : SetZCueingOn
176 //=============================================================================
177 void V3d_View::SetZCueingOn()
179 myView->SetDepthCueingOn (Standard_True);
182 //=============================================================================
183 //function : SetZCueingOff
185 //=============================================================================
186 void V3d_View::SetZCueingOff()
188 myView->SetDepthCueingOn (Standard_False);
191 //=============================================================================
194 //=============================================================================
195 Standard_Boolean V3d_View::ZCueing (Standard_Real& theDepth, Standard_Real& theWidth) const
197 Standard_Boolean isOn = myView->DepthCueingIsOn();
198 Standard_Real aFront = myView->DepthCueingFrontPlane();
199 Standard_Real aBack = myView->DepthCueingBackPlane();
201 theWidth = aFront - aBack ;
202 theDepth = (aFront + aBack) / 2.;