0030853: Visualization, AIS_ViewController - fix 1 pixel Y shift while zooming
[occt.git] / src / AIS / AIS_AnimationCamera.cxx
CommitLineData
1beb58d7 1// Created by: Anastasia BORISOVA
2// Copyright (c) 2016 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#include <AIS_AnimationCamera.hxx>
16
17#include <Graphic3d_Camera.hxx>
18#include <Precision.hxx>
19#include <V3d_View.hxx>
20
21IMPLEMENT_STANDARD_RTTIEXT(AIS_AnimationCamera, AIS_Animation)
22
23//=============================================================================
24//function : AIS_AnimationCamera
25//purpose :
26//=============================================================================
27AIS_AnimationCamera::AIS_AnimationCamera (const TCollection_AsciiString& theAnimationName,
28 const Handle(V3d_View)& theView)
29: AIS_Animation (theAnimationName),
30 myView (theView)
31{
32 //
33}
34
35//=============================================================================
36//function : update
37//purpose :
38//=============================================================================
39void AIS_AnimationCamera::update (const AIS_AnimationProgress& theProgress)
40{
41 if (myView.IsNull()
42 || myCamStart.IsNull()
43 || myCamEnd.IsNull())
44 {
45 return;
46 }
47
48 Handle(Graphic3d_Camera) aCamera = myView->Camera();
49
50 Graphic3d_CameraLerp aCamLerp (myCamStart, myCamEnd);
2108d9a2 51 aCamLerp.Interpolate (HasOwnDuration() ? theProgress.LocalNormalized : 1.0, aCamera);
1beb58d7 52
53 const Standard_Boolean aPrevImmUpdate = myView->SetImmediateUpdate (Standard_False);
54 myView->SetCamera (aCamera);
55 myView->SetImmediateUpdate (aPrevImmUpdate);
56 myView->Invalidate();
57}