GDCM 2.2.0

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

- File List
- File Members

vtkImageColorViewer.h
Go to the documentation of this file.

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