]> Creatis software - cpMesh.git/blob - appli/InteractiveDeformableMeshSegmentation/InteractorStyleImage.h
First commit
[cpMesh.git] / appli / InteractiveDeformableMeshSegmentation / InteractorStyleImage.h
1 #ifndef __IDMS__INTERACTORSTYLEIMAGE__H__
2 #define __IDMS__INTERACTORSTYLEIMAGE__H__
3
4 #include <vtkInteractorStyleImage.h>
5 #include <vtkLineWidget2.h>
6 #include <vtkLineRepresentation.h>
7 #include <vtkOrientationMarkerWidget.h>
8 #include <vtkPlane.h>
9 #include <vtkPropPicker.h>
10 #include <vtkSmartPointer.h>
11
12 class vtkImageData;
13
14 namespace idms
15 {
16   class VolumeActors;
17
18   /**
19    */
20   class InteractorStyleImage
21     : public vtkInteractorStyleImage
22   {
23   public:
24     typedef InteractorStyleImage Self;
25
26     enum InteractionMode
27     {
28       NavigationMode = 0,
29       DeformationMode
30     };
31
32   public:
33     vtkTypeMacro( InteractorStyleImage, vtkInteractorStyleImage );
34
35   public:
36     static Self* New( );
37
38     void Configure( VolumeActors* actors, const int& axis );
39
40     void SetModeToNavigation( );
41     void SetModeToDeformation( );
42     virtual void SetInteractor( vtkRenderWindowInteractor* interactor );
43
44     // Description:
45     // Event bindings controlling the effects of pressing mouse buttons
46     // or moving the mouse.
47     virtual void OnMouseMove( );
48     virtual void OnLeftButtonDown( );
49     virtual void OnLeftButtonUp( );
50     /*
51       virtual void OnMiddleButtonDown( );
52       virtual void OnMiddleButtonUp( );
53       virtual void OnRightButtonDown( );
54       virtual void OnRightButtonUp( );
55     */
56     virtual void OnMouseWheelForward( );
57     virtual void OnMouseWheelBackward( );
58
59     // Description:
60     // Override the "fly-to" (f keypress) for images.
61     virtual void OnChar( );
62
63     // These methods for the different interactions in different modes
64     // are overridden in subclasses to perform the correct motion. Since
65     // they might be called from OnTimer, they do not have mouse coord
66     // parameters (use interactor's GetEventPosition and GetLastEventPosition)
67     virtual void Rotate( )
68       {
69         std::cout << "Rotate" << std::endl;
70       }
71     virtual void Pan( );
72     virtual void Spin( );
73     virtual void Zoom( )
74       {
75         std::cout << "Zoom" << std::endl;
76       }
77     virtual void StartWindowLevel( );
78     virtual void WindowLevel( );
79     virtual void Pick( )
80       {
81         std::cout << "Pick" << std::endl;
82       }
83     virtual void Slice( )
84       {
85         std::cout << "Slice" << std::endl;
86       }
87
88     // Interaction mode entry points used internally.
89     /*
90       virtual void StartWindowLevel();
91       virtual void EndWindowLevel();
92       virtual void StartPick();
93       virtual void EndPick();
94       virtual void StartSlice();
95       virtual void EndSlice();
96     */
97
98     // Description:
99     // Set/Get current mode to 2D or 3D.  The default is 2D.  In 3D mode,
100     // it is possible to rotate the camera to view oblique slices.  In Slicing
101     // mode, it is possible to slice through the data, but not to generate oblique
102     // views by rotating the camera.
103     /*
104       vtkSetClampMacro(InteractionMode, int, VTKIS_IMAGE2D, VTKIS_IMAGE_SLICING);
105       vtkGetMacro(InteractionMode, int);
106       void SetInteractionModeToImage2D() {
107       this->SetInteractionMode(VTKIS_IMAGE2D); }
108       void SetInteractionModeToImage3D() {
109       this->SetInteractionMode(VTKIS_IMAGE3D); }
110       void SetInteractionModeToImageSlicing() {
111       this->SetInteractionMode(VTKIS_IMAGE_SLICING); }
112     */
113
114     // Description:
115     // Set the orientations that will be used when the X, Y, or Z
116     // keys are pressed.  See SetImageOrientation for more information.
117     /*
118       vtkSetVector3Macro(XViewRightVector, double);
119       vtkGetVector3Macro(XViewRightVector, double);
120       vtkSetVector3Macro(XViewUpVector, double);
121       vtkGetVector3Macro(XViewUpVector, double);
122       vtkSetVector3Macro(YViewRightVector, double);
123       vtkGetVector3Macro(YViewRightVector, double);
124       vtkSetVector3Macro(YViewUpVector, double);
125       vtkGetVector3Macro(YViewUpVector, double);
126       vtkSetVector3Macro(ZViewRightVector, double);
127       vtkGetVector3Macro(ZViewRightVector, double);
128       vtkSetVector3Macro(ZViewUpVector, double);
129       vtkGetVector3Macro(ZViewUpVector, double);
130     */
131
132     // Description:
133     // Set the view orientation, in terms of the horizontal and
134     // vertical directions of the computer screen.  The first
135     // vector gives the direction that will correspond to moving
136     // horizontally left-to-right across the screen, and the
137     // second vector gives the direction that will correspond to
138     // moving bottom-to-top up the screen.  This method changes
139     // the position of the camera to provide the desired view.
140     /*
141       void SetImageOrientation(
142       const double leftToRight[3],
143       const double bottomToTop[3]);
144     */
145
146     // Description:
147     // Get the current image property, which is set when StartWindowLevel
148     // is called immediately before StartWindowLevelEvent is generated.
149     // This is the image property of the topmost vtkImageSlice in the
150     // renderer or NULL if no image actors are present.
151     /*
152       vtkImageProperty *GetCurrentImageProperty() {
153       return this->CurrentImageProperty; }
154     */
155
156   protected:
157     InteractorStyleImage( );
158     virtual ~InteractorStyleImage( );
159
160     bool _PickPosition( double pos[ 3 ] );
161     void _UpdateCursor( );
162
163   private:
164     // Purposely not implemented
165     InteractorStyleImage( const Self& );
166     Self& operator=( const Self& );
167
168   protected:
169     Self::InteractionMode Mode;
170
171     vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget;
172     VolumeActors* Actors;
173     int Axis;
174     vtkSmartPointer< vtkPlane > Plane;
175     vtkSmartPointer< vtkPropPicker > PropPicker;
176
177     bool UpdatingRegion;
178
179     vtkSmartPointer< vtkLineRepresentation > LineRep;
180     vtkSmartPointer< vtkLineWidget2 >        LineWdg;
181
182   public:
183     static int SliceEvent;
184   };
185
186 } // ecapseman
187
188 #endif // __IDMS__INTERACTORSTYLEIMAGE__H__
189
190 // eof - $RCSfile$