# vtkImageColorViewer.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkImageColorViewer.h,v $
    00005
    00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
    00007   All rights reserved.
    00008   See Copyright.txt or http://www.kitware.com/Copyright.htm 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 #include "gdcmTypes.h" // GDCM_EXPORT
    00059
    00060 class vtkAlgorithmOutput;
    00061 class vtkImageActor;
    00062 class vtkImageData;
    00063 class vtkImageMapToWindowLevelColors2;
    00064 class vtkInteractorStyleImage;
    00065 class vtkRenderWindow;
    00066 class vtkRenderer;
    00067 class vtkRenderWindowInteractor;
    00068 class vtkPolyData;
    00069
    00070 class GDCM_EXPORT vtkImageColorViewer : public vtkObject
    00071 {
    00072 public:
    00073   static vtkImageColorViewer *New();
    00074   vtkTypeRevisionMacro(vtkImageColorViewer,vtkObject);
    00075   void PrintSelf(ostream& os, vtkIndent indent);
    00076
    00077   // Description:
    00078   // Get the name of rendering window.
    00079   virtual const char *GetWindowName();
    00080
    00081   // Description:
    00082   // Render the resulting image.
    00083   virtual void Render(void);
    00084
    00085   // Description:
    00086   // Set/Get the input image to the viewer.
    00087   virtual void SetInput(vtkImageData *in);
    00088   virtual vtkImageData *GetInput();
    00089   virtual void SetInputConnection(vtkAlgorithmOutput* input);
    00090   virtual void AddInputConnection(vtkAlgorithmOutput* input);
    00091   virtual void AddInput(vtkImageData * input);
    00092   //virtual void AddInput(vtkPolyData * input);
    00093
    00094   double GetOverlayVisibility();
    00095   void SetOverlayVisibility(double vis);
    00096
    00097   // Description:
    00098   // Set/get the slice orientation
    00099   //BTX
    00100   enum
    00101   {
    00102     SLICE_ORIENTATION_YZ = 0,
    00103     SLICE_ORIENTATION_XZ = 1,
    00104     SLICE_ORIENTATION_XY = 2
    00105   };
    00106   //ETX
    00107   vtkGetMacro(SliceOrientation, int);
    00108   virtual void SetSliceOrientation(int orientation);
    00109   virtual void SetSliceOrientationToXY()
    00110     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); };
    00111   virtual void SetSliceOrientationToYZ()
    00112     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); };
    00113   virtual void SetSliceOrientationToXZ()
    00114     { this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XZ); };
    00115
    00116   // Description:
    00117   // Set/Get the current slice to display (depending on the orientation
    00118   // this can be in X, Y or Z).
    00119   vtkGetMacro(Slice, int);
    00120   virtual void SetSlice(int s);
    00121
    00122   // Description:
    00123   // Update the display extent manually so that the proper slice for the
    00124   // given orientation is displayed. It will also try to set a
    00125   // reasonable camera clipping range.
    00126   // This method is called automatically when the Input is changed, but
    00127   // most of the time the input of this class is likely to remain the same,
    00128   // i.e. connected to the output of a filter, or an image reader. When the
    00129   // input of this filter or reader itself is changed, an error message might
    00130   // be displayed since the current display extent is probably outside
    00131   // the new whole extent. Calling this method will ensure that the display
    00132   // extent is reset properly.
    00133   virtual void UpdateDisplayExtent();
    00134
    00135   // Description:
    00136   // Return the minimum and maximum slice values (depending on the orientation
    00137   // this can be in X, Y or Z).
    00138   virtual int GetSliceMin();
    00139   virtual int GetSliceMax();
    00140   virtual void GetSliceRange(int range[2])
    00141     { this->GetSliceRange(range[0], range[1]); }
    00142   virtual void GetSliceRange(int &min, int &max);
    00143   virtual int* GetSliceRange();
    00144
    00145   // Description:
    00146   // Set window and level for mapping pixels to colors.
    00147   virtual double GetColorWindow();
    00148   virtual double GetColorLevel();
    00149   virtual void SetColorWindow(double s);
    00150   virtual void SetColorLevel(double s);
    00151
    00152   // Description:
    00153   // These are here when using a Tk window.
    00154   virtual void SetDisplayId(void *a);
    00155   virtual void SetWindowId(void *a);
    00156   virtual void SetParentId(void *a);
    00157
    00158   // Description:
    00159   // Set/Get the position in screen coordinates of the rendering window.
    00160   virtual int* GetPosition();
    00161   virtual void SetPosition(int a,int b);
    00162   virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); }
    00163
    00164   // Description:
    00165   // Set/Get the size of the window in screen coordinates in pixels.
    00166   virtual int* GetSize();
    00167   virtual void SetSize(int a, int b);
    00168   virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); }
    00169
    00170   // Description:
    00171   // Get the internal render window, renderer, image actor, and
    00172   // image map instances.
    00173   vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
    00174   vtkGetObjectMacro(Renderer, vtkRenderer);
    00175   vtkGetObjectMacro(ImageActor,vtkImageActor);
    00176   vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors2);
    00177   vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage);
    00178
    00179   // Description:
    00180   // Set your own renderwindow and renderer
    00181   virtual void SetRenderWindow(vtkRenderWindow *arg);
    00182   virtual void SetRenderer(vtkRenderer *arg);
    00183
    00184   // Description:
    00185   // Attach an interactor for the internal render window.
    00186   virtual void SetupInteractor(vtkRenderWindowInteractor*);
    00187
    00188   // Description:
    00189   // Create a window in memory instead of on the screen. This may not
    00190   // be supported for every type of window and on some windows you may
    00191   // need to invoke this prior to the first render.
    00192   virtual void SetOffScreenRendering(int);
    00193   virtual int GetOffScreenRendering();
    00194   vtkBooleanMacro(OffScreenRendering,int);
    00195
    00196   // Description:
    00197   // @deprecated Replaced by vtkImageColorViewer::GetSliceMin() as of VTK 5.0.
    00198   VTK_LEGACY(int GetWholeZMin());
    00199
    00200   // Description:
    00201   // @deprecated Replaced by vtkImageColorViewer::GetSliceMax() as of VTK 5.0.
    00202   VTK_LEGACY(int GetWholeZMax());
    00203
    00204   // Description:
    00205   // @deprecated Replaced by vtkImageColorViewer::GetSlice() as of VTK 5.0.
    00206   VTK_LEGACY(int GetZSlice());
    00207
    00208   // Description:
    00209   // @deprecated Replaced by vtkImageColorViewer::SetSlice() as of VTK 5.0.
    00210   VTK_LEGACY(void SetZSlice(int));
    00211
    00212 protected:
    00213   vtkImageColorViewer();
    00214   ~vtkImageColorViewer();
    00215
    00216   virtual void InstallPipeline();
    00217   virtual void UnInstallPipeline();
    00218
    00219   vtkImageMapToWindowLevelColors2  *WindowLevel;
    00220   vtkRenderWindow                 *RenderWindow;
    00221   vtkRenderer                     *Renderer;
    00222   vtkImageActor                   *ImageActor;
    00223   vtkImageActor                   *OverlayImageActor;
    00224   vtkRenderWindowInteractor       *Interactor;
    00225   vtkInteractorStyleImage         *InteractorStyle;
    00226
    00227   int SliceOrientation;
    00228   int FirstRender;
    00229   int Slice;
    00230
    00231   virtual void UpdateOrientation();
    00232
    00233 private:
    00234   vtkImageColorViewer(const vtkImageColorViewer&);  // Not implemented.
    00235   void operator=(const vtkImageColorViewer&);  // Not implemented.
    00236 };
    00237
    00238 #endif
    00239
    00240