#include <cpExtensions/cpExtensions_Export.h>
+#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkImageActor.h>
#include <vtkImageSliceMapper.h>
+#include <vtkPlane.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkPropCollection.h>
-#include <vtkSmartPointer.h>
#include <vtkTextActor.h>
-// -------------------------------------------------------------------------
-#define cpPlugins_ImageSliceActors( name, type ) \
- inline type* Get##name##Actor( ) const \
- { \
- return( \
- dynamic_cast< type* >( \
- const_cast< Self* >( this )-> \
- GetItemAsObject( this->name##ActorIndex ) \
- ) \
- ); \
- }
+#include <cpExtensions/Interaction/ImageInteractorStyle.h>
+#include <cpExtensions/Visualization/ImageBlender.h>
// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
class vtkImageData;
+class vtkLookupTable;
+class vtkRenderer;
// -------------------------------------------------------------------------
namespace cpExtensions
+{
+ namespace Visualization
{
- namespace Visualization
+ /**
+ */
+ class cpExtensions_EXPORT ImageSliceActors
+ : public vtkPropCollection
{
- /**
- */
- class cpExtensions_EXPORT ImageSliceActors
- : public vtkPropCollection
- {
- public:
- typedef ImageSliceActors Self;
-
- public:
- vtkTypeMacro( ImageSliceActors, vtkPropCollection );
-
- cpPlugins_ImageSliceActors( Image, vtkImageActor );
- cpPlugins_ImageSliceActors( Text, vtkTextActor );
- cpPlugins_ImageSliceActors( Plane, vtkActor );
-
- public:
- // Creation
- static ImageSliceActors* New( );
-
- void SetInputConnection( vtkAlgorithmOutput* aout, int axis );
- void SetInputData( vtkImageData* data, int axis );
-
- double* GetDisplayBounds( ) const;
- void GetDisplayBounds( double bounds[ 6 ] ) const;
-
- int GetAxis( ) const;
- int GetSliceNumber( ) const;
- int GetSliceNumberMinValue( ) const;
- int GetSliceNumberMaxValue( ) const;
- void SetSliceNumber( const int& slice );
- void UpdateText( );
-
- protected:
- ImageSliceActors( );
- virtual ~ImageSliceActors( );
-
- private:
- // Purposely not implemented
- ImageSliceActors( const Self& );
- Self& operator=( const Self& );
-
- protected:
- vtkSmartPointer< vtkImageSliceMapper > SliceMapper;
- vtkSmartPointer< vtkPolyData > PlaneSource;
- vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
- char TextBuffer[ 1024 ];
-
- vtkSmartPointer< vtkImageActor > ImageActor;
- vtkSmartPointer< vtkTextActor > TextActor;
- vtkSmartPointer< vtkActor > PlaneActor;
-
- unsigned int ImageActorIndex;
- unsigned int TextActorIndex;
- unsigned int PlaneActorIndex;
- };
-
- } // ecapseman
+ 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;
+
+ public:
+ vtkTypeMacro( ImageSliceActors, vtkPropCollection );
+
+ cpExtensions_BaseInteractorStyle_Commands( Slices );
+ cpExtensions_BaseInteractorStyle_Commands( WindowLevel );
+ cpExtensions_BaseInteractorStyle_Commands( Render );
+
+ public:
+ // Creation
+ static ImageSliceActors* New( );
+
+ ImageBlender* GetBlender( );
+ const ImageBlender* GetBlender( ) const;
+ void SetBlender( ImageBlender* blender );
+ void SetAxis( int axis );
+ void AddInputConnection( vtkAlgorithmOutput* aout );
+ void AddInputData( vtkImageData* data );
+ 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 GetNumberOfImages( ) const;
+ vtkImageActor* GetImageActor( );
+ const vtkImageActor* GetImageActor( ) 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 ] );
+
+ 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( );
+
+ 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( const double& t );
+ void ResetCamera( );
+
+ protected:
+ ImageSliceActors( );
+ virtual ~ImageSliceActors( );
+
+ void _ConfigureStyle( );
+
+ // 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:
+ vtkSmartPointer< TStyle > m_Style;
+ vtkRenderWindow* m_Window;
+
+ // Multiple actors
+ vtkSmartPointer< ImageBlender > m_ImageBlender;
+ vtkSmartPointer< vtkImageSliceMapper > m_ImageMapper;
+ vtkSmartPointer< vtkImageActor > m_ImageActor;
+ bool m_Interpolate;
+
+ 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< vtkPolyData > m_HorizontalLine;
+ vtkSmartPointer< vtkPolyDataMapper > m_HorizontalLineMapper;
+ vtkSmartPointer< vtkActor > m_HorizontalLineActor;
+
+ vtkSmartPointer< vtkPolyData > m_VerticalLine;
+ vtkSmartPointer< vtkPolyDataMapper > m_VerticalLineMapper;
+ vtkSmartPointer< vtkActor > m_VerticalLineActor;
+
+ vtkSmartPointer< vtkPolyData > m_Plane;
+ vtkSmartPointer< vtkPolyDataMapper > m_PlaneMapper;
+ vtkSmartPointer< vtkActor > m_PlaneActor;
+
+ char m_TextBuffer[ 1024 ];
+ vtkSmartPointer< vtkTextActor > m_TextActor;
+
+ double m_StartWindowLevelPos[ 3 ];
+ double m_StartWindowLevel[ 2 ];
+ };
+
+ } // ecapseman
} // ecapseman