]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Interaction/ImageInteractorStyle.h
First dump for version 0.1.0
[cpPlugins.git] / lib / cpExtensions / Interaction / ImageInteractorStyle.h
1 #ifndef __CPEXTENSIONS__INTERACTION__IMAGEINTERACTORSTYLE__H__
2 #define __CPEXTENSIONS__INTERACTION__IMAGEINTERACTORSTYLE__H__
3
4 #include <cpExtensions/Interaction/BaseInteractorStyle.h>
5
6 #include <vector>
7
8 #include <vtkSmartPointer.h>
9 #include <vtkImageActorPointPlacer.h>
10 #include <vtkPropPicker.h>
11 #include <vtkPointHandleRepresentation3D.h>
12 #include <vtkSeedRepresentation.h>
13 #include <cpExtensions/Interaction/SeedWidget.h>
14
15 // Forward definitions
16 class vtkCommand;
17 class vtkImageActor;
18
19 namespace cpExtensions
20 {
21   namespace Interaction
22   {
23     /**
24      */
25     class cpExtensions_EXPORT ImageInteractorStyle
26       : public BaseInteractorStyle
27     {
28     public:
29       typedef ImageInteractorStyle Self;
30       vtkTypeMacro( ImageInteractorStyle, BaseInteractorStyle );
31
32       // Callbacks types
33       typedef Superclass::TMouseCommand            TMouseCommand;
34       typedef Superclass::TMouseWheelCommand       TMouseWheelCommand;
35       typedef Superclass::TKeyCommand              TKeyCommand;
36       typedef Superclass::TVoidCommand             TVoidCommand;
37       typedef Superclass::TMouseMoveCommand        TMouseMoveCommand;
38       typedef Superclass::TMouseClickCommand       TMouseClickCommand;
39       typedef Superclass::TMouseDoubleClickCommand TMouseDoubleClickCommand;
40       typedef Superclass::TExposeCommand           TExposeCommand;
41       typedef Superclass::TConfigureCommand        TConfigureCommand;
42       typedef Superclass::TEnterCommand            TEnterCommand;
43       typedef Superclass::TLeaveCommand            TLeaveCommand;
44
45       // Widgets
46       struct TSeedWidget
47       {
48         vtkSmartPointer< vtkImageActorPointPlacer >              Placer;
49         vtkSmartPointer< vtkPointHandleRepresentation3D >        Handle;
50         vtkSmartPointer< vtkSeedRepresentation >         Representation;
51         vtkSmartPointer< SeedWidget > Widget;
52
53         TSeedWidget(
54           vtkRenderWindowInteractor* interactor, vtkImageActor* actor
55           );
56         void On( );
57         void Off( );
58       };
59
60     public:
61       static Self* New( );
62
63       // Data for local picker
64       virtual void AssociateImageActor( vtkImageActor* actor );
65
66       // Widgets
67       void SeedWidgetOn( );
68       void SeedWidgetOff( );
69       void SetSeedWidgetCommand( vtkCommand* cmd );
70       unsigned int GetNumberOfSeeds( ) const;
71       void GetSeedAsPoint( unsigned int id, double pos[ 3 ] ) const;
72       void GetSeedAsIndex( unsigned int id, int pos[ 3 ] ) const;
73
74     protected:
75       ImageInteractorStyle( );
76       virtual ~ImageInteractorStyle( );
77
78       virtual bool _PickPosition( int idx[ 2 ], double pos[ 3 ] );
79
80     private:
81       // Purposely not implemented
82       ImageInteractorStyle( const Self& );
83       Self& operator=( const Self& );
84
85     protected:
86       vtkSmartPointer< vtkPropPicker > m_PropPicker;
87
88       TSeedWidget* m_SeedWidget;
89     };
90
91   } // ecapseman
92
93 } // ecapseman
94
95 #endif // __CPEXTENSIONS__INTERACTION__IMAGEINTERACTORSTYLE__H__
96
97 // eof - $RCSfile$