]> Creatis software - clitk.git/blob - vv/vvSlicerManagerCommand.cxx
Debug camera position with large image
[clitk.git] / vv / vvSlicerManagerCommand.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #include "vvSlicerManagerCommand.h"
19 #include "vvSlicerManager.h"
20
21 #include <vtkTextProperty.h>
22 #include <vtkRenderer.h>
23 #include <vtkImageActor.h>
24 #include <vtkRenderWindowInteractor.h>
25 #include <vtkPropPicker.h>
26 #include <vtkCamera.h>
27 #include <vtkImageMapToWindowLevelColors.h>
28 #include <vtkLookupTable.h>
29 #include <vtkMath.h>
30 #include <vtkAbstractPropPicker.h>
31 #include <vtkAssemblyPath.h>
32 #include <vtkCornerAnnotation.h>
33 #include <vtkRenderWindow.h>
34 #include <vvImage.h>
35 #include <vtkImageReslice.h>
36 #include "vvSlicer.h"
37 #include "vvInteractorStyleNavigator.h"
38 #include "vtkTransform.h"
39
40 #include <cmath>
41 //------------------------------------------------------------------------------
42 vvSlicerManagerCommand::vvSlicerManagerCommand()
43 {
44   mStartSlicer = -1;
45   mSlicerNumber=-1;
46 }
47 //------------------------------------------------------------------------------
48
49
50 //------------------------------------------------------------------------------
51 //return the num of the current slicer if visible (-1 else)
52 int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
53 {
54   int rvalue;
55   if (renwin != SM->GetSlicer(mSlicerNumber)->GetRenderWindow() ||
56       !SM->GetSlicer(mSlicerNumber)->GetRenderer()->GetDraw())
57     rvalue = -1;
58   else rvalue = mSlicerNumber;
59   //std::cerr << this << ":" << mSlicerNumber << ": " << rvalue << endl;
60   return rvalue;
61 }
62 //------------------------------------------------------------------------------
63
64
65 //------------------------------------------------------------------------------
66 void vvSlicerManagerCommand::Execute(vtkObject *caller,
67                                      unsigned long event,
68                                      void *vtkNotUsed(callData))
69 {
70   //KeyPress event
71   vvInteractorStyleNavigator *isi =
72     dynamic_cast<vvInteractorStyleNavigator *>(caller);
73   if (isi) {
74     double x = isi->GetInteractor()->GetEventPosition()[0];
75     double y = isi->GetInteractor()->GetEventPosition()[1];
76     double z;
77
78     int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
79     vtkRenderer* renderer=NULL;
80     if (VisibleInWindow>-1)
81       renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
82     newLandmark = false;
83
84
85
86     if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1) {
87       for (int i = 0; i < this->SM->GetNumberOfSlicers(); i++) {
88         if (this->SM->GetSlicer(i)->GetCursorVisibility() && !this->SM->IsLinked()) {
89           this->SM->GetSlicer(i)->SetCursorVisibility(0);
90           this->SM->GetSlicer(i)->SetCornerAnnotationVisibility(0);
91           this->SM->GetSlicer(i)->Render();
92         }
93       }
94     }
95     if ( VisibleInWindow > -1 ) {
96       if (event == vtkCommand::KeyPressEvent) {
97         std::string KeyPress = isi->GetInteractor()->GetKeySym();
98         bool bCtrlKey = isi->GetInteractor()->GetControlKey();
99         if (KeyPress == "Tab") {
100           if(isi->GetInteractor()->GetShiftKey())
101             this->SM->PrevImage(VisibleInWindow);
102           else
103             this->SM->NextImage(VisibleInWindow);
104           return;
105         }
106         if (KeyPress == "f" || KeyPress == "F") {
107           FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
108           return;
109         }
110         if (KeyPress == "w") {
111           this->SM->SetLocalColorWindowing(VisibleInWindow, bCtrlKey);
112           return;
113         }
114         if (KeyPress == "0" || KeyPress == "KP_0") {
115           this->SM->SetPreset(WL_AUTO);
116           this->SM->UpdateWindowLevel();
117           return;
118         }
119         if (KeyPress == "1" || KeyPress == "KP_1") {
120           this->SM->SetPreset(WL_HOUNSFIELD);
121           this->SM->UpdateWindowLevel();
122           return;
123         }
124         if (KeyPress == "2" || KeyPress == "KP_2") {
125           this->SM->SetPreset(WL_SOFTTISSUE);
126           this->SM->UpdateWindowLevel();
127
128           return;
129         }
130         if (KeyPress == "3" || KeyPress == "KP_3") {
131           this->SM->SetPreset(WL_LUNGS);
132           this->SM->UpdateWindowLevel();
133           return;
134         }
135         if (KeyPress == "4" || KeyPress == "KP_4") {
136           this->SM->SetPreset(WL_BONES);
137           this->SM->UpdateWindowLevel();
138           return;
139         }
140         if (KeyPress == "5" || KeyPress == "KP_5") {
141           this->SM->SetPreset(WL_HEAD);
142           this->SM->UpdateWindowLevel();
143           return;
144         }
145         if (KeyPress == "6" || KeyPress == "KP_6") {
146           this->SM->SetColorMap(0);
147           this->SM->UpdateWindowLevel();
148           return;
149         }
150         if (KeyPress == "7" || KeyPress == "KP_7") {
151           this->SM->SetColorMap(1);
152           this->SM->UpdateWindowLevel();
153           return;
154         }
155         if (KeyPress == "8" || KeyPress == "KP_8") {
156           this->SM->SetColorMap(2);
157           this->SM->UpdateWindowLevel();
158           return;
159         }
160         if (KeyPress == "9" || KeyPress == "KP_9") {
161           this->SM->SetColorMap(3);
162           this->SM->UpdateWindowLevel();
163           return;
164         }
165         if (KeyPress == "equal") { //keycodes are in vtkWin32RenderWindowInteractor
166           this->SM->SetPreset(WL_VENTILATION);
167           //this->SM->SetColorMap(1);
168           this->SM->UpdateWindowLevel();
169           return;
170         }
171         if (KeyPress == "minus") {
172           this->SM->SetColorWindow(-this->SM->GetColorWindow());
173           this->SM->SetColorMap(-1);
174           this->SM->UpdateWindowLevel();
175           return;
176         }
177         if (KeyPress == "c") {
178           this->SM->ToggleContourSuperposition();
179           this->SM->Render();
180           return;
181         }
182         if (KeyPress == "l") {
183           this->SM->ToggleInterpolation();
184           this->SM->Render();
185           return;
186         }
187         if (KeyPress == "h") {
188           this->SM->SetCursorAndCornerAnnotationVisibility(0);
189           this->SM->Render();
190           return;
191         }
192         if (KeyPress == "x") {
193           for(int i=0; i<SM->GetNumberOfSlicers(); i++) {
194             SM->RemoveActor("overlay",0);
195             SM->SetColorMap(0);
196             SM->Render();
197           }
198           return;
199         }
200         if (KeyPress == "u") {
201           this->SM->Reload();
202           this->SM->Render();
203           return;
204         }
205         if (KeyPress == "r" || KeyPress=="R") {
206           this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
207           this->SM->GetSlicer(VisibleInWindow)->Render();
208           this->SM->UpdateLinkedNavigation( this->SM->GetSlicer(VisibleInWindow) );
209           return;
210         }
211         if (KeyPress == "g") {
212           if(bCtrlKey)
213             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(0,0,0,0);
214           else {
215             double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
216             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
217               cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
218           }
219           this->SM->UpdateViews(1,VisibleInWindow);
220           this->SM->UpdateLinked(VisibleInWindow);
221           return;
222         }
223         if (KeyPress == "F5") {
224           this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
225           this->SM->GetSlicer(VisibleInWindow)->Render();
226           return;
227         }
228         if (KeyPress == "F6") {
229           this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
230           this->SM->GetSlicer(VisibleInWindow)->Render();
231           return;
232         }
233         if (KeyPress == "Up") {
234           this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
235           this->SM->UpdateSlice(VisibleInWindow);
236         }
237         if (KeyPress == "Down") {
238           this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
239           this->SM->UpdateSlice(VisibleInWindow);
240         }
241         if (KeyPress == "space") {
242           newLandmark = true;
243         }
244         if (KeyPress == "Left")
245           this->SM->SetPreviousTSlice(VisibleInWindow);
246         if (KeyPress == "Right")
247           this->SM->SetNextTSlice(VisibleInWindow);
248
249         if (KeyPress == "F2") {
250           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
251           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
252           this->SM->SetSliceOrientation(VisibleInWindow, 0);
253           this->SM->UpdateSliceRange(VisibleInWindow);
254         }
255         if (KeyPress == "F3") {
256           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
257           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
258           this->SM->SetSliceOrientation(VisibleInWindow, 1);
259           this->SM->UpdateSliceRange(VisibleInWindow);
260         }
261         if (KeyPress == "F4") {
262           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
263           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
264           this->SM->SetSliceOrientation(VisibleInWindow, 2);
265           this->SM->UpdateSliceRange(VisibleInWindow);
266         }
267
268         this->SM->EmitKeyPressed(KeyPress);
269       }
270
271       //All type of mouse events
272       if (event == vtkCommand::LeaveEvent) {
273         this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
274             -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice());
275         this->SM->GetSlicer(VisibleInWindow)->Render();
276         return;
277       }
278
279       // Mouse release HERE
280       if (event == vtkCommand::EndPickEvent) {
281         //            DD(VisibleInWindow);
282         if (VisibleInWindow > -1)
283           this->SM->LeftButtonReleaseEvent(VisibleInWindow);
284         return; // no return !!!! ???
285       }
286
287       if (event == vtkCommand::StartWindowLevelEvent) {
288         mStartSlicer = -1;
289         this->InitialWindow = this->SM->GetColorWindow();
290         this->InitialLevel = this->SM->GetColorLevel();
291
292         if (VisibleInWindow > -1) {
293           mStartSlicer = VisibleInWindow;
294         }
295         return;
296       }
297
298       if (event == vtkCommand::EndWindowLevelEvent) {
299         mStartSlicer = -1;
300       }
301
302       if (event == vtkCommand::EndInteractionEvent) {
303         this->SM->Picked();
304         this->SM->UpdateLinkedNavigation(this->SM->GetSlicer(VisibleInWindow),true);
305         return;
306       }
307     }
308     if (VisibleInWindow > -1) {
309       this->SM->Activated();
310       this->SM->GetSlicer(VisibleInWindow)->SetCornerAnnotationVisibility(1);
311
312       if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey()) {
313         this->SM->Picked();
314         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
315         this->SM->UpdateSlice(VisibleInWindow);
316       } else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey()) {
317         double factor = 2;
318         this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
319         Execute(caller, vtkCommand::EndInteractionEvent, NULL);
320       } else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey()) {
321         this->SM->Picked();
322         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
323         this->SM->UpdateSlice(VisibleInWindow);
324       } else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey()) {
325         double factor = -2;
326         this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
327         Execute(caller, vtkCommand::EndInteractionEvent, NULL);
328       }
329       double xWorld=0;
330       double yWorld=0;
331       double zWorld=0;
332
333       //Move into World Coordinate
334       renderer->DisplayToNormalizedDisplay(x,y);
335       renderer->NormalizedDisplayToViewport(x,y);
336       renderer->ViewportToNormalizedViewport(x,y);
337       renderer->NormalizedViewportToView(x,y,z);
338       renderer->ViewToWorld(x,y,z);
339       switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation()) {
340       case vtkImageViewer2::SLICE_ORIENTATION_XY:
341         xWorld = x;
342         yWorld = y;
343         zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
344                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
345                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
346         break;
347
348       case vtkImageViewer2::SLICE_ORIENTATION_XZ:
349         xWorld = x;
350         yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
351                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
352                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
353         zWorld = z;
354         break;
355
356       case vtkImageViewer2::SLICE_ORIENTATION_YZ:
357         xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
358                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
359                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
360         yWorld = y;
361         zWorld = z;
362         break;
363       }
364
365       // <<<<<<< HEAD
366       //       this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
367       //                           this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
368       //       // We propagate the mouse position
369       //       this->SM->EmitMousePositionUpdated(VisibleInWindow);      
370       // =======
371       double p[3]; p[0] = xWorld; p[1] = yWorld; p[2] = zWorld;
372       double pt[3];
373       this->SM->GetSlicer(VisibleInWindow)->GetSlicingTransform()->TransformPoint(p, pt);
374
375       this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(pt[0],pt[1],pt[2],
376           this->SM->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice());
377
378       // We propagate the mouse position
379       this->SM->EmitMousePositionUpdated(VisibleInWindow);
380
381       //>>>>>>> 921642d767beba2442dacc8fdb40dc36396e1b7d
382
383       if (newLandmark) {
384         double pLand[3]; pLand[0] = xWorld; pLand[1] = yWorld; pLand[2] = zWorld;
385         double ptLand[3];
386         this->SM->GetSlicer(VisibleInWindow)->GetConcatenatedTransform()->TransformPoint(pLand, ptLand);
387         this->SM->AddNewLandmark(ptLand[0],ptLand[1],ptLand[2],
388                               this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
389         this->SM->GetSlicer(VisibleInWindow)->RemoveLandmarks();
390         //this->SM->GetSlicer(VisibleInWindow)->DisplayLandmarks();
391         this->SM->Render();
392       }
393       if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) {
394         this->SM->Picked();
395         this->SM->UpdateViews(1,VisibleInWindow);
396         this->SM->UpdateLinked(VisibleInWindow);
397         this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
398       } else {
399         this->SM->GetSlicer(VisibleInWindow)->Render();
400       }
401       //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
402       //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
403       //this->SM->GetSlicer(VisibleInWindow)->Render();
404     }
405
406     if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1) {
407       this->SM->GetSlicer(mStartSlicer)->SetCornerAnnotationVisibility(1);
408       // Adjust the window level here
409       int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
410       double window = this->InitialWindow;
411       double level = this->InitialLevel;
412       double range[2];
413       this->SM->GetImage()->GetScalarRange(range);
414
415       // Compute normalized delta
416       double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
417                                       isi->GetWindowLevelStartPosition()[0]) / size[0];
418       double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
419                                       isi->GetWindowLevelCurrentPosition()[1]) / size[1];
420       //Window is exponential in nature, use exponential to avoid falling into negative numbers
421       dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
422       dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
423
424       this->SM->SetColorWindow(window*dx);
425       this->SM->SetColorLevel(level-dy);
426       this->SM->SetPreset(WL_USER);
427       this->SM->Render();
428       this->SM->UpdateWindowLevel();
429       return;
430     }
431   }
432 }
433 //------------------------------------------------------------------------------
434
435
436 //------------------------------------------------------------------------------
437 void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *interactor)
438 {
439   int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
440   vtkRenderer* renderer;
441   if (VisibleInWindow>-1)
442     renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
443   else {
444     return;
445   }
446
447   double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
448   double oldPos[3], newPos[3], distance[2];
449   vtkCamera *camera = renderer->GetActiveCamera();
450   camera->GetFocalPoint(viewFocus);
451
452   renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
453   renderer->WorldToDisplay();
454   renderer->GetDisplayPoint(viewFocus);
455
456   focalDepth = viewFocus[2];
457
458   oldPos[0] = renderer->GetCenter()[0];
459   oldPos[1] = renderer->GetCenter()[1];
460   oldPos[2] = focalDepth;
461
462   distance[0] = 1/factor*
463                 (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
464   distance[1] = 1/factor*
465                 (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
466
467   newPos[0] = interactor->GetEventPosition()[0] - distance[0];
468   newPos[1] = interactor->GetEventPosition()[1] - distance[1];
469   newPos[2] = focalDepth;
470
471   renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
472   renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
473   renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
474   renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
475   renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
476
477   renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
478   renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
479   renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
480   renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
481   renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
482
483   motionVector[0] = newPos[0] - oldPos[0];
484   motionVector[1] = newPos[1] - oldPos[1];
485   motionVector[2] = newPos[2] - oldPos[2];
486
487   camera->GetFocalPoint(viewFocus);
488   camera->GetPosition(viewPoint);
489   camera->SetFocalPoint(motionVector[0] + viewFocus[0],
490                         motionVector[1] + viewFocus[1],
491                         motionVector[2] + viewFocus[2]);
492
493   camera->SetPosition(motionVector[0] + viewPoint[0],
494                       motionVector[1] + viewPoint[1],
495                       motionVector[2] + viewPoint[2]);
496
497   if (camera->GetParallelProjection()) {
498     camera->SetParallelScale(camera->GetParallelScale() / factor);
499   } else {
500     camera->Dolly(factor);
501   }
502
503   if (interactor->GetLightFollowCamera()) {
504     renderer->UpdateLightsGeometryToFollowCamera();
505   }
506   renderer->ResetCameraClippingRange();
507   //interactor->Render();
508 }
509 //------------------------------------------------------------------------------
510
511
512 //------------------------------------------------------------------------------
513 void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
514 {
515   double flyFrom[3], flyTo[3];
516   double d[3], focalPt[3], position[3], positionFrom[3];
517   int i, j;
518   int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
519   vtkRenderer* renderer=NULL;
520   if (VisibleInWindow>-1)
521     renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
522   else
523     return;
524
525   interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
526                                 interactor->GetEventPosition()[1], 0.0,
527                                 renderer);
528
529   vtkAssemblyPath *path=NULL;
530   vtkAbstractPropPicker *picker;
531   if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker()))) {
532     path = picker->GetPath();
533   }
534   if ( path != NULL ) {
535     flyTo[0] = picker->GetPickPosition()[0];
536     flyTo[1] = picker->GetPickPosition()[1];
537     flyTo[2] = picker->GetPickPosition()[2];
538     renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
539     renderer->GetActiveCamera()->GetPosition(positionFrom);
540
541     switch (slicer->GetSliceOrientation()) {
542     case vtkImageViewer2::SLICE_ORIENTATION_XY:
543       flyTo[2] = flyFrom[2];
544       break;
545
546     case vtkImageViewer2::SLICE_ORIENTATION_XZ:
547       flyTo[1] = flyFrom[1];
548       break;
549
550     case vtkImageViewer2::SLICE_ORIENTATION_YZ:
551       flyTo[0] = flyFrom[0];
552       break;
553     }
554
555
556     for (i=0; i<3; i++) {
557       d[i] = flyTo[i] - flyFrom[i];
558     }
559     double distance = vtkMath::Normalize(d);
560     double delta = distance/15;
561
562     for (i=1; i<=15; i++) {
563       for (j=0; j<3; j++) {
564         focalPt[j] = flyFrom[j] + d[j]*i*delta;
565         position[j] = positionFrom[j] + d[j]*i*delta;
566       }
567       renderer->GetActiveCamera()->SetFocalPoint(focalPt);
568       renderer->GetActiveCamera()->SetPosition(position);
569       renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
570       renderer->ResetCameraClippingRange();
571       interactor->Render();
572     }
573   }
574 }
575 //------------------------------------------------------------------------------