------------------------------------------------------------------------------
| 29 | |
| 30 | //------------------------------------------------------------------------------ |
| 31 | void 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 | //------------------------------------------------------------------------------ |
| 86 | void vtkInteractorStyleMultiTouchCamera::OnEndRotate() |
nothing calls this directly
no test coverage detected