Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
Medical Imaging Interaction Toolkit
QmitkRenderWindow.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 QMITKRENDERWINDOW_H
14 #define QMITKRENDERWINDOW_H
15 
16 #include "mitkRenderWindowBase.h"
17 
18 #include "QmitkRenderWindowMenu.h"
19 #include <MitkQtWidgetsExports.h>
20 
21 #include <vtkGenericOpenGLRenderWindow.h>
22 #include <QVTKOpenGLWidget.h>
23 
24 #include "mitkBaseRenderer.h"
26 
27 class QDragEnterEvent;
28 class QDropEvent;
29 class QInputEvent;
30 
35 class MITKQTWIDGETS_EXPORT QmitkRenderWindow : public QVTKOpenGLWidget, public mitk::RenderWindowBase
36 {
37  Q_OBJECT
38 
39 public:
41  QWidget *parent = nullptr,
42  const QString &name = "unnamed renderwindow",
43  mitk::VtkPropRenderer *renderer = nullptr);
44  ~QmitkRenderWindow() override;
45 
62  virtual void SetResendQtEvents(bool resend);
63 
64  // Set Layout Index to define the Layout Type
65  void SetLayoutIndex(QmitkRenderWindowMenu::LayoutIndex layoutIndex);
66 
67  // Get Layout Index to define the Layout Type
68  QmitkRenderWindowMenu::LayoutIndex GetLayoutIndex();
69 
70  // MenuWidget need to update the Layout Design List when Layout had changed
71  void LayoutDesignListChanged(QmitkRenderWindowMenu::LayoutDesign layoutDesign);
72 
73  // Activate or Deactivate MenuWidget.
74  void ActivateMenuWidget(bool state);
75 
76  bool GetActivateMenuWidgetFlag() { return m_MenuWidgetActivated; }
77  // Get it from the QVTKWidget parent
78  vtkRenderWindow *GetVtkRenderWindow() override { return GetRenderWindow(); }
79 
80  vtkRenderWindowInteractor *GetVtkRenderWindowInteractor() override { return nullptr; }
81 
82 protected:
83 
84  // overloaded move handler
85  void moveEvent(QMoveEvent *event) override;
86  // overloaded show handler
87  void showEvent(QShowEvent *event) override;
88  // overloaded mouse press handler
89  void mousePressEvent(QMouseEvent *event) override;
90  // overloaded mouse double-click handler
91  void mouseDoubleClickEvent(QMouseEvent *event) override;
92  // overloaded mouse move handler
93  void mouseMoveEvent(QMouseEvent *event) override;
94  // overloaded mouse release handler
95  void mouseReleaseEvent(QMouseEvent *event) override;
96  // overloaded key press handler
97  void keyPressEvent(QKeyEvent *event) override;
98  // overloaded enter handler
99  void enterEvent(QEvent *) override;
100  // overloaded leave handler
101  void leaveEvent(QEvent *) override;
102 
103  // Overloaded resize handler, see decs in QVTKOpenGLWidget.
104  // Basically, we have to ensure the VTK rendering is updated for each change in window size.
105  void resizeGL(int w, int h) override;
106 
108  void dragEnterEvent(QDragEnterEvent *event) override;
109 
112  void dropEvent(QDropEvent *event) override;
113 
114 #ifndef QT_NO_WHEELEVENT
115  // overload wheel mouse event
116  void wheelEvent(QWheelEvent *) override;
117 #endif
118 
119  void AdjustRenderWindowMenuVisibility(const QPoint &pos);
120 
121 Q_SIGNALS:
122 
123  void LayoutDesignChanged(QmitkRenderWindowMenu::LayoutDesign);
124 
125  void ResetView();
126 
127  void CrosshairRotationModeChanged(int);
128 
129  void CrosshairVisibilityChanged(bool);
130 
131  void moved();
132 
134  void NodesDropped(QmitkRenderWindow *thisWindow, std::vector<mitk::DataNode *> nodes);
135 
136 private Q_SLOTS:
137 
138  void DeferredHideMenu();
139 
140 private:
141  // Helper Functions to Convert Qt-Events to Mitk-Events
142 
143  mitk::Point2D GetMousePosition(QMouseEvent *me) const;
144  mitk::Point2D GetMousePosition(QWheelEvent *we) const;
147  mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent *me) const;
149  std::string GetKeyLetter(QKeyEvent *ke) const;
150  int GetDelta(QWheelEvent *we) const;
151 
152  bool m_ResendQtEvents;
153 
154  QmitkRenderWindowMenu *m_MenuWidget;
155 
156  bool m_MenuWidgetActivated;
157 
159 
160  vtkSmartPointer<vtkGenericOpenGLRenderWindow> m_InternalRenderWindow;
161 
162 };
163 
164 #endif // QMITKRENDERWINDOW_H
Base class of MITK RenderWindows.
The QmitkRenderWindowMenu is a popup Widget which shows up when the mouse cursor enter a QmitkRenderW...
#define MITKQTWIDGETS_EXPORT
static std::string GetEventButton(mitk::InteractionEvent *event)
GetEventButton Return EventButton as String.
static std::string GetButtonState(mitk::InteractionEvent *event)
GetEventButton Return EventButton as String.
bool GetActivateMenuWidgetFlag()
vtkRenderWindowInteractor * GetVtkRenderWindowInteractor() override
MITK implementation of the QVTKWidget.
ViewDirection
Possible view directions for render windows.
vtkRenderWindow * GetVtkRenderWindow() override