]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Visualization/ImageSliceActors.h
Widget integration (step 5/6): generic widget controller finished and tested on linux...
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageSliceActors.h
index 1a5bf49c998b9383fb74f0506b86148192e579c5..f940a90a6ff6f93a6af1dce2fda93df14c4c575e 100644 (file)
@@ -16,6 +16,8 @@
 #include <vtkSmartPointer.h>
 #include <vtkTextActor.h>
 
+#include <cpExtensions/Visualization/ImageInteractorStyle.h>
+
 // -------------------------------------------------------------------------
 class vtkAlgorithmOutput;
 class vtkImageData;
@@ -33,8 +35,6 @@ namespace cpExtensions
     public:
       typedef ImageSliceActors Self;
 
-      typedef void ( *TUpdateCommand )( void* );
-
     public:
       vtkTypeMacro( ImageSliceActors, vtkPropCollection );
 
@@ -42,10 +42,15 @@ namespace cpExtensions
       // Creation
       static ImageSliceActors* New( );
 
-      void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 0 );
-      void AddInputData( vtkImageData* data, int axis = 0 );
+      void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 );
+      void AddInputData( vtkImageData* data, int axis = 2 );
       void Clear( );
 
+      vtkInteractorStyle* GetStyle( );
+      const vtkInteractorStyle* GetStyle( ) const;
+
+      void PushActorsInto( vtkRenderer* renderer );
+      void PopActorsFrom( vtkRenderer* renderer );
       unsigned int GetNumberOfImageActors( ) const;
       vtkImageActor* GetImageActor( unsigned int id );
       const vtkImageActor* GetImageActor( unsigned int id ) const;
@@ -72,36 +77,58 @@ namespace cpExtensions
       int GetSliceNumberMaxValue( ) const;
       void SetSliceNumber( const int& slice );
       void UpdateText( );
+      void UpdateText( double pos[ 3 ] );
       void UpdateText( const double& w, const double& l );
 
-      void SetUpdateCommand( TUpdateCommand cmd, void* data )
-        {
-          this->m_UpdateCommand = cmd;
-          this->m_UpdateData = data;
-        }
-
     protected:
       ImageSliceActors( );
       virtual ~ImageSliceActors( );
 
       void _ConfigureNewInput( int axis );
 
+      // Events
+      static void _MouseMoveCommand(
+        void* data,
+        const ImageInteractorStyle::ButtonID& btn, double* pos,
+        bool alt, bool ctr, bool sft
+        );
+      static void _MouseClickCommand(
+        void* data,
+        const ImageInteractorStyle::ButtonID& btn, double* pos,
+        bool alt, bool ctr, bool sft
+        );
+      static void _MouseDoubleClickCommand(
+        void* data,
+        const ImageInteractorStyle::ButtonID& btn, 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
+        );
+
     private:
       // Purposely not implemented
       ImageSliceActors( const Self& );
       Self& operator=( const Self& );
 
     protected:
+      vtkSmartPointer< ImageInteractorStyle > Style;
+
       // Multiple actors
       std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers;
       std::vector< vtkSmartPointer< vtkImageActor > >       ImageActors;
-
-      typedef
-      std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > >
-      TActorPair;
-      std::vector< TActorPair > OtherActors;
       bool Interpolate;
 
+      // Other associated actors
+      typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor;
+      typedef std::vector< TAssociatedActor >       TAssociatedActors;
+      TAssociatedActors AssociatedActors;
+
       // Unique objects
       vtkSmartPointer< vtkPlane >          PlaneFunction;
       vtkSmartPointer< vtkPolyData >       PlaneSource;
@@ -109,10 +136,6 @@ namespace cpExtensions
       char                                 TextBuffer[ 1024 ];
       vtkSmartPointer< vtkTextActor >      TextActor;
       vtkSmartPointer< vtkActor >          PlaneActor;
-
-
-      TUpdateCommand m_UpdateCommand;
-      void* m_UpdateData;
     };
 
   } // ecapseman