ALBA
albaInteractorGenericMouse.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaInteractorGenericMouse
5 Authors: Stefano Perticoni
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16
17#ifndef __albaInteractorGenericMouse_h
18#define __albaInteractorGenericMouse_h
19
20//----------------------------------------------------------------------------
21// Include:
22//----------------------------------------------------------------------------
25
26//----------------------------------------------------------------------------
27//forward ref
28//----------------------------------------------------------------------------
30class albaMatrix;
31
32class vtkCamera;
33class vtkDoubleArray;
34
43{
44public:
46
47 //----------------------------------------------------------------------------
48 // Actions performed on mouse driven events
49 //----------------------------------------------------------------------------
50
53 void OnButtonDownAction(int X, int Y);
54
57 void OnMouseMoveAction(int X, int Y);
58
62
68
69 // modified by Rafael. 9-9-2004
70 // Made this function public
71 void SendTransformMatrix(const albaMatrix &matrix, int mouseAction = MOUSE_MOVE, double rotationAngle = 0);
72
74 virtual void SetCurrentCamera(vtkCamera *camera) {m_CurrentCamera=camera;}
75
76 //----------------------------------------------------------------------------
77 // result matrix
78 //----------------------------------------------------------------------------
79
83 { this->m_ResultMatrixConcatenationSemantic = POSTMULTIPLY; }
85 { this->m_ResultMatrixConcatenationSemantic = POSTMULTIPLY; }
87 { return this->m_ResultMatrixConcatenationSemantic; }
88
91 void SetResultMatrixConcatenation(bool active) {this->m_ResultMatrixConcatenation = active;}
92 bool GetResultMatrixConcatenation() {return this->m_ResultMatrixConcatenation;};
93
98 void ResultMatrixConcatenationOn() {this->m_ResultMatrixConcatenation = true;};
99 void ResultMatrixConcatenationOff() {this->m_ResultMatrixConcatenation = false;};
100
101protected:
102
105
107 void EnableTranslationInternal(bool enable);
108 void EnableRotationInternal(bool enable);
109 void EnableScalingInternal(bool enable);
111
113 void Translate(double *p1, double *p2);
114
116 void Rotate(double *p1, double *p2, double *viewup);
117
119 void Scale(double *p1, double *p2, double *viewup);
120
135 int BinarySearch(double pos, vtkDoubleArray *array, int& helper_point_status);
136
137 //----------------------------------------------------------------------------
138 //manage the state of the helper point
139 //----------------------------------------------------------------------------
140
141 // Register the status of the helper point: it could be coincident with
142 // one of the grid points (ON_GRID_POINT) or not (NOT_ON_GRID_POINT)
144
146 {
149 };
150
151 // If m_HelperPointStatus is NOT_ON_GRID_POINT this is the index of the first array
152 // element on the left of the helper point. If m_HelperPointStatus is ON_GRID_POINT this is
153 // the array index corresponding to the helper point position
155
156 //the constrain ref sys matrix
158
159 //----------------------------------------------------------------------------
160 // result matrix: the matrix to keep updated
161 //----------------------------------------------------------------------------
162 // Register the pointer to the matrix to be updated
164
166
167 enum
168 {
171 };
172
173 //----------------------------------------------------------------------------
174 // trackball interaction style stuff
175 //----------------------------------------------------------------------------
176
177 virtual void TrackballRotate();
178 virtual void TrackballTranslate();
179 virtual void TrackballRoll();
180
181 //----------------------------------------------------------------------------
182 // snap on surface
183 //----------------------------------------------------------------------------
185
186
187 //----------------------------------------------------------------------------
188 // normal on surface
189 //----------------------------------------------------------------------------
191
192 //----------------------------------------------------------------------------
193 // trackball interaction style stuff
194 //----------------------------------------------------------------------------
195
196 int m_LastX, m_LastY;
197
198 //----------------------------------------------------------------------------
199
200 int m_MousePointer2DPosition[2];
201 int m_LastMousePointer2DPosition[2];
202
203 vtkCamera *m_CurrentCamera;
204
205 double m_LastPickPosition[3];
206
207private:
208
209 albaInteractorGenericMouse(const albaInteractorGenericMouse&); // Not implemented.
210 void operator=(const albaInteractorGenericMouse&); // Not implemented.
211
212 // Projection Accumulator; accumulates projections of the motion
213 // vector along mouse move events
214 //
215 // P1 P2 P3 PN
216 // ->----->----->-------->
217 // -------m_ProjectionAccumulator-------->
218 //
219 double m_ProjectionAccumulator;
220
229 void SendTransformMatrix(double *versor, double translation, int mouseAction = MOUSE_MOVE);
230 void SendTransformMatrix(double *vector, int mouseAction = MOUSE_MOVE);
231
234 void ConcatenateToResultMatrix(const albaMatrix &matrix);
235
236 bool m_ResultMatrixConcatenation;
237
238};
239#endif
MOUSE_DOWN
Definition: albaDecl.h:295
MOUSE_UP
Definition: albaDecl.h:297
MOUSE_MOVE
Definition: albaDecl.h:296
Abstract class for general purpose interactor.
Constrained interaction with mouse device.
virtual void SetCurrentCamera(vtkCamera *camera)
Set the current camera.
void EnableTranslationInternal(bool enable)
Superclass override; only one flag can be true.
void OnButtonDownAction(int X, int Y)
Action to be performed on button down event.
virtual void TrackballRoll()
vtkCamera * m_CurrentCamera
Stores camera to which the interaction is currently assigned.
void SetResultMatrixConcatenationSemanticToPostMultiply()
Set the semantic of the concatenation, default is postmultiply ie the transform is concatenated after...
void EnableRotationInternal(bool enable)
void Translate(double *p1, double *p2)
Perform translation.
void SetResultMatrixConcatenation(bool active)
Set/Get if the concatenation is active.
virtual void TrackballTranslate()
int BinarySearch(double pos, vtkDoubleArray *array, int &helper_point_status)
Binary search for pos into array.
void Rotate(double *p1, double *p2, double *viewup)
Perform rotation.
void OnMouseMoveAction(int X, int Y)
Action to be performed on mouse move event.
albaTypeMacro(albaInteractorGenericMouse, albaInteractor)
void EnableUniformScalingInternal(bool enable)
void EnableScalingInternal(bool enable)
virtual void TrackballRotate()
void SendTransformMatrix(const albaMatrix &matrix, int mouseAction=MOUSE_MOVE, double rotationAngle=0)
MouseAction
Used to notify the listener about the current mouse action performed; event Id field is set with this...
void Scale(double *p1, double *p2, double *viewup)
Perform scaling.
void ResultMatrixConcatenationOn()
Enable/Disable the concatenation of the transform matrix to be sent to the result matrix
void OnButtonUpAction()
Action to be performed on button up action.
Abstract class for ALBA interactors This class provides base interface and features of ALBA continuou...
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44