ALBA
albaInteractor.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaInteractor
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 __albaInteractor_h
18#define __albaInteractor_h
19
20#include "albaAgent.h"
21#include "albaString.h"
22#include "vtkALBASmartPointer.h"
23
24//----------------------------------------------------------------------------
25// forward declarations :
26//----------------------------------------------------------------------------
27class albaDevice;
29class albaVME;
30class albaMatrix;
31
32class vtkRenderer;
33class vtkProp3D;
34
60class ALBA_EXPORT albaInteractor : public albaAgent
61{
62public:
64 virtual ~albaInteractor();
65
66 //------------------------------------------------------------------------------
67 // Events
68 //------------------------------------------------------------------------------
69 ALBA_ID_DEC(INTERACTION_STARTED);
70 ALBA_ID_DEC(INTERACTION_STOPPED);
71 ALBA_ID_DEC(BUTTON_DOWN);
72 ALBA_ID_DEC(BUTTON_UP);
73
75
79 virtual void SetRendererAndView(vtkRenderer *ren, albaView *view);
80 vtkRenderer *GetRenderer() {return m_Renderer;}
81 albaView *GetView() {return m_View;}
82
84 albaDevice *GetDevice() {return m_Device;}
86 virtual void SetDevice(albaDevice *);
87
89 virtual void SetVME(albaVME *vme);
90
92 void SetProp(vtkProp3D *prop);
93
99 void SetIgnoreTriggerEvents(bool flag) {m_IgnoreTriggerEvents=flag;}
100 int GetIgnoreTriggerEvents(bool flag) {return m_IgnoreTriggerEvents;}
101 void IgnoreTriggerEventsOn() {SetIgnoreTriggerEvents(true);}
102 void IgnoreTriggerEventsOff() {SetIgnoreTriggerEvents(false);}
103
105 void SetStartInteractionEvent(albaID event) {m_StartInteractionEvent=event;}
107 albaID GetStartInteractionEvent() {return m_StartInteractionEvent;}
108
110 void SetStopInteractionEvent(albaID event) {m_StopInteractionEvent=event;}
112 albaID GetStopInteractionEvent() {return m_StopInteractionEvent;}
113
115 void SetStartButton(int btn) {m_StartButton=btn;}
116 int GetStartButton() {return m_StartButton;}
117
119 void SetModifiers(int mod) {m_Modifiers=mod;}
120 int GetModifiers() {return m_Modifiers;}
121
123 int GetCurrentButton() {return m_CurrentButton;}
124
126 unsigned long GetCurrentModifier() {return m_CurrentModifier;}
127
134 virtual int StartInteraction(albaDevice *device);
135
139 virtual int StopInteraction(albaDevice *device);
140
142 virtual bool IsInteracting();
143
145 virtual bool IsInteracting(albaDevice *device);
146
147 enum modalities {SINGLE_BUTTON_MODE=0,MULTI_BUTTON_MODE};
148
149 void SetButtonMode(int mode) {m_ButtonMode=mode;}
150 int GetButtonMode() {return m_ButtonMode;}
151 void SetButtonModeToSingleButton() {m_ButtonMode=SINGLE_BUTTON_MODE;}
152 void SetButtonModeToMultiButton() {m_ButtonMode=MULTI_BUTTON_MODE;}
153
154
156 virtual void OnEvent(albaEventBase *event);
157
159 void TestModeOn() {m_TestMode = true;};
160
162 void TestModeOff() {m_TestMode = false;};
163
165 bool GetTestMode(){return m_TestMode;};
166
167protected:
168
176
183
186
187 void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4]);
188 void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3]);
189
190
195// virtual bool FindPokedVme(albaDevice *device,albaMatrix &point_pose,vtkProp3D *&picked_prop,albaVME *&picked_vme,albaInteractor *&picked_behavior);
196
197
199
206 unsigned long m_Modifiers;
208 unsigned long m_CurrentModifier;
211
214
217
219
220private:
221 albaInteractor(const albaInteractor&); // Not implemented.
222 void operator=(const albaInteractor&); // Not implemented.
223};
224
225#endif
long albaID
type for IDs inside ALBA
Definition: albaDefines.h:58
An agent is a computational object with a default I/O interface.
Definition: albaAgent.h:50
This abstract class manages function calls coming from devices and issue specific events to interacto...
Definition: albaDevice.h:40
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.
Abstract class for ALBA interactors This class provides base interface and features of ALBA continuou...
virtual void SetDevice(albaDevice *)
Set the current input device.
bool GetTestMode()
Get TestMode.
void SetStartInteractionEvent(albaID event)
Set the event used to trigger the start of an interaction session.
void SetStartButton(int btn)
Set the modifier that should start the interaction.
void SetButtonMode(int mode)
void SetIgnoreTriggerEvents(bool flag)
Enable/Disable trigger events processing.
ALBA_ID_DEC(INTERACTION_STOPPED)
Issued when interaction is stopped.
virtual int StopInteraction(albaDevice *device)
Stop the interaction, the optional argument force sending an event on the DefaultChannel advising the...
bool m_DeviceIsSet
true if the device has been set with SetDevice by other classes
virtual bool IsInteracting(albaDevice *device)
return true if the specified device is currently in a interaction session
void SetStopInteractionEvent(albaID event)
Set the event used to trigger the end of an interaction session.
void TestModeOn()
Turn On m_TestMode flag.
ALBA_ID_DEC(BUTTON_UP)
Issued when a button is released.
void SetProp(vtkProp3D *prop)
Set the prop to be transformed (optional and to be removed!!!)
albaID m_StopInteractionEvent
the event ID starting the interaction
virtual void SetVME(albaVME *vme)
Set the node to be transformed.
unsigned long m_Modifiers
modifiers of the button for starting the interaction
albaView * GetView()
int GetIgnoreTriggerEvents(bool flag)
bool m_TestMode
Flag used with cppunitTest.
albaDevice * m_Device
Find the pocked VME at button down.
void IgnoreTriggerEventsOff()
virtual void OnButtonDown(albaEventInteraction *e)
albaVME * m_VME
the object being interacted (optional)
virtual bool IsInteracting()
return true if currently in a interaction session
unsigned long GetCurrentModifier()
return the modifers at start of interaction
int m_ButtonMode
Specify if working in single button or multi button mode.
albaView * m_View
the view this interactor is working on
albaID GetStartInteractionEvent()
Get the event used to trigger the start of an interaction session.
void SetButtonModeToSingleButton()
virtual int OnStopInteraction(albaEventInteraction *e)
Process m_StopInteractionEvent.
ALBA_ID_DEC(BUTTON_DOWN)
Issued when a button is pressed.
virtual void SetRendererAndView(vtkRenderer *ren, albaView *view)
Set/Get the renderer this interactor is attached to.
ALBA_ID_DEC(INTERACTION_STARTED)
Issued when interaction is started.
void ComputeWorldToDisplay(double x, double y, double z, double displayPt[3])
void SetButtonModeToMultiButton()
vtkRenderer * GetRenderer()
albaAbstractTypeMacro(albaInteractor, albaAgent)
vtkALBASmartPointer< vtkRenderer > m_Renderer
the renderer this interactor is working on
void TestModeOff()
Used to turn off m_TestMode flag.
int GetCurrentButton()
return the button which started the interaction
vtkALBASmartPointer< vtkProp3D > m_Prop
the prop being interacted (optional)
void IgnoreTriggerEventsOn()
int m_CurrentButton
the button that started the interaction
int m_ButtonsCounter
Take count of the number of button pressed.
void ComputeDisplayToWorld(double x, double y, double z, double worldPt[4])
int m_InteractionFlag
flag if interacting
int m_StartButton
the button that can start the interaction
virtual int StartInteraction(albaDevice *device)
Start the interaction, the optional argument force sending an event on the DefaultChannel advising th...
virtual ~albaInteractor()
unsigned long m_CurrentModifier
m_Modifiers state when interaction was started
void SetModifiers(int mod)
Set the modifier that should start the interaction.
albaID m_StartInteractionEvent
the event ID starting the interaction
albaID GetStopInteractionEvent()
Set the event used to trigger the end of an interaction session.
albaDevice * GetDevice()
Return the current input device.
virtual void OnButtonUp(albaEventInteraction *e)
virtual void OnEvent(albaEventBase *event)
Process events coming from input device.
int m_IgnoreTriggerEvents
flag to ignore start/stop interaction
virtual int OnStartInteraction(albaEventInteraction *e)
Process StartInteractionEvent.
albaMatrix - Time stamped 4x4 Matrix.
Definition: albaMatrix.h:44
albaVME -
Definition: albaVME.h:150
albaView is the base class for Views in alba.
Definition: albaView.h:79