ALBA
albaAvatar3D.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaAvatar3D
5 Authors: Marco Petrone
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 __albaAvatar3D_h
18#define __albaAvatar3D_h
19
20#include "albaAvatar.h"
21#include "albaMatrix.h"
22
23//----------------------------------------------------------------------------
24// forward declarations :
25//----------------------------------------------------------------------------
28class albaTransform;
30class albaView;
31class albaEventBase;
32class vtkALBARayCast3DPicker;
33class vtkTextMapper;
34class vtkActor2D;
35class vtkOutlineSource;
36class vtkTransform;
37class vtkCellPicker;
38class vtkProp3D;
39class vtkActor;
40class vtkAssemblyPath;;
41class vtkRenderer;
42class vtkRenderWindowInteractor;
43
56class ALBA_EXPORT albaAvatar3D : public albaAvatar
57{
58public:
59 //----------------------------------------------------------------------------
60 // GUI Constants
61 //----------------------------------------------------------------------------
63 {
64 ID_FITTING_COMBO = albaAvatar::ID_LAST,
69 ID_LAST
70 };
71
73 {
74 TRACKER_COORDS=0,
77 };
78
80 {
81 NO_SCALE=0,
83 CANONICAL_TO_WORLD_SCALE
84 };
85
87
92 virtual void SetRendererAndView(vtkRenderer *ren, albaView *view);
93
97 virtual void Hide();
98
102 virtual void Show();
103
105 vtkALBARayCast3DPicker *GetPicker3D();
106
108 vtkCellPicker *GetPicker2D();
109
112 virtual vtkAbstractPropPicker *GetPicker();
113
117 void SetDisplayWorkingBox(int vis);
118 int GetDisplayWorkingBox(){ return m_DisplayWorkingBox;}
119 void DisplayWorkingBoxOn() {SetDisplayWorkingBox(true);}
120 void DisplayWorkingBoxOff() {SetDisplayWorkingBox(false);}
121
125 void SetDisplayDebugText(int vis);
126 int GetDisplayDebugText() {return m_DisplayDebugText;}
127
129 void SetDebugTextPosition(double *pos) {SetDebugTextPosition(pos[0],pos[1]);}
130 void SetDebugTextPosition(double posx,double posy);
131 double *GetDebugTextPosition() {return m_DebugTextPosition;}
132
137 void SetCoordsFrame(int frame) {m_CoordsFrame=frame;}
138 int GetCoordsFrame() {return m_CoordsFrame;}
139
140
142 virtual void OnEvent(albaEventBase *event);
143
146
148 void CanonicalToWorld(const albaMatrix &pose,albaMatrix &dest);
151
152 void WorldToCanonical(const albaMatrix &pose,albaMatrix &dest);
155
156
161 void TrackerToWorld(albaMatrix &tracker_pose,albaMatrix &world_pose,int use_scale=1,int use_rot=1, int use_trans=1);
162 void WorldToTracker(albaMatrix &world_pose,albaMatrix &tracker_pose,int use_scale=1,int use_rot=1, int use_trans=1);
163
164
166 void TrackerToDisplay(albaMatrix &tracker_pose,double xy[2]);
167
169 void WorldToDisplay(albaMatrix &world_pose,double xy[2]);
170
172 void WorldToNormalizedDisplay(albaMatrix &world_pose,double xy[2]);
173
174
176 albaCameraTransform *GetCanonicalToWorldTransform() {return m_CanonicalToWorldTransform;}
177
181 void SetFittingMode(int type);
182
184 int GetFittingMode() {return m_FittingMode;}
185
189 albaMatrix &GetLastPoseMatrix() {return m_LastPoseMatrix;}
190
192 virtual void CreateGui();
193
194protected:
196 virtual ~albaAvatar3D();
197
202
205
207 virtual int InternalInitialize();
208
210 virtual void InternalShutdown();
211
213 virtual void UpdateDebugText(const char *title, albaMatrix &pose);
214
217
220
222 virtual void OnPostResetCamera(albaEventBase *event);
223
225 void SetPicker3D(vtkALBARayCast3DPicker *picker);
226
227 vtkProp3D* m_WorkingBoxActor;
228 vtkOutlineSource* m_WorkingBox;
229
230 vtkTextMapper* m_DebugTextMapper;
231 vtkActor2D* m_DebugTextActor;
232
234
235 vtkALBARayCast3DPicker* m_Picker3D;
236 vtkCellPicker* m_Picker2D;
237
238
240
242
246
248
249private:
250 albaAvatar3D(const albaAvatar3D&); // Not implemented.
251 void operator=(const albaAvatar3D&); // Not implemented.
252};
253
254#endif
Avatars are entities moving in the virtual world according to user's movements, and thus representing...
Definition: albaAvatar3D.h:57
virtual vtkAbstractPropPicker * GetPicker()
return the picker used by this avatar: from the picker is possible to obtain information about the pi...
virtual void CreateGui()
Create the dialog that show the interface for settings.
vtkCellPicker * m_Picker2D
Definition: albaAvatar3D.h:236
vtkALBARayCast3DPicker * GetPicker3D()
Return picker 3D used by 3DAvatar for picking.
void WorldToNormalizedDisplay(albaMatrix &world_pose, double xy[2])
map world coords to normalized display coords
@ TRACKER_TO_WORLD_SCALE
Definition: albaAvatar3D.h:82
virtual void OnMove3DEvent(albaEventInteraction *e)
process a move event
virtual void Show()
Show the 3D cursor.
virtual void SetTracker(albaDeviceButtonsPadTracker *tracker)
return the tracker this avatar is the tracker attached to this avatar
void SetCoordsFrame(int frame)
Display the original tracker's coords in the debug text area.
Definition: albaAvatar3D.h:137
void SetDebugTextPosition(double *pos)
where to display the text
Definition: albaAvatar3D.h:129
void SetLastPoseMatrix(albaMatrix &matrix)
Internally used to set the last pose matrix.
virtual ~albaAvatar3D()
virtual void UpdateDebugText(const char *title, albaMatrix &pose)
internally used to update debug text on the screen
virtual void OnEvent(albaEventBase *event)
Process events coming from tracker.
void SetPicker3D(vtkALBARayCast3DPicker *picker)
Internally used to redefine the 3D picker class.
vtkProp3D * m_WorkingBoxActor
Prop3D of the working box.
Definition: albaAvatar3D.h:227
virtual int InternalInitialize()
redefined to add the Cursor actor into the selected renderer
@ ID_DEBUG_TEXT_POSITION
Definition: albaAvatar3D.h:67
void SetDisplayDebugText(int vis)
Display the debug text showing trackers coordinate.
vtkCellPicker * GetPicker2D()
Return picker 2D used by 3DAvatar for 2D picking.
void CanonicalToWorld(albaTransform *trans)
virtual void SetRendererAndView(vtkRenderer *ren, albaView *view)
Set/Get the renderer this avatar is attached to.
void DisplayWorkingBoxOn()
Definition: albaAvatar3D.h:119
void WorldToDisplay(albaMatrix &world_pose, double xy[2])
map world coords to tracker coords
vtkTextMapper * m_DebugTextMapper
Definition: albaAvatar3D.h:230
void CanonicalToWorld(const albaMatrix &pose, albaMatrix &dest)
Transform a matrix from Canonical to World space.
void TrackerToDisplay(albaMatrix &tracker_pose, double xy[2])
map tracker coords to display normalized coords
void WorldToCanonical(const albaMatrix &pose, albaMatrix &dest)
albaCameraTransform * GetCanonicalToWorldTransform()
return transform between canonical and world space
Definition: albaAvatar3D.h:176
vtkActor2D * m_DebugTextActor
Definition: albaAvatar3D.h:231
int m_CoordsFrame
Whether to display the original tracker's coords.
Definition: albaAvatar3D.h:245
void TrackerToWorld(albaMatrix &tracker_pose, albaMatrix &world_pose, int use_scale=1, int use_rot=1, int use_trans=1)
Transform a matrix from Tracker frame to World frame, the function can optionally avoid to map on the...
void CanonicalToWorld(albaMatrix &pose)
Definition: albaAvatar3D.h:149
int GetDisplayDebugText()
Definition: albaAvatar3D.h:126
virtual int InternalStore(albaStorageElement *node)
This is used to allow nested serialization of subclasses.
void SetDisplayWorkingBox(int vis)
Display a box showing where input coords are mapped.
int m_DisplayWorkingBox
Whether display the working box.
Definition: albaAvatar3D.h:243
albaMatrix & GetLastPoseMatrix()
return the last pose matrix of the avatar's 3d actor in world coordinates.
Definition: albaAvatar3D.h:189
int GetDisplayWorkingBox()
Definition: albaAvatar3D.h:118
double * m_DebugTextPosition
Definition: albaAvatar3D.h:247
void SetDebugTextPosition(double posx, double posy)
albaAbstractTypeMacro(albaAvatar3D, albaAvatar)
vtkOutlineSource * m_WorkingBox
Working box the tracker coords are mapped to.
Definition: albaAvatar3D.h:228
virtual int InternalRestore(albaStorageElement *node)
This is called by Restore() and must be reimplemented by subclasses The element from which the object...
virtual void Hide()
Hide the 3D cursor, i.e.
void WorldToTracker(albaMatrix &world_pose, albaMatrix &tracker_pose, int use_scale=1, int use_rot=1, int use_trans=1)
albaMatrix m_LastPoseMatrix
Definition: albaAvatar3D.h:233
virtual void OnPostResetCamera(albaEventBase *event)
process event sent after a camera reset
int GetFittingMode()
return the mapping rule currently in use
Definition: albaAvatar3D.h:184
vtkALBARayCast3DPicker * m_Picker3D
Used to pick in a VTK Render window.
Definition: albaAvatar3D.h:235
double * GetDebugTextPosition()
Definition: albaAvatar3D.h:131
void DisplayWorkingBoxOff()
Definition: albaAvatar3D.h:120
virtual void InternalShutdown()
redefined to remove Cursor from renderer
int m_DisplayDebugText
Whether display Debug text.
Definition: albaAvatar3D.h:244
void WorldToCanonical(albaMatrix &pose)
Definition: albaAvatar3D.h:153
void OnUpdateBoundsEvent(albaDeviceButtonsPadTracker *tracker)
process an event signaling a change of the tracked bounds
void WorldToCanonical(albaTransform *trans)
albaCameraTransform * m_CanonicalToWorldTransform
Definition: albaAvatar3D.h:239
int GetCoordsFrame()
Definition: albaAvatar3D.h:138
int m_FittingMode
specify the current mapping rule from canonical to world
Definition: albaAvatar3D.h:241
void SetFittingMode(int type)
Set mapping rule, i.e.
Avatars are entities moving in the virtual world according to user's movements, and thus representing...
Definition: albaAvatar.h:48
Implement transform between view coordinates to world coordinates.
Generic spatial position tracking device.
Implementation of the message object for the Subject/Observer design pattern.
Definition: albaEventBase.h:49
Event class to transport a triggering button and a position from pointing devices.
base class for 3D interaction modalities with 6DOF
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
Abstract class representing the interface for the unit of information stored in the storage.
albaTransform - class for homogeneous transformations.
Definition: albaTransform.h:53
albaView is the base class for Views in alba.
Definition: albaView.h:79