GDCM: vtkImageColorViewer.h Source File

GDCM 3.2.10

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 "vtkgdcmModule.h"
57#include "vtkObject.h"
58#include "vtkVersion.h"
59
60class vtkAlgorithm;
61class vtkAlgorithmOutput;
62class vtkImageActor;
63class vtkImageData;
64class vtkImageMapToWindowLevelColors2;
65class vtkInformation;
66class vtkInteractorStyleImage;
67class vtkRenderWindow;
68class vtkRenderer;
69class vtkRenderWindowInteractor;
70class vtkPolyData;
71
72 class VTKGDCM_EXPORT vtkImageColorViewer : public vtkObject
73{
74public:
75 static vtkImageColorViewer *New();
76 vtkTypeMacro(vtkImageColorViewer,vtkObject);
77 void PrintSelf(ostream& os, vtkIndent indent);
78
79 // Description:
80 // Get the name of rendering window.
81 virtual const char *GetWindowName();
82
83 // Description:
84 // Render the resulting image.
85 virtual void Render(void);
86
87 // Description:
88 // Set/Get the input image to the viewer.
89#if (VTK_MAJOR_VERSION >= 6)
90 virtual void SetInputData(vtkImageData *in);
91#else
92 virtual void SetInput(vtkImageData *in);
93#endif
94 virtual vtkImageData *GetInput();
95 virtual void SetInputConnection(vtkAlgorithmOutput* input);
96 virtual void AddInputConnection(vtkAlgorithmOutput* input);
97 virtual void AddInput(vtkImageData * input);
98 //virtual void AddInput(vtkPolyData * input);
99
100 double GetOverlayVisibility();
101 void SetOverlayVisibility(double vis);
102
103 // Description:
104 // Set/get the slice orientation
105 //BTX
106 enum
107 {
108 SLICE_ORIENTATION_YZ = 0,
109 SLICE_ORIENTATION_XZ = 1,
110 SLICE_ORIENTATION_XY = 2
111 };
112 //ETX
113 vtkGetMacro(SliceOrientation, int);
114 virtual void SetSliceOrientation(int orientation);
115 virtual void SetSliceOrientationToXY()
116 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); };
117 virtual void SetSliceOrientationToYZ()
118 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); };
119 virtual void SetSliceOrientationToXZ()
120 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XZ); };
121
122 // Description:
123 // Set/Get the current slice to display (depending on the orientation
124 // this can be in X, Y or Z).
125 vtkGetMacro(Slice, int);
126 virtual void SetSlice(int s);
127
128 // Description:
129 // Update the display extent manually so that the proper slice for the
130 // given orientation is displayed. It will also try to set a
131 // reasonable camera clipping range.
132 // This method is called automatically when the Input is changed, but
133 // most of the time the input of this class is likely to remain the same,
134 // i.e. connected to the output of a filter, or an image reader. When the
135 // input of this filter or reader itself is changed, an error message might
136 // be displayed since the current display extent is probably outside
137 // the new whole extent. Calling this method will ensure that the display
138 // extent is reset properly.
139 virtual void UpdateDisplayExtent();
140
141 // Description:
142 // Return the minimum and maximum slice values (depending on the orientation
143 // this can be in X, Y or Z).
144 virtual int GetSliceMin();
145 virtual int GetSliceMax();
146 virtual void GetSliceRange(int range[2])
147 { this->GetSliceRange(range[0], range[1]); }
148 virtual void GetSliceRange(int &min, int &max);
149 virtual int* GetSliceRange();
150
151 // Description:
152 // Set window and level for mapping pixels to colors.
153 virtual double GetColorWindow();
154 virtual double GetColorLevel();
155 virtual void SetColorWindow(double s);
156 virtual void SetColorLevel(double s);
157
158 // Description:
159 // These are here when using a Tk window.
160 virtual void SetDisplayId(void *a);
161 virtual void SetWindowId(void *a);
162 virtual void SetParentId(void *a);
163
164 // Description:
165 // Set/Get the position in screen coordinates of the rendering window.
166 virtual int* GetPosition();
167 virtual void SetPosition(int a,int b);
168 virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); }
169
170 // Description:
171 // Set/Get the size of the window in screen coordinates in pixels.
172 virtual int* GetSize();
173 virtual void SetSize(int a, int b);
174 virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); }
175
176 // Description:
177 // Get the internal render window, renderer, image actor, and
178 // image map instances.
179 vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
180 vtkGetObjectMacro(Renderer, vtkRenderer);
181 vtkGetObjectMacro(ImageActor,vtkImageActor);
182 vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors2);
183 vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage);
184
185 // Description:
186 // Set your own renderwindow and renderer
187 virtual void SetRenderWindow(vtkRenderWindow *arg);
188 virtual void SetRenderer(vtkRenderer *arg);
189
190 // Description:
191 // Attach an interactor for the internal render window.
192 virtual void SetupInteractor(vtkRenderWindowInteractor*);
193
194 // Description:
195 // Create a window in memory instead of on the screen. This may not
196 // be supported for every type of window and on some windows you may
197 // need to invoke this prior to the first render.
198 virtual void SetOffScreenRendering(int);
199 virtual int GetOffScreenRendering();
200 vtkBooleanMacro(OffScreenRendering,int);
201
202protected:
203 vtkImageColorViewer();
204 ~vtkImageColorViewer();
205
206 virtual void InstallPipeline();
207 virtual void UnInstallPipeline();
208
209 vtkImageMapToWindowLevelColors2 *WindowLevel;
210 vtkRenderWindow *RenderWindow;
211 vtkRenderer *Renderer;
212 vtkImageActor *ImageActor;
213 vtkImageActor *OverlayImageActor;
214 vtkRenderWindowInteractor *Interactor;
215 vtkInteractorStyleImage *InteractorStyle;
216
217 int SliceOrientation;
218 int FirstRender;
219 int Slice;
220
221 virtual void UpdateOrientation();
222
223#if (VTK_MAJOR_VERSION >= 6)
224 vtkAlgorithm* GetInputAlgorithm();
225 vtkInformation* GetInputInformation();
226#endif
227
228 friend class vtkImageColorViewerCallback;
229
230private:
231 vtkImageColorViewer(const vtkImageColorViewer&); // Not implemented.
232 void operator=(const vtkImageColorViewer&); // Not implemented.
233};
234
235#endif
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(RenderWindow, vtkRenderWindow)
vtkImageColorViewer::GetOverlayVisibility
double GetOverlayVisibility()
vtkImageColorViewer::SetColorWindow
virtual void SetColorWindow(double s)
vtkImageColorViewer::SetInputConnection
virtual void SetInputConnection(vtkAlgorithmOutput *input)
vtkImageColorViewer::SetSliceOrientationToXZ
virtual void SetSliceOrientationToXZ()
Definition vtkImageColorViewer.h:119
vtkImageColorViewer::SetSliceOrientationToXY
virtual void SetSliceOrientationToXY()
Definition vtkImageColorViewer.h:115
vtkImageColorViewer::UnInstallPipeline
virtual void UnInstallPipeline()
vtkImageColorViewer::GetPosition
virtual int * GetPosition()
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(WindowLevel, vtkImageMapToWindowLevelColors2)
vtkImageColorViewer::SetWindowId
virtual void SetWindowId(void *a)
vtkImageColorViewer::GetSize
virtual int * GetSize()
vtkImageColorViewer::SetOffScreenRendering
virtual void SetOffScreenRendering(int)
vtkImageColorViewer::vtkImageColorViewerCallback
friend class vtkImageColorViewerCallback
Definition vtkImageColorViewer.h:228
vtkImageColorViewer::Render
virtual void Render(void)
vtkImageColorViewer::vtkImageColorViewer
vtkImageColorViewer()
vtkImageColorViewer::vtkGetMacro
vtkGetMacro(SliceOrientation, int)
vtkImageColorViewer::InteractorStyle
vtkInteractorStyleImage * InteractorStyle
Definition vtkImageColorViewer.h:215
vtkImageColorViewer::GetWindowName
virtual const char * GetWindowName()
vtkImageColorViewer::AddInputConnection
virtual void AddInputConnection(vtkAlgorithmOutput *input)
vtkImageColorViewer::OverlayImageActor
vtkImageActor * OverlayImageActor
Definition vtkImageColorViewer.h:213
vtkImageColorViewer::AddInput
virtual void AddInput(vtkImageData *input)
vtkImageColorViewer::RenderWindow
vtkRenderWindow * RenderWindow
Definition vtkImageColorViewer.h:210
vtkImageColorViewer::SetSize
virtual void SetSize(int a[2])
Definition vtkImageColorViewer.h:174
vtkImageColorViewer::~vtkImageColorViewer
~vtkImageColorViewer()
vtkImageColorViewer::vtkBooleanMacro
vtkBooleanMacro(OffScreenRendering, int)
vtkImageColorViewer::SetSlice
virtual void SetSlice(int s)
vtkImageColorViewer::SetColorLevel
virtual void SetColorLevel(double s)
vtkImageColorViewer::WindowLevel
vtkImageMapToWindowLevelColors2 * WindowLevel
Definition vtkImageColorViewer.h:209
vtkImageColorViewer::SetRenderer
virtual void SetRenderer(vtkRenderer *arg)
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(ImageActor, vtkImageActor)
vtkImageColorViewer::Slice
int Slice
Definition vtkImageColorViewer.h:219
vtkImageColorViewer::GetColorLevel
virtual double GetColorLevel()
vtkImageColorViewer::SetInput
virtual void SetInput(vtkImageData *in)
vtkImageColorViewer::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkImageColorViewer::SLICE_ORIENTATION_XZ
@ SLICE_ORIENTATION_XZ
Definition vtkImageColorViewer.h:109
vtkImageColorViewer::SLICE_ORIENTATION_XY
@ SLICE_ORIENTATION_XY
Definition vtkImageColorViewer.h:110
vtkImageColorViewer::SLICE_ORIENTATION_YZ
@ SLICE_ORIENTATION_YZ
Definition vtkImageColorViewer.h:108
vtkImageColorViewer::InstallPipeline
virtual void InstallPipeline()
vtkImageColorViewer::Interactor
vtkRenderWindowInteractor * Interactor
Definition vtkImageColorViewer.h:214
vtkImageColorViewer::SetRenderWindow
virtual void SetRenderWindow(vtkRenderWindow *arg)
vtkImageColorViewer::UpdateOrientation
virtual void UpdateOrientation()
vtkImageColorViewer::SetOverlayVisibility
void SetOverlayVisibility(double vis)
vtkImageColorViewer::SetPosition
virtual void SetPosition(int a, int b)
vtkImageColorViewer::vtkTypeMacro
vtkTypeMacro(vtkImageColorViewer, vtkObject)
vtkImageColorViewer::SetParentId
virtual void SetParentId(void *a)
vtkImageColorViewer::GetSliceRange
virtual int * GetSliceRange()
vtkImageColorViewer::GetInput
virtual vtkImageData * GetInput()
vtkImageColorViewer::Renderer
vtkRenderer * Renderer
Definition vtkImageColorViewer.h:211
vtkImageColorViewer::SetupInteractor
virtual void SetupInteractor(vtkRenderWindowInteractor *)
vtkImageColorViewer::SetSize
virtual void SetSize(int a, int b)
vtkImageColorViewer::GetOffScreenRendering
virtual int GetOffScreenRendering()
vtkImageColorViewer::ImageActor
vtkImageActor * ImageActor
Definition vtkImageColorViewer.h:212
vtkImageColorViewer::SetSliceOrientationToYZ
virtual void SetSliceOrientationToYZ()
Definition vtkImageColorViewer.h:117
vtkImageColorViewer::GetSliceMin
virtual int GetSliceMin()
vtkImageColorViewer::GetSliceRange
virtual void GetSliceRange(int &min, int &max)
vtkImageColorViewer::UpdateDisplayExtent
virtual void UpdateDisplayExtent()
vtkImageColorViewer::FirstRender
int FirstRender
Definition vtkImageColorViewer.h:218
vtkImageColorViewer::New
static vtkImageColorViewer * New()
vtkImageColorViewer::SliceOrientation
int SliceOrientation
Definition vtkImageColorViewer.h:217
vtkImageColorViewer::vtkGetMacro
vtkGetMacro(Slice, int)
vtkImageColorViewer::GetSliceMax
virtual int GetSliceMax()
vtkImageColorViewer::SetDisplayId
virtual void SetDisplayId(void *a)
vtkImageColorViewer::GetSliceRange
virtual void GetSliceRange(int range[2])
Definition vtkImageColorViewer.h:146
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(InteractorStyle, vtkInteractorStyleImage)
vtkImageColorViewer::SetPosition
virtual void SetPosition(int a[2])
Definition vtkImageColorViewer.h:168
vtkImageColorViewer::SetSliceOrientation
virtual void SetSliceOrientation(int orientation)
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(Renderer, vtkRenderer)
vtkImageColorViewer::GetColorWindow
virtual double GetColorWindow()
vtkImageMapToWindowLevelColors2
Definition vtkImageMapToWindowLevelColors2.h:50