Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
18 #define SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
19 
20 #include "mitkBaseController.h"
21 #include "mitkMessage.h"
22 #include "mitkRenderingManager.h"
23 #include "mitkTimeGeometry.h"
24 #include <MitkCoreExports.h>
25 #pragma GCC visibility push(default)
26 #include <itkEventObject.h>
27 #pragma GCC visibility pop
28 #include "mitkDataStorage.h"
30 #include <itkCommand.h>
31 #include <sstream>
32 // DEPRECATED
33 #include <mitkTimeSlicedGeometry.h>
34 
35 namespace mitk
36 {
37 #define mitkTimeSlicedGeometryEventMacro(classname, super) \
38  class MITKCORE_EXPORT DEPRECATED(classname) : public super \
39  { \
40  public: \
41  typedef classname Self; \
42  typedef super Superclass; \
43  classname(TimeGeometry *aTimeGeometry, unsigned int aPos) : Superclass(aTimeGeometry, aPos) {} \
44  virtual ~classname() {} \
45  virtual const char *GetEventName() const { return #classname; } \
46  virtual bool CheckEvent(const ::itk::EventObject *e) const { return dynamic_cast<const Self *>(e); } \
47  virtual ::itk::EventObject *MakeObject() const { return new Self(GetTimeGeometry(), GetPos()); } \
48  private: \
49  void operator=(const Self &); \
50  }
51 
52 #define mitkTimeGeometryEventMacro(classname, super) \
53  class MITKCORE_EXPORT classname : public super \
54  { \
55  public: \
56  typedef classname Self; \
57  typedef super Superclass; \
58  classname(TimeGeometry *aTimeGeometry, unsigned int aPos) : Superclass(aTimeGeometry, aPos) {} \
59  virtual ~classname() {} \
60  virtual const char *GetEventName() const { return #classname; } \
61  virtual bool CheckEvent(const ::itk::EventObject *e) const { return dynamic_cast<const Self *>(e); } \
62  virtual ::itk::EventObject *MakeObject() const { return new Self(GetTimeGeometry(), GetPos()); } \
63  private: \
64  void operator=(const Self &); \
65  }
66 
67  class PlaneGeometry;
68  class BaseGeometry;
69  class BaseRenderer;
70 
153  {
154  public:
156  // itkFactorylessNewMacro(Self)
157  // mitkNewMacro1Param(Self, const char *);
158  itkNewMacro(Self);
159  // itkCloneMacro(Self)
160 
167  {
171  Original
172  };
173 
181  void SetInputWorldGeometry3D(const mitk::BaseGeometry *geometry);
182  itkGetConstObjectMacro(InputWorldGeometry3D, mitk::BaseGeometry);
183 
193  DEPRECATED(void SetInputWorldGeometry(const mitk::TimeSlicedGeometry *geometry));
198  DEPRECATED(TimeSlicedGeometry *GetInputWorldGeometry());
199 
200  void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry);
201  itkGetConstObjectMacro(InputWorldTimeGeometry, mitk::TimeGeometry);
202 
206  itkGetConstObjectMacro(CreatedWorldGeometry, mitk::TimeGeometry);
207 
215  itkSetEnumMacro(ViewDirection, ViewDirection);
216  itkGetEnumMacro(ViewDirection, ViewDirection);
217 
228  itkSetEnumMacro(DefaultViewDirection, ViewDirection);
229  itkGetEnumMacro(DefaultViewDirection, ViewDirection);
230 
231  const char *GetViewDirectionAsString() const;
232 
233  virtual void SetViewDirectionToDefault();
234 
240  virtual void Update();
241 
247  virtual void Update(ViewDirection viewDirection, bool top = true, bool frontside = true, bool rotated = false);
248 
255  virtual void SendCreatedWorldGeometry();
256 
261  virtual void SendCreatedWorldGeometryUpdate();
262 
269  virtual void SendSlice();
270 
277  virtual void SendTime();
278 
284  itkSetObjectMacro(RenderingManager, RenderingManager);
285  mitk::RenderingManager *GetRenderingManager() const;
286 
287 #pragma GCC visibility push(default)
288  itkEventMacro(UpdateEvent, itk::AnyEvent);
289 #pragma GCC visibility pop
290 
291  class MITKCORE_EXPORT TimeGeometryEvent : public itk::AnyEvent
292  {
293  public:
295  typedef itk::AnyEvent Superclass;
296 
297  TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos) : m_TimeGeometry(aTimeGeometry), m_Pos(aPos) {}
298  virtual ~TimeGeometryEvent() {}
299  virtual const char *GetEventName() const override { return "TimeGeometryEvent"; }
300  virtual bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
301  virtual ::itk::EventObject *MakeObject() const override { return new Self(m_TimeGeometry, m_Pos); }
302  TimeGeometry *GetTimeGeometry() const { return m_TimeGeometry; }
303  unsigned int GetPos() const { return m_Pos; }
304  private:
305  TimeGeometry::Pointer m_TimeGeometry;
306  unsigned int m_Pos;
307  // TimeGeometryEvent(const Self&);
308  void operator=(const Self &); // just hide
309  };
310 
316 
321 
322  template <typename T>
323  void ConnectGeometrySendEvent(T *receiver)
324  {
325  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
326  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
327  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
328  unsigned long tag = AddObserver(GeometrySendEvent(nullptr, 0), eventReceptorCommand);
329  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
330  }
331 
332  template <typename T>
333  void ConnectGeometryUpdateEvent(T *receiver)
334  {
335  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
336  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
337  eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
338  unsigned long tag = AddObserver(GeometryUpdateEvent(nullptr, 0), eventReceptorCommand);
339  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
340  }
341 
342  template <typename T>
343  void ConnectGeometrySliceEvent(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::SetGeometrySlice);
348  unsigned long tag = AddObserver(GeometrySliceEvent(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 ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent = true)
356  {
357  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
358  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
359  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
360  unsigned long tag = AddObserver(GeometryTimeEvent(nullptr, 0), eventReceptorCommand);
361  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
362  if (connectSendEvent)
363  ConnectGeometrySendEvent(receiver);
364  }
365 
366  template <typename T>
367  void ConnectGeometryEvents(T *receiver)
368  {
369  // connect sendEvent only once
370  ConnectGeometrySliceEvent(receiver, false);
371  ConnectGeometryTimeEvent(receiver);
372  }
373 
374  // use a templated method to get the right offset when casting to void*
375  template <typename T>
376  void Disconnect(T *receiver)
377  {
378  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void *>(receiver));
379  if (i == m_ReceiverToObserverTagsMap.end())
380  return;
381  const std::list<unsigned long> &tags = i->second;
382  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
383  {
384  RemoveObserver(*tagIter);
385  }
386  m_ReceiverToObserverTagsMap.erase(i);
387  }
388 
390 
396  virtual void SetGeometry(const itk::EventObject &geometrySliceEvent);
397 
402  virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent);
403 
408  virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent);
409 
411  void SelectSliceByPoint(const mitk::Point3D &point);
412 
414  mitk::TimeGeometry *GetCreatedWorldGeometry();
415 
417  const mitk::BaseGeometry *GetCurrentGeometry3D();
418 
422  const mitk::PlaneGeometry *GetCurrentPlaneGeometry();
423 
427  void SetRenderer(BaseRenderer *renderer);
428 
433  BaseRenderer *GetRenderer() const;
434 
440  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &normal);
441 
445  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &axisVec0, const mitk::Vector3D &axisVec1);
446 
447  void ExecuteOperation(Operation *operation) override;
448 
454  itkSetMacro(SliceLocked, bool);
455  itkGetMacro(SliceLocked, bool);
456  itkBooleanMacro(SliceLocked);
457 
464  itkSetMacro(SliceRotationLocked, bool);
465  itkGetMacro(SliceRotationLocked, bool);
466  itkBooleanMacro(SliceRotationLocked);
467 
472  void AdjustSliceStepperRange();
473 
474  protected:
476  virtual ~SliceNavigationController();
477 
480 
482 
485 
487 
489 
490  itkSetMacro(Top, bool);
491  itkGetMacro(Top, bool);
492  itkBooleanMacro(Top);
493 
494  itkSetMacro(FrontSide, bool);
495  itkGetMacro(FrontSide, bool);
496  itkBooleanMacro(FrontSide);
497 
498  itkSetMacro(Rotated, bool);
499  itkGetMacro(Rotated, bool);
500  itkBooleanMacro(Rotated);
501 
502  bool m_Top;
504  bool m_Rotated;
505 
507 
510  unsigned int m_OldPos;
511 
512  typedef std::map<void *, std::list<unsigned long>> ObserverTagsMapType;
513  ObserverTagsMapType m_ReceiverToObserverTagsMap;
514  };
515 
516 } // namespace mitk
517 
518 #endif /* SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F */
#define mitkTimeGeometryEventMacro(classname, super)
itk::SmartPointer< Self > Pointer
#define MITKCORE_EXPORT
Baseclass for renderer slice-/camera-control.
Base class of all Operation-classes.
Definition: mitkOperation.h:33
mitk::TimeGeometry::Pointer m_CreatedWorldGeometry
virtual bool CheckEvent(const ::itk::EventObject *e) const override
Organizes the rendering process.
static void Update(vtkPolyData *)
Definition: mitkSurface.cpp:35
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:183
void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent=true)
Manager for coordinating the rendering process.
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
Event/message/notification class.
Definition: mitkMessage.h:572
itkEventMacro(ContourModelEvent, itk::AnyEvent)
virtual ::itk::EventObject * MakeObject() const override
mitk::BaseGeometry::ConstPointer m_InputWorldGeometry3D
mitk::TimeGeometry::ConstPointer m_InputWorldTimeGeometry
Describes a two-dimensional, rectangular plane.
mitk::RenderingManager::Pointer m_RenderingManager
ViewDirection
Possible view directions, Original will uses the PlaneGeometry instances in a SlicedGeometry3D provid...
BaseGeometry Describes the geometry of a data object.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.