0024650: Wrong intersection curves obtained for a surface of revolution and a plane.
[occt.git] / src / V3d / V3d_View_3.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
7fd59977 14/***********************************************************************
15
16 FONCTION :
17 ----------
18 Classe V3d_View_3.cxx :
19
20 HISTORIQUE DES MODIFICATIONS :
21 --------------------------------
22 00-09-92 : GG ; Creation.
23 24-12-97 : FMN ; Suppression de GEOMLITE
24 13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guide)
7fd59977 25
26************************************************************************/
27
28#define IMP020300 //GG Don't use ZFitAll in during Rotation
29// for perf improvment
30
31/*----------------------------------------------------------------------*/
32/*
33 * Includes
34 */
35
36#include <V3d_View.jxx>
37#include <V3d_Static.hxx>
38
39#define Zmargin 1.
40
41/*----------------------------------------------------------------------*/
42
43void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
7fd59977 44
b5ac8292 45 if( Start )
46 {
47 myCamStartOpEye = myCamera->Eye();
48
49 gp_Dir aReferencePlane (myCamera->Direction().Reversed());
50 gp_Dir anUp (myCamera->Up());
51 if (!ScreenAxis (aReferencePlane, anUp, MyXscreenAxis, MyYscreenAxis, MyZscreenAxis))
52 {
53 V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
54 }
7fd59977 55 }
b5ac8292 56
57 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
58
59 MyXscreenAxis.Coord (XX,XY,XZ);
60 MyYscreenAxis.Coord (YX,YY,YZ);
61 MyZscreenAxis.Coord (ZX,ZY,ZZ);
62
63 myCamera->SetEye (myCamStartOpEye);
64
65 myCamera->SetEye (myCamera->Eye().XYZ()
66 + Dx * gp_Pnt (XX, XY, XZ).XYZ()
67 + Dy * gp_Pnt (YX, YY, YZ).XYZ()
68 + Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
69 );
70
71 AutoZFit();
72
7fd59977 73 ImmediateUpdate();
74}
75
76void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) {
b5ac8292 77
78 if( Start )
79 {
80 myCamStartOpEye = myCamera->Eye();
7fd59977 81 }
b5ac8292 82 myCamera->SetEye (myCamStartOpEye);
83
84 Standard_Real Vx, Vy, Vz;
85 MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
86
87 myCamera->SetEye (myCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
88
89 AutoZFit();
90
7fd59977 91 ImmediateUpdate();
92}
93
94void V3d_View::Move(const V3d_TypeOfAxe Axe , const Standard_Real Length, const Standard_Boolean Start) {
95
96
97 switch (Axe) {
98 case V3d_X :
99 Move(Length,0.,0.,Start);
100 break ;
101 case V3d_Y :
102 Move(0.,Length,0.,Start);
103 break ;
104 case V3d_Z :
105 Move(0.,0.,Length,Start);
106 break ;
107 }
108}
109
110void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
111
b5ac8292 112 if( Start )
113 {
114 myCamStartOpEye = myCamera->Eye();
115 myCamStartOpCenter = myCamera->Center();
116
117 gp_Dir aReferencePlane (myCamera->Direction().Reversed());
118 gp_Dir anUp (myCamera->Up());
119 if (!ScreenAxis (aReferencePlane, anUp,
120 MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
121 V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
7fd59977 122 }
b5ac8292 123
124 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
125
126 MyXscreenAxis.Coord (XX,XY,XZ);
127 MyYscreenAxis.Coord (YX,YY,YZ);
128 MyZscreenAxis.Coord (ZX,ZY,ZZ);
129
130 myCamera->SetEye (myCamStartOpEye);
131 myCamera->SetCenter (myCamStartOpCenter);
132
133 myCamera->SetCenter (myCamera->Center().XYZ()
134 - Dx * gp_Pnt (XX, XY, XZ).XYZ()
135 - Dy * gp_Pnt (YX, YY, YZ).XYZ()
136 - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
137 );
138
139 myCamera->SetEye (myCamera->Eye().XYZ()
140 - Dx * gp_Pnt (XX, XY, XZ).XYZ()
141 - Dy * gp_Pnt (YX, YY, YZ).XYZ()
142 - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
143 );
144
145 AutoZFit();
146
7fd59977 147 ImmediateUpdate();
148}
149
150void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,const Standard_Boolean Start) {
151
152 switch (Axe) {
153 case V3d_X :
154 Translate(Length,0.,0., Start);
155 break ;
156 case V3d_Y :
157 Translate(0.,Length,0., Start);
158 break ;
159 case V3d_Z :
160 Translate(0.,0.,Length, Start);
161 break ;
162 }
163}
164void V3d_View::Place (const Standard_Integer ix, const Standard_Integer iy,
165 const Quantity_Factor aZoomFactor) {
b5ac8292 166 Standard_Real xpos, ypos;
167 Standard_Integer xc, yc;
168 Center (xpos, ypos);
169 Convert (xpos, ypos, xc, yc);
170 Pan (xc - ix, iy - yc, aZoomFactor / Scale());
7fd59977 171}
b5ac8292 172
173void V3d_View::Translate(const Standard_Real theLength, const Standard_Boolean theStart) {
174
175 Standard_Real aVx, aVy, aVz ;
176 if (theStart)
177 {
178 myCamStartOpCenter = myCamera->Center() ;
7fd59977 179 }
b5ac8292 180 MyDefaultViewAxis.Coord (aVx, aVy, aVz);
181 gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
182 myCamera->SetCenter (aNewCenter);
183
184 AutoZFit();
185
7fd59977 186 ImmediateUpdate();
187}