ALBA
albaInteractionManager.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaInteractionManager
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#ifndef __albaInteractionManager_h
17#define __albaInteractionManager_h
18
19#include "albaObject.h"
20#include "albaObserver.h"
21#include "albaEventSender.h"
22#include "albaStorable.h"
23#include "albaString.h"
24#include "albaSmartPointer.h"
25
26#include <map>
27#include <set>
28#include <list>
29
30//----------------------------------------------------------------------------
31// forward declarations
32//----------------------------------------------------------------------------
33class albaEventBase;
34class albaEvent;
35class albaAction;
36class albaInteractor;
37#ifdef ALBA_EXPORTS
38#include "albaAvatar.h"
39#else
40class albaAvatar;
41#endif
42class albaDevice;
44class albaDeviceSet;
46class albaGUIInteractionSettings;
47class vtkRenderer;
48class vtkRendererWindow;
49class albaView;
50class mflXMLWriter;
51class vtkXMLDataElement;
52class vtkXMLDataParser;
55class albaVME;
56class albaGUIDialog;
57class albaGUI;
58class albaGUITree;
60class albaGUIHolder;
62
63#ifdef ALBA_EXPORTS
64#include "albaDllMacros.h"
66EXPORT_STL_VECTOR(ALBA_EXPORT, albaAvatar *);
68#endif
69
70
84class ALBA_EXPORT albaInteractionManager : public albaObject, public albaObserver, public albaEventSender, public albaStorable
85{
86public:
89
91
93 void EnableSelect(bool enable);
94
96 virtual void OnEvent(albaEventBase *event);
97
99 albaDeviceManager *GetDeviceManager() {return m_DeviceManager;}
100
103
105 //albaAction *GetMouseAction();
106
108 albaAction *AddAction(const char *name, float priority = 0.0);
109
113 int BindAction(const char *action,albaInteractor *agent);
114
118 int UnBindAction(const char *action,albaInteractor *agent);
119
121 void AddAvatar(albaAvatar *avatar);
122
125
127 albaAvatar *GetAvatar(const char *name);
128
129 typedef std::map<albaString,albaAutoPointer<albaAvatar> > mmuAvatarsMap;
130 typedef std::vector<albaAvatar *> mmuAvatarsVector;
131
134
137
139 albaAction *GetAction(const char *name);
140
144
146 albaView *GetSelectedView(albaView *view) {return m_SelectedView;}
147
149 void SetCurrentRenderer(vtkRenderer *ren);
150
153 vtkRenderer *GetCurrentRenderer() {return m_CurrentRenderer;}
154
156 void PreResetCamera(vtkRenderer *ren);
158 void PostResetCamera(vtkRenderer *ren);
159
162
164 int Store(const char *filename);
165
167 int Restore(const char *filename);
168
172 //void CameraUpdate(vtkRendererWindow *rw) {/* NOT YET IMPLEMENTED */}
173
177 void CameraUpdate(albaView *view=NULL);
178
179
181 albaInteractorPER *GetPER() {return m_PositionalEventRouter;}
182
185
188
190 bool PopPER();
191
193 albaInteractorSER *GetSER() {return m_StaticEventRouter;}
194
197
199 albaTimeStamp GetIntraFrameTime() {return m_IntraFrameTime;}
201 void SetIntraFrameTime(albaTimeStamp iftime) {m_IntraFrameTime=iftime;}
202
204 int DeviceChooser(wxString &dev_name,wxString &dev_type);
205
207 void AddDeviceToTree(albaDevice *device,albaDeviceSet *parent=NULL);
209
211 //void UpdateDeviceTree();
212
215
218
220 //bool ShowModal(); //SIL. 07-jun-2006 :
221 albaGUI* GetGui(); //SIL. 07-jun-2006 :
222
223 albaInteractorSER *GetStaticEventRouter() {return m_StaticEventRouter;}
224
225protected:
228
231
232 virtual void OnStartDispatching();
233 virtual void OnEndDispatching();
235 virtual void OnViewSelected(albaEvent *event);
236 virtual void OnDeviceAdded(albaEventBase *event);
237 virtual void OnDeviceRemoving(albaEventBase *event);
238 virtual void OnDeviceNameChanged(albaEventBase *event);
240 virtual void OnAddAvatar(albaEventBase *event);
241 virtual void OnRemoveAvatar(albaEventBase *event);
242
244 void CreateGUI();
245
246 albaGUI* m_Gui; //SIL. 07-jun-2006 :
247 wxFrame* m_Frame;
248 //albaGUIDialog* m_Dialog;
253 //albaGUINamedPanel* m_BindingsPanel;
255
258
262
264 std::list<albaInteractorPER *> m_PERList;
265
266 std::set<albaView *> m_CameraUpdateRequests;
267
269 vtkRenderer* m_CurrentRenderer;
273
274private:
276 int Store(albaStorageElement *element) {return albaStorable::Store(element);}
277
279 int Restore(albaStorageElement *element) {return albaStorable::Restore(element);}
280};
281#endif
double albaTimeStamp
type for time varying data timestamps (not for pipelines timestamps!)
Definition: albaDefines.h:57
#define EXPORT_STL_VECTOR(declspec_, T_)
Definition: albaDllMacros.h:84
#define EXPORT_STL_MAP(declspec_, K_, V_)
Definition: albaDllMacros.h:90
#define EXPORT_STL_LIST(declspec_, T_)
Definition: albaDllMacros.h:87
Class used to route events from devices to interactors.
Definition: albaAction.h:35
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
Class managing the devices inside a ALBA application and the synchronization with wxWindows message p...
This class manages a set of usb-devices, and stores a list of all child devices' pointers.
Definition: albaDeviceSet.h:39
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
class acting as an interface for objects using ALBA hierarchical event communication model This objec...
albaEvent - Class implementing ALBA application events.
Definition: albaEvent.h:55
a CheckList that send albaEventNotification in the form albaEvent(this, widget_id,...
albaGUIDialog is the base class for albaDialogs.
Definition: albaGUIDialog.h:76
class name: albaGUIHolder Secialized panel in which a developer can put a albaGUI.
Definition: albaGUIHolder.h:32
Class Name: albaGUINamedPanel.
albaGUITree allows a simplified and lot easier use of a wxWindows tree widget.
Definition: albaGUITree.h:97
albaGUI is a panel with function to easily create GUI.
Definition: albaGUI.h:110
This class takes care of mastering the interaction inside views.
albaDeviceManager * GetDeviceManager()
Get the device manager object.
std::vector< albaAvatar * > mmuAvatarsVector
int Restore(const char *filename)
restore interaction settings from an XML file (Multimod Interaction Settings - MIS - format)
albaInteractorPER * m_PositionalEventRouter
albaTimeStamp GetIntraFrameTime()
return the minimum time to elapse between two subsequent renderings
virtual void OnDeviceRemoving(albaEventBase *event)
void SetPER(albaInteractorPER *per)
used to override the default PER.
albaDeviceManager * m_DeviceManager
void PostResetCamera(vtkRenderer *ren)
used to propagate PostReset camera event
virtual void OnEndDispatching()
int BindAction(const char *action, albaInteractor *agent)
Bind an agent to the specified action.
albaInteractorSER * GetSER()
return the static event router
albaDeviceButtonsPadMouse * GetMouseDevice()
return the mouse device
void CameraFlyToMode()
Set the FlyTo mode for the selected view.
const mmuAvatarsMap & GetAvatars()
Return the avatars container.
albaAvatar * GetAvatar(const char *name)
Get an avatar given its name.
virtual void OnBindDeviceToAction(albaEvent *e)
virtual int InternalRestore(albaStorageElement *node)
This is called by Restore() to restore information of this object.
albaInteractorSER * GetStaticEventRouter()
int RemoveAvatar(albaAvatar *avatar)
Remove an avatar.
int DeviceChooser(wxString &dev_name, wxString &dev_type)
Open a dialog to choose among available devices.
virtual void OnAddAvatar(albaEventBase *event)
albaGUICheckListBox * m_ActionsList
int UnBindAction(const char *action, albaInteractor *agent)
Unbind an agent from the specified action.
virtual void OnCameraUpdate(albaEventBase *e)
virtual void OnDeviceAdded(albaEventBase *event)
albaInteractorSER * m_StaticEventRouter
std::map< albaString, albaAutoPointer< albaAvatar > > mmuAvatarsMap
virtual void OnStartDispatching()
albaGUI * GetGui()
Show in modal configuration the settings dialog.
void UpdateBindings()
update bindings check list
void VmeSelected(albaVME *vme)
propagate VME_SELECTED event
void CreateGUI()
Create the GUI dialog.
bool PopPER()
restore previous PER instance
virtual int InternalStore(albaStorageElement *node)
This is called by Store() to store information of this object.
virtual void OnDeviceNameChanged(albaEventBase *event)
virtual void OnRemoveAvatar(albaEventBase *event)
albaTimeStamp m_LastRenderTime
used to avoid overloading of the GUI process due to rendering
albaAction * AddAction(const char *name, float priority=0.0)
return the mouse action, an action to which mouse is bound by default
vtkRenderer * GetCurrentRenderer()
Return the renderer of the currently selected view, if its a VTK based view otherwise return NULL.
int Store(const char *filename)
store all interaction settings to an XML file (Multimod Interaction Settings - MIS - format)
void UpdateDevice(albaDevice *device)
Update names in device list.
virtual ~albaInteractionManager()
vtkRenderer * m_CurrentRenderer
the renderer of selected view: to be removed!
void CameraUpdate(albaView *view=NULL)
propagate a request for rendering the specified window or all the windows (rw==NULL).
std::list< albaInteractorPER * > m_PERList
the interactor devoted to Positional Event Routing
albaView * GetSelectedView(albaView *view)
Return the currently selected view.
void AddAvatar(albaAvatar *avatar)
Define a new avatar.
void PreResetCamera(vtkRenderer *ren)
used to propagate PreReset camera event
void GetAvatars(mmuAvatarsVector &avatars)
return an array with the list of avatars currently connected
void EnableSelect(bool enable)
Enable/Disable VME selection by picking.
void RemoveDeviceFromTree(albaDevice *device)
mmuAvatarsMap m_Avatars
keeps a list of visible avatars
albaAction * GetAction(const char *name)
Get an action router.
albaTypeMacro(albaInteractionManager, albaObject)
std::set< albaView * > m_CameraUpdateRequests
requests for Camera update of single views
void SetIntraFrameTime(albaTimeStamp iftime)
set the minimum time to elapse between two subsequent renderings
albaInteractorPER * GetPER()
return the positional event router
albaView * m_SelectedView
the view currently selected
void ViewSelected(albaView *view)
Set the selected view.
albaTimeStamp m_IntraFrameTime
the minimum time to elapse between two subsequent renderings
virtual void OnEvent(albaEventBase *event)
Process incoming events.
void SetCurrentRenderer(vtkRenderer *ren)
Set the selected VTK renderer.
void AddDeviceToTree(albaDevice *device, albaDeviceSet *parent=NULL)
This is used to allow also external objects to add devices.
void PushPER(albaInteractorPER *per)
set a new PER and keep the old one in a list
virtual void OnViewSelected(albaEvent *event)
Class implementing routing of events based on picking.
Class implementing static routing from devices to interactors passing through actions.
Abstract class for ALBA interactors This class provides base interface and features of ALBA continuou...
Abstract superclass for all ALBA classes implementing RTTI APIs.
Definition: albaObject.h:38
Interface implementing the Observer of the Subject/Observer design pattern.
Definition: albaObserver.h:36
albaStorable is an interface for serializable objects.
Definition: albaStorable.h:41
int Restore(albaStorageElement *element)
Restore this object from an XML document.
int Store(albaStorageElement *element)
Storing this object as part of an XML document.
Abstract class representing the interface for the unit of information stored in the storage.
albaString - performs common string operations on c-strings.
Definition: albaString.h:43
albaVME -
Definition: albaVME.h:150
albaView is the base class for Views in alba.
Definition: albaView.h:79