#ifndef _vtkViewImage2D_h_ #define _vtkViewImage2D_h_ #include #include "vtkViewImage.h" class vtkImageActor; class vtkProp; class vtkActor; class vtkLineSource; class vtkTextMapper; class vtkImageReslice; class vtkImageMapToWindowLevelColors; class vtkImageMapToColors; class vtkTransform; class vtkAlgorithmOutput; class vtkImageBlendWithMask; class vtkImageBlend; class vtkLookupTable; class vtkScalarsToColors; class vtkColorTransferFunction; class vtkInteractorStyleImage2D; class vtkDataSet; class vtkPolyDataMapper; class vtkProperty; class vtkCutter; class vtkPlane; class vtkBox; class vtkBoxCutPolyLines; class vtkDataSetMapper; class vtkColorTransferFunction; /** \class vtkViewImage2D vtkViewImage2D.h "vtkViewImage2D.h" \brief 3D image 2D slice viewer \author Pierre Fillard & Marc Traina & Nicolas Toussaint This class allows to view 2D slices of 3D images. Images have to be vtkImageData. It also handles a (unsigned char) mask image, or an overlapping image */ class VTK_EXPORT vtkViewImage2D : public vtkViewImage { public: static vtkViewImage2D* New(); vtkTypeRevisionMacro(vtkViewImage2D, vtkViewImage); //BTX enum InteractionStyleIds { NO_INTERACTION, SELECT_INTERACTION, WINDOW_LEVEL_INTERACTION, FULL_PAGE_INTERACTION, MEASURE_INTERACTION, ZOOM_INTERACTION }; //ETX // from wxVtkViewImage2D /** Update the the display parameters based on the data information. */ virtual void Update(); void PrintSelf(ostream& os, vtkIndent indent); void SetShowDirections(bool p_showDirections); vtkGetMacro (ShowDirections, bool); //bool GetShowDirections(); void SetShowCurrentPoint(bool p_showCurrentPoint); vtkGetMacro (ShowCurrentPoint, bool); //bool GetShowCurrentPoint(); void SetShowSliceNumber(bool p_showSliceNumber); vtkGetMacro (ShowSliceNumber, bool); //bool GetShowSliceNumber(); void Show2DAxis(const bool&); /** Set the current image */ virtual void SetImage(vtkImageData* image); /** Return the vtkImageActor of the view */ vtkGetObjectMacro (ImageActor, vtkImageActor); /** Set a transform to apply to visualize the image. */ void SetTransform(vtkTransform* p_transform); /** Set the orientation of the image @param orientation 0 is XY, 1 is ZY, 2 is XZ */ void SetOrientation(unsigned int orientation); /** Get the orientation of the current image */ vtkGetMacro (Orientation, unsigned int); /** Get the id of the first slice available relative to the current orientation. */ int GetWholeZMin(); /** Get the id of the last slice available relative to the current orientation. */ int GetWholeZMax(); /** Get the current slice. Z is relative to the displayed plan. */ int GetZSlice(); void SetZSlice(int p_slice); /** Set/Get window/level for mapping pixels to colors. */ virtual double GetColorWindow(); /** Set/Get window/level for mapping pixels to colors. */ virtual double GetColorLevel(); /** Set/Get window/level for mapping pixels to colors. */ virtual void SetWindow (double); /** Set/Get window/level for mapping pixels to colors. */ virtual void SetLevel (double); vtkGetObjectMacro (WindowLevel, vtkImageMapToColors); vtkGetObjectMacro (ImageReslice, vtkImageReslice); /** Set/Get the interpolation method (1 or 0). */ void SetInterpolationMode(int i); /** Set/Get the interpolation method (1 or 0). */ int GetInterpolationMode(void); /** Set the user interaction type..*/ vtkSetMacro (LeftButtonInteractionStyle, unsigned int); vtkGetMacro (LeftButtonInteractionStyle, unsigned int); vtkSetMacro (RightButtonInteractionStyle, unsigned int); vtkGetMacro (RightButtonInteractionStyle, unsigned int); vtkSetMacro (MiddleButtonInteractionStyle, unsigned int); vtkGetMacro (MiddleButtonInteractionStyle, unsigned int); vtkSetMacro (WheelInteractionStyle, unsigned int); vtkGetMacro (WheelInteractionStyle, unsigned int); //vtkSetMacro (InteractionStyle, unsigned int); void SetInteractionStyle (const unsigned int& style) { this->SetLeftButtonInteractionStyle (style); this->SetMiddleButtonInteractionStyle (style); this->SetRightButtonInteractionStyle (style); this->SetWheelInteractionStyle (style); } vtkGetMacro (InteractionStyle, unsigned int); /** Setup full interaction on the view (Windowing, zoom, reset ...). */ void SetFullInteraction(void); /** Set a mask image and its corresponding LookupTable */ void SetMaskImage (vtkImageData* mask, vtkLookupTable* lut); vtkGetObjectMacro (MaskImage, vtkImageData); /** Remove the mask image (if any) */ void RemoveMaskImage (void); /** Set an overlapping second image */ void SetOverlappingImage (vtkImageData* image); vtkGetObjectMacro (OverlappingImage, vtkImageData); /** Remove the overlapping image (if any) */ void RemoveOverlappingImage (void); /** Set/Get a user-defined look-up table */ virtual void SetLookupTable (vtkScalarsToColors* lut); /* updates the position of the image (Overridden method). */ virtual void UpdatePosition (); virtual void SetVisibility (int state); virtual int GetVisibility (void); /** Add a dataset to the view. The dataset will be display as its intersection with the displayed image slice, i.e., tetrahedron will be displayed as triangles, triangles as lines, lines as points. A vtkProperty can be specified to change the freshly generated actor properties. */ virtual vtkActor* AddDataSet (vtkDataSet* dataset, vtkProperty* property = NULL); /** This method is similar to AddDataSet(), except it only works on vtkPolyData. It cuts the polydata using 2 planes defined by the current image slice being visualized and a user-provided thickness (spacing between the 2 planes). For instance, it works nicely with lines: AddDataSet() turns lines into points while AddPolyData() displays lines as lines. */ virtual vtkActor* SyncAddPolyData (vtkPolyData* polydata, vtkProperty* property = NULL, double thickness = 0.2); virtual vtkActor* AddPolyData (vtkPolyData* polydata, vtkProperty* property = NULL, double thickness = 0.2); virtual void SetZoom (double factor); protected: vtkViewImage2D(); ~vtkViewImage2D(); /// Initialize rendering parameters only once. m_FirstRender controls if the /// initialization has been done or not void InitializeImagePositionAndSize(void); private: void InitInteractorStyle(unsigned int p_style); // Update data information and set the update and display extents. // Reset the camera position. void UpdateImageActor(); /// this is the mask image vtkImageData* MaskImage; /// internal use: image to input to the mask filter or image blender vtkImageData* AuxInput; /// internal use: image to input to the reslicer vtkImageData* ResliceInput; /// overlapping image vtkImageData* OverlappingImage; /// to map the image to the current window level vtkImageMapToWindowLevelColors* WindowLevelForCorner; vtkImageMapToColors* WindowLevel; /// vtkImageReslice is the swiss-army-knife of image geometry filters: It can /// permute, rotate, flip, scale, resample, deform, and pad image data in any /// combination with reasonably high efficiency. vtkImageReslice* ImageReslice; // mask filter vtkImageBlendWithMask* MaskFilter; // image blender vtkImageBlend* Blender; /// actors and mappers: vtkImageActor* ImageActor; vtkActor* HorizontalLineActor; vtkLineSource* HorizontalLineSource; vtkActor* VerticalLineActor; vtkLineSource* VerticalLineSource; int FirstRender; bool ShowCurrentPoint; bool ShowDirections; bool ShowSliceNumber; /// Orientation: 0 is XY, 1 is ZY, 2 is XZ unsigned int Orientation; /// Current 2D position of the mouse within the view //float m_2DPosition[2]; unsigned int InteractionStyle; vtkPlane* DataSetCutPlane; vtkBox* DataSetCutBox; double BoxThickness; unsigned int LeftButtonInteractionStyle; unsigned int RightButtonInteractionStyle; unsigned int MiddleButtonInteractionStyle; unsigned int WheelInteractionStyle; }; #endif /* _vtkViewImage2D_h_ */