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
54 void SetButtonDownPick(bool picked, double pickedPos[3]);
55
58 void OnButtonDownAction(int X, int Y);
59
62 void OnMouseMoveAction(int X, int Y);
63
67
73
74 // modified by Rafael. 9-9-2004
75 // Made this function public
76 void SendTransformMatrix(const albaMatrix &matrix, int mouseAction = MOUSE_MOVE, double rotationAngle = 0);
77
79 virtual void SetCurrentCamera(vtkCamera *camera) {m_CurrentCamera=camera;}
80
81 //----------------------------------------------------------------------------
82 // result matrix
83 //----------------------------------------------------------------------------
84
88 { this->m_ResultMatrixConcatenationSemantic = POSTMULTIPLY; }
90 { this->m_ResultMatrixConcatenationSemantic = POSTMULTIPLY; }
92 { return this->m_ResultMatrixConcatenationSemantic; }
93
96 void SetResultMatrixConcatenation(bool active) {this->m_ResultMatrixConcatenation = active;}
97 bool GetResultMatrixConcatenation() {return this->m_ResultMatrixConcatenation;};
98
103 void ResultMatrixConcatenationOn() {this->m_ResultMatrixConcatenation = true;};
104 void ResultMatrixConcatenationOff() {this->m_ResultMatrixConcatenation = false;};
105
106protected:
107
110
112 void EnableTranslationInternal(bool enable);
113 void EnableRotationInternal(bool enable);
114 void EnableScalingInternal(bool enable);
116
118 void Translate(double *p1, double *p2);
119
121 void Rotate(double *p1, double *p2, double *viewup);
122
124 void Scale(double *p1, double *p2, double *viewup);
125
140 int BinarySearch(double pos, vtkDoubleArray *array, int& helper_point_status);
141
142 //----------------------------------------------------------------------------
143 //manage the state of the helper point
144 //----------------------------------------------------------------------------
145
146 // Register the status of the helper point: it could be coincident with
147 // one of the grid points (ON_GRID_POINT) or not (NOT_ON_GRID_POINT)
149
151 {
154 };
155
156 // If m_HelperPointStatus is NOT_ON_GRID_POINT this is the index of the first array
157 // element on the left of the helper point. If m_HelperPointStatus is ON_GRID_POINT this is
158 // the array index corresponding to the helper point position
160
161 //the constrain ref sys matrix
163
164 //----------------------------------------------------------------------------
165 // result matrix: the matrix to keep updated
166 //----------------------------------------------------------------------------
167 // Register the pointer to the matrix to be updated
169
171
172 enum
173 {
176 };
177
178 //----------------------------------------------------------------------------
179 // trackball interaction style stuff
180 //----------------------------------------------------------------------------
181
182 virtual void TrackballRotate();
183 virtual void TrackballTranslate();
184 virtual void TrackballRoll();
185
186 //----------------------------------------------------------------------------
187 // snap on surface
188 //----------------------------------------------------------------------------
190
191
192 //----------------------------------------------------------------------------
193 // normal on surface
194 //----------------------------------------------------------------------------
196
197 //----------------------------------------------------------------------------
198 // trackball interaction style stuff
199 //----------------------------------------------------------------------------
200
201 int m_LastX, m_LastY;
202
203 //----------------------------------------------------------------------------
204
205 int m_MousePointer2DPosition[2];
206 int m_LastMousePointer2DPosition[2];
207
208 vtkCamera *m_CurrentCamera;
209
210 double m_LastPickPosition[3];
211
214 double m_ButtonDownPickPosition[3];
215
216private:
217
218 albaInteractorGenericMouse(const albaInteractorGenericMouse&); // Not implemented.
219 void operator=(const albaInteractorGenericMouse&); // Not implemented.
220
221 // Projection Accumulator; accumulates projections of the motion
222 // vector along mouse move events
223 //
224 // P1 P2 P3 PN
225 // ->----->----->-------->
226 // -------m_ProjectionAccumulator-------->
227 //
228 double m_ProjectionAccumulator;
229
238 void SendTransformMatrix(double *versor, double translation, int mouseAction = MOUSE_MOVE);
239 void SendTransformMatrix(double *vector, int mouseAction = MOUSE_MOVE);
240
243 void ConcatenateToResultMatrix(const albaMatrix &matrix);
244
245 bool m_ResultMatrixConcatenation;
246
247};
248#endif
MOUSE_DOWN
Definition: albaDecl.h:293
MOUSE_UP
Definition: albaDecl.h:295
MOUSE_MOVE
Definition: albaDecl.h:294
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.
bool m_ButtonDownPickSet
True if the button down picking has been set by the caller.
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 SetButtonDownPick(bool picked, double pickedPos[3])
Set the picking already performed by the caller at the button down position: the next OnButtonDownAct...
void Rotate(double *p1, double *p2, double *viewup)
Perform rotation.
bool m_ButtonDownPicked
Result of the picking set by the caller.
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:45