Medical Imaging Interaction Toolkit  2022.10.99-efe2ad43
Medical Imaging Interaction Toolkit
mitkSliceNavigationController.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 MITKSLICENAVIGATIONCONTROLLER_H
14 #define MITKSLICENAVIGATIONCONTROLLER_H
15 
16 #include <MitkCoreExports.h>
17 
18 #include <mitkBaseController.h>
19 #include <mitkMessage.h>
20 #include <mitkAnatomicalPlanes.h>
21 #include <mitkRenderingManager.h>
23 #include <mitkTimeGeometry.h>
24 
25 #pragma GCC visibility push(default)
26 #include <itkEventObject.h>
27 #pragma GCC visibility pop
28 
29 #include <itkCommand.h>
30 
31 namespace mitk
32 {
33 #define mitkTimeGeometryEventMacro(classname, super) \
34  class MITKCORE_EXPORT classname : public super \
35  { \
36  public: \
37  typedef classname Self; \
38  typedef super Superclass; \
39  classname(TimeGeometry *aTimeGeometry, unsigned int aPos) : Superclass(aTimeGeometry, aPos) {} \
40  virtual ~classname() {} \
41  virtual const char *GetEventName() const { return #classname; } \
42  virtual bool CheckEvent(const ::itk::EventObject *e) const { return dynamic_cast<const Self *>(e); } \
43  virtual ::itk::EventObject *MakeObject() const { return new Self(GetTimeGeometry(), GetPos()); } \
44  private: \
45  void operator=(const Self &); \
46  }
47 
48  class PlaneGeometry;
49  class BaseGeometry;
50  class BaseRenderer;
51 
133  {
134  public:
135 
137  itkNewMacro(Self);
138 
146  void SetInputWorldTimeGeometry(const TimeGeometry* geometry);
147  itkGetConstObjectMacro(InputWorldTimeGeometry, TimeGeometry);
148 
152  itkGetConstObjectMacro(CreatedWorldGeometry, TimeGeometry);
153  itkGetObjectMacro(CreatedWorldGeometry, TimeGeometry);
154 
162  itkSetEnumMacro(ViewDirection, AnatomicalPlane);
163  itkGetEnumMacro(ViewDirection, AnatomicalPlane);
164 
175  itkSetEnumMacro(DefaultViewDirection, AnatomicalPlane);
176  itkGetEnumMacro(DefaultViewDirection, AnatomicalPlane);
177 
178  const char *GetViewDirectionAsString() const;
179 
180  virtual void SetViewDirectionToDefault();
181 
187  virtual void Update();
188 
194  virtual void Update(AnatomicalPlane viewDirection, bool top = true, bool frontside = true, bool rotated = false);
195 
202  virtual void SendCreatedWorldGeometry();
203 
208  virtual void SendCreatedWorldGeometryUpdate();
209 
216  virtual void SendSlice();
217 
224  virtual void SendTime();
225 
226  class MITKCORE_EXPORT TimeGeometryEvent : public itk::AnyEvent
227  {
228  public:
230  typedef itk::AnyEvent Superclass;
231 
232  TimeGeometryEvent(TimeGeometry* aTimeGeometry, unsigned int aPos) : m_TimeGeometry(aTimeGeometry), m_Pos(aPos) {}
233  ~TimeGeometryEvent() override {}
234  const char* GetEventName() const override { return "TimeGeometryEvent"; }
235  bool CheckEvent(const ::itk::EventObject* e) const override { return dynamic_cast<const Self*>(e); }
236  ::itk::EventObject* MakeObject() const override { return new Self(m_TimeGeometry, m_Pos); }
237  TimeGeometry* GetTimeGeometry() const { return m_TimeGeometry; }
238  unsigned int GetPos() const { return m_Pos; }
239 
240  private:
241  TimeGeometry::Pointer m_TimeGeometry;
242  unsigned int m_Pos;
243  // TimeGeometryEvent(const Self&);
244  void operator=(const Self&); // just hide
245  };
246 
247 
252 
253  template <typename T>
254  void ConnectGeometrySendEvent(T* receiver)
255  {
256  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
257  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
258  unsigned long tag = AddObserver(GeometrySendEvent(nullptr, 0), eventReceptorCommand);
259  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
260  }
261 
262  template <typename T>
263  void ConnectGeometryUpdateEvent(T* receiver)
264  {
265  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
266  eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
267  unsigned long tag = AddObserver(GeometryUpdateEvent(nullptr, 0), eventReceptorCommand);
268  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
269  }
270 
271  template <typename T>
272  void ConnectGeometrySliceEvent(T* receiver)
273  {
274  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
275  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice);
276  unsigned long tag = AddObserver(GeometrySliceEvent(nullptr, 0), eventReceptorCommand);
277  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
278  }
279 
280  template <typename T>
281  void ConnectGeometryTimeEvent(T* receiver)
282  {
283  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
284  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
285  unsigned long tag = AddObserver(GeometryTimeEvent(nullptr, 0), eventReceptorCommand);
286  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
287  }
288 
289  template <typename T>
290  void ConnectGeometryEvents(T* receiver)
291  {
292  // connect sendEvent only once
293  ConnectGeometrySliceEvent(receiver, false);
294  ConnectGeometryTimeEvent(receiver);
295  }
296 
297  // use a templated method to get the right offset when casting to void*
298  template <typename T>
299  void Disconnect(T* receiver)
300  {
301  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void*>(receiver));
302  if (i == m_ReceiverToObserverTagsMap.end())
303  return;
304  const std::list<unsigned long>& tags = i->second;
305  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
306  {
307  RemoveObserver(*tagIter);
308  }
309  m_ReceiverToObserverTagsMap.erase(i);
310  }
311 
313 
319  virtual void SetGeometry(const itk::EventObject& geometrySliceEvent);
320 
325  virtual void SetGeometrySlice(const itk::EventObject& geometrySliceEvent);
326 
331  virtual void SetGeometryTime(const itk::EventObject& geometryTimeEvent);
332 
334  void SelectSliceByPoint(const Point3D& point);
335 
337  const BaseGeometry* GetCurrentGeometry3D();
338 
343 
348  itkSetObjectMacro(Renderer, BaseRenderer);
349  itkGetMacro(Renderer, BaseRenderer*);
350 
356  void ReorientSlices(const Point3D& point, const Vector3D& normal);
357 
361  void ReorientSlices(const Point3D& point, const Vector3D& axisVec0, const Vector3D& axisVec1);
362 
363  void ExecuteOperation(Operation* operation) override;
364 
370  itkSetMacro(SliceLocked, bool);
371  itkGetMacro(SliceLocked, bool);
372  itkBooleanMacro(SliceLocked);
373 
380  itkSetMacro(SliceRotationLocked, bool);
381  itkGetMacro(SliceRotationLocked, bool);
382  itkBooleanMacro(SliceRotationLocked);
383 
388  void AdjustSliceStepperRange();
389 
391  TimeStepType GetSelectedTimeStep() const;
392 
396  TimePointType GetSelectedTimePoint() const;
397 
398  protected:
399 
401  ~SliceNavigationController() override;
402 
403  void CreateWorldGeometry(bool top, bool frontside, bool rotated);
404 
407 
410 
412 
414 
416 
419 
420  typedef std::map<void*, std::list<unsigned long>> ObserverTagsMapType;
422  };
423 
424 } // namespace mitk
425 
426 #endif // MITKSLICENAVIGATIONCONTROLLER_H
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:43
mitk::SliceNavigationController::TimeGeometryEvent
Definition: mitkSliceNavigationController.h:226
mitk::SliceNavigationController::ConnectGeometryUpdateEvent
void ConnectGeometryUpdateEvent(T *receiver)
Definition: mitkSliceNavigationController.h:263
mitk::Message1
Definition: mitkMessage.h:480
mitk::SliceNavigationController::TimeGeometryEvent::TimeGeometryEvent
TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos)
Definition: mitkSliceNavigationController.h:232
mitk::SliceNavigationController::ConnectGeometrySliceEvent
void ConnectGeometrySliceEvent(T *receiver)
Definition: mitkSliceNavigationController.h:272
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::SliceNavigationController::ConnectGeometryEvents
void ConnectGeometryEvents(T *receiver)
Definition: mitkSliceNavigationController.h:290
mitkAnatomicalPlanes.h
mitk::Operation
Base class of all Operation-classes.
Definition: mitkOperation.h:29
mitk::SliceNavigationController::GeometrySendEvent
Definition: mitkSliceNavigationController.h:248
mitk::SliceNavigationController::ConnectGeometryTimeEvent
void ConnectGeometryTimeEvent(T *receiver)
Definition: mitkSliceNavigationController.h:281
mitk::SliceNavigationController::m_InputWorldTimeGeometry
TimeGeometry::ConstPointer m_InputWorldTimeGeometry
Definition: mitkSliceNavigationController.h:405
mitk::SliceNavigationController::m_SliceLocked
bool m_SliceLocked
Definition: mitkSliceNavigationController.h:417
mitk::SliceNavigationController::m_Renderer
BaseRenderer * m_Renderer
Definition: mitkSliceNavigationController.h:413
mitkRestorePlanePositionOperation.h
mitk::SliceNavigationController::GeometryUpdateEvent
Definition: mitkSliceNavigationController.h:249
itk::SmartPointer< Self >
mitk::SliceNavigationController::TimeGeometryEvent::GetEventName
const char * GetEventName() const override
Definition: mitkSliceNavigationController.h:234
mitk::BaseController
Baseclass for renderer slice-/camera-control.
Definition: mitkBaseController.h:37
mitk::SliceNavigationController::ObserverTagsMapType
std::map< void *, std::list< unsigned long > > ObserverTagsMapType
Definition: mitkSliceNavigationController.h:420
mitkTimeGeometry.h
mitkBaseController.h
mitk::SliceNavigationController
Controls the selection of the slice the associated BaseRenderer will display.
Definition: mitkSliceNavigationController.h:132
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::SliceNavigationController::m_ViewDirection
AnatomicalPlane m_ViewDirection
Definition: mitkSliceNavigationController.h:408
mitk::SliceNavigationController::GeometryTimeEvent
Definition: mitkSliceNavigationController.h:250
mitk::SliceNavigationController::TimeGeometryEvent::GetTimeGeometry
TimeGeometry * GetTimeGeometry() const
Definition: mitkSliceNavigationController.h:237
mitk::SliceNavigationController::TimeGeometryEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: mitkSliceNavigationController.h:236
mitk::SliceNavigationController::TimeGeometryEvent::GetPos
unsigned int GetPos() const
Definition: mitkSliceNavigationController.h:238
mitk::SliceNavigationController::m_BlockUpdate
bool m_BlockUpdate
Definition: mitkSliceNavigationController.h:415
mitk::SliceNavigationController::SetCrosshairEvent
Message1< const Point3D & > SetCrosshairEvent
Definition: mitkSliceNavigationController.h:312
mitk::SliceNavigationHelper::SelectSliceByPoint
MITKCORE_EXPORT unsigned int SelectSliceByPoint(const TimeGeometry *timeGeometry, const Point3D &point)
Select a specific slice from the given time geometry given a 3D point.
mitk::AnatomicalPlane
AnatomicalPlane
Definition: mitkAnatomicalPlanes.h:18
mitk::Vector< ScalarType, 3 >
MitkCoreExports.h
mitkMessage.h
mitk::BaseGeometry
BaseGeometry Describes the geometry of a data object.
Definition: mitkBaseGeometry.h:94
mitk::Point
Definition: mitkPoint.h:36
mitk::SliceNavigationController::m_RenderingManager
RenderingManager::Pointer m_RenderingManager
Definition: mitkSliceNavigationController.h:411
mitkTimeGeometryEventMacro
#define mitkTimeGeometryEventMacro(classname, super)
Definition: mitkSliceNavigationController.h:33
mitk::SliceNavigationController::Disconnect
void Disconnect(T *receiver)
Definition: mitkSliceNavigationController.h:299
mitk::SliceNavigationController::ConnectGeometrySendEvent
void ConnectGeometrySendEvent(T *receiver)
Definition: mitkSliceNavigationController.h:254
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitk::SliceNavigationHelper::GetCurrentPlaneGeometry
MITKCORE_EXPORT PlaneGeometry * GetCurrentPlaneGeometry(const TimeGeometry *timeGeometry, TimePointType timePoint, unsigned int slicePosition)
Extracts the plane geometry for the given time step and slice position.
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::SliceNavigationController::TimeGeometryEvent::CheckEvent
bool CheckEvent(const ::itk::EventObject *e) const override
Definition: mitkSliceNavigationController.h:235
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:55
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
mitk::SliceNavigationController::m_DefaultViewDirection
AnatomicalPlane m_DefaultViewDirection
Definition: mitkSliceNavigationController.h:409
mitk::SliceNavigationController::TimeGeometryEvent::~TimeGeometryEvent
~TimeGeometryEvent() override
Definition: mitkSliceNavigationController.h:233
mitkRenderingManager.h
mitk::SliceNavigationController::TimeGeometryEvent::Self
TimeGeometryEvent Self
Definition: mitkSliceNavigationController.h:229
mitk::SliceNavigationController::m_SliceRotationLocked
bool m_SliceRotationLocked
Definition: mitkSliceNavigationController.h:418
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::SliceNavigationController::m_ReceiverToObserverTagsMap
ObserverTagsMapType m_ReceiverToObserverTagsMap
Definition: mitkSliceNavigationController.h:421
mitk::SliceNavigationController::GeometrySliceEvent
Definition: mitkSliceNavigationController.h:251
mitk::SliceNavigationController::m_CreatedWorldGeometry
TimeGeometry::Pointer m_CreatedWorldGeometry
Definition: mitkSliceNavigationController.h:406
mitk::SliceNavigationController::TimeGeometryEvent::Superclass
itk::AnyEvent Superclass
Definition: mitkSliceNavigationController.h:230