#ifndef __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ #define __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ #include #include #include #include #include #include #include #include #include #include #define MAX_TEXT_BUFFER 1024 class vtkAlgorithmOutput; class vtkImageData; class vtkRenderer; namespace cpExtensions { namespace Visualization { /** */ class cpExtensions_EXPORT ImageSliceActors : public vtkPropCollection { public: typedef ImageSliceActors Self; 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 TVoidCommand TRenderCommand; template< class _TSource > struct SourceActor { vtkSmartPointer< _TSource > Source; vtkSmartPointer< vtkPolyDataMapper > Mapper; vtkSmartPointer< vtkActor > Actor; void Create( ) { this->Source = vtkSmartPointer< _TSource >::New( ); this->Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); this->Actor = vtkSmartPointer< vtkActor >::New( ); this->Mapper->SetInputConnection( this->Source->GetOutputPort( ) ); this->Actor->SetMapper( this->Mapper ); } void Modified( ) { this->Source->Modified( ); this->Mapper->Modified( ); this->Actor->Modified( ); } }; public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); cpExtensions_BaseInteractorStyle_Commands( Slices ); cpExtensions_BaseInteractorStyle_Commands( WindowLevel ); cpExtensions_BaseInteractorStyle_Commands( Render ); public: static Self* New( ); void Clear( ); void SetInputConnection( vtkAlgorithmOutput* aout, int orientation ); void SetInputData( vtkImageData* data, int orientation ); void AssociateSlice( Self* slice ); void CleanAssociatedSlices( ); TStyle* GetStyle( ); void SetStyle( vtkInteractorStyle* st ); void PushInto( vtkRenderer* ren ); void PopFrom( vtkRenderer* ren ); long GetSliceNumber( ) const; void SetSliceNumber( long slice ); void ShowPixelText( double* pos ); void GetScalarRange( double r[ 2 ] ) const; void SetScalarRange( const double& a, const double& b ); void UnsetScalarRange( ); void SetWindowLevel( const double& w, const double& l ); double GetWindow( ) const; double GetLevel( ) const; void Render( ); protected: ImageSliceActors( ); virtual ~ImageSliceActors( ); void _ConfigureInput( int orientation ); void _ConfigureCursor( ); // Events static void _MouseMoveCommand( void* data, const TStyle::ButtonID& btn, int* idx, double* pos, bool alt, bool ctr, bool sft ); static void _MouseClickCommand( void* data, const TStyle::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 ); static void _EnterCommand( void* data ); static void _LeaveCommand( void* data ); private: // Purposely not implemented ImageSliceActors( const Self& ); Self& operator=( const Self& ); protected: // Main image vtkSmartPointer< vtkImageSliceMapper > m_Mapper; vtkSmartPointer< vtkImageActor > m_Actor; // Secondary slices std::vector< vtkSmartPointer< Self > > m_AssociatedSlices; // Cursor SourceActor< vtkCursor3D > m_Cursor; // Text char m_TextBuffer[ MAX_TEXT_BUFFER ]; vtkSmartPointer< vtkTextActor > m_TextActor; // WindowLevel double m_ScalarRange[ 2 ]; bool m_ManualScalarRange; // Style vtkSmartPointer< vtkInteractorStyle > m_Style; // Events-related data double m_StartMouseEvent[ 3 ]; double m_StartWindow; double m_StartLevel; }; } // ecapseman } // ecapseman #endif // __CPEXTENSIONS__VISUALIZATION__IMAGESLICEACTORS__H__ // eof - $RCSfile$