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

Generated on Fri Sep 25 2015 17:58:25 for GDCM by doxygen 1.8.9.1
SourceForge.net Logo