Medical Imaging Interaction Toolkit  2023.12.99-27cb8410
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
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
us::ServiceTracker
Definition: usServiceTracker.h:231
mitkNewMacro1Param
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:68
mitk::Dispatcher::ListEventsType
std::list< itk::SmartPointer< InteractionEvent > > ListEventsType
Definition: mitkDispatcher.h:51
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::Dispatcher
Manages event distribution.
Definition: mitkDispatcher.h:44
MitkCoreExports.h
mitkCommon.h
mitk::ProcessEventMode
ProcessEventMode
Definition: mitkDataInteractor.h:34
mitkDataInteractor.h
usServiceTracker.h
mitkDataNode.h
mitkWeakPointer.h
mitk::Dispatcher::ListInteractorType
std::list< mitk::WeakPointer< DataInteractor > > ListInteractorType
Definition: mitkDispatcher.h:48
mitk::DataInteractor
Base class from with interactors that handle DataNodes are to be derived.
Definition: mitkDataInteractor.h:48
mitk::WeakPointer< DataInteractor >
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::InternalEvent
Class to create events from within the application to signal about internal events.
Definition: mitkInternalEvent.h:34