]> Creatis software - bbtk.git/blob - packages/wxvtk/src/wxvtkImageViewer2.cxx
Feature #1774
[bbtk.git] / packages / wxvtk / src / wxvtkImageViewer2.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29
30   Program:   Visualization Toolkit
31   Module:    $RCSfile: wxvtkImageViewer2.cxx,v $
32
33   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
34   All rights reserved.
35   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
36
37      This software is distributed WITHOUT ANY WARRANTY; without even
38      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
39      PURPOSE.  See the above copyright notice for more information.
40
41 =========================================================================*/
42 #include "wxvtkImageViewer2.h"
43
44 #include "vtkCamera.h"
45 #include "vtkCommand.h"
46 #include "vtkImageActor.h"
47 #include "vtkImageData.h"
48 #include "vtkImageData.h"
49 #include "vtkImageMapToWindowLevelColors.h"
50 #include "vtkInteractorStyleImage.h"
51 #include "vtkObjectFactory.h"
52 #include "vtkRenderWindow.h"
53 #include "vtkRenderWindowInteractor.h"
54 #include "vtkRenderer.h"
55
56 vtkCxxRevisionMacro(wxvtkImageViewer2, "$Revision: 1.8 $");
57 vtkStandardNewMacro(wxvtkImageViewer2);
58
59 //----------------------------------------------------------------------------
60 wxvtkImageViewer2::wxvtkImageViewer2()
61 {
62   this->RenderWindow    = NULL;
63   this->Renderer        = NULL;
64   this->ImageActor      = vtkImageActor::New();
65   this->WindowLevel     = vtkImageMapToWindowLevelColors::New();
66   this->Interactor      = NULL;
67   this->InteractorStyle = NULL;
68
69   this->Slice = 0;
70   this->FirstRender = 1;
71   this->SliceOrientation = wxvtkImageViewer2::SLICE_ORIENTATION_XY;
72
73   // Setup the pipeline
74
75   vtkRenderWindow *renwin = vtkRenderWindow::New();
76   this->SetRenderWindow(renwin);
77   renwin->Delete();
78
79   vtkRenderer *ren = vtkRenderer::New();
80   this->SetRenderer(ren);
81   ren->Delete();
82
83   this->InstallPipeline();
84 }
85
86 //----------------------------------------------------------------------------
87 wxvtkImageViewer2::~wxvtkImageViewer2()
88 {
89   if (this->WindowLevel)
90     {
91     this->WindowLevel->Delete();
92     this->WindowLevel = NULL;
93     }
94
95   if (this->ImageActor)
96     {
97     this->ImageActor->Delete();
98     this->ImageActor = NULL;
99     }
100
101   if (this->Renderer)
102     {
103     this->Renderer->Delete();
104     this->Renderer = NULL;
105     }
106
107   if (this->RenderWindow)
108     {
109     this->RenderWindow->Delete();
110     this->RenderWindow = NULL;
111     }
112
113   if (this->Interactor)
114     {
115     this->Interactor->Delete();
116     this->Interactor = NULL;
117     }
118
119   if (this->InteractorStyle)
120     {
121     this->InteractorStyle->Delete();
122     this->InteractorStyle = NULL;
123     }
124 }
125
126 //----------------------------------------------------------------------------
127 void wxvtkImageViewer2::SetupInteractor(vtkRenderWindowInteractor *arg)
128 {
129   if (this->Interactor == arg)
130     {
131     return;
132     }
133
134   this->UnInstallPipeline();
135
136   if (this->Interactor)
137     {
138     this->Interactor->UnRegister(this);
139     }
140
141   this->Interactor = arg;
142
143   if (this->Interactor)
144     {
145     this->Interactor->Register(this);
146     }
147
148   this->InstallPipeline();
149
150   if (this->Renderer)
151     {
152     this->Renderer->GetActiveCamera()->ParallelProjectionOn();
153     }
154 }
155
156 //----------------------------------------------------------------------------
157 void wxvtkImageViewer2::SetRenderWindow(vtkRenderWindow *arg)
158 {
159   if (this->RenderWindow == arg)
160     {
161     return;
162     }
163
164   this->UnInstallPipeline();
165
166   if (this->RenderWindow)
167     {
168     this->RenderWindow->UnRegister(this);
169     }
170
171   this->RenderWindow = arg;
172
173   if (this->RenderWindow)
174     {
175     this->RenderWindow->Register(this);
176     }
177
178   this->InstallPipeline();
179 }
180
181 //----------------------------------------------------------------------------
182 void wxvtkImageViewer2::SetRenderer(vtkRenderer *arg)
183 {
184   if (this->Renderer == arg)
185     {
186     return;
187     }
188
189   this->UnInstallPipeline();
190
191   if (this->Renderer)
192     {
193     this->Renderer->UnRegister(this);
194     }
195
196   this->Renderer = arg;
197
198   if (this->Renderer)
199     {
200     this->Renderer->Register(this);
201     }
202
203   this->InstallPipeline();
204   this->UpdateOrientation();
205 }
206
207 //----------------------------------------------------------------------------
208 void wxvtkImageViewer2::SetSize(int a,int b)
209 {
210   this->RenderWindow->SetSize(a, b);
211 }
212
213 //----------------------------------------------------------------------------
214 int* wxvtkImageViewer2::GetSize()
215 {
216   return this->RenderWindow->GetSize();
217 }
218
219 //----------------------------------------------------------------------------
220 void wxvtkImageViewer2::GetSliceRange(int &min, int &max)
221 {
222   vtkImageData *input = this->GetInput();
223   if (input)
224     {
225     input->UpdateInformation();
226     int *w_ext = input->GetWholeExtent();
227     min = w_ext[this->SliceOrientation * 2];
228     max = w_ext[this->SliceOrientation * 2 + 1];
229     }
230 }
231
232 //----------------------------------------------------------------------------
233 int* wxvtkImageViewer2::GetSliceRange()
234 {
235   vtkImageData *input = this->GetInput();
236   if (input)
237     {
238     input->UpdateInformation();
239     return input->GetWholeExtent() + this->SliceOrientation * 2;
240     }
241   return NULL;
242 }
243
244 //----------------------------------------------------------------------------
245 int wxvtkImageViewer2::GetSliceMin()
246 {
247   int *range = this->GetSliceRange();
248   if (range)
249     {
250     return range[0];
251     }
252   return 0;
253 }
254
255 //----------------------------------------------------------------------------
256 int wxvtkImageViewer2::GetSliceMax()
257 {
258   int *range = this->GetSliceRange();
259   if (range)
260     {
261     return range[1];
262     }
263   return 0;
264 }
265
266 //----------------------------------------------------------------------------
267 void wxvtkImageViewer2::SetSlice(int slice)
268 {
269   int *range = this->GetSliceRange();
270   if (range)
271     {
272     if (slice < range[0])
273       {
274       slice = range[0];
275       }
276     else if (slice > range[1])
277       {
278       slice = range[1];
279       }
280     }
281
282   if (this->Slice == slice)
283     {
284     return;
285     }
286
287   this->Slice = slice;
288   this->Modified();
289
290   this->UpdateDisplayExtent();
291   this->Render();
292 }
293
294 //----------------------------------------------------------------------------
295 void wxvtkImageViewer2::SetSliceOrientation(int orientation)
296 {
297   if (orientation < wxvtkImageViewer2::SLICE_ORIENTATION_YZ ||
298       orientation > wxvtkImageViewer2::SLICE_ORIENTATION_XY)
299     {
300     vtkErrorMacro("Error - invalid slice orientation " << orientation);
301     return;
302     }
303
304   if (this->SliceOrientation == orientation)
305     {
306     return;
307     }
308
309   this->SliceOrientation = orientation;
310
311   // Update the viewer
312
313   int *range = this->GetSliceRange();
314   if (range)
315     {
316     this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
317     }
318
319   this->UpdateOrientation();
320   this->UpdateDisplayExtent();
321
322   if (this->Renderer && this->GetInput())
323     {
324     double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
325     this->Renderer->ResetCamera();
326     this->Renderer->GetActiveCamera()->SetParallelScale(scale);
327     }
328
329   this->Render();
330 }
331
332 //----------------------------------------------------------------------------
333 void wxvtkImageViewer2::UpdateOrientation()
334 {
335   // Set the camera position
336
337   vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
338   if (cam)
339     {
340
341 // EED 21 mars FLIP problem  ..PLOP..           
342     switch (this->SliceOrientation)
343         {
344                 case wxvtkImageViewer2::SLICE_ORIENTATION_YZ:
345                           cam->SetViewUp(0,0,1);
346                           cam->SetPosition(1,0,0); // -1 if medical ?
347                           cam->SetFocalPoint(0,0,0);
348                         break;
349                         
350                 case wxvtkImageViewer2::SLICE_ORIENTATION_XZ:
351                         cam->SetViewUp(0,0,1);
352                         cam->SetPosition(0,-1,0); // 1 if medical ?
353                         cam->SetFocalPoint(0,0,0);
354                         break;
355                         
356                 case wxvtkImageViewer2::SLICE_ORIENTATION_XY:
357                           cam->SetViewUp(0,-1,0);
358                           cam->SetPosition(0,0,-1); 
359                           cam->SetFocalPoint(0,0,0);
360                         break;
361       }
362         
363 /*              
364                 switch (this->SliceOrientation)
365                 {
366                         case wxvtkImageViewer2::SLICE_ORIENTATION_YZ:
367                                 cam->SetViewUp(0,0,1);
368                                 cam->SetPosition(1,0,0); // -1 if medical ?
369                                 cam->SetFocalPoint(0,0,0);
370                                 break;
371  
372                         case wxvtkImageViewer2::SLICE_ORIENTATION_XZ:
373                                 cam->SetViewUp(0,0,1);
374                                 cam->SetPosition(0,-1,0); // 1 if medical ?
375                                 cam->SetFocalPoint(0,0,0);
376                                 break;
377  
378                         case wxvtkImageViewer2::SLICE_ORIENTATION_XY:
379                                 cam->SetViewUp(0,1,0);
380                                 cam->SetPosition(0,0,1); // -1 if medical ?
381                                 cam->SetFocalPoint(0,0,0);
382                                 break;
383  
384                                 
385                 }               
386 */              
387                 
388     }
389 }
390
391 //----------------------------------------------------------------------------
392 void wxvtkImageViewer2::UpdateDisplayExtent()
393 {
394   vtkImageData *input = this->GetInput();
395   if (!input || !this->ImageActor)
396     {
397     return;
398     }
399
400   //  std::cout << "--- wxvtkImageViewer2::UpdateDisplayExtent()"<<std::endl;
401   input->UpdateInformation();
402   int *w_ext = input->GetWholeExtent();
403
404   //    std::cout << "ext = "
405   //    <<w_ext[0]<<" - "<<w_ext[1]<<" ; "
406   //            <<w_ext[2]<<" - "<<w_ext[3]<<" ; "
407   //            <<w_ext[4]<<" - "<<w_ext[5]
408   //            <<std::endl;
409       // Is the slice in range ? If not, fix it
410
411   int slice_min = w_ext[this->SliceOrientation * 2];
412   int slice_max = w_ext[this->SliceOrientation * 2 + 1];
413   if (this->Slice < slice_min || this->Slice > slice_max)
414     {
415     this->Slice = static_cast<int>((slice_min + slice_max) * 0.5);
416     }
417
418   // Set the image actor
419
420   switch (this->SliceOrientation)
421     {
422     case wxvtkImageViewer2::SLICE_ORIENTATION_XY:
423       this->ImageActor->SetDisplayExtent(
424         w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice);
425       break;
426
427     case wxvtkImageViewer2::SLICE_ORIENTATION_XZ:
428       this->ImageActor->SetDisplayExtent(
429         w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5]);
430       break;
431
432     case wxvtkImageViewer2::SLICE_ORIENTATION_YZ:
433       this->ImageActor->SetDisplayExtent(
434         this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
435       break;
436     }
437
438   // Figure out the correct clipping range
439
440   if (this->Renderer)
441     {
442     if (this->InteractorStyle &&
443         this->InteractorStyle->GetAutoAdjustCameraClippingRange())
444       {
445       this->Renderer->ResetCameraClippingRange();
446       }
447     else
448       {
449       vtkCamera *cam = this->Renderer->GetActiveCamera();
450       if (cam)
451         {
452         double bounds[6];
453         this->ImageActor->GetBounds(bounds);
454         double spos = bounds[this->SliceOrientation * 2];
455         double cpos = cam->GetPosition()[this->SliceOrientation];
456         double range = fabs(spos - cpos);
457         double *spacing = input->GetSpacing();
458         double avg_spacing =
459           //(spacing[0] + spacing[1] + spacing[2]) / 3.0;
460           spacing[2]; // JPR??
461         cam->SetClippingRange(
462           range - avg_spacing * 3.0, range + avg_spacing * 3.0);
463         }
464       }
465     }
466 }
467
468 //----------------------------------------------------------------------------
469 void wxvtkImageViewer2::SetPosition(int a,int b)
470 {
471   this->RenderWindow->SetPosition(a, b);
472 }
473
474 //----------------------------------------------------------------------------
475 int* wxvtkImageViewer2::GetPosition()
476 {
477   return this->RenderWindow->GetPosition();
478 }
479
480 //----------------------------------------------------------------------------
481 void wxvtkImageViewer2::SetDisplayId(void *a)
482 {
483   this->RenderWindow->SetDisplayId(a);
484 }
485
486 //----------------------------------------------------------------------------
487 void wxvtkImageViewer2::SetWindowId(void *a)
488 {
489   this->RenderWindow->SetWindowId(a);
490 }
491
492 //----------------------------------------------------------------------------
493 void wxvtkImageViewer2::SetParentId(void *a)
494 {
495   this->RenderWindow->SetParentId(a);
496 }
497
498 //----------------------------------------------------------------------------
499 double wxvtkImageViewer2::GetColorWindow()
500 {
501   return this->WindowLevel->GetWindow();
502 }
503
504 //----------------------------------------------------------------------------
505 double wxvtkImageViewer2::GetColorLevel()
506 {
507   return this->WindowLevel->GetLevel();
508 }
509
510 //----------------------------------------------------------------------------
511 void wxvtkImageViewer2::SetColorWindow(double s)
512 {
513   this->WindowLevel->SetWindow(s);
514 }
515
516 //----------------------------------------------------------------------------
517 void wxvtkImageViewer2::SetColorLevel(double s)
518 {
519   this->WindowLevel->SetLevel(s);
520 }
521
522 //----------------------------------------------------------------------------
523 class wxvtkImageViewer2Callback : public vtkCommand
524 {
525 public:
526   static wxvtkImageViewer2Callback *New() { return new wxvtkImageViewer2Callback; }
527
528   void Execute(vtkObject *caller,
529                unsigned long event,
530                void *vtkNotUsed(callData))
531     {
532       if (this->IV->GetInput() == NULL)
533         {
534         return;
535         }
536
537       // Reset
538
539       if (event == vtkCommand::ResetWindowLevelEvent)
540         {
541         this->IV->GetInput()->UpdateInformation();
542         this->IV->GetInput()->SetUpdateExtent
543           (this->IV->GetInput()->GetWholeExtent());
544         this->IV->GetInput()->Update();
545         double *range = this->IV->GetInput()->GetScalarRange();
546         this->IV->SetColorWindow(range[1] - range[0]);
547         this->IV->SetColorLevel(0.5 * (range[1] + range[0]));
548         this->IV->Render();
549         return;
550         }
551
552       // Start
553
554       if (event == vtkCommand::StartWindowLevelEvent)
555         {
556         this->InitialWindow = this->IV->GetColorWindow();
557         this->InitialLevel = this->IV->GetColorLevel();
558         return;
559         }
560
561       // Adjust the window level here
562
563       vtkInteractorStyleImage *isi =
564         static_cast<vtkInteractorStyleImage *>(caller);
565
566       int *size = this->IV->GetRenderWindow()->GetSize();
567       double window = this->InitialWindow;
568       double level = this->InitialLevel;
569
570       // Compute normalized delta
571
572       double dx = 4.0 *
573         (isi->GetWindowLevelCurrentPosition()[0] -
574          isi->GetWindowLevelStartPosition()[0]) / size[0];
575       double dy = 4.0 *
576         (isi->GetWindowLevelStartPosition()[1] -
577          isi->GetWindowLevelCurrentPosition()[1]) / size[1];
578
579       // Scale by current values
580
581       if (fabs(window) > 0.01)
582         {
583         dx = dx * window;
584         }
585       else
586         {
587         dx = dx * (window < 0 ? -0.01 : 0.01);
588         }
589       if (fabs(level) > 0.01)
590         {
591         dy = dy * level;
592         }
593       else
594         {
595         dy = dy * (level < 0 ? -0.01 : 0.01);
596         }
597
598       // Abs so that direction does not flip
599
600       if (window < 0.0)
601         {
602         dx = -1*dx;
603         }
604       if (level < 0.0)
605         {
606         dy = -1*dy;
607         }
608
609       // Compute new window level
610
611       double newWindow = dx + window;
612       double newLevel;
613       newLevel = level - dy;
614
615       // Stay away from zero and really
616
617       if (fabs(newWindow) < 0.01)
618         {
619         newWindow = 0.01*(newWindow < 0 ? -1 : 1);
620         }
621       if (fabs(newLevel) < 0.01)
622         {
623         newLevel = 0.01*(newLevel < 0 ? -1 : 1);
624         }
625
626       this->IV->SetColorWindow(newWindow);
627       this->IV->SetColorLevel(newLevel);
628       this->IV->Render();
629     }
630
631   wxvtkImageViewer2 *IV;
632   double InitialWindow;
633   double InitialLevel;
634 };
635
636 //----------------------------------------------------------------------------
637 void wxvtkImageViewer2::InstallPipeline()
638 {
639   if (this->RenderWindow && this->Renderer)
640     {
641     this->RenderWindow->AddRenderer(this->Renderer);
642     }
643
644   if (this->Interactor)
645     {
646     if (!this->InteractorStyle)
647       {
648       this->InteractorStyle = vtkInteractorStyleImage::New();
649       wxvtkImageViewer2Callback *cbk = wxvtkImageViewer2Callback::New();
650       cbk->IV = this;
651       this->InteractorStyle->AddObserver(
652         vtkCommand::WindowLevelEvent, cbk);
653       this->InteractorStyle->AddObserver(
654         vtkCommand::StartWindowLevelEvent, cbk);
655       this->InteractorStyle->AddObserver(
656         vtkCommand::ResetWindowLevelEvent, cbk);
657       cbk->Delete();
658       }
659
660     this->Interactor->SetInteractorStyle(this->InteractorStyle);
661     this->Interactor->SetRenderWindow(this->RenderWindow);
662     }
663
664   if (this->Renderer && this->ImageActor)
665     {
666     this->Renderer->AddViewProp(this->ImageActor);
667     }
668
669   if (this->ImageActor && this->WindowLevel)
670     {
671     this->ImageActor->SetInput(this->WindowLevel->GetOutput());
672     }
673 }
674
675 //----------------------------------------------------------------------------
676 void wxvtkImageViewer2::UnInstallPipeline()
677 {
678   if (this->ImageActor)
679     {
680     this->ImageActor->SetInput(NULL);
681     }
682
683   if (this->Renderer && this->ImageActor)
684     {
685     this->Renderer->RemoveViewProp(this->ImageActor);
686     }
687
688   if (this->RenderWindow && this->Renderer)
689     {
690     this->RenderWindow->RemoveRenderer(this->Renderer);
691     }
692
693   if (this->Interactor)
694     {
695     this->Interactor->SetInteractorStyle(NULL);
696     this->Interactor->SetRenderWindow(NULL);
697     }
698 }
699
700 //----------------------------------------------------------------------------
701 void wxvtkImageViewer2::Render()
702 {
703   if (this->FirstRender)
704     {
705     // Initialize the size if not set yet
706
707     vtkImageData *input = this->GetInput();
708     if (this->RenderWindow->GetSize()[0] == 0 &&
709         input)
710       {
711
712       input->UpdateInformation();
713       int *w_ext = input->GetWholeExtent();
714       int xs = 0, ys = 0;
715
716       //        std::cout << "wxvtkImageViewer2::Render ext = "
717       //        <<w_ext[0]<<" - "<<w_ext[1]<<" ; "
718       //                <<w_ext[2]<<" - "<<w_ext[3]<<" ; "
719       //                <<w_ext[4]<<" - "<<w_ext[5]
720       //                <<std::endl;
721
722       switch (this->SliceOrientation)
723         {
724         case wxvtkImageViewer2::SLICE_ORIENTATION_XY:
725         default:
726           xs = w_ext[1] - w_ext[0] + 1;
727           ys = w_ext[3] - w_ext[2] + 1;
728           //      std::cout << "SLICE_ORIENTATION_XY" << std::endl;
729           break;
730
731         case wxvtkImageViewer2::SLICE_ORIENTATION_XZ:
732           xs = w_ext[1] - w_ext[0] + 1;
733           ys = w_ext[5] - w_ext[4] + 1;
734           //      std::cout << "SLICE_ORIENTATION_XZ" << std::endl;
735           break;
736
737         case wxvtkImageViewer2::SLICE_ORIENTATION_YZ:
738           xs = w_ext[3] - w_ext[2] + 1;
739           ys = w_ext[5] - w_ext[4] + 1;
740           //      std::cout << "SLICE_ORIENTATION_YZ" << std::endl;
741           break;
742         }
743
744       // if it would be smaller than 150 by 100 then limit to 150 by 100
745       this->RenderWindow->SetSize(
746         xs < 150 ? 150 : xs, ys < 100 ? 100 : ys);
747
748       //      std::cout << "wxvtkImageViewer2::Render() : "<<xs<<"-"<<ys<<std::endl;
749       if (this->Renderer)
750         {
751         this->Renderer->ResetCamera();
752         this->Renderer->GetActiveCamera()->SetParallelScale(
753           xs < 150 ? 75 : (xs - 1 ) / 2.0);
754         }
755       this->FirstRender = 0;
756
757       }
758     }
759   if (this->GetInput())
760     {
761     this->RenderWindow->Render();
762     }
763 }
764
765 //----------------------------------------------------------------------------
766 const char* wxvtkImageViewer2::GetWindowName()
767 {
768   return this->RenderWindow->GetWindowName();
769 }
770
771 //----------------------------------------------------------------------------
772 void wxvtkImageViewer2::SetOffScreenRendering(int i)
773 {
774   this->RenderWindow->SetOffScreenRendering(i);
775 }
776
777 //----------------------------------------------------------------------------
778 int wxvtkImageViewer2::GetOffScreenRendering()
779 {
780   return this->RenderWindow->GetOffScreenRendering();
781 }
782
783 //----------------------------------------------------------------------------
784 void wxvtkImageViewer2::SetInput(vtkImageData *in)
785 {
786   //  std::cout << "### wxvtkImageViewer2::SetInput"<<std::endl;
787   this->WindowLevel->SetInput(in);
788   this->UpdateDisplayExtent();
789   // LG 03/12/08
790   //  FirstRender = 1;
791 }
792 //----------------------------------------------------------------------------
793 vtkImageData* wxvtkImageViewer2::GetInput()
794 {
795   return vtkImageData::SafeDownCast(this->WindowLevel->GetInput());
796 }
797
798 //----------------------------------------------------------------------------
799 void wxvtkImageViewer2::SetInputConnection(vtkAlgorithmOutput* input)
800 {
801   this->WindowLevel->SetInputConnection(input);
802   this->UpdateDisplayExtent();
803 }
804
805 //----------------------------------------------------------------------------
806 #ifndef VTK_LEGACY_REMOVE
807 int wxvtkImageViewer2::GetWholeZMin()
808 {
809   VTK_LEGACY_REPLACED_BODY(wxvtkImageViewer2::GetWholeZMin, "VTK 5.0",
810                            wxvtkImageViewer2::GetSliceMin);
811   return this->GetSliceMin();
812 }
813 int wxvtkImageViewer2::GetWholeZMax()
814 {
815   VTK_LEGACY_REPLACED_BODY(wxvtkImageViewer2::GetWholeZMax, "VTK 5.0",
816                            wxvtkImageViewer2::GetSliceMax);
817   return this->GetSliceMax();
818 }
819 int wxvtkImageViewer2::GetZSlice()
820 {
821   VTK_LEGACY_REPLACED_BODY(wxvtkImageViewer2::GetZSlice, "VTK 5.0",
822                            wxvtkImageViewer2::GetSlice);
823   return this->GetSlice();
824 }
825 void wxvtkImageViewer2::SetZSlice(int s)
826 {
827   VTK_LEGACY_REPLACED_BODY(wxvtkImageViewer2::SetZSlice, "VTK 5.0",
828                            wxvtkImageViewer2::SetSlice);
829   this->SetSlice(s);
830 }
831 #endif
832
833 //----------------------------------------------------------------------------
834 void wxvtkImageViewer2::PrintSelf(ostream& os, vtkIndent indent)
835 {
836   this->Superclass::PrintSelf(os, indent);
837
838   os << indent << "RenderWindow:\n";
839   this->RenderWindow->PrintSelf(os,indent.GetNextIndent());
840   os << indent << "Renderer:\n";
841   this->Renderer->PrintSelf(os,indent.GetNextIndent());
842   os << indent << "ImageActor:\n";
843   this->ImageActor->PrintSelf(os,indent.GetNextIndent());
844   os << indent << "WindowLevel:\n" << endl;
845   this->WindowLevel->PrintSelf(os,indent.GetNextIndent());
846   os << indent << "Slice: " << this->Slice << endl;
847   os << indent << "SliceOrientation: " << this->SliceOrientation << endl;
848   os << indent << "InteractorStyle: " << endl;
849   if (this->InteractorStyle)
850     {
851     os << "\n";
852     this->InteractorStyle->PrintSelf(os,indent.GetNextIndent());
853     }
854   else
855     {
856     os << "None";
857     }
858 }