Medical Imaging Interaction Toolkit  2026.06.00
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 
54  class MITKCORE_EXPORT Dispatcher : public itk::LightObject
55  {
56  public:
57  mitkClassMacroItkParent(Dispatcher, itk::LightObject);
58  mitkNewMacro1Param(Self, const std::string &);
59 
61  typedef std::list<mitk::WeakPointer<DataInteractor>> ListInteractorType;
63  typedef std::list<itk::SmartPointer<InteractionEvent>> ListEventsType;
64 
77 
91 
100  void AddDataInteractor(const DataNode *dataNode);
101 
106  void RemoveDataInteractor(const DataNode *dataNode);
107 
113 
114  protected:
115  Dispatcher(const std::string &rendererName);
116  ~Dispatcher() override;
117 
118  private:
119  ListInteractorType m_Interactors;
120  ListEventsType m_QueuedEvents;
121 
126  void RemoveOrphanedInteractors();
127 
131  ProcessEventMode m_ProcessingMode;
132  mitk::WeakPointer<DataInteractor> m_SelectedInteractor;
133 
134  void SetEventProcessingMode(DataInteractor *);
135 
141  bool HandleInternalEvent(InternalEvent *internalEvent);
142 
147  us::ServiceTracker<InteractionEventObserver> *m_EventObserverTracker;
148  };
149 
150 } /* namespace mitk */
151 #endif
#define MITKCORE_EXPORT
Base class for interactors that operate on DataNodes.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Central event distribution hub for interaction events.
std::list< itk::SmartPointer< InteractionEvent > > ListEventsType
List type for storing queued InteractionEvents.
void QueueEvent(InteractionEvent *event)
Queue an event for deferred processing.
Dispatcher(const std::string &rendererName)
~Dispatcher() override
bool ProcessEvent(InteractionEvent *event)
Process an interaction event by dispatching it to registered DataInteractors.
void RemoveDataInteractor(const DataNode *dataNode)
Remove all DataInteractors associated with the given DataNode.
size_t GetNumberOfInteractors()
Get the number of currently registered DataInteractors.
void AddDataInteractor(const DataNode *dataNode)
Register the DataInteractor associated with the given DataNode.
std::list< mitk::WeakPointer< DataInteractor > > ListInteractorType
List type for storing weak pointers to DataInteractors.
mitkNewMacro1Param(Self, const std::string &)
mitkClassMacroItkParent(Dispatcher, itk::LightObject)
Base class for all interaction events in MITK.
Class to create events from within the application to signal about internal events.
Find image slices visible on a given plane.