GDCM 3.0.24
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;
65class vtkInformation;
66class vtkInteractorStyleImage;
67class vtkRenderWindow;
68class vtkRenderer;
69class vtkRenderWindowInteractor;
70class vtkPolyData;
71
72class VTKGDCM_EXPORT vtkImageColorViewer : public vtkObject
73{
74public:
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
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);
116 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); };
118 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); };
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);
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);
200 vtkBooleanMacro(OffScreenRendering,int);
201
202protected:
205
206 virtual void InstallPipeline();
207 virtual void UnInstallPipeline();
208
210 vtkRenderWindow *RenderWindow;
211 vtkRenderer *Renderer;
212 vtkImageActor *ImageActor;
213 vtkImageActor *OverlayImageActor;
214 vtkRenderWindowInteractor *Interactor;
215 vtkInteractorStyleImage *InteractorStyle;
216
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
Definition vtkImageColorViewer.h:73
vtkGetObjectMacro(RenderWindow, vtkRenderWindow)
double GetOverlayVisibility()
virtual void SetColorWindow(double s)
virtual void SetInputConnection(vtkAlgorithmOutput *input)
virtual void SetSliceOrientationToXZ()
Definition vtkImageColorViewer.h:119
virtual void SetSliceOrientationToXY()
Definition vtkImageColorViewer.h:115
virtual void UnInstallPipeline()
virtual int * GetPosition()
vtkGetObjectMacro(WindowLevel, vtkImageMapToWindowLevelColors2)
virtual void SetWindowId(void *a)
virtual int * GetSize()
virtual void SetOffScreenRendering(int)
virtual void Render(void)
vtkGetMacro(SliceOrientation, int)
vtkInteractorStyleImage * InteractorStyle
Definition vtkImageColorViewer.h:215
virtual const char * GetWindowName()
@ SLICE_ORIENTATION_XZ
Definition vtkImageColorViewer.h:109
@ SLICE_ORIENTATION_XY
Definition vtkImageColorViewer.h:110
@ SLICE_ORIENTATION_YZ
Definition vtkImageColorViewer.h:108
virtual void AddInputConnection(vtkAlgorithmOutput *input)
vtkImageActor * OverlayImageActor
Definition vtkImageColorViewer.h:213
virtual void AddInput(vtkImageData *input)
vtkRenderWindow * RenderWindow
Definition vtkImageColorViewer.h:210
virtual void SetSize(int a[2])
Definition vtkImageColorViewer.h:174
vtkBooleanMacro(OffScreenRendering, int)
virtual void SetSlice(int s)
virtual void SetColorLevel(double s)
vtkImageMapToWindowLevelColors2 * WindowLevel
Definition vtkImageColorViewer.h:209
virtual void SetRenderer(vtkRenderer *arg)
vtkGetObjectMacro(ImageActor, vtkImageActor)
int Slice
Definition vtkImageColorViewer.h:219
virtual double GetColorLevel()
virtual void SetInput(vtkImageData *in)
void PrintSelf(ostream &os, vtkIndent indent)
virtual void InstallPipeline()
vtkRenderWindowInteractor * Interactor
Definition vtkImageColorViewer.h:214
virtual void SetRenderWindow(vtkRenderWindow *arg)
virtual void UpdateOrientation()
void SetOverlayVisibility(double vis)
virtual void SetPosition(int a, int b)
vtkTypeMacro(vtkImageColorViewer, vtkObject)
virtual void SetParentId(void *a)
virtual int * GetSliceRange()
virtual vtkImageData * GetInput()
vtkRenderer * Renderer
Definition vtkImageColorViewer.h:211
virtual void SetupInteractor(vtkRenderWindowInteractor *)
virtual void SetSize(int a, int b)
virtual int GetOffScreenRendering()
vtkImageActor * ImageActor
Definition vtkImageColorViewer.h:212
virtual void SetSliceOrientationToYZ()
Definition vtkImageColorViewer.h:117
virtual int GetSliceMin()
virtual void GetSliceRange(int &min, int &max)
virtual void UpdateDisplayExtent()
int FirstRender
Definition vtkImageColorViewer.h:218
static vtkImageColorViewer * New()
int SliceOrientation
Definition vtkImageColorViewer.h:217
vtkGetMacro(Slice, int)
virtual int GetSliceMax()
virtual void SetDisplayId(void *a)
virtual void GetSliceRange(int range[2])
Definition vtkImageColorViewer.h:146
vtkGetObjectMacro(InteractorStyle, vtkInteractorStyleImage)
virtual void SetPosition(int a[2])
Definition vtkImageColorViewer.h:168
virtual void SetSliceOrientation(int orientation)
vtkGetObjectMacro(Renderer, vtkRenderer)
virtual double GetColorWindow()
Definition vtkImageMapToWindowLevelColors2.h:50