]> Creatis software - bbtk.git/blob - packages/wxvtk/src/wxvtkImageViewer2.h
969b658fd25715e16dbe4f8a286afce3e0314477
[bbtk.git] / packages / wxvtk / src / wxvtkImageViewer2.h
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.h,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 // .NAME wxvtkImageViewer2 - Display a 2D image.
43 // .SECTION Description
44 // wxvtkImageViewer2 is a convenience class for displaying a 2D image.  It
45 // packages up the functionality found in vtkRenderWindow, vtkRenderer,
46 // vtkImageActor and vtkImageMapToWindowLevelColors into a single easy to use
47 // class.  This class also creates an image interactor style
48 // (vtkInteractorStyleImage) that allows zooming and panning of images, and
49 // supports interactive window/level operations on the image. Note that
50 // wxvtkImageViewer2 is simply a wrapper around these classes.
51 //
52 // wxvtkImageViewer2 uses the 3D rendering and texture mapping engine
53 // to draw an image on a plane.  This allows for rapid rendering,
54 // zooming, and panning. The image is placed in the 3D scene at a
55 // depth based on the z-coordinate of the particular image slice. Each
56 // call to SetSlice() changes the image data (slice) displayed AND
57 // changes the depth of the displayed slice in the 3D scene. This can
58 // be controlled by the AutoAdjustCameraClippingRange ivar of the
59 // InteractorStyle member.
60 //
61 // It is possible to mix images and geometry, using the methods:
62 //
63 // viewer->SetInput( myImage );
64 // viewer->GetRenderer()->AddActor( myActor );
65 //
66 // This can be used to annotate an image with a PolyData of "edges" or
67 // or highlight sections of an image or display a 3D isosurface
68 // with a slice from the volume, etc. Any portions of your geometry
69 // that are in front of the displayed slice will be visible; any
70 // portions of your geometry that are behind the displayed slice will
71 // be obscured. A more general framework (with respect to viewing
72 // direction) for achieving this effect is provided by the
73 // vtkImagePlaneWidget .
74 //
75 // Note that pressing 'r' will reset the window/level and pressing
76 // shift+'r' or control+'r' will reset the camera.
77 //
78 // .SECTION See Also
79 // vtkRenderWindow vtkRenderer vtkImageActor vtkImageMapToWindowLevelColors
80
81 #ifndef __wxvtkImageViewer2_h
82 #define __wxvtkImageViewer2_h
83
84 #include "vtkVersion.h"
85 #include "vtkObject.h"
86
87 class vtkAlgorithmOutput;
88 class vtkImageActor;
89 class vtkImageData;
90 class vtkImageMapToWindowLevelColors;
91 class vtkInteractorStyleImage;
92 class vtkRenderWindow;
93 class vtkRenderer;
94 class vtkRenderWindowInteractor;
95
96 class /*VTK_RENDERING_EXPORT*/ wxvtkImageViewer2 : public vtkObject 
97 {
98 public:
99   static wxvtkImageViewer2 *New();
100
101 //EED 2017-01-01 Migration VTK7
102 #if VTK_MAJOR_VERSION <= 5
103   vtkTypeRevisionMacro(wxvtkImageViewer2,vtkObject);
104 #else
105   vtkTypeMacro(wxvtkImageViewer2,vtkObject);
106 #endif
107
108   void PrintSelf(ostream& os, vtkIndent indent);
109
110   // Description:
111   // Get the name of rendering window.
112   virtual const char *GetWindowName();
113
114   // Description:
115   // Render the resulting image.
116   virtual void Render(void);
117   
118   // Description:
119   // Set/Get the input image to the viewer.
120   virtual void SetInput(vtkImageData *in);
121   virtual vtkImageData *GetInput();
122   virtual void SetInputConnection(vtkAlgorithmOutput* input);
123   
124   // Description:
125   // Set/get the slice orientation
126   //BTX
127   enum
128   {
129     SLICE_ORIENTATION_YZ = 0,
130     SLICE_ORIENTATION_XZ = 1,
131     SLICE_ORIENTATION_XY = 2
132   };
133   //ETX
134   vtkGetMacro(SliceOrientation, int);
135   virtual void SetSliceOrientation(int orientation);
136   virtual void SetSliceOrientationToXY()
137     { this->SetSliceOrientation(wxvtkImageViewer2::SLICE_ORIENTATION_XY); };
138   virtual void SetSliceOrientationToYZ()
139     { this->SetSliceOrientation(wxvtkImageViewer2::SLICE_ORIENTATION_YZ); };
140   virtual void SetSliceOrientationToXZ()
141     { this->SetSliceOrientation(wxvtkImageViewer2::SLICE_ORIENTATION_XZ); };
142
143   // Description:
144   // Set/Get the current slice to display (depending on the orientation
145   // this can be in X, Y or Z).
146   vtkGetMacro(Slice, int);
147   virtual void SetSlice(int s);
148
149   // Description:
150   // Update the display extent manually so that the proper slice for the
151   // given orientation is displayed. It will also try to set a
152   // reasonable camera clipping range.
153   // This method is called automatically when the Input is changed, but
154   // most of the time the input of this class is likely to remain the same,
155   // i.e. connected to the output of a filter, or an image reader. When the
156   // input of this filter or reader itself is changed, an error message might
157   // be displayed since the current display extent is probably outside
158   // the new whole extent. Calling this method will ensure that the display
159   // extent is reset properly.
160   virtual void UpdateDisplayExtent();
161   
162   // Description:
163   // Return the minimum and maximum slice values (depending on the orientation
164   // this can be in X, Y or Z).
165   virtual int GetSliceMin();
166   virtual int GetSliceMax();
167   virtual void GetSliceRange(int range[2])
168         { 
169                 this->GetSliceRange(range[0], range[1]); 
170         }
171   virtual void GetSliceRange(int &min, int &max);
172   virtual int* GetSliceRange();
173   
174   // Description:
175   // Set window and level for mapping pixels to colors.
176   virtual double GetColorWindow();
177   virtual double GetColorLevel();
178   virtual void SetColorWindow(double s);
179   virtual void SetColorLevel(double s);
180
181   // Description:
182   // These are here when using a Tk window.
183   virtual void SetDisplayId(void *a);
184   virtual void SetWindowId(void *a);
185   virtual void SetParentId(void *a);
186   
187   // Description:
188   // Set/Get the position in screen coordinates of the rendering window.
189   virtual int* GetPosition();
190   virtual void SetPosition(int a,int b);
191   virtual void SetPosition(int a[2]) 
192         { 
193                 this->SetPosition(a[0],a[1]); 
194         }
195   
196   // Description:
197   // Set/Get the size of the window in screen coordinates in pixels.
198   virtual int* GetSize();
199   virtual void SetSize(int a, int b);
200   virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); }
201   
202   // Description:
203   // Get the internal render window, renderer, image actor, and
204   // image map instances.
205   vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
206   vtkGetObjectMacro(Renderer, vtkRenderer);
207   vtkGetObjectMacro(ImageActor,vtkImageActor);
208   vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors);
209   vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage);
210   
211   // Description:
212   // Set your own renderwindow and renderer
213   virtual void SetRenderWindow(vtkRenderWindow *arg);
214   virtual void SetRenderer(vtkRenderer *arg);
215
216   // Description:
217   // Attach an interactor for the internal render window.
218   virtual void SetupInteractor(vtkRenderWindowInteractor*);
219   
220   // Description:  
221   // Create a window in memory instead of on the screen. This may not
222   // be supported for every type of window and on some windows you may
223   // need to invoke this prior to the first render.
224   virtual void SetOffScreenRendering(int);
225   virtual int GetOffScreenRendering();
226   vtkBooleanMacro(OffScreenRendering,int);
227
228   // Description:
229   // @deprecated Replaced by wxvtkImageViewer2::GetSliceMin() as of VTK 5.0.
230   VTK_LEGACY(int GetWholeZMin());
231
232   // Description:
233   // @deprecated Replaced by wxvtkImageViewer2::GetSliceMax() as of VTK 5.0.
234   VTK_LEGACY(int GetWholeZMax());
235
236   // Description:
237   // @deprecated Replaced by wxvtkImageViewer2::GetSlice() as of VTK 5.0.
238   VTK_LEGACY(int GetZSlice());
239
240   // Description:
241   // @deprecated Replaced by wxvtkImageViewer2::SetSlice() as of VTK 5.0.
242   VTK_LEGACY(void SetZSlice(int));
243
244 protected:
245   wxvtkImageViewer2();
246   ~wxvtkImageViewer2();
247
248   virtual void InstallPipeline();
249   virtual void UnInstallPipeline();
250
251   vtkImageMapToWindowLevelColors  *WindowLevel;
252   vtkRenderWindow                 *RenderWindow;
253   vtkRenderer                     *Renderer;
254   vtkImageActor                   *ImageActor;
255   vtkRenderWindowInteractor       *Interactor;
256   vtkInteractorStyleImage         *InteractorStyle;
257
258   int SliceOrientation;
259   int FirstRender;
260   int Slice;
261
262   virtual void UpdateOrientation();
263
264 private:
265   wxvtkImageViewer2(const wxvtkImageViewer2&);  // Not implemented.
266   void operator=(const wxvtkImageViewer2&);  // Not implemented.
267 };
268
269 #endif
270
271