GDCM 2.2.1

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

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