GDCM 2.0.17
|
00001 /*========================================================================= 00002 00003 Program: GDCM (Grassroots DICOM). A DICOM library 00004 Module: $URL$ 00005 00006 Copyright (c) 2006-2010 Mathieu Malaterre 00007 All rights reserved. 00008 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 // .NAME vtkImageColorViewer - Display a 2D image. 00016 // .SECTION Description 00017 // vtkImageColorViewer is a convenience class for displaying a 2D image. It 00018 // packages up the functionality found in vtkRenderWindow, vtkRenderer, 00019 // vtkImageActor and vtkImageMapToWindowLevelColors into a single easy to use 00020 // class. This class also creates an image interactor style 00021 // (vtkInteractorStyleImage) that allows zooming and panning of images, and 00022 // supports interactive window/level operations on the image. Note that 00023 // vtkImageColorViewer is simply a wrapper around these classes. 00024 // 00025 // vtkImageColorViewer uses the 3D rendering and texture mapping engine 00026 // to draw an image on a plane. This allows for rapid rendering, 00027 // zooming, and panning. The image is placed in the 3D scene at a 00028 // depth based on the z-coordinate of the particular image slice. Each 00029 // call to SetSlice() changes the image data (slice) displayed AND 00030 // changes the depth of the displayed slice in the 3D scene. This can 00031 // be controlled by the AutoAdjustCameraClippingRange ivar of the 00032 // InteractorStyle member. 00033 // 00034 // It is possible to mix images and geometry, using the methods: 00035 // 00036 // viewer->SetInput( myImage ); 00037 // viewer->GetRenderer()->AddActor( myActor ); 00038 // 00039 // This can be used to annotate an image with a PolyData of "edges" or 00040 // or highlight sections of an image or display a 3D isosurface 00041 // with a slice from the volume, etc. Any portions of your geometry 00042 // that are in front of the displayed slice will be visible; any 00043 // portions of your geometry that are behind the displayed slice will 00044 // be obscured. A more general framework (with respect to viewing 00045 // direction) for achieving this effect is provided by the 00046 // vtkImagePlaneWidget . 00047 // 00048 // Note that pressing 'r' will reset the window/level and pressing 00049 // shift+'r' or control+'r' will reset the camera. 00050 // 00051 // .SECTION See Also 00052 // vtkRenderWindow vtkRenderer vtkImageActor vtkImageMapToWindowLevelColors 00053 00054 #ifndef VTKIMAGECOLORVIEWER_H 00055 #define VTKIMAGECOLORVIEWER_H 00056 00057 #include "vtkObject.h" 00058 00059 class vtkAlgorithmOutput; 00060 class vtkImageActor; 00061 class vtkImageData; 00062 class vtkImageMapToWindowLevelColors2; 00063 class vtkInteractorStyleImage; 00064 class vtkRenderWindow; 00065 class vtkRenderer; 00066 class vtkRenderWindowInteractor; 00067 class vtkPolyData; 00068 00069 class VTK_EXPORT vtkImageColorViewer : public vtkObject 00070 { 00071 public: 00072 static vtkImageColorViewer *New(); 00073 vtkTypeRevisionMacro(vtkImageColorViewer,vtkObject); 00074 void PrintSelf(ostream& os, vtkIndent indent); 00075 00076 // Description: 00077 // Get the name of rendering window. 00078 virtual const char *GetWindowName(); 00079 00080 // Description: 00081 // Render the resulting image. 00082 virtual void Render(void); 00083 00084 // Description: 00085 // Set/Get the input image to the viewer. 00086 virtual void SetInput(vtkImageData *in); 00087 virtual vtkImageData *GetInput(); 00088 virtual void SetInputConnection(vtkAlgorithmOutput* input); 00089 virtual void AddInputConnection(vtkAlgorithmOutput* input); 00090 virtual void AddInput(vtkImageData * input); 00091 //virtual void AddInput(vtkPolyData * input); 00092 00093 double GetOverlayVisibility(); 00094 void SetOverlayVisibility(double vis); 00095 00096 // Description: 00097 // Set/get the slice orientation 00098 //BTX 00099 enum 00100 { 00101 SLICE_ORIENTATION_YZ = 0, 00102 SLICE_ORIENTATION_XZ = 1, 00103 SLICE_ORIENTATION_XY = 2 00104 }; 00105 //ETX 00106 vtkGetMacro(SliceOrientation, int); 00107 virtual void SetSliceOrientation(int orientation); 00108 virtual void SetSliceOrientationToXY() 00109 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); }; 00110 virtual void SetSliceOrientationToYZ() 00111 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); }; 00112 virtual void SetSliceOrientationToXZ() 00113 { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XZ); }; 00114 00115 // Description: 00116 // Set/Get the current slice to display (depending on the orientation 00117 // this can be in X, Y or Z). 00118 vtkGetMacro(Slice, int); 00119 virtual void SetSlice(int s); 00120 00121 // Description: 00122 // Update the display extent manually so that the proper slice for the 00123 // given orientation is displayed. It will also try to set a 00124 // reasonable camera clipping range. 00125 // This method is called automatically when the Input is changed, but 00126 // most of the time the input of this class is likely to remain the same, 00127 // i.e. connected to the output of a filter, or an image reader. When the 00128 // input of this filter or reader itself is changed, an error message might 00129 // be displayed since the current display extent is probably outside 00130 // the new whole extent. Calling this method will ensure that the display 00131 // extent is reset properly. 00132 virtual void UpdateDisplayExtent(); 00133 00134 // Description: 00135 // Return the minimum and maximum slice values (depending on the orientation 00136 // this can be in X, Y or Z). 00137 virtual int GetSliceMin(); 00138 virtual int GetSliceMax(); 00139 virtual void GetSliceRange(int range[2]) 00140 { this->GetSliceRange(range[0], range[1]); } 00141 virtual void GetSliceRange(int &min, int &max); 00142 virtual int* GetSliceRange(); 00143 00144 // Description: 00145 // Set window and level for mapping pixels to colors. 00146 virtual double GetColorWindow(); 00147 virtual double GetColorLevel(); 00148 virtual void SetColorWindow(double s); 00149 virtual void SetColorLevel(double s); 00150 00151 // Description: 00152 // These are here when using a Tk window. 00153 virtual void SetDisplayId(void *a); 00154 virtual void SetWindowId(void *a); 00155 virtual void SetParentId(void *a); 00156 00157 // Description: 00158 // Set/Get the position in screen coordinates of the rendering window. 00159 virtual int* GetPosition(); 00160 virtual void SetPosition(int a,int b); 00161 virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); } 00162 00163 // Description: 00164 // Set/Get the size of the window in screen coordinates in pixels. 00165 virtual int* GetSize(); 00166 virtual void SetSize(int a, int b); 00167 virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); } 00168 00169 // Description: 00170 // Get the internal render window, renderer, image actor, and 00171 // image map instances. 00172 vtkGetObjectMacro(RenderWindow,vtkRenderWindow); 00173 vtkGetObjectMacro(Renderer, vtkRenderer); 00174 vtkGetObjectMacro(ImageActor,vtkImageActor); 00175 vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors2); 00176 vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage); 00177 00178 // Description: 00179 // Set your own renderwindow and renderer 00180 virtual void SetRenderWindow(vtkRenderWindow *arg); 00181 virtual void SetRenderer(vtkRenderer *arg); 00182 00183 // Description: 00184 // Attach an interactor for the internal render window. 00185 virtual void SetupInteractor(vtkRenderWindowInteractor*); 00186 00187 // Description: 00188 // Create a window in memory instead of on the screen. This may not 00189 // be supported for every type of window and on some windows you may 00190 // need to invoke this prior to the first render. 00191 virtual void SetOffScreenRendering(int); 00192 virtual int GetOffScreenRendering(); 00193 vtkBooleanMacro(OffScreenRendering,int); 00194 00195 // Description: 00196 // @deprecated Replaced by vtkImageColorViewer::GetSliceMin() as of VTK 5.0. 00197 VTK_LEGACY(int GetWholeZMin()); 00198 00199 // Description: 00200 // @deprecated Replaced by vtkImageColorViewer::GetSliceMax() as of VTK 5.0. 00201 VTK_LEGACY(int GetWholeZMax()); 00202 00203 // Description: 00204 // @deprecated Replaced by vtkImageColorViewer::GetSlice() as of VTK 5.0. 00205 VTK_LEGACY(int GetZSlice()); 00206 00207 // Description: 00208 // @deprecated Replaced by vtkImageColorViewer::SetSlice() as of VTK 5.0. 00209 VTK_LEGACY(void SetZSlice(int)); 00210 00211 protected: 00212 vtkImageColorViewer(); 00213 ~vtkImageColorViewer(); 00214 00215 virtual void InstallPipeline(); 00216 virtual void UnInstallPipeline(); 00217 00218 vtkImageMapToWindowLevelColors2 *WindowLevel; 00219 vtkRenderWindow *RenderWindow; 00220 vtkRenderer *Renderer; 00221 vtkImageActor *ImageActor; 00222 vtkImageActor *OverlayImageActor; 00223 vtkRenderWindowInteractor *Interactor; 00224 vtkInteractorStyleImage *InteractorStyle; 00225 00226 int SliceOrientation; 00227 int FirstRender; 00228 int Slice; 00229 00230 virtual void UpdateOrientation(); 00231 00232 private: 00233 vtkImageColorViewer(const vtkImageColorViewer&); // Not implemented. 00234 void operator=(const vtkImageColorViewer&); // Not implemented. 00235 }; 00236 00237 #endif