Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
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 
29 namespace mitk
30 {
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 
133  {
134  public:
136  // itkFactorylessNewMacro(Self)
137  // mitkNewMacro1Param(Self, const char *);
138  itkNewMacro(Self);
139  // itkCloneMacro(Self)
140 
147  {
151  Original
152  };
153 
161  void SetInputWorldGeometry3D(const mitk::BaseGeometry *geometry);
162  itkGetConstObjectMacro(InputWorldGeometry3D, mitk::BaseGeometry);
163 
164  void SetInputWorldTimeGeometry(const mitk::TimeGeometry *geometry);
165  itkGetConstObjectMacro(InputWorldTimeGeometry, mitk::TimeGeometry);
166 
170  itkGetConstObjectMacro(CreatedWorldGeometry, mitk::TimeGeometry);
171 
179  itkSetEnumMacro(ViewDirection, ViewDirection);
180  itkGetEnumMacro(ViewDirection, ViewDirection);
181 
192  itkSetEnumMacro(DefaultViewDirection, ViewDirection);
193  itkGetEnumMacro(DefaultViewDirection, ViewDirection);
194 
195  const char *GetViewDirectionAsString() const;
196 
197  virtual void SetViewDirectionToDefault();
198 
204  virtual void Update();
205 
211  virtual void Update(ViewDirection viewDirection, bool top = true, bool frontside = true, bool rotated = false);
212 
219  virtual void SendCreatedWorldGeometry();
220 
225  virtual void SendCreatedWorldGeometryUpdate();
226 
233  virtual void SendSlice();
234 
241  virtual void SendTime();
242 
243 #pragma GCC visibility push(default)
244  itkEventMacro(UpdateEvent, itk::AnyEvent);
245 #pragma GCC visibility pop
246 
247  class MITKCORE_EXPORT TimeGeometryEvent : public itk::AnyEvent
248  {
249  public:
251  typedef itk::AnyEvent Superclass;
252 
253  TimeGeometryEvent(TimeGeometry *aTimeGeometry, unsigned int aPos) : m_TimeGeometry(aTimeGeometry), m_Pos(aPos) {}
254  ~TimeGeometryEvent() override {}
255  const char *GetEventName() const override { return "TimeGeometryEvent"; }
256  bool CheckEvent(const ::itk::EventObject *e) const override { return dynamic_cast<const Self *>(e); }
257  ::itk::EventObject *MakeObject() const override { return new Self(m_TimeGeometry, m_Pos); }
258  TimeGeometry *GetTimeGeometry() const { return m_TimeGeometry; }
259  unsigned int GetPos() const { return m_Pos; }
260  private:
261  TimeGeometry::Pointer m_TimeGeometry;
262  unsigned int m_Pos;
263  // TimeGeometryEvent(const Self&);
264  void operator=(const Self &); // just hide
265  };
266 
267 
272 
273  template <typename T>
274  void ConnectGeometrySendEvent(T *receiver)
275  {
276  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
277  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
278  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
279  unsigned long tag = AddObserver(GeometrySendEvent(nullptr, 0), eventReceptorCommand);
280  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
281  }
282 
283  template <typename T>
284  void ConnectGeometryUpdateEvent(T *receiver)
285  {
286  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
287  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
288  eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
289  unsigned long tag = AddObserver(GeometryUpdateEvent(nullptr, 0), eventReceptorCommand);
290  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
291  }
292 
293  template <typename T>
294  void ConnectGeometrySliceEvent(T *receiver, bool connectSendEvent = true)
295  {
296  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
297  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
298  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice);
299  unsigned long tag = AddObserver(GeometrySliceEvent(nullptr, 0), eventReceptorCommand);
300  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
301  if (connectSendEvent)
302  ConnectGeometrySendEvent(receiver);
303  }
304 
305  template <typename T>
306  void ConnectGeometryTimeEvent(T *receiver, bool connectSendEvent = true)
307  {
308  typedef typename itk::ReceptorMemberCommand<T>::Pointer ReceptorMemberCommandPointer;
309  ReceptorMemberCommandPointer eventReceptorCommand = itk::ReceptorMemberCommand<T>::New();
310  eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
311  unsigned long tag = AddObserver(GeometryTimeEvent(nullptr, 0), eventReceptorCommand);
312  m_ReceiverToObserverTagsMap[static_cast<void *>(receiver)].push_back(tag);
313  if (connectSendEvent)
314  ConnectGeometrySendEvent(receiver);
315  }
316 
317  template <typename T>
318  void ConnectGeometryEvents(T *receiver)
319  {
320  // connect sendEvent only once
321  ConnectGeometrySliceEvent(receiver, false);
322  ConnectGeometryTimeEvent(receiver);
323  }
324 
325  // use a templated method to get the right offset when casting to void*
326  template <typename T>
327  void Disconnect(T *receiver)
328  {
329  auto i = m_ReceiverToObserverTagsMap.find(static_cast<void *>(receiver));
330  if (i == m_ReceiverToObserverTagsMap.end())
331  return;
332  const std::list<unsigned long> &tags = i->second;
333  for (auto tagIter = tags.begin(); tagIter != tags.end(); ++tagIter)
334  {
335  RemoveObserver(*tagIter);
336  }
337  m_ReceiverToObserverTagsMap.erase(i);
338  }
339 
341 
347  virtual void SetGeometry(const itk::EventObject &geometrySliceEvent);
348 
353  virtual void SetGeometrySlice(const itk::EventObject &geometrySliceEvent);
354 
359  virtual void SetGeometryTime(const itk::EventObject &geometryTimeEvent);
360 
362  void SelectSliceByPoint(const mitk::Point3D &point);
363 
365  mitk::TimeGeometry *GetCreatedWorldGeometry();
366 
368  const mitk::BaseGeometry *GetCurrentGeometry3D();
369 
373  const mitk::PlaneGeometry *GetCurrentPlaneGeometry();
374 
378  void SetRenderer(BaseRenderer *renderer);
379 
384  BaseRenderer *GetRenderer() const;
385 
391  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &normal);
392 
396  void ReorientSlices(const mitk::Point3D &point, const mitk::Vector3D &axisVec0, const mitk::Vector3D &axisVec1);
397 
398  void ExecuteOperation(Operation *operation) override;
399 
405  itkSetMacro(SliceLocked, bool);
406  itkGetMacro(SliceLocked, bool);
407  itkBooleanMacro(SliceLocked);
408 
415  itkSetMacro(SliceRotationLocked, bool);
416  itkGetMacro(SliceRotationLocked, bool);
417  itkBooleanMacro(SliceRotationLocked);
418 
423  void AdjustSliceStepperRange();
424 
426  TimeStepType GetSelectedTimeStep() const;
427 
431  TimePointType GetSelectedTimePoint() const;
432 
433  protected:
435  ~SliceNavigationController() override;
436 
439 
441 
444 
446 
448 
449  itkSetMacro(Top, bool);
450  itkGetMacro(Top, bool);
451  itkBooleanMacro(Top);
452 
453  itkSetMacro(FrontSide, bool);
454  itkGetMacro(FrontSide, bool);
455  itkBooleanMacro(FrontSide);
456 
457  itkSetMacro(Rotated, bool);
458  itkGetMacro(Rotated, bool);
459  itkBooleanMacro(Rotated);
460 
461  bool m_Top;
463  bool m_Rotated;
464 
466 
469  unsigned int m_OldPos;
470 
471  typedef std::map<void *, std::list<unsigned long>> ObserverTagsMapType;
472  ObserverTagsMapType m_ReceiverToObserverTagsMap;
473  };
474 
475 } // namespace mitk
476 
477 #endif /* SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F */
#define mitkTimeGeometryEventMacro(classname, super)
#define MITKCORE_EXPORT
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
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.
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...
mitk::ScalarType TimePointType
std::vcl_size_t TimeStepType
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.