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 /***********************************************************************
18 Classe V3d_View_3.cxx :
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)
26 ************************************************************************/
28 #define IMP020300 //GG Don't use ZFitAll in during Rotation
29 // for perf improvment
31 /*----------------------------------------------------------------------*/
36 #include <V3d_View.jxx>
37 #include <V3d_Static.hxx>
41 /*----------------------------------------------------------------------*/
43 void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
47 myCamStartOpEye = myCamera->Eye();
49 gp_Dir aReferencePlane (myCamera->Direction().Reversed());
50 gp_Dir anUp (myCamera->Up());
51 if (!ScreenAxis (aReferencePlane, anUp, MyXscreenAxis, MyYscreenAxis, MyZscreenAxis))
53 V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
57 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
59 MyXscreenAxis.Coord (XX,XY,XZ);
60 MyYscreenAxis.Coord (YX,YY,YZ);
61 MyZscreenAxis.Coord (ZX,ZY,ZZ);
63 myCamera->SetEye (myCamStartOpEye);
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()
76 void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) {
80 myCamStartOpEye = myCamera->Eye();
82 myCamera->SetEye (myCamStartOpEye);
84 Standard_Real Vx, Vy, Vz;
85 MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
87 myCamera->SetEye (myCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
94 void V3d_View::Move(const V3d_TypeOfAxe Axe , const Standard_Real Length, const Standard_Boolean Start) {
99 Move(Length,0.,0.,Start);
102 Move(0.,Length,0.,Start);
105 Move(0.,0.,Length,Start);
110 void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
114 myCamStartOpEye = myCamera->Eye();
115 myCamStartOpCenter = myCamera->Center();
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");
124 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
126 MyXscreenAxis.Coord (XX,XY,XZ);
127 MyYscreenAxis.Coord (YX,YY,YZ);
128 MyZscreenAxis.Coord (ZX,ZY,ZZ);
130 myCamera->SetEye (myCamStartOpEye);
131 myCamera->SetCenter (myCamStartOpCenter);
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()
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()
150 void V3d_View::Translate(const V3d_TypeOfAxe Axe, const Standard_Real Length,const Standard_Boolean Start) {
154 Translate(Length,0.,0., Start);
157 Translate(0.,Length,0., Start);
160 Translate(0.,0.,Length, Start);
165 //=======================================================================
168 //=======================================================================
169 void V3d_View::Place (const Standard_Integer theXp,
170 const Standard_Integer theYp,
171 const Quantity_Factor theZoomFactor)
173 Standard_Integer aWinWidth = 0;
174 Standard_Integer aWinHeight = 0;
175 View()->Window()->Size (aWinWidth, aWinHeight);
177 Standard_Integer aWinCXp = aWinWidth / 2;
178 Standard_Integer aWinCYp = aWinHeight / 2;
179 Pan (aWinCXp - theXp, aWinCYp - theYp, theZoomFactor / Scale());
182 void V3d_View::Translate(const Standard_Real theLength, const Standard_Boolean theStart) {
184 Standard_Real aVx, aVy, aVz ;
187 myCamStartOpCenter = myCamera->Center() ;
189 MyDefaultViewAxis.Coord (aVx, aVy, aVz);
190 gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
191 myCamera->SetCenter (aNewCenter);