- if (this->CurrentRenderer == NULL)
- {
- return;
- }
-
- double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
- double oldPos[3], newPos[3], distance[2];
- vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
- camera->GetFocalPoint(viewFocus);
- this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2],
- viewFocus);
- focalDepth = viewFocus[2];
-
- oldPos[0] = this->CurrentRenderer->GetCenter()[0];
- oldPos[1] = this->CurrentRenderer->GetCenter()[1];
- oldPos[2] = focalDepth;
-
- distance[0] = 1/factor*
- (this->Interactor->GetEventPosition()[0]-this->CurrentRenderer->GetCenter()[0]);
- distance[1] = 1/factor*
- (this->Interactor->GetEventPosition()[1]-this->CurrentRenderer->GetCenter()[1]);
-
- newPos[0] = this->Interactor->GetEventPosition()[0] - distance[0];
- newPos[1] = this->Interactor->GetEventPosition()[1] - distance[1];
- newPos[2] = focalDepth;
-
- this->CurrentRenderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
- this->CurrentRenderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
- this->CurrentRenderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
- this->CurrentRenderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
- this->CurrentRenderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
-
- this->CurrentRenderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
- this->CurrentRenderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
- this->CurrentRenderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
- this->CurrentRenderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
- this->CurrentRenderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
-
- motionVector[0] = newPos[0] - oldPos[0];
- motionVector[1] = newPos[1] - oldPos[1];
- motionVector[2] = newPos[2] - oldPos[2];
-
- camera->GetFocalPoint(viewFocus);
- camera->GetPosition(viewPoint);
- camera->SetFocalPoint(motionVector[0] + viewFocus[0],
- motionVector[1] + viewFocus[1],
- motionVector[2] + viewFocus[2]);
-
- camera->SetPosition(motionVector[0] + viewPoint[0],
- motionVector[1] + viewPoint[1],
- motionVector[2] + viewPoint[2]);
-
- if (camera->GetParallelProjection())
- {
- camera->SetParallelScale(camera->GetParallelScale() / factor);
- }
- else
- {
- camera->Dolly(factor);
- if (this->AutoAdjustCameraClippingRange)
- {
- this->CurrentRenderer->ResetCameraClippingRange();
- }
- }
-
- if (this->Interactor->GetLightFollowCamera())
- {
- this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
- }
- this->CurrentRenderer->ResetCameraClippingRange();
- //this->Interactor->Render();
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+
+ double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
+ double oldPos[3], newPos[3], distance[2];
+ vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
+ camera->GetFocalPoint(viewFocus);
+ this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2],
+ viewFocus);
+ focalDepth = viewFocus[2];
+
+ oldPos[0] = this->CurrentRenderer->GetCenter()[0];
+ oldPos[1] = this->CurrentRenderer->GetCenter()[1];
+ oldPos[2] = focalDepth;
+
+ distance[0] = 1/factor*
+ (this->Interactor->GetEventPosition()[0]-this->CurrentRenderer->GetCenter()[0]);
+ distance[1] = 1/factor*
+ (this->Interactor->GetEventPosition()[1]-this->CurrentRenderer->GetCenter()[1]);
+
+ newPos[0] = this->Interactor->GetEventPosition()[0] - distance[0];
+ newPos[1] = this->Interactor->GetEventPosition()[1] - distance[1];
+ newPos[2] = focalDepth;
+
+ this->CurrentRenderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
+ this->CurrentRenderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
+ this->CurrentRenderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
+ this->CurrentRenderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
+ this->CurrentRenderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
+
+ this->CurrentRenderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
+ this->CurrentRenderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
+ this->CurrentRenderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
+ this->CurrentRenderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
+ this->CurrentRenderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
+
+ motionVector[0] = newPos[0] - oldPos[0];
+ motionVector[1] = newPos[1] - oldPos[1];
+ motionVector[2] = newPos[2] - oldPos[2];
+
+ camera->GetFocalPoint(viewFocus);
+ camera->GetPosition(viewPoint);
+ camera->SetFocalPoint(motionVector[0] + viewFocus[0],
+ motionVector[1] + viewFocus[1],
+ motionVector[2] + viewFocus[2]);
+
+ camera->SetPosition(motionVector[0] + viewPoint[0],
+ motionVector[1] + viewPoint[1],
+ motionVector[2] + viewPoint[2]);
+
+ if (camera->GetParallelProjection()) {
+ camera->SetParallelScale(camera->GetParallelScale() / factor);
+ } else {
+ camera->Dolly(factor);
+ if (this->AutoAdjustCameraClippingRange) {
+ this->CurrentRenderer->ResetCameraClippingRange();
+ }
+ }
+
+ if (this->Interactor->GetLightFollowCamera()) {
+ this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
+ }
+ this->CurrentRenderer->ResetCameraClippingRange();
+ //this->Interactor->Render();
+
+ this->InvokeEvent(vtkCommand::EndInteractionEvent, this);