]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.h
merge async example
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.h
index 962c8f2b0cf0b2388981f949b1be19f85d768236..6c97448f48c5c0cfcec9192ccc49642225da77f4 100644 (file)
@@ -22,6 +22,7 @@
 // -------------------------------------------------------------------------
 class vtkAlgorithmOutput;
 class vtkImageData;
+class vtkLookupTable;
 
 // -------------------------------------------------------------------------
 namespace cpExtensions
@@ -37,30 +38,33 @@ namespace cpExtensions
       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 );
 
-      enum LUTType
-      {
-        LUTType_None = 0,
-        LUTType_WindowLevel,
-        LUTType_Colors
-      };
+      vtkGetMacro( MinWindow, double );
+      vtkGetMacro( MaxWindow, double );
+      vtkGetMacro( MinLevel, double );
+      vtkGetMacro( MaxLevel, double );
 
     public:
       // Creation
       static ImageSliceActors* New( );
 
-      void AddInputConnection(
-        vtkAlgorithmOutput* aout,
-        int axis = 2,
-        LUTType lut = Self::LUTType_None
-        );
-      void AddInputData(
-        vtkImageData* data,
-        int axis = 2,
-        LUTType lut = Self::LUTType_None );
+      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 );
@@ -97,12 +101,17 @@ namespace cpExtensions
       vtkImageMapToColors* GetImageMap( unsigned int id );
       const vtkImageMapToColors* GetImageMap( unsigned int id ) const;
 
-      double GetWindow( unsigned int id ) const;
-      double GetLevel( unsigned int id ) const;
-      void SetWindow( unsigned int id, double w );
-      void SetLevel( unsigned int id, double l );
-      void SetWindowLevel( unsigned int id, double w, double l );
-      void ResetWindowLevel( unsigned int id );
+      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;
@@ -118,7 +127,7 @@ namespace cpExtensions
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
-      void _ConfigureNewLUT( vtkImageData* data, LUTType lut_t );
+      void _ConfigureNewLUT( vtkImageData* data );
       void _ConfigureNewInput( int axis );
 
       // Events
@@ -160,11 +169,23 @@ namespace cpExtensions
       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;
@@ -175,7 +196,7 @@ namespace cpExtensions
       vtkSmartPointer< vtkPolyDataMapper > CursorMapper;
       vtkSmartPointer< vtkActor >          CursorActor;
       vtkSmartPointer< vtkPlane >          PlaneFunction;
-      vtkSmartPointer< vtkPolyData >       PlaneSource;
+      vtkSmartPointer< vtkPolyData >       Plane;
       vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
       char                                 TextBuffer[ 1024 ];
       vtkSmartPointer< vtkTextActor >      TextActor;