Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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 TimeNavigationController_h
14 #define TimeNavigationController_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 
101  class MITKCORE_EXPORT TimeEvent : public itk::AnyEvent
102  {
103  public:
104 
105  typedef TimeEvent Self;
106  typedef itk::AnyEvent Superclass;
107 
108  TimeEvent(TimeStepType timeStep) : m_TimeStep(timeStep) {}
109  ~TimeEvent() override {}
110  const char *GetEventName() const override { return "TimeEvent"; }
111  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
112  ::itk::EventObject *MakeObject() const override { return new Self(m_TimeStep); }
113  TimeStepType GetTimeStep() const { return m_TimeStep; }
114  private:
115 
116  TimeStepType m_TimeStep;
117  void operator=(const Self &);
118  };
119 
120  template <typename T>
121  void ConnectTimeEvent(T* receiver)
122  {
123  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
124  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
125  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
126  unsigned long tag = AddObserver(TimeEvent(0), eventReceptorCommand);
127  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
128  }
129 
130  // use a templated method to get the right offset when casting to void*
131  template <typename T>
132  void Disconnect(T* receiver)
133  {
134  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void*>(receiver));
135  if (i == m_ReceiverToObserverTagsMap.end())
136  return;
137  const std::list<unsigned long>& tags = i->second;
138  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
139  {
140  RemoveObserver(*tagIter);
141  }
142  m_ReceiverToObserverTagsMap.erase(i);
143  }
144 
148  TimeStepType GetSelectedTimeStep() const;
149 
155  TimePointType GetSelectedTimePoint() const;
156 
157  protected:
158 
160  ~TimeNavigationController() override;
161 
163 
165 
166  typedef std::map<void*, std::list<unsigned long>> ObserverTagsMapType;
168  };
169 
170 } // namespace mitk
171 
172 #endif
mitk::TimeNavigationController::TimeEvent::Superclass
itk::AnyEvent Superclass
Definition: mitkTimeNavigationController.h:106
mitk::TimeNavigationController::TimeEvent::GetTimeStep
TimeStepType GetTimeStep() const
Definition: mitkTimeNavigationController.h:113
mitk::TimeNavigationController::TimeEvent::GetEventName
const char * GetEventName() const override
Definition: mitkTimeNavigationController.h:110
mitk::TimeNavigationController::TimeEvent::TimeEvent
TimeEvent(TimeStepType timeStep)
Definition: mitkTimeNavigationController.h:108
mitk::TimeNavigationController
Controls the time-related properties of the time stepper, according to the given input world time geo...
Definition: mitkTimeNavigationController.h:69
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:45
mitk::TimeNavigationController::m_ReceiverToObserverTagsMap
ObserverTagsMapType m_ReceiverToObserverTagsMap
Definition: mitkTimeNavigationController.h:167
mitk::TimeNavigationController::TimeEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: mitkTimeNavigationController.h:111
mitk::TimeNavigationController::m_BlockUpdate
bool m_BlockUpdate
Definition: mitkTimeNavigationController.h:164
itk::SmartPointer< const Self >
mitk::TimeNavigationController::ObserverTagsMapType
std::map< void *, std::list< unsigned long > > ObserverTagsMapType
Definition: mitkTimeNavigationController.h:166
mitk::BaseController
Baseclass for renderer slice-/camera-/time-control.
Definition: mitkBaseController.h:35
mitkTimeGeometry.h
mitkBaseController.h
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::TimeNavigationController::m_InputWorldTimeGeometry
TimeGeometry::ConstPointer m_InputWorldTimeGeometry
Definition: mitkTimeNavigationController.h:162
MitkCoreExports.h
mitk::TimeNavigationController::Disconnect
void Disconnect(T *receiver)
Definition: mitkTimeNavigationController.h:132
mitk::TimeNavigationController::TimeEvent::Self
TimeEvent Self
Definition: mitkTimeNavigationController.h:105
mitk::TimeNavigationController::TimeEvent
Definition: mitkTimeNavigationController.h:101
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
mitk::TimeNavigationController::TimeEvent::~TimeEvent
~TimeEvent() override
Definition: mitkTimeNavigationController.h:109
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::TimeNavigationController::ConnectTimeEvent
void ConnectTimeEvent(T *receiver)
Definition: mitkTimeNavigationController.h:121
mitk::TimeNavigationController::TimeEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: mitkTimeNavigationController.h:112