Medical Imaging Interaction Toolkit  2021.10.99-9c07a326
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 <QVTKOpenGLNativeWidget.h>
23 
24 #include "mitkBaseRenderer.h"
26 
27 class QDragEnterEvent;
28 class QDropEvent;
29 class QInputEvent;
30 class QMouseEvent;
31 
36 class MITKQTWIDGETS_EXPORT QmitkRenderWindow : public QVTKOpenGLNativeWidget, public mitk::RenderWindowBase
37 {
38  Q_OBJECT
39 
40 public:
42  QWidget *parent = nullptr,
43  const QString &name = "unnamed renderwindow",
44  mitk::VtkPropRenderer *renderer = nullptr);
45  ~QmitkRenderWindow() override;
46 
63  virtual void SetResendQtEvents(bool resend);
64 
65  // Set Layout Index to define the Layout Type
66  void SetLayoutIndex(QmitkRenderWindowMenu::LayoutIndex layoutIndex);
67 
68  // Get Layout Index to define the Layout Type
69  QmitkRenderWindowMenu::LayoutIndex GetLayoutIndex();
70 
71  // MenuWidget need to update the Layout Design List when Layout had changed
72  void UpdateLayoutDesignList(QmitkRenderWindowMenu::LayoutDesign layoutDesign);
73 
74  void UpdateCrosshairVisibility(bool);
75 
76  void UpdateCrosshairRotationMode(int);
77 
78  // Activate or Deactivate MenuWidget.
79  void ActivateMenuWidget(bool state);
80 
81  bool GetActivateMenuWidgetFlag() { return m_MenuWidgetActivated; }
82  // Get it from the QVTKWidget parent
83  vtkRenderWindow *GetVtkRenderWindow() override { return this->renderWindow(); }
84 
85  vtkRenderWindowInteractor *GetVtkRenderWindowInteractor() override { return nullptr; }
86 
87 protected:
88 
89  // catch-all event handler
90  bool event(QEvent *e) override;
91  // overloaded move handler
92  void moveEvent(QMoveEvent *event) override;
93  // overloaded show handler
94  void showEvent(QShowEvent *event) override;
95  // overloaded enter handler
96  void enterEvent(QEvent *) override;
97  // overloaded leave handler
98  void leaveEvent(QEvent *) override;
99 
100  // Overloaded resize handler, see decs in QVTKOpenGLWidget.
101  // Basically, we have to ensure the VTK rendering is updated for each change in window size.
102  void resizeGL(int w, int h) override;
103 
105  void dragEnterEvent(QDragEnterEvent *event) override;
106 
109  void dropEvent(QDropEvent *event) override;
110 
111 Q_SIGNALS:
112 
113  void LayoutDesignChanged(QmitkRenderWindowMenu::LayoutDesign);
114 
115  void ResetView();
116 
117  void CrosshairRotationModeChanged(int);
118 
119  void CrosshairVisibilityChanged(bool);
120 
121  void moved();
122 
124  void NodesDropped(QmitkRenderWindow *thisWindow, std::vector<mitk::DataNode *> nodes);
125 
126 private Q_SLOTS:
127 
128  void DeferredHideMenu();
129 
130 private:
131  // Helper Functions to Convert Qt-Events to Mitk-Events
132 
133  mitk::Point2D GetMousePosition(QMouseEvent *me) const;
134  mitk::Point2D GetMousePosition(QWheelEvent *we) const;
135  mitk::InteractionEvent::MouseButtons GetEventButton(QMouseEvent *me) const;
136  mitk::InteractionEvent::MouseButtons GetButtonState(QMouseEvent *me) const;
137  mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent *me) const;
138  mitk::InteractionEvent::MouseButtons GetButtonState(QWheelEvent *we) const;
139  std::string GetKeyLetter(QKeyEvent *ke) const;
140  int GetDelta(QWheelEvent *we) const;
141 
142  bool m_ResendQtEvents;
143 
144  QmitkRenderWindowMenu *m_MenuWidget;
145 
146  bool m_MenuWidgetActivated;
147 
149 
150  vtkSmartPointer<vtkGenericOpenGLRenderWindow> m_InternalRenderWindow;
151 
152 };
153 
154 #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
bool GetActivateMenuWidgetFlag()
vtkRenderWindowInteractor * GetVtkRenderWindowInteractor() override
MITK implementation of the QVTKWidget.
ViewDirection
Possible view directions for render windows.
vtkRenderWindow * GetVtkRenderWindow() override