]> Creatis software - gdcm.git/blob - vtk/vtkImageColorViewer.h
Fix mistypings
[gdcm.git] / vtk / vtkImageColorViewer.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkImageColorViewer.h,v $
5   Date:      $Date: 2008/01/28 09:26:24 $
6   Version:   $Revision: 1.3 $
7   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8   All rights reserved.
9   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10
11      This software is distributed WITHOUT ANY WARRANTY; without even
12      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13      PURPOSE.  See the above copyright notice for more information.
14
15 =========================================================================*/
16 // .NAME vtkImageColorViewer - Display a 2D image.
17 // .SECTION Description
18 // vtkImageColorViewer is a convenience class for displaying a 2D image.  It
19 // packages up the functionality found in vtkRenderWindow, vtkRenderer,
20 // vtkImageActor and vtkImageMapToWindowLevelColors into a single easy to use
21 // class.  This class also creates an image interactor style
22 // (vtkInteractorStyleImage) that allows zooming and panning of images, and
23 // supports interactive window/level operations on the image. Note that
24 // vtkImageColorViewer is simply a wrapper around these classes.
25 //
26 // vtkImageColorViewer uses the 3D rendering and texture mapping engine
27 // to draw an image on a plane.  This allows for rapid rendering,
28 // zooming, and panning. The image is placed in the 3D scene at a
29 // depth based on the z-coordinate of the particular image slice. Each
30 // call to SetSlice() changes the image data (slice) displayed AND
31 // changes the depth of the displayed slice in the 3D scene. This can
32 // be controlled by the AutoAdjustCameraClippingRange ivar of the
33 // InteractorStyle member.
34 //
35 // It is possible to mix images and geometry, using the methods:
36 //
37 // viewer->SetInput( myImage );
38 // viewer->GetRenderer()->AddActor( myActor );
39 //
40 // This can be used to annotate an image with a PolyData of "edges" or
41 // or highlight sections of an image or display a 3D isosurface
42 // with a slice from the volume, etc. Any portions of your geometry
43 // that are in front of the displayed slice will be visible; any
44 // portions of your geometry that are behind the displayed slice will
45 // be obscured. A more general framework (with respect to viewing
46 // direction) for achieving this effect is provided by the
47 // vtkImagePlaneWidget .
48 //
49 // Note that pressing 'r' will reset the window/level and pressing
50 // shift+'r' or control+'r' will reset the camera.
51 //
52 // .SECTION See Also
53 // vtkRenderWindow vtkRenderer vtkImageActor vtkImageMapToWindowLevelColors
54
55 #ifndef __vtkImageColorViewer_h
56 #define __vtkImageColorViewer_h
57
58 #include "vtkObject.h"
59
60 class vtkAlgorithmOutput;
61 class vtkImageActor;
62 class vtkImageData;
63 class vtkImageMapToWindowLevelColors2;
64 class vtkInteractorStyleImage;
65 class vtkRenderWindow;
66 class vtkRenderer;
67 class vtkRenderWindowInteractor;
68
69 class VTK_EXPORT vtkImageColorViewer : public vtkObject 
70 {
71 public:
72   static vtkImageColorViewer *New();
73   vtkTypeRevisionMacro(vtkImageColorViewer,vtkObject);
74   void PrintSelf(ostream& os, vtkIndent indent);
75
76   // Description:
77   // Get the name of rendering window.
78   virtual const char *GetWindowName();
79
80   // Description:
81   // Render the resulting image.
82   virtual void Render(void);
83   
84   // Description:
85   // Set/Get the input image to the viewer.
86   virtual void SetInput(vtkImageData *in);
87   virtual vtkImageData *GetInput();
88   virtual void SetInputConnection(vtkAlgorithmOutput* input);
89   
90   // Description:
91   // Set/get the slice orientation
92   //BTX
93   enum
94   {
95     SLICE_ORIENTATION_YZ = 0,
96     SLICE_ORIENTATION_XZ = 1,
97     SLICE_ORIENTATION_XY = 2
98   };
99   //ETX
100   vtkGetMacro(SliceOrientation, int);
101   virtual void SetSliceOrientation(int orientation);
102   virtual void SetSliceOrientationToXY()
103     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); };
104   virtual void SetSliceOrientationToYZ()
105     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); };
106   virtual void SetSliceOrientationToXZ()
107     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XZ); };
108
109   // Description:
110   // Set/Get the current slice to display (depending on the orientation
111   // this can be in X, Y or Z).
112   vtkGetMacro(Slice, int);
113   virtual void SetSlice(int s);
114
115   // Description:
116   // Update the display extent manually so that the proper slice for the
117   // given orientation is displayed. It will also try to set a
118   // reasonable camera clipping range.
119   // This method is called automatically when the Input is changed, but
120   // most of the time the input of this class is likely to remain the same,
121   // i.e. connected to the output of a filter, or an image reader. When the
122   // input of this filter or reader itself is changed, an error message might
123   // be displayed since the current display extent is probably outside
124   // the new whole extent. Calling this method will ensure that the display
125   // extent is reset properly.
126   virtual void UpdateDisplayExtent();
127   
128   // Description:
129   // Return the minimum and maximum slice values (depending on the orientation
130   // this can be in X, Y or Z).
131   virtual int GetSliceMin();
132   virtual int GetSliceMax();
133   virtual void GetSliceRange(int range[2])
134     { this->GetSliceRange(range[0], range[1]); }
135   virtual void GetSliceRange(int &min, int &max);
136   virtual int* GetSliceRange();
137   
138   // Description:
139   // Set window and level for mapping pixels to colors.
140   virtual double GetColorWindow();
141   virtual double GetColorLevel();
142   virtual void SetColorWindow(double s);
143   virtual void SetColorLevel(double s);
144
145   // Description:
146   // These are here when using a Tk window.
147   virtual void SetDisplayId(void *a);
148   virtual void SetWindowId(void *a);
149   virtual void SetParentId(void *a);
150   
151   // Description:
152   // Set/Get the position in screen coordinates of the rendering window.
153   virtual int* GetPosition();
154   virtual void SetPosition(int a,int b);
155   virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); }
156   
157   // Description:
158   // Set/Get the size of the window in screen coordinates in pixels.
159   virtual int* GetSize();
160   virtual void SetSize(int a, int b);
161   virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); }
162   
163   // Description:
164   // Get the internal render window, renderer, image actor, and
165   // image map instances.
166   vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
167   vtkGetObjectMacro(Renderer, vtkRenderer);
168   vtkGetObjectMacro(ImageActor,vtkImageActor);
169   vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors2);
170   vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage);
171   
172   // Description:
173   // Set your own renderwindow and renderer
174   virtual void SetRenderWindow(vtkRenderWindow *arg);
175   virtual void SetRenderer(vtkRenderer *arg);
176
177   // Description:
178   // Attach an interactor for the internal render window.
179   virtual void SetupInteractor(vtkRenderWindowInteractor*);
180   
181   // Description:  
182   // Create a window in memory instead of on the screen. This may not
183   // be supported for every type of window and on some windows you may
184   // need to invoke this prior to the first render.
185   virtual void SetOffScreenRendering(int);
186   virtual int GetOffScreenRendering();
187   vtkBooleanMacro(OffScreenRendering,int);
188
189   // Description:
190   // @deprecated Replaced by vtkImageColorViewer::GetSliceMin() as of VTK 5.0.
191   VTK_LEGACY(int GetWholeZMin());
192
193   // Description:
194   // @deprecated Replaced by vtkImageColorViewer::GetSliceMax() as of VTK 5.0.
195   VTK_LEGACY(int GetWholeZMax());
196
197   // Description:
198   // @deprecated Replaced by vtkImageColorViewer::GetSlice() as of VTK 5.0.
199   VTK_LEGACY(int GetZSlice());
200
201   // Description:
202   // @deprecated Replaced by vtkImageColorViewer::SetSlice() as of VTK 5.0.
203   VTK_LEGACY(void SetZSlice(int));
204
205 protected:
206   vtkImageColorViewer();
207   ~vtkImageColorViewer();
208
209   virtual void InstallPipeline();
210   virtual void UnInstallPipeline();
211
212   vtkImageMapToWindowLevelColors2  *WindowLevel;
213   vtkRenderWindow                 *RenderWindow;
214   vtkRenderer                     *Renderer;
215   vtkImageActor                   *ImageActor;
216   vtkRenderWindowInteractor       *Interactor;
217   vtkInteractorStyleImage         *InteractorStyle;
218
219   int SliceOrientation;
220   int FirstRender;
221   int Slice;
222
223   virtual void UpdateOrientation();
224
225 private:
226   vtkImageColorViewer(const vtkImageColorViewer&);  // Not implemented.
227   void operator=(const vtkImageColorViewer&);  // Not implemented.
228 };
229
230 #endif
231
232