]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.h
merge async example
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.h
index f940a90a6ff6f93a6af1dce2fda93df14c4c575e..6c97448f48c5c0cfcec9192ccc49642225da77f4 100644 (file)
@@ -6,14 +6,15 @@
 #include <utility>
 #include <vector>
 
+#include <vtkSmartPointer.h>
 #include <vtkActor.h>
 #include <vtkImageActor.h>
+#include <vtkImageMapToColors.h>
 #include <vtkImageSliceMapper.h>
 #include <vtkPlane.h>
 #include <vtkPolyData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkPropCollection.h>
-#include <vtkSmartPointer.h>
 #include <vtkTextActor.h>
 
 #include <cpExtensions/Visualization/ImageInteractorStyle.h>
@@ -21,6 +22,7 @@
 // -------------------------------------------------------------------------
 class vtkAlgorithmOutput;
 class vtkImageData;
+class vtkLookupTable;
 
 // -------------------------------------------------------------------------
 namespace cpExtensions
@@ -35,22 +37,44 @@ namespace cpExtensions
     public:
       typedef ImageSliceActors Self;
 
+      typedef void ( *TCursorCommand )( double*, int, void* );
+      typedef ImageInteractorStyle::TMouseCommand      TMouseCommand;
+      typedef ImageInteractorStyle::TMouseWheelCommand TMouseWheelCommand;
+      typedef ImageInteractorStyle::TKeyCommand        TKeyCommand;
+
     public:
       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
 
+      vtkGetMacro( MinWindow, double );
+      vtkGetMacro( MaxWindow, double );
+      vtkGetMacro( MinLevel, double );
+      vtkGetMacro( MaxLevel, double );
+
     public:
       // Creation
       static ImageSliceActors* New( );
 
+      void AddCursorCommand( TCursorCommand command, void* data )
+      {
+        this->CursorCommands.push_back(
+          std::pair< TCursorCommand, void* >(
+            command, data
+            )
+          );
+      }
+
       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
       void AddInputData( vtkImageData* data, int axis = 2 );
       void Clear( );
 
+      void AssociateSlice( Self* other );
+      void SetSlicesCommand( TCursorCommand cmd, void* data );
+
       vtkInteractorStyle* GetStyle( );
       const vtkInteractorStyle* GetStyle( ) const;
 
-      void PushActorsInto( vtkRenderer* renderer );
-      void PopActorsFrom( vtkRenderer* renderer );
+      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;
@@ -71,11 +95,30 @@ namespace cpExtensions
       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 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 );
@@ -84,6 +127,7 @@ namespace cpExtensions
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
+      void _ConfigureNewLUT( vtkImageData* data );
       void _ConfigureNewInput( int axis );
 
       // Events
@@ -120,22 +164,46 @@ namespace cpExtensions
       vtkSmartPointer< ImageInteractorStyle > Style;
 
       // Multiple actors
+      std::vector< vtkSmartPointer< vtkImageMapToColors > > ImageMaps;
       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
       bool Interpolate;
 
+      // Window-Level values
+      double MinWindow, MaxWindow;
+      double MinLevel, MaxLevel;
+
+      // Other associated slices
+      std::vector< vtkSmartPointer< Self > > AssociatedSlices;
+      TCursorCommand SlicesCommand;
+      void* SlicesData;
+
+      // Associated commands
+      std::vector< std::pair< TCursorCommand, void* > > CursorCommands;
+      std::vector< TMouseCommand >      MouseCommands;
+      std::vector< TMouseCommand >      MouseClickCommands;
+      std::vector< TMouseCommand >      MouseDoubleClickCommands;
+      std::vector< TMouseWheelCommand > MouseWheelCommands;
+      std::vector< TKeyCommand >        KeyCommands;
+
       // Other associated actors
       typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
       typedef std::vector< TAssociatedActor >       TAssociatedActors;
       TAssociatedActors AssociatedActors;
 
       // Unique objects
+      vtkSmartPointer< vtkPolyData >       Cursor;
+      vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
+      vtkSmartPointer< vtkActor >          CursorActor;
       vtkSmartPointer< vtkPlane >          PlaneFunction;
-      vtkSmartPointer< vtkPolyData >       PlaneSource;
+      vtkSmartPointer< vtkPolyData >       Plane;
       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
       char                                 TextBuffer[ 1024 ];
       vtkSmartPointer< vtkTextActor >      TextActor;
       vtkSmartPointer< vtkActor >          PlaneActor;
+
+      double StartWindowLevelPos[ 3 ];
+      double StartWindowLevel[ 2 ];
     };
 
   } // ecapseman