#ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ #include #include #include #include #include #include #include #include #include #include #include #include #include #include // ------------------------------------------------------------------------- class vtkAlgorithmOutput; class vtkImageData; class vtkLookupTable; class vtkRenderer; // ------------------------------------------------------------------------- namespace cpExtensions { namespace Visualization { /** */ class cpExtensions_EXPORT ImageSliceActors : public vtkPropCollection { public: typedef ImageSliceActors Self; typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle; typedef cpExtensions::Interaction::ImageInteractorStyle TStyle; typedef void ( *TSlicesCommand )( double*, int, void* ); typedef void ( *TWindowLevelCommand )( double, double, void* ); typedef TBaseStyle::TMouseCommand TMouseCommand; typedef TBaseStyle::TMouseWheelCommand TMouseWheelCommand; typedef TBaseStyle::TKeyCommand TKeyCommand; typedef TBaseStyle::TVoidCommand TVoidCommand; public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); public: // Creation static ImageSliceActors* New( ); void AddSlicesCommand( TSlicesCommand command, void* data ); void AddWindowLevelCommand( TWindowLevelCommand command, void* data ); void AddRenderCommand( TVoidCommand command, void* data ); void RemoveSlicesCommand( TSlicesCommand command ); void RemoveWindowLevelCommand( TWindowLevelCommand command ); void RemoveRenderCommand( TVoidCommand command ); void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 ); void AddInputData( vtkImageData* data, int axis = 2 ); void Clear( ); void AssociateSlice( Self* slice ); vtkImageData* GetInputImage( unsigned int id ); const vtkImageData* GetInputImage( unsigned int id ) const; vtkInteractorStyle* GetStyle( ); const vtkInteractorStyle* GetStyle( ) const; void PushActorsInto( vtkRenderWindow* window, bool force_style = true ); void PopActorsFrom( vtkRenderWindow* window ); unsigned int GetNumberOfImageActors( ) const; vtkImageActor* GetImageActor( unsigned int id ); const vtkImageActor* GetImageActor( unsigned int id ) const; vtkTextActor* GetTextActor( ); const vtkTextActor* GetTextActor( ) const; vtkActor* GetPlaneActor( ); const vtkActor* GetPlaneActor( ) const; vtkPlane* GetPlaneFunction( ); const vtkPlane* GetPlaneFunction( ) const; void SetInterpolate( bool v ); void InterpolateOn( ); void InterpolateOff( ); double* GetDisplayBounds( ) const; void GetDisplayBounds( double bounds[ 6 ] ) const; void ResetCursor( ); void SetCursor( double pos[ 3 ] ); vtkImageMapToColors* GetImageMap( unsigned int id ); const vtkImageMapToColors* GetImageMap( unsigned int id ) const; double GetMinWindow( ) const; double GetMaxWindow( ) const; double GetMinLevel( ) const; double GetMaxLevel( ) const; double GetWindow( ) const; double GetLevel( ) const; void SetWindow( double w ); void SetLevel( double l ); void SetWindowLevel( double w, double l ); void ResetWindowLevel( ); void SetLookupTable( unsigned int id, vtkLookupTable* lut ); void SetLookupTableAsColor( unsigned int id, double r, double g, double b ); int GetAxis( ) const; int GetSliceNumber( ) const; int GetSliceNumberMinValue( ) const; int GetSliceNumberMaxValue( ) const; void SetSliceNumber( const int& slice ); void SetSlice( double* pos ); void UpdateText( ); void UpdateText( double pos[ 3 ] ); void UpdateText( const double& w, const double& l ); void Render( ); void ResetCamera( ); protected: ImageSliceActors( ); virtual ~ImageSliceActors( ); void _ConfigureStyle( ); void _ConfigureNewLUT( vtkImageData* data ); void _ConfigureNewInput( int axis ); // Events static void _MouseMoveCommand( void* data, const TBaseStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); static void _MouseClickCommand( void* data, const TBaseStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); static void _MouseWheelCommand( void* data, const int& dir, bool alt, bool ctr, bool sft ); static void _KeyCommand( void* data, const char& key ); private: // Purposely not implemented ImageSliceActors( const Self& ); Self& operator=( const Self& ); protected: vtkSmartPointer< TStyle > m_Style; vtkRenderWindow* m_Window; // Multiple actors std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps; std::vector< vtkSmartPointer< vtkImageSliceMapper > > m_SliceMappers; std::vector< vtkSmartPointer< vtkImageActor > > m_ImageActors; bool m_Interpolate; // Associated slices std::vector< Self* > m_AssociatedSlices; // Window-Level values double m_MinWindow, m_MaxWindow; double m_MinLevel, m_MaxLevel; // Associated commands std::map< TSlicesCommand, void* > m_SlicesCommands; std::map< TWindowLevelCommand, void* > m_WindowLevelCommands; std::map< TVoidCommand, void* > m_RenderCommands; // Unique objects vtkSmartPointer< vtkPolyData > m_Cursor; vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper; vtkSmartPointer< vtkActor > m_CursorActor; vtkSmartPointer< vtkPlane > m_PlaneFunction; vtkSmartPointer< vtkPolyData > m_Plane; vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper; char m_TextBuffer[ 1024 ]; vtkSmartPointer< vtkTextActor > m_TextActor; vtkSmartPointer< vtkActor > m_PlaneActor; double m_StartWindowLevelPos[ 3 ]; double m_StartWindowLevel[ 2 ]; }; } // ecapseman } // ecapseman #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ // eof - $RCSfile$