Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkTimeNavigationController.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 mitkTimeNavigationController_h
14 #define mitkTimeNavigationController_h
15 
16 #include <MitkCoreExports.h>
17 
18 #include <mitkBaseController.h>
19 #include <mitkTimeGeometry.h>
20 
21 #include <itkCommand.h>
22 
23 namespace mitk
24 {
70  {
71  public:
72 
74  itkNewMacro(Self);
75 
83  void SetInputWorldTimeGeometry(const TimeGeometry* geometry);
84  itkGetConstObjectMacro(InputWorldTimeGeometry, mitk::TimeGeometry);
85 
91  virtual void Update();
92 
99  virtual void SendTime();
100 
108  class MITKCORE_EXPORT TimeEvent : public itk::AnyEvent
109  {
110  public:
111 
112  typedef TimeEvent Self;
113  typedef itk::AnyEvent Superclass;
114 
115  TimeEvent(TimeStepType timeStep) : m_TimeStep(timeStep) {}
116  ~TimeEvent() override {}
117  const char *GetEventName() const override { return "TimeEvent"; }
118  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
119  ::itk::EventObject *MakeObject() const override { return new Self(m_TimeStep); }
120 
122  TimeStepType GetTimeStep() const { return m_TimeStep; }
123  private:
124 
125  TimeStepType m_TimeStep;
126  void operator=(const Self &);
127  };
128 
138  template <typename T>
139  void ConnectTimeEvent(T* receiver)
140  {
141  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
142  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
143  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
144  unsigned long tag = AddObserver(TimeEvent(0), eventReceptorCommand);
145  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
146  }
147 
157  template <typename T>
158  void Disconnect(T* receiver)
159  {
160  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void*>(receiver));
161  if (i == m_ReceiverToObserverTagsMap.end())
162  return;
163  const std::list<unsigned long>& tags = i->second;
164  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
165  {
166  RemoveObserver(*tagIter);
167  }
168  m_ReceiverToObserverTagsMap.erase(i);
169  }
170 
175 
182 
183  protected:
184 
187 
188  TimeGeometry::ConstPointer m_InputWorldTimeGeometry;
189 
191 
192  typedef std::map<void*, std::list<unsigned long>> ObserverTagsMapType;
194  };
195 
196 } // namespace mitk
197 
198 #endif
#define MITKCORE_EXPORT
Base class for renderer slice, camera, and time control.
ITK event that carries the currently selected time step.
bool CheckEvent(const ::itk::EventObject *e) const override
::itk::EventObject * MakeObject() const override
TimeStepType GetTimeStep() const
Return the time step carried by this event.
Controls the time-related properties of the time stepper, according to the given input world time geo...
void ConnectTimeEvent(T *receiver)
Connect a receiver to TimeEvent notifications.
TimePointType GetSelectedTimePoint() const
Convenience method that returns the time point that corresponds to the selected time step....
void Disconnect(T *receiver)
Disconnect a receiver from TimeEvent notifications.
virtual void Update()
Do the actual time-related properties extraction and send the currently selected time step to the con...
virtual void SendTime()
Send the currently selected time step to the connected observers (renderers).
TimeGeometry::ConstPointer m_InputWorldTimeGeometry
TimeStepType GetSelectedTimeStep() const
Convenience method that returns the time step currently selected by the controller.
mitkClassMacro(TimeNavigationController, BaseController)
std::map< void *, std::list< unsigned long > > ObserverTagsMapType
void SetInputWorldTimeGeometry(const TimeGeometry *geometry)
Set the input time geometry out of which the time-related properties will be generated.
Find image slices visible on a given plane.
std::size_t TimeStepType
Type for time step indices (non-negative integers starting from 0).
mitk::ScalarType TimePointType
Type for time point values in milliseconds (ms).