ALBA
albaEventInteraction.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaEventInteraction
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 __albaEventInteraction_h
18#define __albaEventInteraction_h
19
20#include "albaEventBase.h"
21#include "albaMatrix.h"
22#include "albaSmartPointer.h"
23
24template class ALBA_EXPORT albaAutoPointer<albaMatrix>;
25
26class albaView;
27class albaDevice;
28class albaVME;
29class albaInteractor;
30class vtkProp3D;
31
41class ALBA_EXPORT albaEventInteraction : public albaEventBase
42{
43public:
46
48 void Set2DPosition(double x,double y);
50 void Set2DPosition(const double pos[2]);
51
53 void Get2DPosition(double pos[2]);
54
56 void SetXYFlag(bool val);
57
59 bool GetXYFlag();
60
62 void SetButton(int button);
64 int GetButton() {return m_Button;}
65
67 void SetKey(unsigned char key);
69 unsigned char GetKey() {return m_Key;}
70
74 void SetMatrix(albaMatrix *matrix);
75
77 void SetModifier(unsigned long idx,bool value=true);
79 bool GetModifier(unsigned long idx);
81 void SetModifiers(unsigned long modifiers);
83 unsigned long GetModifiers() {return m_Modifiers;}
84
86 virtual void DeepCopy(const albaEventBase *event);
87
92 bool FindPokedVme(albaView *view, albaDevice *device, vtkProp3D *&pickedProp, albaVME *&pickedVme, albaInteractor *&pickedBehavior);
93
95 void GetPickedPosition(double pos[3]);
96
98 void ResetPick();
99
101 albaEventInteraction(void *sender=NULL,albaID id=-1,int button=0,unsigned long modifiers=0):
102 albaEventBase(sender,id),m_Button(button),m_Modifiers(modifiers),m_Key(0),m_X(0),m_Y(0),m_XYFlag(false) {ResetPick();}
103
105 albaEventInteraction(void *sender,albaID id,albaMatrix *matrix,int button=0,unsigned long modifiers=0):
106 albaEventBase(sender,id),m_Button(button),m_Modifiers(modifiers),m_Key(0),m_Matrix(matrix),m_X(0),m_Y(0),m_XYFlag(false) {ResetPick();}
107
109 albaEventInteraction(void *sender,albaID id,double x,double y,int button=0,unsigned long modifiers=0):
110 albaEventBase(sender,id),m_X(x),m_Y(y),m_XYFlag(true),m_Button(button),m_Modifiers(modifiers),m_Key(0) {ResetPick();}
112
113protected:
114
116 bool m_Picked;
119 vtkProp3D *m_PickedProp;
122 double m_PickedPosition[3];
123
125 unsigned long m_Modifiers;
126 unsigned char m_Key;
127 double m_X;
128 double m_Y;
129 bool m_XYFlag;
130
132};
133
134#endif /* __albaEventInteraction_h */
135
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:61
Hold a reference to a T instance.
This abstract class manages function calls coming from devices and issue specific events to interacto...
Definition: albaDevice.h:42
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.
void Set2DPosition(const double pos[2])
Set screen position, for 2D tracking devices.
albaEventInteraction(void *sender, albaID id, albaMatrix *matrix, int button=0, unsigned long modifiers=0)
overloaded constructor
albaView * m_PickView
View used by the cached picking.
albaDevice * m_PickDevice
Device used by the cached picking.
albaInteractor * m_PickedBehavior
Cached behavior of the picked VME.
void ResetPick()
Discard the cached picking, to be called when the scene or the camera has been changed.
void SetMatrix(albaMatrix *matrix)
Set the pose matrix, for 3D tracking devices.
void SetKey(unsigned char key)
Set the optional key argument.
void SetModifiers(unsigned long modifiers)
Set the given modifiers value.
void SetModifier(unsigned long idx, bool value=true)
Set the given modifier value.
void Get2DPosition(double pos[2])
Get screen position, for 2D tracking devices.
unsigned char m_Key
Optional Key.
double m_X
X coordinate, used by mouse device.
albaEventInteraction(void *sender=NULL, albaID id=-1, int button=0, unsigned long modifiers=0)
overloaded constructor
albaVME * m_PickedVme
Cached picked VME.
bool m_XYFlag
Used to signal a 2D coordinate is present.
virtual void DeepCopy(const albaEventBase *event)
Deep Copy of the object (the cached picking is not copied)
bool GetXYFlag()
get the flag for 2D coords
void Set2DPosition(double x, double y)
Set screen position, for 2D tracking devices.
unsigned long GetModifiers()
Get the given modifiers value.
bool m_Picked
True if the cached picking found a VME.
vtkProp3D * m_PickedProp
Cached picked prop.
albaAutoPointer< albaMatrix > m_Matrix
Pose matrix, used by 3D trackers.
albaEventInteraction(void *sender, albaID id, double x, double y, int button=0, unsigned long modifiers=0)
overloaded constructor
albaTypeMacro(albaEventInteraction, albaEventBase)
RTTI macro.
void SetXYFlag(bool val)
set the flag for 2D coords
bool m_PickDone
True if the picking has been performed for this event.
double m_Y
Y coordinate, used by mouse device.
unsigned long m_Modifiers
Optional modifiers for the button.
void GetPickedPosition(double pos[3])
Return the position picked by FindPokedVme, meaningful only if a VME has been picked.
void SetButton(int button)
Set the triggering button.
bool GetModifier(unsigned long idx)
Get the given modifier value.
int GetButton()
Get the triggering button.
albaMatrix * GetMatrix()
Get the pose matrix, for 3D tracking devices.
int m_Button
Optional button which triggered the event.
unsigned char GetKey()
Get the optional key argument.
bool FindPokedVme(albaView *view, albaDevice *device, vtkProp3D *&pickedProp, albaVME *&pickedVme, albaInteractor *&pickedBehavior)
Find the VME picked by the device at the event position on the given view.
Abstract class for ALBA interactors This class provides base interface and features of ALBA continuou...
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:45
albaVME -
Definition: albaVME.h:150
albaView is the base class for Views in alba.
Definition: albaView.h:79