vtkImageColorViewer.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkImageColorViewer - Display a 2D image.
// .SECTION Description
// vtkImageColorViewer is a convenience class for displaying a 2D image. It
// packages up the functionality found in vtkRenderWindow, vtkRenderer,
// vtkImageActor and vtkImageMapToWindowLevelColors into a single easy to use
// class. This class also creates an image interactor style
// (vtkInteractorStyleImage) that allows zooming and panning of images, and
// supports interactive window/level operations on the image. Note that
// vtkImageColorViewer is simply a wrapper around these classes.
//
// vtkImageColorViewer uses the 3D rendering and texture mapping engine
// to draw an image on a plane. This allows for rapid rendering,
// zooming, and panning. The image is placed in the 3D scene at a
// depth based on the z-coordinate of the particular image slice. Each
// call to SetSlice() changes the image data (slice) displayed AND
// changes the depth of the displayed slice in the 3D scene. This can
// be controlled by the AutoAdjustCameraClippingRange ivar of the
// InteractorStyle member.
//
// It is possible to mix images and geometry, using the methods:
//
// viewer->SetInput( myImage );
// viewer->GetRenderer()->AddActor( myActor );
//
// This can be used to annotate an image with a PolyData of "edges" or
// or highlight sections of an image or display a 3D isosurface
// with a slice from the volume, etc. Any portions of your geometry
// that are in front of the displayed slice will be visible; any
// portions of your geometry that are behind the displayed slice will
// be obscured. A more general framework (with respect to viewing
// direction) for achieving this effect is provided by the
// vtkImagePlaneWidget .
//
// Note that pressing 'r' will reset the window/level and pressing
// shift+'r' or control+'r' will reset the camera.
//
// .SECTION See Also
// vtkRenderWindow vtkRenderer vtkImageActor vtkImageMapToWindowLevelColors
#ifndef VTKIMAGECOLORVIEWER_H
#define VTKIMAGECOLORVIEWER_H
#include "vtkgdcmModule.h"
#include "vtkObject.h"
#include "vtkVersion.h"
class vtkAlgorithm;
class vtkAlgorithmOutput;
class vtkImageActor;
class vtkImageData;
class vtkImageMapToWindowLevelColors2;
class vtkInformation;
class vtkInteractorStyleImage;
class vtkRenderWindow;
class vtkRenderer;
class vtkRenderWindowInteractor;
class vtkPolyData;
class VTKGDCM_EXPORT vtkImageColorViewer : public vtkObject
{
public:
static vtkImageColorViewer *New();
vtkTypeMacro(vtkImageColorViewer,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the name of rendering window.
virtual const char *GetWindowName();
// Description:
// Render the resulting image.
virtual void Render(void);
// Description:
// Set/Get the input image to the viewer.
#if (VTK_MAJOR_VERSION >= 6)
virtual void SetInputData(vtkImageData *in);
#else
virtual void SetInput(vtkImageData *in);
#endif
virtual vtkImageData *GetInput();
virtual void SetInputConnection(vtkAlgorithmOutput* input);
virtual void AddInputConnection(vtkAlgorithmOutput* input);
virtual void AddInput(vtkImageData * input);
//virtual void AddInput(vtkPolyData * input);
double GetOverlayVisibility();
void SetOverlayVisibility(double vis);
// Description:
// Set/get the slice orientation
//BTX
enum
{
SLICE_ORIENTATION_YZ = 0,
SLICE_ORIENTATION_XZ = 1,
SLICE_ORIENTATION_XY = 2
};
//ETX
vtkGetMacro(SliceOrientation, int);
virtual void SetSliceOrientation(int orientation);
virtual void SetSliceOrientationToXY()
{ this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XY); };
virtual void SetSliceOrientationToYZ()
{ this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_YZ); };
virtual void SetSliceOrientationToXZ()
{ this->SetSliceOrientation(vtkImageColorViewer::SLICE_ORIENTATION_XZ); };
// Description:
// Set/Get the current slice to display (depending on the orientation
// this can be in X, Y or Z).
vtkGetMacro(Slice, int);
virtual void SetSlice(int s);
// Description:
// Update the display extent manually so that the proper slice for the
// given orientation is displayed. It will also try to set a
// reasonable camera clipping range.
// This method is called automatically when the Input is changed, but
// most of the time the input of this class is likely to remain the same,
// i.e. connected to the output of a filter, or an image reader. When the
// input of this filter or reader itself is changed, an error message might
// be displayed since the current display extent is probably outside
// the new whole extent. Calling this method will ensure that the display
// extent is reset properly.
virtual void UpdateDisplayExtent();
// Description:
// Return the minimum and maximum slice values (depending on the orientation
// this can be in X, Y or Z).
virtual int GetSliceMin();
virtual int GetSliceMax();
virtual void GetSliceRange(int range[2])
{ this->GetSliceRange(range[0], range[1]); }
virtual void GetSliceRange(int &min, int &max);
virtual int* GetSliceRange();
// Description:
// Set window and level for mapping pixels to colors.
virtual double GetColorWindow();
virtual double GetColorLevel();
virtual void SetColorWindow(double s);
virtual void SetColorLevel(double s);
// Description:
// These are here when using a Tk window.
virtual void SetDisplayId(void *a);
virtual void SetWindowId(void *a);
virtual void SetParentId(void *a);
// Description:
// Set/Get the position in screen coordinates of the rendering window.
virtual int* GetPosition();
virtual void SetPosition(int a,int b);
virtual void SetPosition(int a[2]) { this->SetPosition(a[0],a[1]); }
// Description:
// Set/Get the size of the window in screen coordinates in pixels.
virtual int* GetSize();
virtual void SetSize(int a, int b);
virtual void SetSize(int a[2]) { this->SetSize(a[0],a[1]); }
// Description:
// Get the internal render window, renderer, image actor, and
// image map instances.
vtkGetObjectMacro(RenderWindow,vtkRenderWindow);
vtkGetObjectMacro(Renderer, vtkRenderer);
vtkGetObjectMacro(ImageActor,vtkImageActor);
vtkGetObjectMacro(WindowLevel,vtkImageMapToWindowLevelColors2);
vtkGetObjectMacro(InteractorStyle,vtkInteractorStyleImage);
// Description:
// Set your own renderwindow and renderer
virtual void SetRenderWindow(vtkRenderWindow *arg);
virtual void SetRenderer(vtkRenderer *arg);
// Description:
// Attach an interactor for the internal render window.
virtual void SetupInteractor(vtkRenderWindowInteractor*);
// Description:
// Create a window in memory instead of on the screen. This may not
// be supported for every type of window and on some windows you may
// need to invoke this prior to the first render.
virtual void SetOffScreenRendering(int);
virtual int GetOffScreenRendering();
vtkBooleanMacro(OffScreenRendering,int);
protected:
vtkImageColorViewer();
~vtkImageColorViewer();
virtual void InstallPipeline();
virtual void UnInstallPipeline();
vtkImageMapToWindowLevelColors2 *WindowLevel;
vtkRenderWindow *RenderWindow;
vtkRenderer *Renderer;
vtkImageActor *ImageActor;
vtkImageActor *OverlayImageActor;
vtkRenderWindowInteractor *Interactor;
vtkInteractorStyleImage *InteractorStyle;
int SliceOrientation;
int FirstRender;
int Slice;
virtual void UpdateOrientation();
#if (VTK_MAJOR_VERSION >= 6)
vtkAlgorithm* GetInputAlgorithm();
vtkInformation* GetInputInformation();
#endif
friend class vtkImageColorViewerCallback;
private:
vtkImageColorViewer(const vtkImageColorViewer&); // Not implemented.
void operator=(const vtkImageColorViewer&); // Not implemented.
};
#endif
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(RenderWindow, vtkRenderWindow)
vtkImageColorViewer::GetOverlayVisibility
double GetOverlayVisibility()
vtkImageColorViewer::SetColorWindow
virtual void SetColorWindow(double s)
vtkImageColorViewer::SetInputConnection
virtual void SetInputConnection(vtkAlgorithmOutput *input)
vtkImageColorViewer::SetSliceOrientationToXZ
virtual void SetSliceOrientationToXZ()
Definition vtkImageColorViewer.h:119
vtkImageColorViewer::SetSliceOrientationToXY
virtual void SetSliceOrientationToXY()
Definition vtkImageColorViewer.h:115
vtkImageColorViewer::UnInstallPipeline
virtual void UnInstallPipeline()
vtkImageColorViewer::GetPosition
virtual int * GetPosition()
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(WindowLevel, vtkImageMapToWindowLevelColors2)
vtkImageColorViewer::SetWindowId
virtual void SetWindowId(void *a)
vtkImageColorViewer::GetSize
virtual int * GetSize()
vtkImageColorViewer::SLICE_ORIENTATION_XZ
@ SLICE_ORIENTATION_XZ
Definition vtkImageColorViewer.h:109
vtkImageColorViewer::SLICE_ORIENTATION_XY
@ SLICE_ORIENTATION_XY
Definition vtkImageColorViewer.h:110
vtkImageColorViewer::SLICE_ORIENTATION_YZ
@ SLICE_ORIENTATION_YZ
Definition vtkImageColorViewer.h:108
vtkImageColorViewer::SetOffScreenRendering
virtual void SetOffScreenRendering(int)
vtkImageColorViewer::vtkImageColorViewerCallback
friend class vtkImageColorViewerCallback
Definition vtkImageColorViewer.h:228
vtkImageColorViewer::Render
virtual void Render(void)
vtkImageColorViewer::vtkImageColorViewer
vtkImageColorViewer()
vtkImageColorViewer::vtkGetMacro
vtkGetMacro(SliceOrientation, int)
vtkImageColorViewer::InteractorStyle
vtkInteractorStyleImage * InteractorStyle
Definition vtkImageColorViewer.h:215
vtkImageColorViewer::GetWindowName
virtual const char * GetWindowName()
vtkImageColorViewer::AddInputConnection
virtual void AddInputConnection(vtkAlgorithmOutput *input)
vtkImageColorViewer::OverlayImageActor
vtkImageActor * OverlayImageActor
Definition vtkImageColorViewer.h:213
vtkImageColorViewer::AddInput
virtual void AddInput(vtkImageData *input)
vtkImageColorViewer::RenderWindow
vtkRenderWindow * RenderWindow
Definition vtkImageColorViewer.h:210
vtkImageColorViewer::SetSize
virtual void SetSize(int a[2])
Definition vtkImageColorViewer.h:174
vtkImageColorViewer::~vtkImageColorViewer
~vtkImageColorViewer()
vtkImageColorViewer::vtkBooleanMacro
vtkBooleanMacro(OffScreenRendering, int)
vtkImageColorViewer::SetSlice
virtual void SetSlice(int s)
vtkImageColorViewer::SetColorLevel
virtual void SetColorLevel(double s)
vtkImageColorViewer::WindowLevel
vtkImageMapToWindowLevelColors2 * WindowLevel
Definition vtkImageColorViewer.h:209
vtkImageColorViewer::SetRenderer
virtual void SetRenderer(vtkRenderer *arg)
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(ImageActor, vtkImageActor)
vtkImageColorViewer::Slice
int Slice
Definition vtkImageColorViewer.h:219
vtkImageColorViewer::GetColorLevel
virtual double GetColorLevel()
vtkImageColorViewer::SetInput
virtual void SetInput(vtkImageData *in)
vtkImageColorViewer::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkImageColorViewer::InstallPipeline
virtual void InstallPipeline()
vtkImageColorViewer::Interactor
vtkRenderWindowInteractor * Interactor
Definition vtkImageColorViewer.h:214
vtkImageColorViewer::SetRenderWindow
virtual void SetRenderWindow(vtkRenderWindow *arg)
vtkImageColorViewer::UpdateOrientation
virtual void UpdateOrientation()
vtkImageColorViewer::SetOverlayVisibility
void SetOverlayVisibility(double vis)
vtkImageColorViewer::SetPosition
virtual void SetPosition(int a, int b)
vtkImageColorViewer::vtkTypeMacro
vtkTypeMacro(vtkImageColorViewer, vtkObject)
vtkImageColorViewer::SetParentId
virtual void SetParentId(void *a)
vtkImageColorViewer::GetSliceRange
virtual int * GetSliceRange()
vtkImageColorViewer::GetInput
virtual vtkImageData * GetInput()
vtkImageColorViewer::Renderer
vtkRenderer * Renderer
Definition vtkImageColorViewer.h:211
vtkImageColorViewer::SetupInteractor
virtual void SetupInteractor(vtkRenderWindowInteractor *)
vtkImageColorViewer::SetSize
virtual void SetSize(int a, int b)
vtkImageColorViewer::GetOffScreenRendering
virtual int GetOffScreenRendering()
vtkImageColorViewer::ImageActor
vtkImageActor * ImageActor
Definition vtkImageColorViewer.h:212
vtkImageColorViewer::SetSliceOrientationToYZ
virtual void SetSliceOrientationToYZ()
Definition vtkImageColorViewer.h:117
vtkImageColorViewer::GetSliceMin
virtual int GetSliceMin()
vtkImageColorViewer::GetSliceRange
virtual void GetSliceRange(int &min, int &max)
vtkImageColorViewer::UpdateDisplayExtent
virtual void UpdateDisplayExtent()
vtkImageColorViewer::FirstRender
int FirstRender
Definition vtkImageColorViewer.h:218
vtkImageColorViewer::New
static vtkImageColorViewer * New()
vtkImageColorViewer::SliceOrientation
int SliceOrientation
Definition vtkImageColorViewer.h:217
vtkImageColorViewer::vtkGetMacro
vtkGetMacro(Slice, int)
vtkImageColorViewer::GetSliceMax
virtual int GetSliceMax()
vtkImageColorViewer::SetDisplayId
virtual void SetDisplayId(void *a)
vtkImageColorViewer::GetSliceRange
virtual void GetSliceRange(int range[2])
Definition vtkImageColorViewer.h:146
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(InteractorStyle, vtkInteractorStyleImage)
vtkImageColorViewer::SetPosition
virtual void SetPosition(int a[2])
Definition vtkImageColorViewer.h:168
vtkImageColorViewer::SetSliceOrientation
virtual void SetSliceOrientation(int orientation)
vtkImageColorViewer::vtkGetObjectMacro
vtkGetObjectMacro(Renderer, vtkRenderer)
vtkImageColorViewer::GetColorWindow
virtual double GetColorWindow()
vtkImageMapToWindowLevelColors2
Definition vtkImageMapToWindowLevelColors2.h:50