X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FImageSliceActors.h;h=b4cec90e6fec8e3c7a3c8f28b4eb74c49fb5b717;hb=b6c7e73ebcce23619daced67f85d9e1364b33f30;hp=6c7d40547deac4957c3a3de3a3e46f9d26ff6826;hpb=fdd4f2cec18107de380ebd350cb1019eed7c294c;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index 6c7d405..b4cec90 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -3,14 +3,11 @@ #include -#include -#include - #include #include #include -#include #include +#include #include #include #include @@ -18,11 +15,13 @@ #include #include +#include // ------------------------------------------------------------------------- class vtkAlgorithmOutput; class vtkImageData; class vtkLookupTable; +class vtkRenderer; // ------------------------------------------------------------------------- namespace cpExtensions @@ -37,42 +36,64 @@ namespace cpExtensions public: typedef ImageSliceActors Self; - typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle; typedef cpExtensions::Interaction::ImageInteractorStyle TStyle; + typedef TStyle::TMouseCommand TMouseCommand; + typedef TStyle::TMouseWheelCommand TMouseWheelCommand; + typedef TStyle::TKeyCommand TKeyCommand; + typedef TStyle::TVoidCommand TVoidCommand; + typedef TStyle::TMouseMoveCommand TMouseMoveCommand; + typedef TStyle::TMouseClickCommand TMouseClickCommand; + typedef TStyle::TMouseDoubleClickCommand TMouseDoubleClickCommand; + typedef TStyle::TExposeCommand TExposeCommand; + typedef TStyle::TConfigureCommand TConfigureCommand; + typedef TStyle::TEnterCommand TEnterCommand; + typedef TStyle::TLeaveCommand TLeaveCommand; 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; + typedef TVoidCommand TRenderCommand; + + typedef cpExtensions::Visualization::ImageBlender TBlender; public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); + cpExtensions_BaseInteractorStyle_Commands( Slices ); + cpExtensions_BaseInteractorStyle_Commands( WindowLevel ); + cpExtensions_BaseInteractorStyle_Commands( Render ); + public: // Creation static ImageSliceActors* New( ); - void AddSlicesCommand( TSlicesCommand command, void* data ); - void AddWindowLevelCommand( TWindowLevelCommand command, void* data ); - void AddRenderCommand( TVoidCommand command, void* data ); + void SetAxis( int axis ); + void SetInputConnection( vtkAlgorithmOutput* aout ); + void SetInputImage( vtkImageData* data ); + int AddBinaryConnection( + vtkAlgorithmOutput* aout, + const double& r, const double& g, const double& b + ); + int AddBinaryImage( + vtkImageData* data, + const double& r, const double& g, const double& b + ); + void Clear( ); - void RemoveSlicesCommand( TSlicesCommand command ); - void RemoveWindowLevelCommand( TWindowLevelCommand command ); - void RemoveRenderCommand( TVoidCommand command ); + void AssociateSlice( Self* slice ); - void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 ); - void AddInputData( vtkImageData* data, int axis = 2 ); - void Clear( ); + vtkImageData* GetInputImage( ); + const vtkImageData* GetInputImage( ) 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; + unsigned int GetNumberOfImages( ) const; + + vtkImageActor* GetImageActor( ); + const vtkImageActor* GetImageActor( ) const; + vtkImageActor* GetBinaryActor( ); + const vtkImageActor* GetBinaryActor( ) const; vtkTextActor* GetTextActor( ); const vtkTextActor* GetTextActor( ) const; vtkActor* GetPlaneActor( ); @@ -90,8 +111,8 @@ namespace cpExtensions void ResetCursor( ); void SetCursor( double pos[ 3 ] ); - vtkImageMapToColors* GetImageMap( unsigned int id ); - const vtkImageMapToColors* GetImageMap( unsigned int id ) const; + void ResetAxesCursor( ); + void SetAxesCursor( double pos[ 3 ] ); double GetMinWindow( ) const; double GetMaxWindow( ) const; @@ -104,11 +125,6 @@ namespace cpExtensions 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; @@ -127,19 +143,21 @@ namespace cpExtensions virtual ~ImageSliceActors( ); void _ConfigureStyle( ); - void _ConfigureNewLUT( vtkImageData* data ); - void _ConfigureNewInput( int axis ); + void _ConfigureInputImage( ); + void _ConfigureBinaryImage( + const double& r, const double& g, const double& b + ); // Events static void _MouseMoveCommand( void* data, - const TBaseStyle::ButtonID& btn, + const TStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); static void _MouseClickCommand( void* data, - const TBaseStyle::ButtonID& btn, + const TStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); @@ -151,6 +169,8 @@ namespace cpExtensions void* data, const char& key ); + static void _EnterCommand( void* data ); + static void _LeaveCommand( void* data ); private: // Purposely not implemented @@ -158,33 +178,50 @@ namespace cpExtensions Self& operator=( const Self& ); protected: + static double m_PlaneColors[ 3 ][ 3 ]; + 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; + vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper; + vtkSmartPointer< vtkImageActor > m_ImageActor; + + vtkSmartPointer< vtkImageData > m_BlenderBase; + vtkSmartPointer< TBlender > m_Blender; + vtkSmartPointer< vtkImageSliceMapper > m_BlenderMapper; + vtkSmartPointer< vtkLookupTable > m_BlenderLUT; + vtkSmartPointer< vtkImageActor > m_BlenderActor; + bool m_Interpolate; - // Window-Level values - double m_MinWindow, m_MaxWindow; - double m_MinLevel, m_MaxLevel; + double m_WLRange[ 4 ]; - // Associated commands - std::map< TSlicesCommand, void* > m_SlicesCommands; - std::map< TWindowLevelCommand, void* > m_WindowLevelCommands; - std::map< TVoidCommand, void* > m_RenderCommands; + int m_VisibleExtent[ 6 ]; + double m_VisibleBounds[ 6 ]; + + // Associated slices + std::vector< Self* > m_AssociatedSlices; // Unique objects vtkSmartPointer< vtkPolyData > m_Cursor; vtkSmartPointer< vtkPolyDataMapper > m_CursorMapper; vtkSmartPointer< vtkActor > m_CursorActor; - vtkSmartPointer< vtkPlane > m_PlaneFunction; + + vtkSmartPointer< vtkPolyData > m_Axis1; + vtkSmartPointer< vtkPolyDataMapper > m_Axis1Mapper; + vtkSmartPointer< vtkActor > m_Axis1Actor; + + vtkSmartPointer< vtkPolyData > m_Axis2; + vtkSmartPointer< vtkPolyDataMapper > m_Axis2Mapper; + vtkSmartPointer< vtkActor > m_Axis2Actor; + vtkSmartPointer< vtkPolyData > m_Plane; vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper; + vtkSmartPointer< vtkActor > m_PlaneActor; + char m_TextBuffer[ 1024 ]; vtkSmartPointer< vtkTextActor > m_TextActor; - vtkSmartPointer< vtkActor > m_PlaneActor; double m_StartWindowLevelPos[ 3 ]; double m_StartWindowLevel[ 2 ];