24#include "vtkObjectFactory.h"
30 if (this->CurrentRenderer ==
NULL)
35 vtkRenderWindowInteractor *rwi = this->Interactor;
37 int dx = - (rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0]);
38 int dy = - (rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1]);
40 int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
42 double a = (double)dx / (
double)size[0] * (double)180.0;
43 double e = (double)dy / (
double)size[1] * (double)180.0;
45 if (rwi->GetShiftKey())
47 if (fabs((
double)dx) >= fabs((
double)dy))
60 vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
63 double dop[3], vup[3];
65 camera->GetDirectionOfProjection(dop);
66 vtkMath::Normalize(dop);
67 camera->GetViewUp(vup);
68 vtkMath::Normalize(vup);
70 const double dAngleLimit = 5.0;
72 double angle = acos(vtkMath::Dot(dop, vup)) / vtkMath::RadiansFromDegrees( 1.0 );
73 if ((angle + e) > 180.0-dAngleLimit)
75 e = 180.0-dAngleLimit-angle;
77 else if ((angle + e) < dAngleLimit)
79 e = dAngleLimit-angle;
83 if (this->AutoAdjustCameraClippingRange)
85 this->CurrentRenderer->ResetCameraClippingRange();
vtkStandardNewMacro(CCustomInteractorStyle)