Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkDispatcher.h
Go to the documentation of this file.
1 /*===================================================================
2 
3  The Medical Imaging Interaction Toolkit (MITK)
4 
5  Copyright (c) German Cancer Research Center,
6  Division of Medical and Biological Informatics.
7  All rights reserved.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without
10  even the implied warranty of MERCHANTABILITY or FITNESS FOR
11  A PARTICULAR PURPOSE.
12 
13  See LICENSE.txt or http://www.mitk.org for details.
14 
15  ===================================================================*/
16 
17 #ifndef mitkDispatcher_h
18 #define mitkDispatcher_h
19 
20 #include "itkLightObject.h"
21 #include "itkObjectFactory.h"
22 #include "mitkCommon.h"
23 #include "mitkDataInteractor.h"
24 #include "mitkDataNode.h"
25 #include "usServiceTracker.h"
26 #include <MitkCoreExports.h>
27 #include <list>
28 #include <mitkWeakPointer.h>
29 
30 namespace mitk
31 {
32  class InternalEvent;
33  class InteractionEvent;
34  struct InteractionEventObserver;
35 
48  class MITKCORE_EXPORT Dispatcher : public itk::LightObject
49  {
50  public:
51  mitkClassMacroItkParent(Dispatcher, itk::LightObject);
52  mitkNewMacro1Param(Self, const std::string &);
53 
54  typedef std::list<mitk::WeakPointer<DataInteractor>> ListInteractorType;
55  typedef std::list<itk::SmartPointer<InteractionEvent>> ListEventsType;
56 
62  bool ProcessEvent(InteractionEvent *event);
63 
79  void QueueEvent(InteractionEvent *event);
80 
87  void AddDataInteractor(const DataNode *dataNode);
91  void RemoveDataInteractor(const DataNode *dataNode);
92  size_t GetNumberOfInteractors(); // DEBUG TESTING
93 
94  protected:
95  Dispatcher(const std::string &rendererName);
96  virtual ~Dispatcher();
97 
98  private:
99  ListInteractorType m_Interactors;
100  ListEventsType m_QueuedEvents;
101 
106  void RemoveOrphanedInteractors();
107 
111  ProcessEventMode m_ProcessingMode;
112  mitk::WeakPointer<DataInteractor> m_SelectedInteractor;
113 
114  void SetEventProcessingMode(DataInteractor *);
115 
121  bool HandleInternalEvent(InternalEvent *internalEvent);
122 
127  us::ServiceTracker<InteractionEventObserver> *m_EventObserverTracker;
128  };
129 
130 } /* namespace mitk */
131 #endif /* mitkDispatcher_h */
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:76
Manages event distribution.
std::list< mitk::WeakPointer< DataInteractor > > ListInteractorType
DataCollection - Class to facilitate loading/accessing structured data.
Class to create events from within the application to signal about internal events.
Base class from with interactors that handle DataNodes are to be derived.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
std::list< itk::SmartPointer< InteractionEvent > > ListEventsType
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66