ALBA
albaDeviceButtonsPadTracker.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaDeviceButtonsPadTracker
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 __albaDeviceButtonsPadTracker_h
18#define __albaDeviceButtonsPadTracker_h
19
21#include "albaMutexLock.h"
22#include "albaSmartPointer.h"
23#include "albaOBB.h"
24#include "albaAvatar.h"
25//----------------------------------------------------------------------------
26// forward declarations :
27//----------------------------------------------------------------------------
28class albaTransform;
29class albaMatrix;
30class albaOBB;
31
32template class ALBA_EXPORT albaAutoPointer<albaAvatar>;
33
68{
69public:
71
72 //------------------------------------------------------------------------------
73 // Events
74 //------------------------------------------------------------------------------
77 // ALBA_ID_DEC(TRACKER_3D_MOVE)
80 // ALBA_ID_DEC(TRACKER_BOUNDS_UPDATED)
81
82 //----------------------------------------------------------------------------
83 // GUI Constants
84 //----------------------------------------------------------------------------
86 {
87 ID_TB_X_EXTENT=Superclass::ID_LAST,
94 ID_LAST
95 };
96
99
104 virtual void OnEvent(albaEventBase *event);
105
110 void SetLastPoseMatrix(const albaMatrix &matrix);
112
114 void SetMoveEventTimeOut(albaTimeStamp t) {m_MoveEventTimeOut=t;}
115 albaTimeStamp GetMoveEventTimeOut() {return m_MoveEventTimeOut;}
116
120
125
128 //void TrackerToCanonical(vtkMatrix4x4 *pose,vtkMatrix4x4 *dest=NULL);
129 void TrackerToCanonical(const albaMatrix &pose,albaMatrix &dest);
132
135 void CanonicalToTracker(const albaMatrix &pose, albaMatrix &dest);
138
141 void SetAvatar(albaAvatar *avatar);
142 albaAvatar *GetAvatar() {return m_Avatar;}
143
151 albaAvatar *GetDefaultAvatar() {return m_DefaultAvatar;}
152
158
166
169
174 albaOBB &GetTrackedBounds() {return m_TrackedBounds;}
175
180 double *GetTrackedBoxOrientation() {return m_TrackedBoxOrientation;}
181
183 inline double GetMax(double x,double y);
184
186 inline double GetMax3(double x,double y,double z);
187
189 virtual void CreateGui();
190
192 virtual void UpdateGui();
193
194protected:
197
200
201 virtual int InternalInitialize();
202 virtual void InternalShutdown();
203
206
207 int AvatarChooser(wxString &avatar_name,wxString &avatar_type);
208
213 //albaEventInteraction* m_LastMoveEvent;
215
217
220
221
222
226 double m_TrackedBoxOrientation[3];
227 double m_TBPosition[3];
228
229private:
231 void operator=(const albaDeviceButtonsPadTracker&); // Not implemented.
232};
233
234//------------------------------------------------------------------------------
235// Return the maximum value among two.
236inline double albaDeviceButtonsPadTracker::GetMax(double x,double y)
237//------------------------------------------------------------------------------
238{
239 return (x>=y)?x:y;
240}
241
242//------------------------------------------------------------------------------
243// Return the maximum value among the 3 values for X,Y and Z axes.
244inline double albaDeviceButtonsPadTracker::GetMax3(double x,double y, double z)
245//------------------------------------------------------------------------------
246{
247 return (x>=y)?x:((y>=z)?y:z);
248}
249
250#endif
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:58
double albaTimeStamp
type for time varying data timestamps (not for pipelines timestamps!)
Definition: albaDefines.h:57
Hold a reference to a T instance.
Avatars are entities moving in the virtual world according to user's movements, and thus representing...
Definition: albaAvatar.h:48
Generic spatial position tracking device.
virtual ~albaDeviceButtonsPadTracker()
albaAutoPointer< albaAvatar > m_Avatar
the current avatar
int AvatarChooser(wxString &avatar_name, wxString &avatar_type)
albaOBB m_CanonicalBounds
Bounds of canonical space.
double GetMax3(double x, double y, double z)
utility function for finding maximum among 3 values
albaMatrix & GetLastPoseMatrix()
virtual void OnEvent(albaEventBase *event)
Reimplemented to manage fusion of move events.
static albaID GetTrackerBoundsUpdatedId()
return th tracker bounds updated id
void CanonicalToTracker(const albaMatrix &pose, albaMatrix &dest)
This is used to map a pose in canonical frame into tracker's frame.
double GetMax(double x, double y)
utility function for finding maximum among 2 values
virtual int InternalStore(albaStorageElement *node)
This is used to allow nested serialization of subclasses.
void TrackerToCanonical(albaTransform *trans)
albaMatrix * m_LastPoseMatrix
stores the last pose matrix
albaOBB & GetCanonicalBounds()
return bounds of canonical space
void RestoreDefaultAvatar()
Restore the avatar to the default one.
void SetMoveEventTimeOut(albaTimeStamp t)
set the timeout after which the event is discarded (in seconds)
static albaID GetTracker3DMoveId()
return the tracker 3d move id
void SetTrackerToCanonicalTransform(albaTransform *trans)
Set the transform to be used to map coordinates between tracker and canonical frames.
void ComputeTrackerToCanonicalTansform()
Update the Tracker to Canonical transform.
albaAutoPointer< albaAvatar > m_DefaultAvatar
the avatar set thorugh the GUI
void SetDefaultAvatar(albaAvatar *avatar)
Set the default avatar, i.e.
albaTypeMacro(albaDeviceButtonsPadTracker, albaDeviceButtonsPad)
virtual void SendButtonEvent(albaEventInteraction *event)
add pose matrix to the event
virtual void InternalShutdown()
to be redefined by subclasses to define the shutdown actions
virtual int InternalInitialize()
start device
albaOBB & GetTrackedBounds()
return bounds of tracked volume.
double * GetTrackedBoxOrientation()
return orientation of tracked volume.
albaTransform * GetTrackerToCanonicalTransform()
return the transform mapping coordinates from tracker to canonical frame.
void SetLastPoseMatrix(const albaMatrix &matrix)
Internally used to set the last pose matrix.
virtual void CreateGui()
internal function to create device GUI for settings
int m_LastPose
Flag used when last pose has not been served yet.
void SetAvatar(albaAvatar *avatar)
Set/Get the avatar assigned to this device.
void TrackerToCanonical(const albaMatrix &pose, albaMatrix &dest)
This is used to map the RAW transform in tracker's frame into the canonical frame.
albaOBB m_TrackedBounds
Stores tracked volume bounds (xmin,xmax,ymin,ymax,zmin,zmax)
virtual void UpdateGui()
force GUI update
virtual int InternalRestore(albaStorageElement *node)
This function fills in the device with settings restored from the node.
albaTimeStamp m_LastMoveTime
Time stamp of last MoveEvent.
void CanonicalToTracker(albaTransform *trans)
Device implementing interface for buttons.
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.
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
Critical section locking class that can be allocated on the stack.
Definition: albaMutexLock.h:33
This class simply stores a Box boundary (i.e.
Definition: albaOBB.h:37
Abstract class representing the interface for the unit of information stored in the storage.
albaTransform - class for homogeneous transformations.
Definition: albaTransform.h:53
TRACKER_WIDGET_ID
Issued when the tracker is moved.