Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
14 #define SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
15 
16 #include "mitkBaseController.h"
17 #include "mitkMessage.h"
18 #include "mitkRenderingManager.h"
19 #include "mitkTimeGeometry.h"
20 #include <MitkCoreExports.h>
21 #pragma GCC visibility push(default)
22 #include <itkEventObject.h>
23 #pragma GCC visibility pop
24 #include "mitkDataStorage.h"
26 #include <itkCommand.h>
27 #include <sstream>
28 // DEPRECATED
29 #include <mitkTimeSlicedGeometry.h>
30 
31 namespace mitk
32 {
33 #define mitkTimeSlicedGeometryEventMacro(classname, super) \
34  class MITKCORE_EXPORT DEPRECATED(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 #define mitkTimeGeometryEventMacro(classname, super) \
49  class MITKCORE_EXPORT classname : public super \
50  { \
51  public: \
52  typedef classname Self; \
53  typedef super Superclass; \
54  classname(TimeGeometry *aTimeGeometry, unsigned int aPos) : Superclass(aTimeGeometry, aPos) {} \
55  virtual ~classname() {} \
56  virtual const char *GetEventName() const { return #classname; } \
57  virtual bool CheckEvent(const ::itk::EventObject *e) const { return dynamic_cast<const Self *>(e); } \
58  virtual ::itk::EventObject *MakeObject() const { return new Self(GetTimeGeometry(), GetPos()); } \
59  private: \
60  void operator=(const Self &); \
61  }
62 
63  class PlaneGeometry;
64  class BaseGeometry;
65  class BaseRenderer;
66 
149  {
150  public:
152  // itkFactorylessNewMacro(Self)
153  // mitkNewMacro1Param(Self, const char *);
154  itkNewMacro(Self);
155  // itkCloneMacro(Self)
156 
163  {
167  Original
168  };
169 
177  void SetInputWorldGeometry3D(const mitk::BaseGeometry *geometry);
178  itkGetConstObjectMacro(InputWorldGeometry3D, mitk::BaseGeometry);
179 
189  DEPRECATED(void SetInputWorldGeometry(const mitk::TimeSlicedGeometry *geometry));
194  DEPRECATED(TimeSlicedGeometry *GetInputWorldGeometry());
195 
196  void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry);
197  itkGetConstObjectMacro(InputWorldTimeGeometry, mitk::TimeGeometry);
198 
202  itkGetConstObjectMacro(CreatedWorldGeometry, mitk::TimeGeometry);
203 
211  itkSetEnumMacro(ViewDirection, ViewDirection);
212  itkGetEnumMacro(ViewDirection, ViewDirection);
213 
224  itkSetEnumMacro(DefaultViewDirection, ViewDirection);
225  itkGetEnumMacro(DefaultViewDirection, ViewDirection);
226 
227  const char *GetViewDirectionAsString() const;
228 
229  virtual void SetViewDirectionToDefault();
230 
236  virtual void Update();
237 
243  virtual void Update(ViewDirection viewDirection, bool top = true, bool frontside = true, bool rotated = false);
244 
251  virtual void SendCreatedWorldGeometry();
252 
257  virtual void SendCreatedWorldGeometryUpdate();
258 
265  virtual void SendSlice();
266 
273  virtual void SendTime();
274 
275 #pragma GCC visibility push(default)
276  itkEventMacro(UpdateEvent, itk::AnyEvent);
277 #pragma GCC visibility pop
278 
279  class MITKCORE_EXPORT TimeGeometryEvent : public itk::AnyEvent
280  {
281  public:
283  typedef itk::AnyEvent Superclass;
284 
285  TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos) : m_TimeGeometry(aTimeGeometry), m_Pos(aPos) {}
286  ~TimeGeometryEvent() override {}
287  const char *GetEventName() const override { return "TimeGeometryEvent"; }
288  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
289  ::itk::EventObject *MakeObject() const override { return new Self(m_TimeGeometry, m_Pos); }
290  TimeGeometry *GetTimeGeometry() const { return m_TimeGeometry; }
291  unsigned int GetPos() const { return m_Pos; }
292  private:
293  TimeGeometry::Pointer m_TimeGeometry;
294  unsigned int m_Pos;
295  // TimeGeometryEvent(const Self&);
296  void operator=(const Self &); // just hide
297  };
298 
304 
309 
310  template <typename T>
311  void ConnectGeometrySendEvent(T *receiver)
312  {
313  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
314  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
315  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
316  unsigned long tag = AddObserver(GeometrySendEvent(nullptr, 0), eventReceptorCommand);
317  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
318  }
319 
320  template <typename T>
321  void ConnectGeometryUpdateEvent(T *receiver)
322  {
323  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
324  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
325  eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
326  unsigned long tag = AddObserver(GeometryUpdateEvent(nullptr, 0), eventReceptorCommand);
327  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
328  }
329 
330  template <typename T>
331  void ConnectGeometrySliceEvent(T *receiver, bool connectSendEvent = true)
332  {
333  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
334  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
335  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice);
336  unsigned long tag = AddObserver(GeometrySliceEvent(nullptr, 0), eventReceptorCommand);
337  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
338  if (connectSendEvent)
339  ConnectGeometrySendEvent(receiver);
340  }
341 
342  template <typename T>
343  void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent = true)
344  {
345  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
346  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
347  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
348  unsigned long tag = AddObserver(GeometryTimeEvent(nullptr, 0), eventReceptorCommand);
349  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
350  if (connectSendEvent)
351  ConnectGeometrySendEvent(receiver);
352  }
353 
354  template <typename T>
355  void ConnectGeometryEvents(T *receiver)
356  {
357  // connect sendEvent only once
358  ConnectGeometrySliceEvent(receiver, false);
359  ConnectGeometryTimeEvent(receiver);
360  }
361 
362  // use a templated method to get the right offset when casting to void*
363  template <typename T>
364  void Disconnect(T *receiver)
365  {
366  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void *>(receiver));
367  if (i == m_ReceiverToObserverTagsMap.end())
368  return;
369  const std::list<unsigned long> &tags = i->second;
370  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
371  {
372  RemoveObserver(*tagIter);
373  }
374  m_ReceiverToObserverTagsMap.erase(i);
375  }
376 
378 
384  virtual void SetGeometry(const itk::EventObject &geometrySliceEvent);
385 
390  virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent);
391 
396  virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent);
397 
399  void SelectSliceByPoint(const mitk::Point3D &point);
400 
402  mitk::TimeGeometry *GetCreatedWorldGeometry();
403 
405  const mitk::BaseGeometry *GetCurrentGeometry3D();
406 
410  const mitk::PlaneGeometry *GetCurrentPlaneGeometry();
411 
415  void SetRenderer(BaseRenderer *renderer);
416 
421  BaseRenderer *GetRenderer() const;
422 
428  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &normal);
429 
433  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &axisVec0, const mitk::Vector3D &axisVec1);
434 
435  void ExecuteOperation(Operation *operation) override;
436 
442  itkSetMacro(SliceLocked, bool);
443  itkGetMacro(SliceLocked, bool);
444  itkBooleanMacro(SliceLocked);
445 
452  itkSetMacro(SliceRotationLocked, bool);
453  itkGetMacro(SliceRotationLocked, bool);
454  itkBooleanMacro(SliceRotationLocked);
455 
460  void AdjustSliceStepperRange();
461 
462  protected:
464  ~SliceNavigationController() override;
465 
468 
470 
473 
475 
477 
478  itkSetMacro(Top, bool);
479  itkGetMacro(Top, bool);
480  itkBooleanMacro(Top);
481 
482  itkSetMacro(FrontSide, bool);
483  itkGetMacro(FrontSide, bool);
484  itkBooleanMacro(FrontSide);
485 
486  itkSetMacro(Rotated, bool);
487  itkGetMacro(Rotated, bool);
488  itkBooleanMacro(Rotated);
489 
490  bool m_Top;
492  bool m_Rotated;
493 
495 
498  unsigned int m_OldPos;
499 
500  typedef std::map<void *, std::list<unsigned long>> ObserverTagsMapType;
501  ObserverTagsMapType m_ReceiverToObserverTagsMap;
502  };
503 
504 } // namespace mitk
505 
506 #endif /* SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F */
#define mitkTimeGeometryEventMacro(classname, super)
#define MITKCORE_EXPORT
Baseclass for renderer slice-/camera-control.
Base class of all Operation-classes.
Definition: mitkOperation.h:29
mitk::TimeGeometry::Pointer m_CreatedWorldGeometry
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:31
DataCollection - Class to facilitate loading/accessing structured data.
std::map< void *, std::list< unsigned long > > ObserverTagsMapType
TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos)
void ConnectGeometrySliceEvent(T *receiver, bool connectSendEvent=true)
Controls the selection of the slice the associated BaseRenderer will display.
#define DEPRECATED(func)
Definition: mitkCommon.h:179
void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent=true)
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
itkEventMacro(ContourModelEvent, itk::AnyEvent)
mitk::BaseGeometry::ConstPointer m_InputWorldGeometry3D
mitk::TimeGeometry::ConstPointer m_InputWorldTimeGeometry
Describes a two-dimensional, rectangular plane.
mitk::RenderingManager::Pointer m_RenderingManager
bool CheckEvent(const ::itk::EventObject *e) const override
BaseGeometry Describes the geometry of a data object.