0027756: Visualization - add Draw() method taking Graphic3d_Group to tools Prs3d_Arro...
[occt.git] / src / V3d / V3d_View_1.cxx
CommitLineData
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 : SetZClippingDepth
44//purpose :
45//=============================================================================
46void V3d_View::SetZClippingDepth (const Standard_Real theDepth)
47{
48 Standard_Real aFront = 0., aBack = 0., aWidth = 0.;
49
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);
7fd59977 57}
58
c357e426 59//=============================================================================
60//function : SetZClippingWidth
61//purpose :
62//=============================================================================
63void V3d_View::SetZClippingWidth (const Standard_Real theWidth)
64{
65 Standard_Real aFront = 0., aBack = 0., aDepth = 0.;
66 V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZClippingWidth, bad width");
67
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);
7fd59977 75}
76
c357e426 77//=============================================================================
78//function : SetZClippingType
79//purpose :
80//=============================================================================
81void V3d_View::SetZClippingType (const V3d_TypeOfZclipping theType)
82{
83 switch (theType)
84 {
85 case V3d_OFF :
86 myView->SetFrontZClippingOn (Standard_False);
87 myView->SetBackZClippingOn (Standard_False);
88 break;
89
90 case V3d_BACK :
91 myView->SetBackZClippingOn (Standard_True);
92 myView->SetFrontZClippingOn (Standard_False);
93 break;
94
95 case V3d_FRONT :
96 myView->SetFrontZClippingOn (Standard_True);
97 myView->SetBackZClippingOn (Standard_False);
98 break;
99
100 case V3d_SLICE :
101 myView->SetFrontZClippingOn (Standard_False);
102 myView->SetBackZClippingOn (Standard_False);
103 break;
7fd59977 104 }
7fd59977 105}
106
c357e426 107//=============================================================================
108//function : ZClipping
109//purpose :
110//=============================================================================
111V3d_TypeOfZclipping V3d_View::ZClipping (Standard_Real& theDepth, Standard_Real& theWidth) const
112{
113 V3d_TypeOfZclipping aType = V3d_OFF;
114
115 Standard_Real aBack = myView->ZClippingBackPlane();
116 Standard_Real aFront = myView->ZClippingFrontPlane();
117 Standard_Boolean isBackOn = myView->BackZClippingIsOn();
118 Standard_Boolean isFrontOn = myView->FrontZClippingIsOn();
119
120 theWidth = aFront - aBack ;
121 theDepth = (aFront + aBack) / 2.0;
122 if (isBackOn)
123 {
124 if (isFrontOn)
125 {
126 aType = V3d_SLICE;
127 }
128 else
129 {
130 aType = V3d_BACK;
131 }
132 }
133 else if (isFrontOn)
134 {
135 aType = V3d_FRONT;
136 }
7fd59977 137
c357e426 138 return aType;
7fd59977 139}
140
c357e426 141//=============================================================================
142//function : SetZCueingDepth
143//purpose :
144//=============================================================================
145void V3d_View::SetZCueingDepth (const Standard_Real theDepth)
146{
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);
7fd59977 154}
155
c357e426 156//=============================================================================
157//function : SetZCueingWidth
158//purpose :
159//=============================================================================
160void V3d_View::SetZCueingWidth (const Standard_Real theWidth)
161{
162 V3d_BadValue_Raise_if (theWidth <= 0., "V3d_View::SetZCueingWidth, bad width");
163
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);
7fd59977 171}
172
c357e426 173//=============================================================================
174//function : SetZCueingOn
175//purpose :
176//=============================================================================
177void V3d_View::SetZCueingOn()
178{
179 myView->SetDepthCueingOn (Standard_True);
7fd59977 180}
181
c357e426 182//=============================================================================
183//function : SetZCueingOff
184//purpose :
185//=============================================================================
186void V3d_View::SetZCueingOff()
187{
188 myView->SetDepthCueingOn (Standard_False);
7fd59977 189}
190
c357e426 191//=============================================================================
192//function : ZCueing
193//purpose :
194//=============================================================================
195Standard_Boolean V3d_View::ZCueing (Standard_Real& theDepth, Standard_Real& theWidth) const
196{
197 Standard_Boolean isOn = myView->DepthCueingIsOn();
198 Standard_Real aFront = myView->DepthCueingFrontPlane();
199 Standard_Real aBack = myView->DepthCueingBackPlane();
7fd59977 200
c357e426 201 theWidth = aFront - aBack ;
202 theDepth = (aFront + aBack) / 2.;
7fd59977 203
c357e426 204 return isOn;
7fd59977 205}