-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
/***********************************************************************
00-09-92 : GG ; Creation.
24-12-97 : FMN ; Suppression de GEOMLITE
13-06-98 : FMN ; PRO14896: Correction sur la gestion de la perspective (cf Programming Guide)
- 22-12-98 : FMN ; Rename CSF_WALKTHROW en CSF_WALKTHROUGH
- IMP240100: GG -> Activates WalkThrough model.
************************************************************************/
/*----------------------------------------------------------------------*/
void V3d_View::Move(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
-
- Graphic3d_Vertex Prp ;
- Graphic3d_Vector Vpn ;
- Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
-
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Move, alignment of Eye,At,Up");
- }
- MyXscreenAxis.Coord(XX,XY,XZ) ;
- MyYscreenAxis.Coord(YX,YY,YZ) ;
- MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Dx*XX + Dy*YX + Dz*ZX ;
- Yeye = Zrp*Ypn + Dx*XY + Dy*YY + Dz*ZY ;
- Zeye = Zrp*Zpn + Dx*XZ + Dy*YZ + Dz*ZZ ;
- Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
-#ifdef DEB
- Standard_Real focale =
-#endif
- Focale();
- Prp.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(Prp) ;
- Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
- Vpn.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
- // Check ZClipping planes
-#ifdef IMP020300
- MyView->SetViewMapping(MyViewMapping) ;
- SetZSize(0.);
-#else
- Standard_Real Zmax,Xat,Yat,Zat ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xeye += Xat ; Yeye += Yat ; Zeye += Zat ;
- Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) {
- SetFocale(focale) ;
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
+
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp (myCamera->Up());
+ if (!ScreenAxis (aReferencePlane, anUp, MyXscreenAxis, MyYscreenAxis, MyZscreenAxis))
+ {
+ V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
}
- MyView->SetViewMapping(MyViewMapping) ;
}
-#endif
+
+ Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
+
+ MyXscreenAxis.Coord (XX,XY,XZ);
+ MyYscreenAxis.Coord (YX,YY,YZ);
+ MyZscreenAxis.Coord (ZX,ZY,ZZ);
+
+ myCamera->SetEye (myCamStartOpEye);
+
+ myCamera->SetEye (myCamera->Eye().XYZ()
+ + Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ + Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ + Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ View()->AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Move(const Standard_Real Length, const Standard_Boolean Start) {
- Graphic3d_Vertex Prp ;
- Graphic3d_Vector Vpn ;
- Standard_Real Vx,Vy,Vz ;
- Standard_Real Xrp,Yrp,Zrp,Xpn,Ypn,Zpn,Xeye,Yeye,Zeye ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint() ;
- }
- MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Vx*Length ;
- Yeye = Zrp*Ypn + Vy*Length ;
- Zeye = Zrp*Zpn + Vz*Length ;
- Zrp = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- V3d_BadValue_Raise_if( Zrp <= 0. ,"V3d_View::Move:: Eye,At are Confused");
-
-#ifdef DEB
- Standard_Real focale =
-#endif
- Focale();
- Prp.SetCoord(Xrp,Yrp,Zrp) ;
- MyViewMapping.SetProjectionReferencePoint(Prp) ;
- Xpn = Xeye / Zrp ; Ypn = Yeye / Zrp ; Zpn = Zeye / Zrp ;
- Vpn.SetCoord(Xpn,Ypn,Zpn) ;
- MyViewOrientation.SetViewReferencePlane(Vpn) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-
-#ifdef IMP020300
- MyView->SetViewMapping(MyViewMapping) ;
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Zmax,Xat,Yat,Zat ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xeye += Xat ; Yeye += Yat ; Zeye += Zat ;
- Zmax = sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
- } else {
- if( MyType == V3d_PERSPECTIVE ) {
- SetFocale(focale) ;
- }
- MyView->SetViewMapping(MyViewMapping) ;
+
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
}
-#endif
+ myCamera->SetEye (myCamStartOpEye);
+
+ Standard_Real Vx, Vy, Vz;
+ MyDefaultViewAxis.Coord (Vx, Vy, Vz) ;
+
+ myCamera->SetEye (myCamera->Eye().XYZ() + Length * gp_Pnt (Vx, Vy, Vz).XYZ());
+
+ View()->AutoZFit();
+
ImmediateUpdate();
}
void V3d_View::Translate(const Standard_Real Dx, const Standard_Real Dy, const Standard_Real Dz, const Standard_Boolean Start) {
- Graphic3d_Vertex Vrp ;
- Standard_Real XX,XY,XZ,YX,YY,YZ,ZX,ZY,ZZ ;
- Standard_Real Xat,Yat,Zat ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- MyViewReferencePlane = MyViewOrientation.ViewReferencePlane() ;
- MyViewReferenceUp = MyViewOrientation.ViewReferenceUp() ;
- MyProjReferencePoint = MyViewMapping.ProjectionReferencePoint();
- if (!ScreenAxis(MyViewReferencePlane,MyViewReferenceUp,
- MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
- V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
- }
- MyXscreenAxis.Coord(XX,XY,XZ) ;
- MyYscreenAxis.Coord(YX,YY,YZ) ;
- MyZscreenAxis.Coord(ZX,ZY,ZZ) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xat -= Dx*XX + Dy*YX + Dz*ZX ;
- Yat -= Dx*XY + Dy*YY + Dz*ZY ;
- Zat -= Dx*XZ + Dy*YZ + Dz*ZZ ;
- Vrp.SetCoord(Xat,Yat,Zat) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-#ifdef IMP020300
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
- sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
+ if( Start )
+ {
+ myCamStartOpEye = myCamera->Eye();
+ myCamStartOpCenter = myCamera->Center();
+
+ gp_Dir aReferencePlane (myCamera->Direction().Reversed());
+ gp_Dir anUp (myCamera->Up());
+ if (!ScreenAxis (aReferencePlane, anUp,
+ MyXscreenAxis,MyYscreenAxis,MyZscreenAxis))
+ V3d_BadValue::Raise ("V3d_View::Translate, alignment of Eye,At,Up");
}
-#endif
+
+ Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
+
+ MyXscreenAxis.Coord (XX,XY,XZ);
+ MyYscreenAxis.Coord (YX,YY,YZ);
+ MyZscreenAxis.Coord (ZX,ZY,ZZ);
+
+ myCamera->SetEye (myCamStartOpEye);
+ myCamera->SetCenter (myCamStartOpCenter);
+
+ myCamera->SetCenter (myCamera->Center().XYZ()
+ - Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ - Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ myCamera->SetEye (myCamera->Eye().XYZ()
+ - Dx * gp_Pnt (XX, XY, XZ).XYZ()
+ - Dy * gp_Pnt (YX, YY, YZ).XYZ()
+ - Dz * gp_Pnt (ZX, ZY, ZZ).XYZ()
+ );
+
+ View()->AutoZFit();
+
ImmediateUpdate();
}
break ;
}
}
-void V3d_View::Place (const Standard_Integer ix, const Standard_Integer iy,
- const Quantity_Factor aZoomFactor) {
- Standard_Real xpos,ypos;
- Standard_Integer xc,yc;
- Center(xpos,ypos);
- Convert(xpos,ypos,xc,yc);
- Pan(xc-ix,iy-yc,aZoomFactor/Scale());
+
+//=======================================================================
+//function : Place
+//purpose :
+//=======================================================================
+void V3d_View::Place (const Standard_Integer theXp,
+ const Standard_Integer theYp,
+ const Quantity_Factor theZoomFactor)
+{
+ Standard_Integer aWinWidth = 0;
+ Standard_Integer aWinHeight = 0;
+ View()->Window()->Size (aWinWidth, aWinHeight);
+
+ Standard_Integer aWinCXp = aWinWidth / 2;
+ Standard_Integer aWinCYp = aWinHeight / 2;
+ Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale());
}
-void V3d_View::Translate(const Standard_Real Length,const Standard_Boolean Start) {
- Graphic3d_Vertex Vrp ;
- Standard_Real Xat,Yat,Zat,Vx,Vy,Vz ;
- if( Start ) {
- MyViewReferencePoint = MyViewOrientation.ViewReferencePoint() ;
- }
- MyDefaultViewAxis.Coord(Vx,Vy,Vz) ;
- MyViewReferencePoint.Coord(Xat,Yat,Zat) ;
- Xat -= Vx*Length ; Yat -= Vy*Length ; Zat -= Vz*Length ;
- Vrp.SetCoord(Xat,Yat,Zat) ;
- MyViewOrientation.SetViewReferencePoint(Vrp) ;
- MyView->SetViewOrientation(MyViewOrientation) ;
-
-#ifdef IMP020300
- SetZSize(0.);
-#else
- // Check ZClipping planes
- Standard_Real Xpn,Ypn,Zpn,Xrp,Yrp,Zrp,Xeye,Yeye,Zeye,Zmax ;
- MyProjReferencePoint.Coord(Xrp,Yrp,Zrp) ;
- MyViewReferencePlane.Coord(Xpn,Ypn,Zpn) ;
- Xeye = Zrp*Xpn + Xat ; Yeye = Zrp*Ypn + Yat ; Zeye = Zrp*Zpn + Zat ;
- Zmax = Max(sqrt( Xeye*Xeye + Yeye*Yeye + Zeye*Zeye ) ,
- sqrt( Xat*Xat + Yat*Yat + Zat*Zat )) ;
- if( Zmax > MyViewMapping.FrontPlaneDistance() &&
- MyProjModel == V3d_TPM_SCREEN ) {
- SetZSize(2.*Zmax+Zmax*Zmargin) ;
+
+void V3d_View::Translate(const Standard_Real theLength, const Standard_Boolean theStart) {
+
+ Standard_Real aVx, aVy, aVz ;
+ if (theStart)
+ {
+ myCamStartOpCenter = myCamera->Center() ;
}
-#endif
+ MyDefaultViewAxis.Coord (aVx, aVy, aVz);
+ gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - gp_Pnt (aVx, aVy, aVz).XYZ() * theLength);
+ myCamera->SetCenter (aNewCenter);
+
+ View()->AutoZFit();
+
ImmediateUpdate();
}