Medical Imaging Interaction Toolkit  2024.06.00
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>
22 #include <mitkTimeGeometry.h>
23 
24 #pragma GCC visibility push(default)
25 #include <itkEventObject.h>
26 #pragma GCC visibility pop
27 
28 #include <itkCommand.h>
29 
30 namespace mitk
31 {
32 #define mitkTimeGeometryEventMacro(classname, super) \
33  class MITKCORE_EXPORT classname : public super \
34  { \
35  public: \
36  typedef classname Self; \
37  typedef super Superclass; \
38  classname(TimeGeometry *aTimeGeometry, unsigned int aPos) : Superclass(aTimeGeometry, aPos) {} \
39  virtual ~classname() {} \
40  virtual const char *GetEventName() const { return #classname; } \
41  virtual bool CheckEvent(const ::itk::EventObject *e) const { return dynamic_cast<const Self *>(e); } \
42  virtual ::itk::EventObject *MakeObject() const { return new Self(GetTimeGeometry(), GetPos()); } \
43  private: \
44  void operator=(const Self &); \
45  }
46 
47  class PlaneGeometry;
48  class BaseGeometry;
49  class BaseRenderer;
50 
131  {
132  public:
133 
135  itkNewMacro(Self);
136 
144  void SetInputWorldTimeGeometry(const TimeGeometry* geometry);
145  itkGetConstObjectMacro(InputWorldTimeGeometry, TimeGeometry);
146 
150  itkGetConstObjectMacro(CreatedWorldGeometry, TimeGeometry);
151  itkGetObjectMacro(CreatedWorldGeometry, TimeGeometry);
152 
160  itkSetEnumMacro(ViewDirection, AnatomicalPlane);
161  itkGetEnumMacro(ViewDirection, AnatomicalPlane);
162 
173  itkSetEnumMacro(DefaultViewDirection, AnatomicalPlane);
174  itkGetEnumMacro(DefaultViewDirection, AnatomicalPlane);
175 
176  const char *GetViewDirectionAsString() const;
177 
178  virtual void SetViewDirectionToDefault();
179 
185  virtual void Update();
186 
192  virtual void Update(AnatomicalPlane viewDirection, bool top = true, bool frontside = true, bool rotated = false);
193 
200  virtual void SendCreatedWorldGeometry();
201 
206  virtual void SendCreatedWorldGeometryUpdate();
207 
214  virtual void SendSlice();
215 
216  class MITKCORE_EXPORT TimeGeometryEvent : public itk::AnyEvent
217  {
218  public:
220  typedef itk::AnyEvent Superclass;
221 
222  TimeGeometryEvent(TimeGeometry* aTimeGeometry, unsigned int aPos) : m_TimeGeometry(aTimeGeometry), m_Pos(aPos) {}
223  ~TimeGeometryEvent() override {}
224  const char* GetEventName() const override { return "TimeGeometryEvent"; }
225  bool CheckEvent(const ::itk::EventObject* e) const override { return dynamic_cast<const Self*>(e); }
226  ::itk::EventObject* MakeObject() const override { return new Self(m_TimeGeometry, m_Pos); }
227  TimeGeometry* GetTimeGeometry() const { return m_TimeGeometry; }
228  unsigned int GetPos() const { return m_Pos; }
229 
230  private:
231  TimeGeometry::Pointer m_TimeGeometry;
232  unsigned int m_Pos;
233  // TimeGeometryEvent(const Self&);
234  void operator=(const Self&); // just hide
235  };
236 
237 
241 
242  template <typename T>
243  void ConnectGeometrySendEvent(T* receiver)
244  {
245  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
246  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
247  unsigned long tag = AddObserver(GeometrySendEvent(nullptr, 0), eventReceptorCommand);
248  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
249  }
250 
251  template <typename T>
252  void ConnectGeometryUpdateEvent(T* receiver)
253  {
254  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
255  eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
256  unsigned long tag = AddObserver(GeometryUpdateEvent(nullptr, 0), eventReceptorCommand);
257  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
258  }
259 
260  template <typename T>
261  void ConnectGeometrySliceEvent(T* receiver)
262  {
263  auto eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
264  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice);
265  unsigned long tag = AddObserver(GeometrySliceEvent(nullptr, 0), eventReceptorCommand);
266  m_ReceiverToObserverTagsMap[static_cast<void*>(receiver)].push_back(tag);
267  }
268 
269  // use a templated method to get the right offset when casting to void*
270  template <typename T>
271  void Disconnect(T* receiver)
272  {
273  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void*>(receiver));
274  if (i == m_ReceiverToObserverTagsMap.end())
275  return;
276  const std::list<unsigned long>& tags = i->second;
277  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
278  {
279  RemoveObserver(*tagIter);
280  }
281  m_ReceiverToObserverTagsMap.erase(i);
282  }
283 
285 
287  void SelectSliceByPoint(const Point3D& point);
288 
290  const BaseGeometry* GetCurrentGeometry3D();
291 
296 
301  itkSetObjectMacro(Renderer, BaseRenderer);
302  itkGetMacro(Renderer, BaseRenderer*);
303 
309  void ReorientSlices(const Point3D& point, const Vector3D& normal);
310 
314  void ReorientSlices(const Point3D& point, const Vector3D& axisVec0, const Vector3D& axisVec1);
315 
316  void ExecuteOperation(Operation* operation) override;
317 
323  itkSetMacro(SliceLocked, bool);
324  itkGetMacro(SliceLocked, bool);
325  itkBooleanMacro(SliceLocked);
326 
333  itkSetMacro(SliceRotationLocked, bool);
334  itkGetMacro(SliceRotationLocked, bool);
335  itkBooleanMacro(SliceRotationLocked);
336 
341  void AdjustSliceStepperRange();
342 
343  protected:
344 
346  ~SliceNavigationController() override;
347 
348  void CreateWorldGeometry(bool top, bool frontside, bool rotated);
349 
352 
355 
357 
359 
361 
364 
365  typedef std::map<void*, std::list<unsigned long>> ObserverTagsMapType;
367  };
368 
369 } // namespace mitk
370 
371 #endif
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:45
mitk::SliceNavigationController::TimeGeometryEvent
Definition: mitkSliceNavigationController.h:216
mitk::SliceNavigationController::ConnectGeometryUpdateEvent
void ConnectGeometryUpdateEvent(T *receiver)
Definition: mitkSliceNavigationController.h:252
mitk::Message1
Definition: mitkMessage.h:480
mitk::SliceNavigationController::TimeGeometryEvent::TimeGeometryEvent
TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos)
Definition: mitkSliceNavigationController.h:222
mitk::SliceNavigationController::ConnectGeometrySliceEvent
void ConnectGeometrySliceEvent(T *receiver)
Definition: mitkSliceNavigationController.h:261
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitkAnatomicalPlanes.h
mitk::Operation
Base class of all Operation-classes.
Definition: mitkOperation.h:29
mitk::SliceNavigationController::GeometrySendEvent
Definition: mitkSliceNavigationController.h:238
mitk::SliceNavigationController::m_InputWorldTimeGeometry
TimeGeometry::ConstPointer m_InputWorldTimeGeometry
Definition: mitkSliceNavigationController.h:350
mitk::SliceNavigationController::m_SliceLocked
bool m_SliceLocked
Definition: mitkSliceNavigationController.h:362
mitk::SliceNavigationController::m_Renderer
BaseRenderer * m_Renderer
Definition: mitkSliceNavigationController.h:358
mitk::SliceNavigationController::GeometryUpdateEvent
Definition: mitkSliceNavigationController.h:239
itk::SmartPointer< Self >
mitk::SliceNavigationController::TimeGeometryEvent::GetEventName
const char * GetEventName() const override
Definition: mitkSliceNavigationController.h:224
mitk::BaseController
Baseclass for renderer slice-/camera-/time-control.
Definition: mitkBaseController.h:35
mitk::SliceNavigationController::ObserverTagsMapType
std::map< void *, std::list< unsigned long > > ObserverTagsMapType
Definition: mitkSliceNavigationController.h:365
mitkTimeGeometry.h
mitkBaseController.h
mitk::SliceNavigationController
Controls the selection of the slice the associated BaseRenderer will display.
Definition: mitkSliceNavigationController.h:130
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::SliceNavigationController::m_ViewDirection
AnatomicalPlane m_ViewDirection
Definition: mitkSliceNavigationController.h:353
mitk::SliceNavigationController::TimeGeometryEvent::GetTimeGeometry
TimeGeometry * GetTimeGeometry() const
Definition: mitkSliceNavigationController.h:227
mitk::SliceNavigationController::TimeGeometryEvent::MakeObject
::itk::EventObject * MakeObject() const override
Definition: mitkSliceNavigationController.h:226
mitk::SliceNavigationController::TimeGeometryEvent::GetPos
unsigned int GetPos() const
Definition: mitkSliceNavigationController.h:228
mitk::SliceNavigationController::m_BlockUpdate
bool m_BlockUpdate
Definition: mitkSliceNavigationController.h:360
mitk::SliceNavigationController::SetCrosshairEvent
Message1< const Point3D & > SetCrosshairEvent
Definition: mitkSliceNavigationController.h:284
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:38
mitk::SliceNavigationController::m_RenderingManager
RenderingManager::Pointer m_RenderingManager
Definition: mitkSliceNavigationController.h:356
mitkTimeGeometryEventMacro
#define mitkTimeGeometryEventMacro(classname, super)
Definition: mitkSliceNavigationController.h:32
mitk::SliceNavigationController::Disconnect
void Disconnect(T *receiver)
Definition: mitkSliceNavigationController.h:271
mitk::SliceNavigationController::ConnectGeometrySendEvent
void ConnectGeometrySendEvent(T *receiver)
Definition: mitkSliceNavigationController.h:243
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:225
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:56
mitk::SliceNavigationController::m_DefaultViewDirection
AnatomicalPlane m_DefaultViewDirection
Definition: mitkSliceNavigationController.h:354
mitk::SliceNavigationController::TimeGeometryEvent::~TimeGeometryEvent
~TimeGeometryEvent() override
Definition: mitkSliceNavigationController.h:223
mitkRenderingManager.h
mitk::SliceNavigationController::TimeGeometryEvent::Self
TimeGeometryEvent Self
Definition: mitkSliceNavigationController.h:219
mitk::SliceNavigationController::m_SliceRotationLocked
bool m_SliceRotationLocked
Definition: mitkSliceNavigationController.h:363
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15
mitk::SliceNavigationController::m_ReceiverToObserverTagsMap
ObserverTagsMapType m_ReceiverToObserverTagsMap
Definition: mitkSliceNavigationController.h:366
mitk::SliceNavigationController::GeometrySliceEvent
Definition: mitkSliceNavigationController.h:240
mitk::SliceNavigationController::m_CreatedWorldGeometry
TimeGeometry::Pointer m_CreatedWorldGeometry
Definition: mitkSliceNavigationController.h:351
mitk::SliceNavigationController::TimeGeometryEvent::Superclass
itk::AnyEvent Superclass
Definition: mitkSliceNavigationController.h:220