]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.h
More widgets added
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.h
index 96d4550c52039613aaf8b96109d6afce535e75a8..6c7d40547deac4957c3a3de3a3e46f9d26ff6826 100644 (file)
@@ -3,8 +3,8 @@
 
 #include <cpExtensions/cpExtensions_Export.h>
 
+#include <map>
 #include <utility>
-#include <vector>
 
 #include <vtkSmartPointer.h>
 #include <vtkActor.h>
@@ -17,7 +17,7 @@
 #include <vtkPropCollection.h>
 #include <vtkTextActor.h>
 
-#include <cpExtensions/Visualization/ImageInteractorStyle.h>
+#include <cpExtensions/Interaction/ImageInteractorStyle.h>
 
 // -------------------------------------------------------------------------
 class vtkAlgorithmOutput;
@@ -37,11 +37,14 @@ namespace cpExtensions
     public:
       typedef ImageSliceActors Self;
 
-      typedef void ( *TCursorCommand )( double*, int, void* );
-      typedef BaseInteractorStyle::TMouseCommand      TMouseCommand;
-      typedef BaseInteractorStyle::TMouseWheelCommand TMouseWheelCommand;
-      typedef BaseInteractorStyle::TKeyCommand        TKeyCommand;
-      typedef BaseInteractorStyle::TVoidCommand       TVoidCommand;
+      typedef cpExtensions::Interaction::BaseInteractorStyle  TBaseStyle;
+      typedef cpExtensions::Interaction::ImageInteractorStyle TStyle;
+      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;
 
     public:
       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
@@ -50,15 +53,18 @@ namespace cpExtensions
       // Creation
       static ImageSliceActors* New( );
 
-      void AddSlicesCommand( TCursorCommand command, void* data );
-      void AddSeedCommand( TCursorCommand command, void* data );
+      void AddSlicesCommand( TSlicesCommand command, void* data );
+      void AddWindowLevelCommand( TWindowLevelCommand command, void* data );
+      void AddRenderCommand( TVoidCommand command, void* data );
+
+      void RemoveSlicesCommand( TSlicesCommand command );
+      void RemoveWindowLevelCommand( TWindowLevelCommand command );
+      void RemoveRenderCommand( TVoidCommand command );
 
       void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
       void AddInputData( vtkImageData* data, int axis = 2 );
       void Clear( );
 
-      void AssociateSlice( Self* other );
-
       vtkInteractorStyle* GetStyle( );
       const vtkInteractorStyle* GetStyle( ) const;
 
@@ -74,9 +80,6 @@ namespace cpExtensions
       vtkPlane* GetPlaneFunction( );
       const vtkPlane* GetPlaneFunction( ) const;
 
-      void AddActor( vtkAlgorithm* algorithm, vtkActor* actor );
-      void AddActor( vtkActor* actor );
-
       void SetInterpolate( bool v );
       void InterpolateOn( );
       void InterpolateOff( );
@@ -116,6 +119,9 @@ namespace cpExtensions
       void UpdateText( double pos[ 3 ] );
       void UpdateText( const double& w, const double& l );
 
+      void Render( );
+      void ResetCamera( );
+
     protected:
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
@@ -127,17 +133,14 @@ namespace cpExtensions
       // Events
       static void _MouseMoveCommand(
         void* data,
-        const BaseInteractorStyle::ButtonID& btn, double* pos,
+        const TBaseStyle::ButtonID& btn,
+        int* idx, double* pos,
         bool alt, bool ctr, bool sft
         );
       static void _MouseClickCommand(
         void* data,
-        const BaseInteractorStyle::ButtonID& btn, double* pos,
-        bool alt, bool ctr, bool sft
-        );
-      static void _MouseDoubleClickCommand(
-        void* data,
-        const BaseInteractorStyle::ButtonID& btn, double* pos,
+        const TBaseStyle::ButtonID& btn,
+        int* idx, double* pos,
         bool alt, bool ctr, bool sft
         );
       static void _MouseWheelCommand(
@@ -155,7 +158,7 @@ namespace cpExtensions
       Self& operator=( const Self& );
 
     protected:
-      vtkSmartPointer< ImageInteractorStyle > m_Style;
+      vtkSmartPointer< TStyle > m_Style;
 
       // Multiple actors
       std::vector< vtkSmartPointer< vtkImageMapToColors > > m_ImageMaps;
@@ -167,17 +170,10 @@ namespace cpExtensions
       double m_MinWindow, m_MaxWindow;
       double m_MinLevel, m_MaxLevel;
 
-      // Other associated slices
-      std::vector< vtkSmartPointer< Self > > m_AssociatedSlices;
-
       // Associated commands
-      std::vector< std::pair< TCursorCommand, void* > > m_SlicesCommands;
-      std::vector< std::pair< TCursorCommand, void* > > m_SeedCommands;
-
-      // Other associated actors
-      typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
-      typedef std::vector< TAssociatedActor >       TAssociatedActors;
-      TAssociatedActors m_AssociatedActors;
+      std::map< TSlicesCommand, void* >      m_SlicesCommands;
+      std::map< TWindowLevelCommand, void* > m_WindowLevelCommands;
+      std::map< TVoidCommand, void* >        m_RenderCommands;
 
       // Unique objects
       vtkSmartPointer< vtkPolyData >       m_Cursor;