NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkMultiWindowWidget_p.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkMultiWindowWidget_h
16 #define niftkMultiWindowWidget_h
17 
18 #include <QColor>
19 
20 #include <mitkBaseGeometry.h>
21 #include <mitkDataNode.h>
22 #include <mitkDataStorage.h>
23 #include <mitkTextOverlay2D.h>
24 #include <mitkVector.h>
25 #include <QmitkStdMultiWidget.h>
26 
27 #include <niftkDnDDisplayEnums.h>
28 
29 class QGridLayout;
30 class QStackedLayout;
31 class DisplayGeometryModificationCommand;
32 
33 class vtkRenderer;
34 class vtkSideAnnotation;
35 
36 namespace mitk
37 {
38 class SliceNavigationController;
39 }
40 
41 
42 namespace niftk
43 {
44 
79 class MultiWindowWidget : private QmitkStdMultiWidget
80 {
81 
82  Q_OBJECT
83 
84  friend class SingleViewerWidget;
85 
86 public:
87 
89  MultiWindowWidget(QWidget* parent = 0,
90  Qt::WindowFlags f = 0,
91  mitk::RenderingManager* renderingManager = 0,
92  mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard,
93  const QString& name = "DnD-Viewer");
94 
96  virtual ~MultiWindowWidget();
97 
99  bool IsEnabled() const;
100 
103  void SetEnabled(bool enabled);
104 
106  bool IsCursorVisible() const;
107 
109  void SetCursorVisible(bool visible);
110 
112  bool AreDirectionAnnotationsVisible() const;
113 
115  void SetDirectionAnnotationsVisible(bool visible);
116 
118  bool IsIntensityAnnotationVisible() const;
119 
121  void SetIntensityAnnotationVisible(bool visible);
122 
125 
127  void SetShow3DWindowIn2x2WindowLayout(bool visible);
128 
131  void SetTimeGeometry(const mitk::TimeGeometry* timeGeometry);
132 
134  void SetWindowLayout(WindowLayout windowLayout);
135 
138 
140  void SetBackgroundColour(QColor color);
141 
143  QColor GetBackgroundColour() const;
144 
148  bool IsFocused() const;
149 
153  void SetFocused();
154 
156  bool IsLinkedNavigationEnabled() const;
157 
159  void SetLinkedNavigationEnabled(bool linkedNavigationEnabled);
160 
169  QmitkRenderWindow* GetSelectedRenderWindow() const;
170 
176  void SetSelectedRenderWindow(QmitkRenderWindow* renderWindow);
177 
179  int GetSelectedWindowIndex() const;
180 
182  void SetSelectedWindowIndex(int selectedWindowIndex);
183 
187  std::vector<QmitkRenderWindow*> GetVisibleRenderWindows() const;
188 
190  const std::vector<QmitkRenderWindow*>& GetRenderWindows() const;
191 
193  bool ContainsRenderWindow(QmitkRenderWindow* renderWindow) const;
194 
196  int GetMaxSlice(int windowIndex) const;
197 
199  int GetMaxTimeStep() const;
200 
202  int GetSelectedSlice(int windowIndex) const;
203 
205  void SetSelectedSlice(int windowIndex, int selectedSlice);
206 
215  void MoveSlice(int windowIndex, int delta, bool restart = false);
216 
218  int GetTimeStep() const;
219 
221  void SetTimeStep(int timeStep);
222 
224  const mitk::Point3D& GetSelectedPosition() const;
225 
235  void SetSelectedPosition(const mitk::Point3D& selectedPosition);
236 
243  const mitk::Vector2D& GetCursorPosition(int windowIndex) const;
244 
254  void SetCursorPosition(int windowIndex, const mitk::Vector2D& cursorPosition);
255 
264  const std::vector<mitk::Vector2D>& GetCursorPositions() const;
265 
274  void SetCursorPositions(const std::vector<mitk::Vector2D>& cursorPositions);
275 
277  double GetScaleFactor(int windowIndex) const;
278 
283  void SetScaleFactor(int windowIndex, double scaleFactor);
284 
290  const std::vector<double>& GetScaleFactors() const;
291 
296  void SetScaleFactors(const std::vector<double>& scaleFactors);
297 
299  const mitk::Vector3D& GetVoxelSize() const;
300 
302  double GetMagnification(int windowIndex) const;
303 
305  void SetMagnification(int windowIndex, double magnification);
306 
315  void FitRenderWindows(double scaleFactor = 0.0);
316 
324  void FitRenderWindow(int windowIndex, double scaleFactor = 0.0);
325 
327  void SetVisibility(std::vector<mitk::DataNode*> nodes, bool visibility);
328 
330  void RequestUpdate();
331 
333  int GetSliceUpDirection(WindowOrientation orientation) const;
334 
336  bool GetCursorPositionBinding() const;
337 
339  void SetCursorPositionBinding(bool cursorPositionBinding);
340 
342  bool GetScaleFactorBinding() const;
343 
345  void SetScaleFactorBinding(bool scaleFactorBinding);
346 
364  bool BlockUpdate(bool blocked);
365 
366  bool BlockDisplayEvents(bool blocked);
367 
368 signals:
369 
371  void WindowLayoutChanged(WindowLayout windowLayout);
372 
374  void SelectedPositionChanged(const mitk::Point3D& selectedPosition);
375 
379  void TimeStepChanged(int timeStep);
380 
382  void CursorPositionChanged(int windowIndex, const mitk::Vector2D& cursorPosition);
383 
385  void ScaleFactorChanged(int windowIndex, double scaleFactor);
386 
389 
392 
393 private:
394 
398  void UpdateBorders();
399 
405  void UpdateCursorPosition(int windowIndex);
406 
409  void MoveToCursorPosition(int windowIndex);
410 
413  void ZoomAroundCursorPosition(int windowIndex);
414 
416  void OnAxialSliceChanged(const itk::EventObject& geometrySliceEvent);
417 
419  void OnSagittalSliceChanged(const itk::EventObject& geometrySliceEvent);
420 
422  void OnCoronalSliceChanged(const itk::EventObject& geometrySliceEvent);
423 
425  void OnTimeStepChanged(const itk::EventObject& geometryTimeEvent);
426 
429  void OnSelectedPositionChanged(int orientation);
430 
434  void SynchroniseCursorPositions(int windowIndex);
435 
437  void Update3DWindowVisibility();
438 
440  void SetVisibility(QmitkRenderWindow* renderWindow, mitk::DataNode* node, bool visibility);
441 
443  void AddDisplayGeometryModificationObserver(int windowIndex);
444 
446  void RemoveDisplayGeometryModificationObserver(int windowIndex);
447 
449  void OnDisplayGeometryModified(int windowIndex);
450 
452  void OnOriginChanged(int windowIndex, bool beingPanned);
453 
455  void OnScaleFactorChanged(int windowIndex, double scaleFactor);
456 
459  int GetDominantAxis(int orientation) const;
460 
462  void OnFocusChanged();
463 
465  void InitialiseIntensityAnnotations();
466 
468  void UpdateIntensityAnnotation(int windowIndex) const;
469 
470  std::vector<QmitkRenderWindow*> m_RenderWindows;
471 
474  std::string m_Name;
475 
476  QColor m_BackgroundColour;
477  QGridLayout* m_GridLayout;
478  unsigned long m_AxialSliceObserverTag;
479  unsigned long m_SagittalSliceObserverTag;
480  unsigned long m_CoronalSliceObserverTag;
481  unsigned long m_TimeStepObserverTag;
482  bool m_IsFocused;
483  bool m_LinkedNavigationEnabled;
484  bool m_Enabled;
485  int m_SelectedWindowIndex;
486  int m_FocusLosingWindowIndex;
487  bool m_CursorVisibility;
488  bool m_Show3DWindowIn2x2WindowLayout;
489  WindowLayout m_WindowLayout;
490 
491  mitk::Point3D m_SelectedPosition;
492 
493  int m_TimeStep;
494 
495  std::vector<mitk::Vector2D> m_CursorPositions;
496 
497  std::vector<const mitk::PlaneGeometry*> m_WorldGeometries;
498  std::vector<mitk::Vector2D> m_RenderWindowSizes;
499  std::vector<mitk::Vector2D> m_Origins;
500 
502  std::vector<double> m_ScaleFactors;
503 
504  typedef enum { ImageGeometry, AxialGeometry, SagittalGeometry, CoronalGeometry } GeometryType;
505  GeometryType m_GeometryType;
506 
507  int m_OrientationAxes[3];
508 
513  int m_UpDirections[3];
514 
517  const mitk::TimeGeometry* m_TimeGeometry;
518 
522  mitk::BaseGeometry* m_Geometry;
523 
527  double m_MmPerVx[3];
528 
529  vtkSideAnnotation* m_DirectionAnnotations[3];
530  vtkRenderer* m_DirectionAnnotationRenderers[3];
531 
535  bool m_CursorPositionBinding;
536 
540  bool m_CursorAxialPositionsAreBound;
541 
545  bool m_CursorSagittalPositionsAreBound;
546 
551  bool m_CursorCoronalPositionsAreBound;
552 
554  bool m_ScaleFactorBinding;
555 
557  unsigned long m_DisplayGeometryModificationObservers[3];
558 
562  bool m_BlockDisplayEvents;
563 
568  bool m_BlockSncEvents;
569 
570  bool m_BlockFocusEvents;
571 
573  unsigned long m_FocusManagerObserverTag;
574 
576  bool m_BlockUpdate;
577 
578  bool m_FocusHasChanged;
579  bool m_GeometryHasChanged;
580  bool m_WindowLayoutHasChanged;
581  std::vector<bool> m_SelectedSliceHasChanged;
582  bool m_TimeStepHasChanged;
583  std::vector<bool> m_CursorPositionHasChanged;
584  std::vector<bool> m_ScaleFactorHasChanged;
585  bool m_CursorPositionBindingHasChanged;
586  bool m_ScaleFactorBindingHasChanged;
587 
588  mitk::TextOverlay2D::Pointer m_IntensityAnnotations[3];
589  bool m_IntensityAnnotationIsVisible;
590 
592 
593 };
594 
595 }
596 
597 #endif
const std::vector< mitk::Vector2D > & GetCursorPositions() const
Gets the positions of the cursor in the 2D render windows normalised with the render window size...
Definition: niftkMultiWindowWidget.cxx:2437
WindowOrientation
Describes the different types of orientation, axial, sagittal, coronal, that can be achieved in the D...
Definition: niftkDnDDisplayEnums.h:29
bool ContainsRenderWindow(QmitkRenderWindow *renderWindow) const
Returns true if this widget contains the provided window and false otherwise.
Definition: niftkMultiWindowWidget.cxx:828
int GetMaxTimeStep() const
Returns the maximum allowed time step.
Definition: niftkMultiWindowWidget.cxx:1692
void SetIntensityAnnotationVisible(bool visible)
Sets the visibility of the intensity annotation.
Definition: niftkMultiWindowWidget.cxx:720
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2537
void SetVisibility(std::vector< mitk::DataNode * > nodes, bool visibility)
Sets the visible flag for all the nodes, and all the renderers in the QmitkStdMultiWidget base class...
Definition: niftkMultiWindowWidget.cxx:814
void SetWindowLayout(WindowLayout windowLayout)
Switches the window layout, i.e. the set and the arrangement of the render windows.
Definition: niftkMultiWindowWidget.cxx:1436
bool BlockUpdate(bool blocked)
Blocks the update of the widget.
Definition: niftkMultiWindowWidget.cxx:2819
void SetLinkedNavigationEnabled(bool linkedNavigationEnabled)
Sets the flag that controls whether we are listening to the navigation controller events...
Definition: niftkMultiWindowWidget.cxx:2725
bool IsIntensityAnnotationVisible() const
Tells if the intensity annotation is visible.
Definition: niftkMultiWindowWidget.cxx:713
bool BlockDisplayEvents(bool blocked)
Definition: niftkMultiWindowWidget.cxx:2810
void WindowLayoutChanged(WindowLayout windowLayout)
Emitted when the window layout has changed.
QmitkRenderWindow * GetSelectedRenderWindow() const
Returns the selected render window. The selected render window is one of the visible render windows...
Definition: niftkMultiWindowWidget.cxx:451
void SetDirectionAnnotationsVisible(bool visible)
Sets the visibility of the direction annotations.
Definition: niftkMultiWindowWidget.cxx:703
const std::vector< QmitkRenderWindow * > & GetRenderWindows() const
Returns the list of all QmitkRenderWindow contained herein.
Definition: niftkMultiWindowWidget.cxx:838
void SetSelectedPosition(const mitk::Point3D &selectedPosition)
Sets the selected position in the world coordinate system (mm).
Definition: niftkMultiWindowWidget.cxx:2113
int GetMaxSlice(int windowIndex) const
Returns the maximum allowed slice index for a given orientation.
Definition: niftkMultiWindowWidget.cxx:1676
void SetBackgroundColour(QColor color)
Set the background color, applied to 2D and 3D windows, and currently we don't do gradients...
Definition: niftkMultiWindowWidget.cxx:412
void SetEnabled(bool enabled)
There are several things we turn off/on depending on whether the widget is visible or considered acti...
Definition: niftkMultiWindowWidget.cxx:649
Definition: niftkMultiWindowWidget.cxx:49
void CursorPositionChanged(int windowIndex, const mitk::Vector2D &cursorPosition)
Emitted when the cursor position has changed in a render window.
void SetSelectedRenderWindow(QmitkRenderWindow *renderWindow)
Sets the selected render window. If this widget has the focus then the focuse is transferred to the g...
Definition: niftkMultiWindowWidget.cxx:460
bool GetShow3DWindowIn2x2WindowLayout() const
Returns the flag indicating if nodes will be visible in 3D window when in 2x2 window layout...
Definition: niftkMultiWindowWidget.cxx:732
const mitk::Vector2D & GetCursorPosition(int windowIndex) const
Gets the cursor position normalised with the render window size.
Definition: niftkMultiWindowWidget.cxx:1700
void SetTimeStep(int timeStep)
Set the current time step.
Definition: niftkMultiWindowWidget.cxx:2286
Definition: ReceptorMemberCommandTest.cxx:25
void SelectedPositionChanged(const mitk::Point3D &selectedPosition)
Emitted when the selected slice has changed in a render window.
MultiWindowWidget(QWidget *parent=0, Qt::WindowFlags f=0, mitk::RenderingManager *renderingManager=0, mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard, const QString &name="DnD-Viewer")
Constructor.
Definition: niftkMultiWindowWidget.cxx:85
void SetScaleFactor(int windowIndex, double scaleFactor)
Sets the scale factor of the render window to the given value (mm/px) and moves the image so that the...
Definition: niftkMultiWindowWidget.cxx:2497
bool IsEnabled() const
Return whether this widget is considered 'enabled'.
Definition: niftkMultiWindowWidget.cxx:642
void SetScaleFactors(const std::vector< double > &scaleFactors)
Sets the scale factor of the render windows to the given values.
Definition: niftkMultiWindowWidget.cxx:2532
void TimeStepChanged(int timeStep)
Emitted when the selected time step has changed in the rendering manager. Note that the time navigati...
void SetFocused()
Sets the focus to the selected render window of this widget. The focused render window receives the k...
Definition: niftkMultiWindowWidget.cxx:436
void SetScaleFactorBinding(bool scaleFactorBinding)
Sets the flag that controls whether the scale factors are bound across the 2D render windows...
Definition: niftkMultiWindowWidget.cxx:2781
bool IsLinkedNavigationEnabled() const
Gets the flag that controls whether we are listening to the navigation controller events...
Definition: niftkMultiWindowWidget.cxx:2718
WindowLayout
Describes the different render window layouts. So one WindowLayout could have multiple windows of dif...
Definition: niftkDnDDisplayEnums.h:49
void ScaleFactorBindingChanged()
Emitted when the scale factor binding has changed.
int GetTimeStep() const
Get the current time step.
Definition: niftkMultiWindowWidget.cxx:2279
void SetCursorPositions(const std::vector< mitk::Vector2D > &cursorPositions)
Sets the positions of the cursor in the 2D render windows normalised with the render window size...
Definition: niftkMultiWindowWidget.cxx:2444
Subclass of QmitkStdMultiWidget to provide MIDAS specific functionality by having convenient methods ...
Definition: niftkMultiWindowWidget_p.h:79
Subclass of vtkCornerAnnotation to display annotations on the four sides of a render window...
Definition: vtkSideAnnotation_p.h:28
void RequestUpdate()
Only request an update for screens that are visible and enabled.
Definition: niftkMultiWindowWidget.cxx:584
const mitk::Point3D & GetSelectedPosition() const
Gets the selected point in the world coordinate system (mm).
Definition: niftkMultiWindowWidget.cxx:2106
void SetCursorPositionBinding(bool cursorPositionBinding)
Sets the flag that controls whether the cursor position is bound between the 2D render windows...
Definition: niftkMultiWindowWidget.cxx:2743
double GetMagnification(int windowIndex) const
Computes the magnification of a render window.
Definition: niftkMultiWindowWidget.cxx:2604
A widget to wrap a single MultiWindowWidget, providing methods for switching the render window layout...
Definition: niftkSingleViewerWidget.h:78
void FitRenderWindows(double scaleFactor=0.0)
Moves the displayed regions to the centre of the 2D render windows and scales them, optionally. If no scale factor is given or the specified value is 0.0 then the maximal zooming is applied, using which each region fits into their window, also considering whether the scale factors are bound across the windows. If a positive scale factor is given then the scale factor of each render window is set to the specified value. If the specified scale factor is -1.0 then no scaling is applied. The regions are moved to the middle of the render windows in each cases.
Definition: niftkMultiWindowWidget.cxx:845
void MoveSlice(int windowIndex, int delta, bool restart=false)
Move n slices towards or opposite of the up direction. If delta is positive, the direction is the up ...
Definition: niftkMultiWindowWidget.cxx:2048
GLuint color
Definition: glew.h:6687
bool GetScaleFactorBinding() const
Gets the flag controls whether the scale factors are bound across the 2D render windows.
Definition: niftkMultiWindowWidget.cxx:2774
void SetShow3DWindowIn2x2WindowLayout(bool visible)
If true, then nodes will be visible in 3D window when in 2x2 window layout. In 3D window layout...
Definition: niftkMultiWindowWidget.cxx:739
void SetMagnification(int windowIndex, double magnification)
Sets the magnification of a render window to the given value.
Definition: niftkMultiWindowWidget.cxx:2627
void ScaleFactorChanged(int windowIndex, double scaleFactor)
Emitted when the scale factor has changed.
int GetSliceUpDirection(WindowOrientation orientation) const
According to the currently set geometry will return +1, or -1 for the direction to increment the slic...
Definition: niftkMultiWindowWidget.cxx:2650
void SetCursorVisible(bool visible)
Turn the 2D cursors visible/invisible for this viewer (renderer specific properties).
Definition: niftkMultiWindowWidget.cxx:676
void FitRenderWindow(int windowIndex, double scaleFactor=0.0)
Moves the displayed region to the centre of the 2D render window and scales it, optionally. If no scale factor is given or the specified value is 0.0 then the region is scaled to the maximum size that fits into the render window. If a positive scale factor is given then the region is scaled to the specified value. If the specified scale factor is -1.0 then no scaling is applied. The region is moved to the middle of the render window in each cases. The function c.
Definition: niftkMultiWindowWidget.cxx:946
int GetSelectedWindowIndex() const
Returns the index of the selected window.
Definition: niftkMultiWindowWidget.cxx:470
std::vector< QmitkRenderWindow * > GetVisibleRenderWindows() const
Returns the specifically selected render window, which may be 1 if the viewer is showing a single axi...
Definition: niftkMultiWindowWidget.cxx:559
bool IsFocused() const
Tells if the selected render window of this widget has the focus. The focused render window receives ...
Definition: niftkMultiWindowWidget.cxx:429
bool GetCursorPositionBinding() const
Gets the flag that controls whether the cursor position is bound between the 2D render windows...
Definition: niftkMultiWindowWidget.cxx:2736
GLuint const GLchar * name
Definition: glew.h:1798
WindowLayout GetWindowLayout() const
Gets the window layout, i.e. the set and the arrangement of the render windows.
Definition: niftkMultiWindowWidget.cxx:1669
void SetTimeGeometry(const mitk::TimeGeometry *timeGeometry)
Initialises the geometry in the QmitkStdMultiWidget base class. This has been a difficult method to g...
Definition: niftkMultiWindowWidget.cxx:1024
void CursorPositionBindingChanged()
Emitted when the cursor position binding has changed.
int GetSelectedSlice(int windowIndex) const
Get the current slice index.
Definition: niftkMultiWindowWidget.cxx:2006
QColor GetBackgroundColour() const
Get the background color, applied to 2D and 3D windows, and currently we don't do gradients...
Definition: niftkMultiWindowWidget.cxx:422
void SetCursorPosition(int windowIndex, const mitk::Vector2D &cursorPosition)
Sets the cursor position normalised with the render window size.
Definition: niftkMultiWindowWidget.cxx:1707
const std::vector< double > & GetScaleFactors() const
Gets the scale factors of the 2D render windows.
Definition: niftkMultiWindowWidget.cxx:2525
bool AreDirectionAnnotationsVisible() const
Tells if the direction annotations are visible.
Definition: niftkMultiWindowWidget.cxx:694
void SetSelectedWindowIndex(int selectedWindowIndex)
Sets the selected render window by its index.
Definition: niftkMultiWindowWidget.cxx:478
virtual ~MultiWindowWidget()
Destructor.
Definition: niftkMultiWindowWidget.cxx:293
bool IsCursorVisible() const
Get the flag controlling the 2D cursors visibility (renderer specific properties).
Definition: niftkMultiWindowWidget.cxx:669
Definition: niftkExceptionObject.h:21
GLsizei const GLcharARB ** string
Definition: glew.h:5194
double GetScaleFactor(int windowIndex) const
Gets the scale factor of the given render window. (mm/px)
Definition: niftkMultiWindowWidget.cxx:2490
const mitk::Vector3D & GetVoxelSize() const
Gets the voxel size (mm/vx).
GLclampf f
Definition: glew.h:3136
void SetSelectedSlice(int windowIndex, int selectedSlice)
Set the current slice index.
Definition: niftkMultiWindowWidget.cxx:2028