Medical Imaging Interaction Toolkit  2018.4.99-08619e4f
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkDispatcher_h
14 #define mitkDispatcher_h
15 
16 #include "itkLightObject.h"
17 #include "itkObjectFactory.h"
18 #include "mitkCommon.h"
19 #include "mitkDataInteractor.h"
20 #include "mitkDataNode.h"
21 #include "usServiceTracker.h"
22 #include <MitkCoreExports.h>
23 #include <list>
24 #include <mitkWeakPointer.h>
25 
26 namespace mitk
27 {
28  class InternalEvent;
29  class InteractionEvent;
30  struct InteractionEventObserver;
31 
44  class MITKCORE_EXPORT Dispatcher : public itk::LightObject
45  {
46  public:
47  mitkClassMacroItkParent(Dispatcher, itk::LightObject);
48  mitkNewMacro1Param(Self, const std::string &);
49 
50  typedef std::list<mitk::WeakPointer<DataInteractor>> ListInteractorType;
51  typedef std::list<itk::SmartPointer<InteractionEvent>> ListEventsType;
52 
58  bool ProcessEvent(InteractionEvent *event);
59 
75  void QueueEvent(InteractionEvent *event);
76 
83  void AddDataInteractor(const DataNode *dataNode);
87  void RemoveDataInteractor(const DataNode *dataNode);
88  size_t GetNumberOfInteractors(); // DEBUG TESTING
89 
90  protected:
91  Dispatcher(const std::string &rendererName);
92  ~Dispatcher() override;
93 
94  private:
95  ListInteractorType m_Interactors;
96  ListEventsType m_QueuedEvents;
97 
102  void RemoveOrphanedInteractors();
103 
107  ProcessEventMode m_ProcessingMode;
108  mitk::WeakPointer<DataInteractor> m_SelectedInteractor;
109 
110  void SetEventProcessingMode(DataInteractor *);
111 
117  bool HandleInternalEvent(InternalEvent *internalEvent);
118 
123  us::ServiceTracker<InteractionEventObserver> *m_EventObserverTracker;
124  };
125 
126 } /* namespace mitk */
127 #endif /* mitkDispatcher_h */
#define MITKCORE_EXPORT
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
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:49
std::list< itk::SmartPointer< InteractionEvent > > ListEventsType
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57