MCPcopy Create free account
hub / github.com/Kitware/VTK / OnRotate

Method OnRotate

Interaction/Style/vtkInteractorStyleMultiTouchCamera.cxx:31–83  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

29
30//------------------------------------------------------------------------------
31void vtkInteractorStyleMultiTouchCamera::OnRotate()
32{
33 if (this->State != VTKIS_GESTURE)
34 {
35 return;
36 }
37
38 int pointer = this->Interactor->GetPointerIndex();
39
40 this->FindPokedRenderer(this->Interactor->GetEventPositions(pointer)[0],
41 this->Interactor->GetEventPositions(pointer)[1]);
42
43 if (this->CurrentRenderer == nullptr)
44 {
45 return;
46 }
47
48 vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
49
50 int* pinchPositionDisplay = this->Interactor->GetEventPositions(pointer);
51
52 // Calculate the focal depth since we'll be using it a lot
53 double viewFocus[4];
54 camera->GetFocalPoint(viewFocus);
55 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], viewFocus);
56 double focalDepth = viewFocus[2];
57
58 double oldPickPoint[4] = { 0, 0, 0, 0 };
59 vtkInteractorObserver::ComputeDisplayToWorld(this->CurrentRenderer, pinchPositionDisplay[0],
60 pinchPositionDisplay[1], focalDepth, oldPickPoint);
61
62 camera->Roll(this->Interactor->GetRotation() - this->Interactor->GetLastRotation());
63
64 camera->GetFocalPoint(viewFocus);
65 this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], viewFocus);
66 focalDepth = viewFocus[2];
67
68 double newPickPoint[4] = { 0, 0, 0, 0 };
69 vtkInteractorObserver::ComputeDisplayToWorld(this->CurrentRenderer, pinchPositionDisplay[0],
70 pinchPositionDisplay[1], focalDepth, newPickPoint);
71
72 double motionVector[3] = { 0, 0, 0 };
73 vtkMath::Subtract(oldPickPoint, newPickPoint, motionVector);
74
75 vtkNew<vtkTransform> cameraTransform;
76 cameraTransform->Identity();
77 cameraTransform->Translate(motionVector);
78 camera->ApplyTransform(cameraTransform);
79
80 camera->OrthogonalizeViewUp();
81
82 this->Interactor->Render();
83}
84
85//------------------------------------------------------------------------------
86void vtkInteractorStyleMultiTouchCamera::OnEndRotate()

Callers

nothing calls this directly

Calls 10

GetActiveCameraMethod · 0.80
ComputeWorldToDisplayMethod · 0.80
OrthogonalizeViewUpMethod · 0.80
RenderMethod · 0.65
SubtractFunction · 0.50
FindPokedRendererMethod · 0.45
RollMethod · 0.45
IdentityMethod · 0.45
TranslateMethod · 0.45
ApplyTransformMethod · 0.45

Tested by

no test coverage detected