diff --git a/Modules/QtWidgets/include/QmitkRenderWindow.h b/Modules/QtWidgets/include/QmitkRenderWindow.h index 4f392e2b82..012fd35019 100644 --- a/Modules/QtWidgets/include/QmitkRenderWindow.h +++ b/Modules/QtWidgets/include/QmitkRenderWindow.h @@ -1,172 +1,170 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef QMITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66 -#define QMITKRENDERWINDOW_H_HEADER_INCLUDED_C1C40D66 +#ifndef QMITKRENDERWINDOW_H +#define QMITKRENDERWINDOW_H #include "mitkRenderWindowBase.h" #include "QmitkRenderWindowMenu.h" #include #include #include #include "mitkBaseRenderer.h" #include "mitkInteractionEventConst.h" -class QmitkAbstractMultiWidget; class QDragEnterEvent; class QDropEvent; class QInputEvent; /** * \ingroup QmitkModule * \brief MITK implementation of the QVTKWidget */ class MITKQTWIDGETS_EXPORT QmitkRenderWindow : public QVTKOpenGLWidget, public mitk::RenderWindowBase { Q_OBJECT public: QmitkRenderWindow( QWidget *parent = nullptr, const QString &name = "unnamed renderwindow", mitk::VtkPropRenderer *renderer = nullptr, mitk::RenderingManager *renderingManager = nullptr, mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard); ~QmitkRenderWindow() override; /** * \brief Whether Qt events should be passed to parent (default: true) * * With introduction of the QVTKWidget the behaviour regarding Qt events changed. * QVTKWidget "accepts" Qt events like mouse clicks (i.e. set an "accepted" flag). * When this flag is set, Qt fininshed handling of this event -- otherwise it is * reached through to the widget's parent. * * This reaching through to the parent was implicitly required by QmitkMaterialWidget / QmitkMaterialShowCase. * * The default behaviour of QmitkRenderWindow is now to clear the "accepted" flag * of Qt events after they were handled by QVTKWidget. This way parents can also * handle events. * * If you don't want this behaviour, call SetResendQtEvents(true) on your render window. */ virtual void SetResendQtEvents(bool resend); // Set Layout Index to define the Layout Type - void SetLayoutIndex(unsigned int layoutIndex); + void SetLayoutIndex(QmitkRenderWindowMenu::LayoutIndex layoutIndex); // Get Layout Index to define the Layout Type - unsigned int GetLayoutIndex(); + QmitkRenderWindowMenu::LayoutIndex GetLayoutIndex(); // MenuWidget need to update the Layout Design List when Layout had changed - void LayoutDesignListChanged(int layoutDesignIndex); - - void HideRenderWindowMenu(); + void LayoutDesignListChanged(QmitkRenderWindowMenu::LayoutDesign layoutDesign); // Activate or Deactivate MenuWidget. - void ActivateMenuWidget(bool state, QmitkAbstractMultiWidget *multiWidget = nullptr); + void ActivateMenuWidget(bool state); bool GetActivateMenuWidgetFlag() { return m_MenuWidgetActivated; } // Get it from the QVTKWidget parent vtkRenderWindow *GetVtkRenderWindow() override { return GetRenderWindow(); } + vtkRenderWindowInteractor *GetVtkRenderWindowInteractor() override { return nullptr; } - void FullScreenMode(bool state); protected: + // overloaded move handler void moveEvent(QMoveEvent *event) override; // overloaded show handler void showEvent(QShowEvent *event) override; // overloaded mouse press handler void mousePressEvent(QMouseEvent *event) override; // overloaded mouse double-click handler void mouseDoubleClickEvent(QMouseEvent *event) override; // overloaded mouse move handler void mouseMoveEvent(QMouseEvent *event) override; // overloaded mouse release handler void mouseReleaseEvent(QMouseEvent *event) override; // overloaded key press handler void keyPressEvent(QKeyEvent *event) override; // overloaded enter handler void enterEvent(QEvent *) override; // overloaded leave handler void leaveEvent(QEvent *) override; // Overloaded resize handler, see decs in QVTKOpenGLWidget. // Basically, we have to ensure the VTK rendering is updated for each change in window size. void resizeGL(int w, int h) Q_DECL_OVERRIDE; /// \brief Simply says we accept the event type. void dragEnterEvent(QDragEnterEvent *event) override; /// \brief If the dropped type is application/x-mitk-datanodes we process the request by converting to mitk::DataNode /// pointers and emitting the NodesDropped signal. void dropEvent(QDropEvent *event) override; #ifndef QT_NO_WHEELEVENT // overload wheel mouse event void wheelEvent(QWheelEvent *) override; #endif void AdjustRenderWindowMenuVisibility(const QPoint &pos); -signals: +Q_SIGNALS: + + void LayoutDesignChanged(QmitkRenderWindowMenu::LayoutDesign); void ResetView(); - void ChangeCrosshairRotationMode(int); + void CrosshairRotationModeChanged(int); - void SignalLayoutDesignChanged(int layoutDesignIndex); + void CrosshairVisibilityChanged(bool); void moved(); /// \brief Emits a signal to say that this window has had the following nodes dropped on it. void NodesDropped(QmitkRenderWindow *thisWindow, std::vector nodes); -protected slots: - - void OnChangeLayoutDesign(int layoutDesignIndex); - - void OnWidgetPlaneModeChanged(int); +private Q_SLOTS: void DeferredHideMenu(); private: // Helper Functions to Convert Qt-Events to Mitk-Events mitk::Point2D GetMousePosition(QMouseEvent *me) const; mitk::Point2D GetMousePosition(QWheelEvent *we) const; mitk::InteractionEvent::MouseButtons GetEventButton(QMouseEvent *me) const; mitk::InteractionEvent::MouseButtons GetButtonState(QMouseEvent *me) const; mitk::InteractionEvent::ModifierKeys GetModifiers(QInputEvent *me) const; mitk::InteractionEvent::MouseButtons GetButtonState(QWheelEvent *we) const; std::string GetKeyLetter(QKeyEvent *ke) const; int GetDelta(QWheelEvent *we) const; + bool m_ResendQtEvents; QmitkRenderWindowMenu *m_MenuWidget; bool m_MenuWidgetActivated; - unsigned int m_LayoutIndex; + QmitkRenderWindowMenu::LayoutIndex m_LayoutIndex; vtkSmartPointer m_InternalRenderWindow; + }; -#endif +#endif // QMITKRENDERWINDOW_H diff --git a/Modules/QtWidgets/include/QmitkRenderWindowMenu.h b/Modules/QtWidgets/include/QmitkRenderWindowMenu.h index ff30d756b9..4059f06637 100644 --- a/Modules/QtWidgets/include/QmitkRenderWindowMenu.h +++ b/Modules/QtWidgets/include/QmitkRenderWindowMenu.h @@ -1,342 +1,213 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef QmitkRenderWindowMenu_h -#define QmitkRenderWindowMenu_h +#ifndef QMITKRENDERWINDOWMENU_H +#define QMITKRENDERWINDOWMENU_H #if defined(_WIN32) || defined(__APPLE__) #define QMITK_USE_EXTERNAL_RENDERWINDOW_MENU #endif -#include "mitkBaseRenderer.h" -#include +// mitk qtwidgets module +#include "MitkQtWidgetsExports.h" +#include "QmitkMultiWidgetLayoutManager.h" +// mitk core +#include + +// qt #include #include #include #include #include #include #include #include -class QmitkAbstractMultiWidget; - /** * \ingroup QmitkModule * \brief The QmitkRenderWindowMenu is a popup Widget which shows - * up when the mouse curser enter a QmitkRenderWindow. + * up when the mouse cursor enter a QmitkRenderWindow. * The Menu Widget is located in the right top corner of each * RenderWindow. It includes different settings. For example * the layout design can be changed with the setting button. Switching * between full-screen mode and layout design can be done - * with the full-screen button. Splitting the Widget horizontal or - * vertical as well closing the Widget is not implemented yet. + * with the full-screen button. * The popup Widget can be deactivated with ActivateMenuWidget(false) in * QmitkRenderWindow. * * \sa QmitkRenderWindow - * \sa QmitkAbstractMultiWidget * */ class MITKQTWIDGETS_EXPORT QmitkRenderWindowMenu : public QWidget { Q_OBJECT public: + + using LayoutIndex = mitk::BaseRenderer::ViewDirection; + using LayoutDesign = QmitkMultiWidgetLayoutManager::LayoutDesign; + QmitkRenderWindowMenu(QWidget *parent = nullptr, Qt::WindowFlags f = nullptr, - mitk::BaseRenderer *b = nullptr, - QmitkAbstractMultiWidget *mw = nullptr); + mitk::BaseRenderer *b = nullptr); ~QmitkRenderWindowMenu() override; /*! Return visibility of settings menu. The menu is connected with m_SettingsButton and includes layout direction (axial, coronal .. ) and layout design (standard layout, 2D images top, 3D bottom ... ). */ bool GetSettingsMenuVisibilty() { - if (m_Settings == nullptr) + if (m_LayoutActionsMenu == nullptr) return false; else - return m_Settings->isVisible(); + return m_LayoutActionsMenu->isVisible(); } /*! Set layout index. Defines layout direction (axial, coronal, sagital or threeD) of the parent. */ - void SetLayoutIndex(unsigned int layoutIndex); + void SetLayoutIndex(LayoutIndex layoutIndex); /*! Return layout direction of parent (axial, coronal, sagital or threeD) */ - unsigned int GetLayoutIndex() { return m_Layout; } + LayoutIndex GetLayoutIndex() { return m_Layout; } /*! Update list of layout design (standard layout, 2D images top, 3D bottom ..). Set action of current layout design to disable and all other to enable. */ - void UpdateLayoutDesignList(int layoutDesignIndex); + void UpdateLayoutDesignList(LayoutDesign layoutDesign); /*! Move menu widget to correct position (right upper corner). E.g. it is necessary when the full-screen mode is activated.*/ #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU void MoveWidgetToCorrectPos(float opacity); #else void MoveWidgetToCorrectPos(float /*opacity*/); #endif - void ChangeFullScreenMode(bool state); - - void NotifyNewWidgetPlanesMode(int mode); + void ShowMenu(); + void HideMenu(); protected: - /*! Create menu widget. The menu contains five QPushButtons (hori-split, verti-split, full-screen, settings and close - button) - and their signal/slot connection for handling. */ - void CreateMenuWidget(); - - /*! Create settings menu which contains layout direction and the different layout designs. */ - void CreateSettingsWidget(); /*! Reimplemented from QWidget. The paint event is a request to repaint all or part of a widget.*/ void paintEvent(QPaintEvent *event) override; - /*! Update list of layout direction (axial, coronal, sagital or threeD). Set action of currect layout direction - to disable and all other to enable. Normaly the user can switch here between the different layout direction, but - this is not supported yet. */ - void UpdateLayoutList(); + void CreateMenuWidget(); + + /*! Create settings menu which contains layout direction and the different layout designs. */ + void CreateSettingsWidget(); /*! Change Icon of full-screen button depending on full-screen mode. */ void ChangeFullScreenIcon(); - int currentCrosshairRotationMode; - -public slots: - - void SetCrossHairVisibility(bool state); - -signals: +Q_SIGNALS: void ResetView(); // == "global reinit" - // \brief int parameters are enum from QmitkAbstractMultiWidget - void ChangeCrosshairRotationMode(int); + void CrosshairVisibilityChanged(bool); + + // \brief int parameters are enum from QmitkStdMultiWidget + void CrosshairRotationModeChanged(int); /*! emit signal, when layout design changed by the setting menu.*/ - void SignalChangeLayoutDesign(int layoutDesign); + void LayoutDesignChanged(LayoutDesign layoutDesign); -public slots: +public Q_SLOTS: - void DeferredHideMenu(); void DeferredShowMenu(); + void DeferredHideMenu(); + /*! This method is responsible for non fluttering of + the renderWindowMenu when mouse cursor moves along the renderWindowMenu*/ void smoothHide(); -protected slots: +protected Q_SLOTS: - /// - /// this function is continously called by a timer + void enterEvent(QEvent * /*e*/) override; + void leaveEvent(QEvent * /*e*/) override; + + /// this function is continuously called by a timer /// to do the auto rotation - /// void AutoRotateNextStep(); - /// + /// this function is invoked when the auto-rotate action /// is clicked - /// void OnAutoRotationActionTriggered(); - void enterEvent(QEvent * /*e*/) override; - void leaveEvent(QEvent * /*e*/) override; void OnTSNumChanged(int); + void OnCrosshairMenuAboutToShow(); + void OnCrosshairVisibilityChanged(bool); void OnCrosshairRotationModeSelected(QAction *); /*! slot for activating/deactivating the full-screen mode. The slot is connected to the clicked() event of m_FullScreenButton. Activating the full-screen maximize the current widget, deactivating restore If layout design changed by the settings - menu, - the full-Screen mode is automatically switch to false. */ + menu, the full-Screen mode is automatically switched to false. */ void OnFullScreenButton(bool checked); /*! Slot for opening setting menu. The slot is connected to the clicked() event of m_SettingsButton. The settings menu includes different layout directions (axial, coronal, sagittal and 3D) as well all layout design (standard layout, 2D images top, 3D bottom ..)*/ - void OnSettingsButton(bool checked); - - /*! Slot for changing layout design to standard layout. The slot is connected to the triggered() signal of - * m_DefaultLayoutAction. */ - void OnChangeLayoutToDefault(bool); - - /*! Slot for changing layout design to 2D images top, 3D bottom layout. The slot is connected to the triggered() - * signal of m_2DImagesUpLayoutAction. */ - void OnChangeLayoutTo2DImagesUp(bool); - - /*! Slot for changing layout design to 2D images left, 3D right layout. The slot is connected to the triggered() - * signal of m_2DImagesLeftLayoutAction. */ - void OnChangeLayoutTo2DImagesLeft(bool); - - /*! Slot for changing layout to Big 3D layout. The slot is connected to the triggered() signal of m_Big3DLayoutAction. - */ - void OnChangeLayoutToBig3D(bool); - - /*! Slot for changing layout design to Axial plane layout. The slot is connected to the triggered() signal of - * m_Widget1LayoutAction. */ - void OnChangeLayoutToWidget1(bool); - - /*! Slot for changing layout design to Sagittal plane layout. The slot is connected to the triggered() signal of - * m_Widget2LayoutAction. */ - void OnChangeLayoutToWidget2(bool); - - /*! Slot for changing layout design to Coronal plane layout. The slot is connected to the triggered() signal of - * m_Widget3LayoutAction. */ - void OnChangeLayoutToWidget3(bool); + void OnLayoutDesignButton(bool checked); - /*! Slot for changing layout design to Coronal top, 3D bottom layout. The slot is connected to the triggered() signal - * of m_RowWidget3And4LayoutAction. */ - void OnChangeLayoutToRowWidget3And4(bool); - - /*! Slot for changing layout design to Coronal left, 3D right layout. The slot is connected to the triggered() signal - * of m_ColumnWidget3And4LayoutAction. */ - void OnChangeLayoutToColumnWidget3And4(bool); - - /*! Slot for changing layout design to Sagittal top, Coronal n 3D bottom layout. The slot is connected to the - * triggered() signal of m_SmallUpperWidget2Big3and4LayoutAction. */ - void OnChangeLayoutToSmallUpperWidget2Big3and4(bool); - - /*! Slot for changing layout design to Axial n Sagittal left, 3D right layout. The slot is connected to the - * triggered() signal of m_2x2Dand3DWidgetLayoutAction. */ - void OnChangeLayoutTo2x2Dand3DWidget(bool); - - /*! Slot for changing layout design to Axial n 3D left, Sagittal right layout. The slot is connected to the - * triggered() signal of m_Left2Dand3DRight2DLayoutAction. */ - void OnChangeLayoutToLeft2Dand3DRight2D(bool); - - void OnCrossHairMenuAboutToShow(); - -public: - /*! enum for layout direction*/ - enum - { - AXIAL, - SAGITTAL, - CORONAL, - THREE_D - }; - - /*! enum for layout design */ - enum - { - LAYOUT_DEFAULT, - LAYOUT_2DIMAGEUP, - LAYOUT_2DIMAGELEFT, - LAYOUT_BIG3D, - LAYOUT_AXIAL, - LAYOUT_SAGITTAL, - LAYOUT_CORONAL, - LAYOUT_2X2DAND3DWIDGET, - LAYOUT_ROWWIDGET3AND4, - LAYOUT_COLUMNWIDGET3AND4, - LAYOUT_ROWWIDGETSMALL3ANDBIG4, // not in use in this class, but we need it here to synchronize with the - // SdtMultiWidget. - LAYOUT_SMALLUPPERWIDGET2BIGAND4, - LAYOUT_LEFT2DAND3DRIGHT2D - }; - - void ShowMenu(); - void HideMenu(); + void OnSetLayout(LayoutDesign layoutDesign); protected: - QToolButton *m_CrosshairModeButton; - - // QAction* m_ShowHideCrosshairVisibilityAction; - - /*! QPushButton for activating/deactivating full-screen mode*/ - QToolButton *m_FullScreenButton; - - /*! QPushButton for open the settings menu*/ - QToolButton *m_SettingsButton; - - /*! QAction for Default layout design */ - QAction *m_DefaultLayoutAction; - - /*! QAction for 2D images up layout design */ - QAction *m_2DImagesUpLayoutAction; - /*! QAction for 2D images left layout design */ - QAction *m_2DImagesLeftLayoutAction; + QToolButton* m_CrosshairModeButton; - /*! QAction for big 3D layout design */ - QAction *m_Big3DLayoutAction; + QToolButton* m_FullScreenButton; - /*! QAction for big axial layout design */ - QAction *m_Widget1LayoutAction; - - /*! QAction for big saggital layout design */ - QAction *m_Widget2LayoutAction; - - /*! QAction for big coronal layout design */ - QAction *m_Widget3LayoutAction; - - /*! QAction for coronal top, 3D bottom layout design */ - QAction *m_RowWidget3And4LayoutAction; - - /*! QAction for coronal left, 3D right layout design */ - QAction *m_ColumnWidget3And4LayoutAction; - - /*! QAction for sagittal top, coronal n 3D bottom layout design */ - QAction *m_SmallUpperWidget2Big3and4LayoutAction; - - /*! QAction for axial n sagittal left, 3D right layout design */ - QAction *m_2x2Dand3DWidgetLayoutAction; - - /*! QAction for axial n 3D left, sagittal right layout design*/ - QAction *m_Left2Dand3DRight2DLayoutAction; + QToolButton* m_LayoutDesignButton; + QMenu* m_LayoutActionsMenu; + QAction* m_DefaultLayoutAction; + QAction* m_All2DTop3DBottomLayoutAction; + QAction* m_All2DLeft3DRightLayoutAction; + QAction* m_OneBigLayoutAction; + QAction* m_Only2DHorizontalLayoutAction; + QAction* m_Only2DVerticalLayoutAction; + QAction* m_OneTop3DBottomLayoutAction; + QAction* m_OneLeft3DRightLayoutAction; + QAction* m_AllHorizontalLayoutAction; + QAction* m_AllVerticalLayoutAction; QLabel *m_TSLabel; - /*! QMenu containg all layout direction and layout design settings.*/ - QMenu *m_Settings; - QMenu *m_CrosshairMenu; - /*! Index of layout direction. 0: axial; 1: saggital; 2: coronal; 3: threeD */ - unsigned int m_Layout; - - /*! Index of layout design. 0: LAYOUT_DEFAULT; 1: LAYOUT_2DIMAGEUP; 2: LAYOUT_2DIMAGELEFT; 3: LAYOUT_BIG3D - 4: LAYOUT_AXIAL; 5: LAYOUT_SAGITTAL; 6: LAYOUT_CORONAL; 7: LAYOUT_2X2DAND3DWIDGET; 8: LAYOUT_ROWWIDGET3AND4; - 9: LAYOUT_COLUMNWIDGET3AND4; 10: LAYOUT_ROWWIDGETSMALL3ANDBIG4; 11: LAYOUT_SMALLUPPERWIDGET2BIGAND4; 12: - LAYOUT_LEFT2DAND3DRIGHT2D */ - unsigned int m_LayoutDesign; - - /*! Store index of old layout design. It is used e.g. for the full-screen mode, when deactivating the mode the former - * layout design will restore.*/ - unsigned int m_OldLayoutDesign; - /*! Flag if full-screen mode is activated or deactivated. */ bool m_FullScreenMode; - bool m_Entered; - private: - mitk::BaseRenderer::Pointer m_Renderer; - QmitkAbstractMultiWidget *m_MultiWidget; + mitk::BaseRenderer::Pointer m_Renderer; - /// - /// a timer for the auto rotate action - /// - QTimer m_AutoRotationTimer; - QTimer m_HideTimer; + QTimer* m_AutoRotationTimer; + QTimer* m_HideTimer; QWidget *m_Parent; //memory because mode is set to default for slice num = 1 static unsigned int m_DefaultThickMode; + + int m_CrosshairRotationMode; + bool m_CrosshairVisibility; + + LayoutIndex m_Layout; + LayoutDesign m_LayoutDesign; + LayoutDesign m_OldLayoutDesign; + }; -#endif // QmitkRenderWindowMenu_H +#endif // QMITKRENDERWINDOWMENU_H diff --git a/Modules/QtWidgets/src/QmitkRenderWindow.cpp b/Modules/QtWidgets/src/QmitkRenderWindow.cpp index 8ea3e0c785..becf3d7a2c 100644 --- a/Modules/QtWidgets/src/QmitkRenderWindow.cpp +++ b/Modules/QtWidgets/src/QmitkRenderWindow.cpp @@ -1,506 +1,506 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRenderWindow.h" #include "mitkInteractionKeyEvent.h" #include "mitkInternalEvent.h" #include "mitkMouseDoubleClickEvent.h" #include "mitkMouseMoveEvent.h" #include "mitkMousePressEvent.h" #include "mitkMouseReleaseEvent.h" #include "mitkMouseWheelEvent.h" #include #include #include #include #include #include #include #include #include #include #include "QmitkMimeTypes.h" #include "QmitkRenderWindowMenu.h" QmitkRenderWindow::QmitkRenderWindow(QWidget *parent, const QString &name, mitk::VtkPropRenderer *, mitk::RenderingManager *renderingManager, mitk::BaseRenderer::RenderingMode::Type renderingMode) - : QVTKOpenGLWidget(parent), - m_ResendQtEvents(true), - m_MenuWidget(nullptr), - m_MenuWidgetActivated(false), - m_LayoutIndex(0) + : QVTKOpenGLWidget(parent) + , m_ResendQtEvents(true) + , m_MenuWidget(nullptr) + , m_MenuWidgetActivated(false) + , m_LayoutIndex(QmitkRenderWindowMenu::LayoutIndex::AXIAL) { m_InternalRenderWindow = vtkSmartPointer::New(); m_InternalRenderWindow->SetMultiSamples(0); m_InternalRenderWindow->SetAlphaBitPlanes(0); - this->SetRenderWindow(m_InternalRenderWindow); + SetRenderWindow(m_InternalRenderWindow); - this->Initialize(renderingManager, name.toStdString().c_str(), renderingMode); + Initialize(renderingManager, name.toStdString().c_str(), renderingMode); - this->setFocusPolicy(Qt::StrongFocus); - this->setMouseTracking(true); + setFocusPolicy(Qt::StrongFocus); + setMouseTracking(true); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - this->setSizePolicy(sizePolicy); + setSizePolicy(sizePolicy); } QmitkRenderWindow::~QmitkRenderWindow() { Destroy(); // Destroy mitkRenderWindowBase } void QmitkRenderWindow::SetResendQtEvents(bool resend) { m_ResendQtEvents = resend; } -void QmitkRenderWindow::SetLayoutIndex(unsigned int layoutIndex) +void QmitkRenderWindow::SetLayoutIndex(QmitkRenderWindowMenu::LayoutIndex layoutIndex) { m_LayoutIndex = layoutIndex; - if (m_MenuWidget) + if (nullptr != m_MenuWidget) + { m_MenuWidget->SetLayoutIndex(layoutIndex); + } } -unsigned int QmitkRenderWindow::GetLayoutIndex() +QmitkRenderWindowMenu::LayoutIndex QmitkRenderWindow::GetLayoutIndex() { - if (m_MenuWidget) + if (nullptr != m_MenuWidget) + { return m_MenuWidget->GetLayoutIndex(); + } else - return 0; + { + return QmitkRenderWindowMenu::LayoutIndex::AXIAL; + } } -void QmitkRenderWindow::LayoutDesignListChanged(int layoutDesignIndex) +void QmitkRenderWindow::LayoutDesignListChanged(QmitkRenderWindowMenu::LayoutDesign layoutDesign) { - if (m_MenuWidget) - m_MenuWidget->UpdateLayoutDesignList(layoutDesignIndex); + if (nullptr != m_MenuWidget) + { + m_MenuWidget->UpdateLayoutDesignList(layoutDesign); + } +} + +void QmitkRenderWindow::ActivateMenuWidget(bool state) +{ + if (nullptr == m_MenuWidget) + { + m_MenuWidget = new QmitkRenderWindowMenu(this, nullptr, m_Renderer); + m_MenuWidget->SetLayoutIndex(m_LayoutIndex); + } + + m_MenuWidgetActivated = state; + + if (m_MenuWidgetActivated) + { + connect(m_MenuWidget, &QmitkRenderWindowMenu::LayoutDesignChanged, this, &QmitkRenderWindow::LayoutDesignChanged); + connect(m_MenuWidget, &QmitkRenderWindowMenu::ResetView, this, &QmitkRenderWindow::ResetView); + connect(m_MenuWidget, &QmitkRenderWindowMenu::CrosshairVisibilityChanged, this, &QmitkRenderWindow::CrosshairVisibilityChanged); + connect(m_MenuWidget, &QmitkRenderWindowMenu::CrosshairRotationModeChanged, this, &QmitkRenderWindow::CrosshairRotationModeChanged); + } + else + { + disconnect(m_MenuWidget, &QmitkRenderWindowMenu::LayoutDesignChanged, this, &QmitkRenderWindow::LayoutDesignChanged); + disconnect(m_MenuWidget, &QmitkRenderWindowMenu::ResetView, this, &QmitkRenderWindow::ResetView); + disconnect(m_MenuWidget, &QmitkRenderWindowMenu::CrosshairVisibilityChanged, this, &QmitkRenderWindow::CrosshairVisibilityChanged); + disconnect(m_MenuWidget, &QmitkRenderWindowMenu::CrosshairRotationModeChanged, this, &QmitkRenderWindow::CrosshairRotationModeChanged); + + m_MenuWidget->hide(); + } +} + +void QmitkRenderWindow::moveEvent(QMoveEvent *event) +{ + QVTKOpenGLWidget::moveEvent(event); + + // after a move the overlays need to be positioned + emit moved(); +} + +void QmitkRenderWindow::showEvent(QShowEvent *event) +{ + QVTKOpenGLWidget::showEvent(event); + + // this singleshot is necessary to have the overlays positioned correctly after initial show + // simple call of moved() is no use here!! + QTimer::singleShot(0, this, SIGNAL(moved())); } void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) { // Get mouse position in vtk display coordinate system. me contains qt display infos... mitk::Point2D displayPos = GetMousePosition(me); mitk::MousePressEvent::Pointer mPressEvent = mitk::MousePressEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { QVTKOpenGLWidget::mousePressEvent(me); } if (m_ResendQtEvents) + { me->ignore(); + } } void QmitkRenderWindow::mouseDoubleClickEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::MouseDoubleClickEvent::Pointer mPressEvent = mitk::MouseDoubleClickEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { QVTKOpenGLWidget::mousePressEvent(me); } if (m_ResendQtEvents) + { me->ignore(); + } } void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::MouseReleaseEvent::Pointer mReleaseEvent = mitk::MouseReleaseEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mReleaseEvent.GetPointer())) { QVTKOpenGLWidget::mouseReleaseEvent(me); } if (m_ResendQtEvents) + { me->ignore(); + } } void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); - this->AdjustRenderWindowMenuVisibility(me->pos()); + AdjustRenderWindowMenuVisibility(me->pos()); mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me)); if (!this->HandleEvent(mMoveEvent.GetPointer())) { QVTKOpenGLWidget::mouseMoveEvent(me); } } void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { mitk::Point2D displayPos = GetMousePosition(we); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { QVTKOpenGLWidget::wheelEvent(we); } if (m_ResendQtEvents) + { we->ignore(); + } } void QmitkRenderWindow::keyPressEvent(QKeyEvent *ke) { mitk::InteractionEvent::ModifierKeys modifiers = GetModifiers(ke); std::string key = GetKeyLetter(ke); mitk::InteractionKeyEvent::Pointer keyEvent = mitk::InteractionKeyEvent::New(m_Renderer, key, modifiers); if (!this->HandleEvent(keyEvent.GetPointer())) { QVTKOpenGLWidget::keyPressEvent(ke); } if (m_ResendQtEvents) + { ke->ignore(); + } } void QmitkRenderWindow::enterEvent(QEvent *e) { // TODO implement new event QVTKOpenGLWidget::enterEvent(e); } -void QmitkRenderWindow::DeferredHideMenu() -{ - MITK_DEBUG << "QmitkRenderWindow::DeferredHideMenu"; - - if (m_MenuWidget) - m_MenuWidget->HideMenu(); -} - void QmitkRenderWindow::leaveEvent(QEvent *e) { mitk::InternalEvent::Pointer internalEvent = mitk::InternalEvent::New(this->m_Renderer, nullptr, "LeaveRenderWindow"); this->HandleEvent(internalEvent.GetPointer()); - if (m_MenuWidget) + if (nullptr != m_MenuWidget) + { m_MenuWidget->smoothHide(); + } QVTKOpenGLWidget::leaveEvent(e); } -//----------------------------------------------------------------------------- void QmitkRenderWindow::resizeGL(int w, int h) { this->GetRenderer()->GetRenderingManager()->ForceImmediateUpdate(GetRenderWindow()); QVTKOpenGLWidget::resizeGL(w, h); } -void QmitkRenderWindow::moveEvent(QMoveEvent *event) -{ - QVTKOpenGLWidget::moveEvent(event); - - // after a move the overlays need to be positioned - emit moved(); -} - -void QmitkRenderWindow::showEvent(QShowEvent *event) +void QmitkRenderWindow::dragEnterEvent(QDragEnterEvent *event) { - QVTKOpenGLWidget::showEvent(event); - - // this singleshot is necessary to have the overlays positioned correctly after initial show - // simple call of moved() is no use here!! - QTimer::singleShot(0, this, SIGNAL(moved())); + if (event->mimeData()->hasFormat("application/x-mitk-datanodes")) + { + event->accept(); + } } -void QmitkRenderWindow::ActivateMenuWidget(bool state, QmitkAbstractMultiWidget *multiWidget) +void QmitkRenderWindow::dropEvent(QDropEvent *event) { - m_MenuWidgetActivated = state; - - if (!m_MenuWidgetActivated && m_MenuWidget) - { - // disconnect Signal/Slot Connection - disconnect(m_MenuWidget, SIGNAL(SignalChangeLayoutDesign(int)), this, SLOT(OnChangeLayoutDesign(int))); - disconnect(m_MenuWidget, SIGNAL(ResetView()), this, SIGNAL(ResetView())); - disconnect(m_MenuWidget, SIGNAL(ChangeCrosshairRotationMode(int)), this, SIGNAL(ChangeCrosshairRotationMode(int))); - - delete m_MenuWidget; - m_MenuWidget = nullptr; - } - else if (m_MenuWidgetActivated && !m_MenuWidget) + QList dataNodeList = QmitkMimeTypes::ToDataNodePtrList(event->mimeData()); + if (!dataNodeList.empty()) { - // create render window MenuBar for split, close Window or set new setting. - m_MenuWidget = new QmitkRenderWindowMenu(this, nullptr, m_Renderer, multiWidget); - m_MenuWidget->SetLayoutIndex(m_LayoutIndex); - - // create Signal/Slot Connection - connect(m_MenuWidget, SIGNAL(SignalChangeLayoutDesign(int)), this, SLOT(OnChangeLayoutDesign(int))); - connect(m_MenuWidget, SIGNAL(ResetView()), this, SIGNAL(ResetView())); - connect(m_MenuWidget, SIGNAL(ChangeCrosshairRotationMode(int)), this, SIGNAL(ChangeCrosshairRotationMode(int))); + emit NodesDropped(this, dataNodeList.toVector().toStdVector()); } } void QmitkRenderWindow::AdjustRenderWindowMenuVisibility(const QPoint & /*pos*/) { - if (m_MenuWidget) + if (nullptr != m_MenuWidget) { m_MenuWidget->ShowMenu(); m_MenuWidget->MoveWidgetToCorrectPos(1.0f); } } -void QmitkRenderWindow::HideRenderWindowMenu() -{ - // DEPRECATED METHOD -} - -void QmitkRenderWindow::OnChangeLayoutDesign(int layoutDesignIndex) -{ - emit SignalLayoutDesignChanged(layoutDesignIndex); -} - -void QmitkRenderWindow::OnWidgetPlaneModeChanged(int mode) -{ - if (m_MenuWidget) - m_MenuWidget->NotifyNewWidgetPlanesMode(mode); -} - -void QmitkRenderWindow::FullScreenMode(bool state) +void QmitkRenderWindow::DeferredHideMenu() { - if (m_MenuWidget) - m_MenuWidget->ChangeFullScreenMode(state); -} + MITK_DEBUG << "QmitkRenderWindow::DeferredHideMenu"; -void QmitkRenderWindow::dragEnterEvent(QDragEnterEvent *event) -{ - if (event->mimeData()->hasFormat("application/x-mitk-datanodes")) + if (nullptr != m_MenuWidget) { - event->accept(); - } -} - -void QmitkRenderWindow::dropEvent(QDropEvent *event) -{ - QList dataNodeList = QmitkMimeTypes::ToDataNodePtrList(event->mimeData()); - if (!dataNodeList.empty()) - { - emit NodesDropped(this, dataNodeList.toVector().toStdVector()); + m_MenuWidget->HideMenu(); } } mitk::Point2D QmitkRenderWindow::GetMousePosition(QMouseEvent *me) const { mitk::Point2D point; point[0] = me->x(); // We need to convert the y component, as the display and vtk have other definitions for the y direction point[1] = m_Renderer->GetSizeY() - me->y(); return point; } mitk::Point2D QmitkRenderWindow::GetMousePosition(QWheelEvent *we) const { mitk::Point2D point; point[0] = we->x(); // We need to convert the y component, as the display and vtk have other definitions for the y direction point[1] = m_Renderer->GetSizeY() - we->y(); return point; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetEventButton(QMouseEvent *me) const { mitk::InteractionEvent::MouseButtons eventButton; switch (me->button()) { - case Qt::LeftButton: - eventButton = mitk::InteractionEvent::LeftMouseButton; - break; - case Qt::RightButton: - eventButton = mitk::InteractionEvent::RightMouseButton; - break; - case Qt::MidButton: - eventButton = mitk::InteractionEvent::MiddleMouseButton; - break; - default: - eventButton = mitk::InteractionEvent::NoButton; - break; + case Qt::LeftButton: + eventButton = mitk::InteractionEvent::LeftMouseButton; + break; + case Qt::RightButton: + eventButton = mitk::InteractionEvent::RightMouseButton; + break; + case Qt::MidButton: + eventButton = mitk::InteractionEvent::MiddleMouseButton; + break; + default: + eventButton = mitk::InteractionEvent::NoButton; + break; } return eventButton; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetButtonState(QMouseEvent *me) const { mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; if (me->buttons() & Qt::LeftButton) { buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; } if (me->buttons() & Qt::RightButton) { buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; } if (me->buttons() & Qt::MidButton) { buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; } return buttonState; } mitk::InteractionEvent::ModifierKeys QmitkRenderWindow::GetModifiers(QInputEvent *me) const { mitk::InteractionEvent::ModifierKeys modifiers = mitk::InteractionEvent::NoKey; if (me->modifiers() & Qt::ALT) { modifiers = modifiers | mitk::InteractionEvent::AltKey; } if (me->modifiers() & Qt::CTRL) { modifiers = modifiers | mitk::InteractionEvent::ControlKey; } if (me->modifiers() & Qt::SHIFT) { modifiers = modifiers | mitk::InteractionEvent::ShiftKey; } return modifiers; } mitk::InteractionEvent::MouseButtons QmitkRenderWindow::GetButtonState(QWheelEvent *we) const { mitk::InteractionEvent::MouseButtons buttonState = mitk::InteractionEvent::NoButton; if (we->buttons() & Qt::LeftButton) { buttonState = buttonState | mitk::InteractionEvent::LeftMouseButton; } if (we->buttons() & Qt::RightButton) { buttonState = buttonState | mitk::InteractionEvent::RightMouseButton; } if (we->buttons() & Qt::MidButton) { buttonState = buttonState | mitk::InteractionEvent::MiddleMouseButton; } return buttonState; } std::string QmitkRenderWindow::GetKeyLetter(QKeyEvent *ke) const { // Converting Qt Key Event to string element. std::string key = ""; int tkey = ke->key(); if (tkey < 128) { // standard ascii letter key = (char)toupper(tkey); } else { // special keys switch (tkey) { - case Qt::Key_Return: - key = mitk::InteractionEvent::KeyReturn; - break; - case Qt::Key_Enter: - key = mitk::InteractionEvent::KeyEnter; - break; - case Qt::Key_Escape: - key = mitk::InteractionEvent::KeyEsc; - break; - case Qt::Key_Delete: - key = mitk::InteractionEvent::KeyDelete; - break; - case Qt::Key_Up: - key = mitk::InteractionEvent::KeyArrowUp; - break; - case Qt::Key_Down: - key = mitk::InteractionEvent::KeyArrowDown; - break; - case Qt::Key_Left: - key = mitk::InteractionEvent::KeyArrowLeft; - break; - case Qt::Key_Right: - key = mitk::InteractionEvent::KeyArrowRight; - break; - - case Qt::Key_F1: - key = mitk::InteractionEvent::KeyF1; - break; - case Qt::Key_F2: - key = mitk::InteractionEvent::KeyF2; - break; - case Qt::Key_F3: - key = mitk::InteractionEvent::KeyF3; - break; - case Qt::Key_F4: - key = mitk::InteractionEvent::KeyF4; - break; - case Qt::Key_F5: - key = mitk::InteractionEvent::KeyF5; - break; - case Qt::Key_F6: - key = mitk::InteractionEvent::KeyF6; - break; - case Qt::Key_F7: - key = mitk::InteractionEvent::KeyF7; - break; - case Qt::Key_F8: - key = mitk::InteractionEvent::KeyF8; - break; - case Qt::Key_F9: - key = mitk::InteractionEvent::KeyF9; - break; - case Qt::Key_F10: - key = mitk::InteractionEvent::KeyF10; - break; - case Qt::Key_F11: - key = mitk::InteractionEvent::KeyF11; - break; - case Qt::Key_F12: - key = mitk::InteractionEvent::KeyF12; - break; - - case Qt::Key_End: - key = mitk::InteractionEvent::KeyEnd; - break; - case Qt::Key_Home: - key = mitk::InteractionEvent::KeyPos1; - break; - case Qt::Key_Insert: - key = mitk::InteractionEvent::KeyInsert; - break; - case Qt::Key_PageDown: - key = mitk::InteractionEvent::KeyPageDown; - break; - case Qt::Key_PageUp: - key = mitk::InteractionEvent::KeyPageUp; - break; - case Qt::Key_Space: - key = mitk::InteractionEvent::KeySpace; - break; + case Qt::Key_Return: + key = mitk::InteractionEvent::KeyReturn; + break; + case Qt::Key_Enter: + key = mitk::InteractionEvent::KeyEnter; + break; + case Qt::Key_Escape: + key = mitk::InteractionEvent::KeyEsc; + break; + case Qt::Key_Delete: + key = mitk::InteractionEvent::KeyDelete; + break; + case Qt::Key_Up: + key = mitk::InteractionEvent::KeyArrowUp; + break; + case Qt::Key_Down: + key = mitk::InteractionEvent::KeyArrowDown; + break; + case Qt::Key_Left: + key = mitk::InteractionEvent::KeyArrowLeft; + break; + case Qt::Key_Right: + key = mitk::InteractionEvent::KeyArrowRight; + break; + + case Qt::Key_F1: + key = mitk::InteractionEvent::KeyF1; + break; + case Qt::Key_F2: + key = mitk::InteractionEvent::KeyF2; + break; + case Qt::Key_F3: + key = mitk::InteractionEvent::KeyF3; + break; + case Qt::Key_F4: + key = mitk::InteractionEvent::KeyF4; + break; + case Qt::Key_F5: + key = mitk::InteractionEvent::KeyF5; + break; + case Qt::Key_F6: + key = mitk::InteractionEvent::KeyF6; + break; + case Qt::Key_F7: + key = mitk::InteractionEvent::KeyF7; + break; + case Qt::Key_F8: + key = mitk::InteractionEvent::KeyF8; + break; + case Qt::Key_F9: + key = mitk::InteractionEvent::KeyF9; + break; + case Qt::Key_F10: + key = mitk::InteractionEvent::KeyF10; + break; + case Qt::Key_F11: + key = mitk::InteractionEvent::KeyF11; + break; + case Qt::Key_F12: + key = mitk::InteractionEvent::KeyF12; + break; + + case Qt::Key_End: + key = mitk::InteractionEvent::KeyEnd; + break; + case Qt::Key_Home: + key = mitk::InteractionEvent::KeyPos1; + break; + case Qt::Key_Insert: + key = mitk::InteractionEvent::KeyInsert; + break; + case Qt::Key_PageDown: + key = mitk::InteractionEvent::KeyPageDown; + break; + case Qt::Key_PageUp: + key = mitk::InteractionEvent::KeyPageUp; + break; + case Qt::Key_Space: + key = mitk::InteractionEvent::KeySpace; + break; } } return key; } int QmitkRenderWindow::GetDelta(QWheelEvent *we) const { return we->delta(); } diff --git a/Modules/QtWidgets/src/QmitkRenderWindowMenu.cpp b/Modules/QtWidgets/src/QmitkRenderWindowMenu.cpp index 6b3bcb0490..7859c7ddfc 100644 --- a/Modules/QtWidgets/src/QmitkRenderWindowMenu.cpp +++ b/Modules/QtWidgets/src/QmitkRenderWindowMenu.cpp @@ -1,984 +1,637 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRenderWindowMenu.h" +// mitk core #include "mitkProperties.h" #include "mitkResliceMethodProperty.h" +// qt #include #include #include #include #include -#include #include -#include #include #include #include -#include - -#include "QmitkAbstractMultiWidget.h" - //#include"iconClose.xpm" #include "iconCrosshairMode.xpm" #include "iconFullScreen.xpm" //#include"iconHoriSplit.xpm" #include "iconSettings.xpm" //#include"iconVertiSplit.xpm" #include "iconLeaveFullScreen.xpm" +// c++ #include unsigned int QmitkRenderWindowMenu::m_DefaultThickMode(1); #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU -QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget *parent, - Qt::WindowFlags, - mitk::BaseRenderer *b, - QmitkAbstractMultiWidget *mw) - : QWidget(nullptr, Qt::Tool | Qt::FramelessWindowHint), +QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget* parent, + Qt::WindowFlags flags, + mitk::BaseRenderer* baseRenderer) + : QWidget(nullptr, Qt::Tool | Qt::FramelessWindowHint) #else -QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget *parent, - Qt::WindowFlags f, - mitk::BaseRenderer *b, - QmitkAbstractMultiWidget *mw) - : QWidget(parent, f), +QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget* parent, + Qt::WindowFlags flags, + mitk::BaseRenderer* baseRenderer) + : QWidget(parent, flags) #endif - m_Settings(nullptr), - m_CrosshairMenu(nullptr), - m_Layout(0), - m_LayoutDesign(0), - m_OldLayoutDesign(0), - m_FullScreenMode(false), - m_Entered(false), - m_Renderer(b), - m_MultiWidget(mw), - m_Parent(parent) -{ - // Create Menu Widget - this->CreateMenuWidget(); - this->setMinimumWidth(61); // DIRTY.. If you add or remove a button, you need to change the size. - this->setMaximumWidth(61); - this->setAutoFillBackground(true); + , m_LayoutActionsMenu(nullptr) + , m_CrosshairMenu(nullptr) + , m_FullScreenMode(false) + , m_Renderer(baseRenderer) + , m_Parent(parent) + , m_CrosshairRotationMode(0) + , m_CrosshairVisibility(false) + , m_Layout(LayoutIndex::AXIAL) + , m_LayoutDesign(LayoutDesign::DEFAULT) + , m_OldLayoutDesign(LayoutDesign::DEFAULT) +{ + CreateMenuWidget(); + setMinimumWidth(61); // DIRTY.. If you add or remove a button, you need to change the size. + setMaximumWidth(61); + setAutoFillBackground(true); // Else part fixes the render window menu issue on Linux bug but caused bugs on macOS and Windows // for macOS see bug 3192 // for Windows see bug 12130 //... so macOS and Windows must be treated differently: #if defined(Q_OS_MAC) this->show(); this->setWindowOpacity(0.0f); #else this->setVisible(false); #endif - // this->setAttribute( Qt::WA_NoSystemBackground ); - // this->setBackgroundRole( QPalette::Dark ); - // this->update(); - - // SetOpacity -- its just posible if the widget is a window. - // Windows indicates that the widget is a window, usually with a window system frame and a title bar, - // irrespective of whether the widget has a parent or not. - /* - this->setWindowFlags( Qt::Window | Qt::FramelessWindowHint); - */ - // this->setAttribute(Qt::WA_TranslucentBackground); - // this->setWindowOpacity(0.75); - - currentCrosshairRotationMode = 0; - - // for autorotating - m_AutoRotationTimer.setInterval(75); - connect(&m_AutoRotationTimer, SIGNAL(timeout()), this, SLOT(AutoRotateNextStep())); - m_HideTimer.setSingleShot(true); - connect(&m_HideTimer, SIGNAL(timeout()), this, SLOT(DeferredHideMenu())); - connect(m_Parent, SIGNAL(destroyed()), this, SLOT(deleteLater())); + m_AutoRotationTimer = new QTimer(this); + m_AutoRotationTimer->setInterval(75); + + m_HideTimer = new QTimer(this); + m_HideTimer->setSingleShot(true); + + connect(m_AutoRotationTimer, &QTimer::timeout, this, &QmitkRenderWindowMenu::AutoRotateNextStep); + connect(m_HideTimer, &QTimer::timeout, this, &QmitkRenderWindowMenu::DeferredHideMenu); + connect(m_Parent, &QObject::destroyed, this, &QmitkRenderWindowMenu::deleteLater); } QmitkRenderWindowMenu::~QmitkRenderWindowMenu() { - if (m_AutoRotationTimer.isActive()) - m_AutoRotationTimer.stop(); + if (m_AutoRotationTimer->isActive()) + { + m_AutoRotationTimer->stop(); + } } -void QmitkRenderWindowMenu::CreateMenuWidget() +void QmitkRenderWindowMenu::SetLayoutIndex(LayoutIndex layoutIndex) { - QHBoxLayout *layout = new QHBoxLayout(this); - layout->setAlignment(Qt::AlignRight); - layout->setContentsMargins(1, 1, 1, 1); - - QSize size(13, 13); + m_Layout = layoutIndex; +} - m_CrosshairMenu = new QMenu(this); - connect(m_CrosshairMenu, SIGNAL(aboutToShow()), this, SLOT(OnCrossHairMenuAboutToShow())); +void QmitkRenderWindowMenu::UpdateLayoutDesignList(LayoutDesign layoutDesign) +{ + m_LayoutDesign = layoutDesign; - // button for changing rotation mode - m_CrosshairModeButton = new QToolButton(this); - m_CrosshairModeButton->setMaximumSize(15, 15); - m_CrosshairModeButton->setIconSize(size); - m_CrosshairModeButton->setMenu(m_CrosshairMenu); - m_CrosshairModeButton->setIcon(QIcon(QPixmap(iconCrosshairMode_xpm))); - m_CrosshairModeButton->setPopupMode(QToolButton::InstantPopup); - m_CrosshairModeButton->setStyleSheet("QToolButton::menu-indicator { image: none; }"); - m_CrosshairModeButton->setAutoRaise(true); - layout->addWidget(m_CrosshairModeButton); + if (nullptr == m_LayoutActionsMenu) + { + CreateSettingsWidget(); + } - // fullScreenButton - m_FullScreenButton = new QToolButton(this); - m_FullScreenButton->setMaximumSize(15, 15); - m_FullScreenButton->setIconSize(size); - m_FullScreenButton->setIcon(QIcon(QPixmap(iconFullScreen_xpm))); - m_FullScreenButton->setAutoRaise(true); - layout->addWidget(m_FullScreenButton); + m_DefaultLayoutAction->setEnabled(true); + m_All2DTop3DBottomLayoutAction->setEnabled(true); + m_All2DLeft3DRightLayoutAction->setEnabled(true); + m_OneBigLayoutAction->setEnabled(true); + m_Only2DHorizontalLayoutAction->setEnabled(true); + m_Only2DVerticalLayoutAction->setEnabled(true); + m_OneTop3DBottomLayoutAction->setEnabled(true); + m_OneLeft3DRightLayoutAction->setEnabled(true); + m_AllHorizontalLayoutAction->setEnabled(true); + m_AllVerticalLayoutAction->setEnabled(true); - // settingsButton - m_SettingsButton = new QToolButton(this); - m_SettingsButton->setMaximumSize(15, 15); - m_SettingsButton->setIconSize(size); - m_SettingsButton->setIcon(QIcon(QPixmap(iconSettings_xpm))); - m_SettingsButton->setAutoRaise(true); - layout->addWidget(m_SettingsButton); - - // Create Connections -- coming soon? - connect(m_FullScreenButton, SIGNAL(clicked(bool)), this, SLOT(OnFullScreenButton(bool))); - connect(m_SettingsButton, SIGNAL(clicked(bool)), this, SLOT(OnSettingsButton(bool))); + switch (m_LayoutDesign) + { + case LayoutDesign::DEFAULT: + { + m_DefaultLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ALL_2D_TOP_3D_BOTTOM: + { + m_All2DTop3DBottomLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ALL_2D_LEFT_3D_RIGHT: + { + m_All2DLeft3DRightLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ONE_BIG: + { + m_OneBigLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ONLY_2D_HORIZONTAL: + { + m_Only2DHorizontalLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ONLY_2D_VERTICAL: + { + m_Only2DVerticalLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ONE_TOP_3D_BOTTOM: + { + m_OneTop3DBottomLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ONE_LEFT_3D_RIGHT: + { + m_OneLeft3DRightLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ALL_HORIZONTAL: + { + m_AllHorizontalLayoutAction->setEnabled(false); + break; + } + case LayoutDesign::ALL_VERTICAL: + { + m_AllVerticalLayoutAction->setEnabled(false); + break; + } + } } -void QmitkRenderWindowMenu::CreateSettingsWidget() +#ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU +void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float opacity) +#else +void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float /*opacity*/) +#endif { - m_Settings = new QMenu(this); +#ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU + int X = floor(double(this->m_Parent->width() - this->width() - 8.0)); + int Y = 7; - m_DefaultLayoutAction = new QAction("standard layout", m_Settings); - m_DefaultLayoutAction->setDisabled(true); + QPoint pos = this->m_Parent->mapToGlobal(QPoint(0, 0)); - m_2DImagesUpLayoutAction = new QAction("2D images top, 3D bottom", m_Settings); - m_2DImagesUpLayoutAction->setDisabled(false); - - m_2DImagesLeftLayoutAction = new QAction("2D images left, 3D right", m_Settings); - m_2DImagesLeftLayoutAction->setDisabled(false); - - m_Big3DLayoutAction = new QAction("Big 3D", m_Settings); - m_Big3DLayoutAction->setDisabled(false); - - m_Widget1LayoutAction = new QAction("Axial plane", m_Settings); - m_Widget1LayoutAction->setDisabled(false); - - m_Widget2LayoutAction = new QAction("Sagittal plane", m_Settings); - m_Widget2LayoutAction->setDisabled(false); - - m_Widget3LayoutAction = new QAction("Coronal plane", m_Settings); - m_Widget3LayoutAction->setDisabled(false); - - m_RowWidget3And4LayoutAction = new QAction("Coronal top, 3D bottom", m_Settings); - m_RowWidget3And4LayoutAction->setDisabled(false); - - m_ColumnWidget3And4LayoutAction = new QAction("Coronal left, 3D right", m_Settings); - m_ColumnWidget3And4LayoutAction->setDisabled(false); - - m_SmallUpperWidget2Big3and4LayoutAction = new QAction("Sagittal top, Coronal n 3D bottom", m_Settings); - m_SmallUpperWidget2Big3and4LayoutAction->setDisabled(false); - - m_2x2Dand3DWidgetLayoutAction = new QAction("Axial n Sagittal left, 3D right", m_Settings); - m_2x2Dand3DWidgetLayoutAction->setDisabled(false); - - m_Left2Dand3DRight2DLayoutAction = new QAction("Axial n 3D left, Sagittal right", m_Settings); - m_Left2Dand3DRight2DLayoutAction->setDisabled(false); - - m_Settings->addAction(m_DefaultLayoutAction); - m_Settings->addAction(m_2DImagesUpLayoutAction); - m_Settings->addAction(m_2DImagesLeftLayoutAction); - m_Settings->addAction(m_Big3DLayoutAction); - m_Settings->addAction(m_Widget1LayoutAction); - m_Settings->addAction(m_Widget2LayoutAction); - m_Settings->addAction(m_Widget3LayoutAction); - m_Settings->addAction(m_RowWidget3And4LayoutAction); - m_Settings->addAction(m_ColumnWidget3And4LayoutAction); - m_Settings->addAction(m_SmallUpperWidget2Big3and4LayoutAction); - m_Settings->addAction(m_2x2Dand3DWidgetLayoutAction); - m_Settings->addAction(m_Left2Dand3DRight2DLayoutAction); - - m_Settings->setVisible(false); - - connect(m_DefaultLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToDefault(bool))); - connect(m_2DImagesUpLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2DImagesUp(bool))); - connect(m_2DImagesLeftLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2DImagesLeft(bool))); - connect(m_Big3DLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToBig3D(bool))); - connect(m_Widget1LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget1(bool))); - connect(m_Widget2LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget2(bool))); - connect(m_Widget3LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget3(bool))); - connect(m_RowWidget3And4LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToRowWidget3And4(bool))); - connect( - m_ColumnWidget3And4LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToColumnWidget3And4(bool))); - connect(m_SmallUpperWidget2Big3and4LayoutAction, - SIGNAL(triggered(bool)), - this, - SLOT(OnChangeLayoutToSmallUpperWidget2Big3and4(bool))); - connect(m_2x2Dand3DWidgetLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2x2Dand3DWidget(bool))); - connect( - m_Left2Dand3DRight2DLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToLeft2Dand3DRight2D(bool))); -} + this->move(X + pos.x(), Y + pos.y()); -void QmitkRenderWindowMenu::paintEvent(QPaintEvent * /*e*/) -{ - QPainter painter(this); - QColor semiTransparentColor = Qt::black; - semiTransparentColor.setAlpha(255); - painter.fillRect(rect(), semiTransparentColor); + if (opacity < 0) + opacity = 0; + else if (opacity > 1) + opacity = 1; + + this->setWindowOpacity(opacity); +#else + int moveX = floor(double(this->m_Parent->width() - this->width() - 4.0)); + this->move(moveX, 3); + this->show(); +#endif } -void QmitkRenderWindowMenu::SetLayoutIndex(unsigned int layoutIndex) +void QmitkRenderWindowMenu::ShowMenu() { - m_Layout = layoutIndex; + MITK_DEBUG << "menu showMenu"; + DeferredShowMenu(); } void QmitkRenderWindowMenu::HideMenu() { MITK_DEBUG << "menu hideEvent"; DeferredHideMenu(); } -void QmitkRenderWindowMenu::ShowMenu() +void QmitkRenderWindowMenu::paintEvent(QPaintEvent * /*e*/) { - MITK_DEBUG << "menu showMenu"; - DeferredShowMenu(); + QPainter painter(this); + QColor semiTransparentColor = Qt::black; + semiTransparentColor.setAlpha(255); + painter.fillRect(rect(), semiTransparentColor); } -void QmitkRenderWindowMenu::enterEvent(QEvent * /*e*/) +void QmitkRenderWindowMenu::CreateMenuWidget() { - MITK_DEBUG << "menu enterEvent"; - DeferredShowMenu(); + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setAlignment(Qt::AlignRight); + layout->setContentsMargins(1, 1, 1, 1); - m_Entered = true; -} + QSize size(13, 13); -void QmitkRenderWindowMenu::DeferredHideMenu() -{ - MITK_DEBUG << "menu deferredhidemenu"; -// Else part fixes the render window menu issue on Linux bug but caused bugs on macOS and Windows -// for macOS see bug 3192 -// for Windows see bug 12130 -//... so macOS and Windows must be treated differently: -#if defined(Q_OS_MAC) - this->setWindowOpacity(0.0f); -#else - this->setVisible(false); -#endif + m_CrosshairMenu = new QMenu(this); + connect(m_CrosshairMenu, &QMenu::aboutToShow, this, &QmitkRenderWindowMenu::OnCrosshairMenuAboutToShow); - // setVisible(false); - // setWindowOpacity(0.0f); - /// hide(); -} + m_CrosshairModeButton = new QToolButton(this); + m_CrosshairModeButton->setMaximumSize(15, 15); + m_CrosshairModeButton->setIconSize(size); + m_CrosshairModeButton->setMenu(m_CrosshairMenu); + m_CrosshairModeButton->setIcon(QIcon(QPixmap(iconCrosshairMode_xpm))); + m_CrosshairModeButton->setPopupMode(QToolButton::InstantPopup); + m_CrosshairModeButton->setStyleSheet("QToolButton::menu-indicator { image: none; }"); + m_CrosshairModeButton->setAutoRaise(true); + layout->addWidget(m_CrosshairModeButton); -void QmitkRenderWindowMenu::leaveEvent(QEvent * /*e*/) -{ - MITK_DEBUG << "menu leaveEvent"; + m_FullScreenButton = new QToolButton(this); + m_FullScreenButton->setMaximumSize(15, 15); + m_FullScreenButton->setIconSize(size); + m_FullScreenButton->setIcon(QIcon(QPixmap(iconFullScreen_xpm))); + m_FullScreenButton->setAutoRaise(true); + layout->addWidget(m_FullScreenButton); - m_Entered = false; - smoothHide(); -} + m_LayoutDesignButton = new QToolButton(this); + m_LayoutDesignButton->setMaximumSize(15, 15); + m_LayoutDesignButton->setIconSize(size); + m_LayoutDesignButton->setIcon(QIcon(QPixmap(iconSettings_xpm))); + m_LayoutDesignButton->setAutoRaise(true); + layout->addWidget(m_LayoutDesignButton); -/* This method is responsible for non fluttering of - the renderWindowMenu when mouse cursor moves along the renderWindowMenu*/ -void QmitkRenderWindowMenu::smoothHide() -{ - MITK_DEBUG << "menu leaveEvent"; - m_HideTimer.start(10); + connect(m_FullScreenButton, &QToolButton::clicked, this, &QmitkRenderWindowMenu::OnFullScreenButton); + connect(m_LayoutDesignButton, &QToolButton::clicked, this, &QmitkRenderWindowMenu::OnLayoutDesignButton); } -void QmitkRenderWindowMenu::ChangeFullScreenMode(bool state) -{ - this->OnFullScreenButton(state); -} -/// \brief -void QmitkRenderWindowMenu::OnFullScreenButton(bool /*checked*/) +void QmitkRenderWindowMenu::CreateSettingsWidget() { - if (!m_FullScreenMode) - { - m_FullScreenMode = true; - m_OldLayoutDesign = m_LayoutDesign; - - switch (m_Layout) - { - case AXIAL: - { - emit SignalChangeLayoutDesign(LAYOUT_AXIAL); - break; - } + m_LayoutActionsMenu = new QMenu(this); - case SAGITTAL: - { - emit SignalChangeLayoutDesign(LAYOUT_SAGITTAL); - break; - } - case CORONAL: - { - emit SignalChangeLayoutDesign(LAYOUT_CORONAL); - break; - } - case THREE_D: - { - emit SignalChangeLayoutDesign(LAYOUT_BIG3D); - break; - } - } + m_DefaultLayoutAction = new QAction("Standard layout", m_LayoutActionsMenu); + m_DefaultLayoutAction->setDisabled(true); - // Move Widget and show again - this->MoveWidgetToCorrectPos(1.0f); + m_All2DTop3DBottomLayoutAction = new QAction("All 2D top, 3D bottom", m_LayoutActionsMenu); + m_All2DTop3DBottomLayoutAction->setDisabled(false); - // change icon - this->ChangeFullScreenIcon(); - } - else - { - m_FullScreenMode = false; - emit SignalChangeLayoutDesign(m_OldLayoutDesign); + m_All2DLeft3DRightLayoutAction = new QAction("All 2D left, 3D right", m_LayoutActionsMenu); + m_All2DLeft3DRightLayoutAction->setDisabled(false); - // Move Widget and show again - this->MoveWidgetToCorrectPos(1.0f); + m_OneBigLayoutAction = new QAction("This big", m_LayoutActionsMenu); + m_OneBigLayoutAction->setDisabled(false); - // change icon - this->ChangeFullScreenIcon(); - } + m_Only2DHorizontalLayoutAction = new QAction("Only 2D horizontal", m_LayoutActionsMenu); + m_Only2DHorizontalLayoutAction->setDisabled(false); - DeferredShowMenu(); -} + m_Only2DVerticalLayoutAction = new QAction("Only 2D vertical", m_LayoutActionsMenu); + m_Only2DVerticalLayoutAction->setDisabled(false); -/// \brief -void QmitkRenderWindowMenu::OnSettingsButton(bool /*checked*/) -{ - if (m_Settings == nullptr) - this->CreateSettingsWidget(); + m_OneTop3DBottomLayoutAction = new QAction("This top, 3D bottom", m_LayoutActionsMenu); + m_OneTop3DBottomLayoutAction->setDisabled(false); - QPoint point = this->mapToGlobal(m_SettingsButton->geometry().topLeft()); - m_Settings->setVisible(true); - m_Settings->exec(point); -} + m_OneLeft3DRightLayoutAction = new QAction("This left, 3D right", m_LayoutActionsMenu); + m_OneLeft3DRightLayoutAction->setDisabled(false); -void QmitkRenderWindowMenu::OnChangeLayoutTo2DImagesUp(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); + m_AllHorizontalLayoutAction = new QAction("All horizontal", m_LayoutActionsMenu); + m_AllHorizontalLayoutAction->setDisabled(false); - m_LayoutDesign = LAYOUT_2DIMAGEUP; - emit SignalChangeLayoutDesign(LAYOUT_2DIMAGEUP); + m_AllVerticalLayoutAction = new QAction("All vertical", m_LayoutActionsMenu); + m_AllVerticalLayoutAction->setDisabled(false); - DeferredShowMenu(); -} -void QmitkRenderWindowMenu::OnChangeLayoutTo2DImagesLeft(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); + m_LayoutActionsMenu->addAction(m_DefaultLayoutAction); + m_LayoutActionsMenu->addAction(m_All2DTop3DBottomLayoutAction); + m_LayoutActionsMenu->addAction(m_All2DLeft3DRightLayoutAction); + m_LayoutActionsMenu->addAction(m_OneBigLayoutAction); + m_LayoutActionsMenu->addAction(m_Only2DHorizontalLayoutAction); + m_LayoutActionsMenu->addAction(m_Only2DVerticalLayoutAction); + m_LayoutActionsMenu->addAction(m_OneTop3DBottomLayoutAction); + m_LayoutActionsMenu->addAction(m_OneLeft3DRightLayoutAction); + m_LayoutActionsMenu->addAction(m_AllHorizontalLayoutAction); + m_LayoutActionsMenu->addAction(m_AllVerticalLayoutAction); - m_LayoutDesign = LAYOUT_2DIMAGELEFT; - emit SignalChangeLayoutDesign(LAYOUT_2DIMAGELEFT); + m_LayoutActionsMenu->setVisible(false); - DeferredShowMenu(); + connect(m_DefaultLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::DEFAULT); }); + connect(m_All2DTop3DBottomLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ALL_2D_TOP_3D_BOTTOM); }); + connect(m_All2DLeft3DRightLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ALL_2D_LEFT_3D_RIGHT); }); + connect(m_OneBigLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ONE_BIG); }); + connect(m_Only2DHorizontalLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ONLY_2D_HORIZONTAL); }); + connect(m_Only2DVerticalLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ONLY_2D_VERTICAL); }); + connect(m_OneTop3DBottomLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ONE_TOP_3D_BOTTOM); }); + connect(m_OneLeft3DRightLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ONE_LEFT_3D_RIGHT); }); + connect(m_AllHorizontalLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ALL_HORIZONTAL); }); + connect(m_AllVerticalLayoutAction, &QAction::triggered, [this]() { this->OnSetLayout(LayoutDesign::ALL_VERTICAL); }); } -void QmitkRenderWindowMenu::OnChangeLayoutToDefault(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_DEFAULT; - emit SignalChangeLayoutDesign(LAYOUT_DEFAULT); - DeferredShowMenu(); +void QmitkRenderWindowMenu::ChangeFullScreenIcon() +{ + m_FullScreenButton->setIcon(m_FullScreenMode ? QPixmap(iconLeaveFullScreen_xpm) : QPixmap(iconFullScreen_xpm)); } void QmitkRenderWindowMenu::DeferredShowMenu() { MITK_DEBUG << "deferred show menu"; - m_HideTimer.stop(); + m_HideTimer->stop(); -// Else part fixes the render window menu issue on Linux bug but caused bugs on macOS and Windows -// for macOS see bug 3192 -// for Windows see bug 12130 -//... so macOS and Windows must be treated differently: + // Else part fixes the render window menu issue on Linux bug but caused bugs on macOS and Windows + // for macOS see bug 3192 + // for Windows see bug 12130 + //... so macOS and Windows must be treated differently: #if defined(Q_OS_MAC) this->setWindowOpacity(1.0f); #else this->setVisible(true); this->raise(); #endif } -void QmitkRenderWindowMenu::OnChangeLayoutToBig3D(bool) -{ - MITK_DEBUG << "OnChangeLayoutToBig3D"; - - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_BIG3D; - emit SignalChangeLayoutDesign(LAYOUT_BIG3D); - - DeferredShowMenu(); -} - -void QmitkRenderWindowMenu::OnChangeLayoutToWidget1(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_AXIAL; - emit SignalChangeLayoutDesign(LAYOUT_AXIAL); - - DeferredShowMenu(); -} -void QmitkRenderWindowMenu::OnChangeLayoutToWidget2(bool) +void QmitkRenderWindowMenu::DeferredHideMenu() { - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_SAGITTAL; - emit SignalChangeLayoutDesign(LAYOUT_SAGITTAL); - - DeferredShowMenu(); + MITK_DEBUG << "menu deferredhidemenu"; + // Else part fixes the render window menu issue on Linux bug but caused bugs on macOS and Windows + // for macOS see bug 3192 + // for Windows see bug 12130 + //... so macOS and Windows must be treated differently: +#if defined(Q_OS_MAC) + this->setWindowOpacity(0.0f); +#else + this->setVisible(false); +#endif } -void QmitkRenderWindowMenu::OnChangeLayoutToWidget3(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_CORONAL; - emit SignalChangeLayoutDesign(LAYOUT_CORONAL); - DeferredShowMenu(); -} -void QmitkRenderWindowMenu::OnChangeLayoutToRowWidget3And4(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_ROWWIDGET3AND4; - emit SignalChangeLayoutDesign(LAYOUT_ROWWIDGET3AND4); - - DeferredShowMenu(); -} -void QmitkRenderWindowMenu::OnChangeLayoutToColumnWidget3And4(bool) +void QmitkRenderWindowMenu::smoothHide() { - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_COLUMNWIDGET3AND4; - emit SignalChangeLayoutDesign(LAYOUT_COLUMNWIDGET3AND4); - - DeferredShowMenu(); + MITK_DEBUG << "menu leaveEvent"; + m_HideTimer->start(10); } -void QmitkRenderWindowMenu::OnChangeLayoutToSmallUpperWidget2Big3and4(bool) +void QmitkRenderWindowMenu::enterEvent(QEvent * /*e*/) { - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_SMALLUPPERWIDGET2BIGAND4; - emit SignalChangeLayoutDesign(LAYOUT_SMALLUPPERWIDGET2BIGAND4); - + MITK_DEBUG << "menu enterEvent"; DeferredShowMenu(); } -void QmitkRenderWindowMenu::OnChangeLayoutTo2x2Dand3DWidget(bool) -{ - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_2X2DAND3DWIDGET; - emit SignalChangeLayoutDesign(LAYOUT_2X2DAND3DWIDGET); - DeferredShowMenu(); -} -void QmitkRenderWindowMenu::OnChangeLayoutToLeft2Dand3DRight2D(bool) +void QmitkRenderWindowMenu::leaveEvent(QEvent * /*e*/) { - // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List - m_FullScreenMode = false; - this->ChangeFullScreenIcon(); - - m_LayoutDesign = LAYOUT_LEFT2DAND3DRIGHT2D; - emit SignalChangeLayoutDesign(LAYOUT_LEFT2DAND3DRIGHT2D); - - DeferredShowMenu(); + MITK_DEBUG << "menu leaveEvent"; + smoothHide(); } -void QmitkRenderWindowMenu::UpdateLayoutDesignList(int layoutDesignIndex) +void QmitkRenderWindowMenu::AutoRotateNextStep() { - m_LayoutDesign = layoutDesignIndex; - - if (m_Settings == nullptr) - this->CreateSettingsWidget(); - - switch (m_LayoutDesign) + if (m_Renderer->GetCameraRotationController()) { - case LAYOUT_DEFAULT: - { - m_DefaultLayoutAction->setEnabled(false); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - - case LAYOUT_2DIMAGEUP: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(false); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_2DIMAGELEFT: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(false); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_BIG3D: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(false); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_AXIAL: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(false); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_SAGITTAL: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(false); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_CORONAL: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(false); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_2X2DAND3DWIDGET: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(false); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_ROWWIDGET3AND4: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(false); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_COLUMNWIDGET3AND4: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(false); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_SMALLUPPERWIDGET2BIGAND4: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(false); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(true); - break; - } - case LAYOUT_LEFT2DAND3DRIGHT2D: - { - m_DefaultLayoutAction->setEnabled(true); - m_2DImagesUpLayoutAction->setEnabled(true); - m_2DImagesLeftLayoutAction->setEnabled(true); - m_Big3DLayoutAction->setEnabled(true); - m_Widget1LayoutAction->setEnabled(true); - m_Widget2LayoutAction->setEnabled(true); - m_Widget3LayoutAction->setEnabled(true); - m_RowWidget3And4LayoutAction->setEnabled(true); - m_ColumnWidget3And4LayoutAction->setEnabled(true); - m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); - m_2x2Dand3DWidgetLayoutAction->setEnabled(true); - m_Left2Dand3DRight2DLayoutAction->setEnabled(false); - break; - } + m_Renderer->GetCameraRotationController()->GetSlice()->Next(); } } -#ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU -void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float opacity) -#else -void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float /*opacity*/) -#endif -{ -#ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU - int X = floor(double(this->m_Parent->width() - this->width() - 8.0)); - int Y = 7; - - QPoint pos = this->m_Parent->mapToGlobal(QPoint(0, 0)); - - this->move(X + pos.x(), Y + pos.y()); - - if (opacity < 0) - opacity = 0; - else if (opacity > 1) - opacity = 1; - - this->setWindowOpacity(opacity); -#else - int moveX = floor(double(this->m_Parent->width() - this->width() - 4.0)); - this->move(moveX, 3); - this->show(); -#endif -} - -void QmitkRenderWindowMenu::ChangeFullScreenIcon() -{ - m_FullScreenButton->setIcon(m_FullScreenMode ? QPixmap(iconLeaveFullScreen_xpm) : QPixmap(iconFullScreen_xpm)); -} - -void QmitkRenderWindowMenu::OnCrosshairRotationModeSelected(QAction *action) -{ - MITK_DEBUG << "selected crosshair mode " << action->data().toInt(); - emit ChangeCrosshairRotationMode(action->data().toInt()); -} - -void QmitkRenderWindowMenu::SetCrossHairVisibility(bool state) +void QmitkRenderWindowMenu::OnAutoRotationActionTriggered() { - if (m_Renderer.IsNotNull()) + if (m_AutoRotationTimer->isActive()) { - if (nullptr != m_MultiWidget) - { - m_MultiWidget->SetCrosshairVisibility(state); - } + m_AutoRotationTimer->stop(); + m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOff(); + } + else + { + m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOn(); + m_AutoRotationTimer->start(); } } void QmitkRenderWindowMenu::OnTSNumChanged(int num) { MITK_DEBUG << "Thickslices num: " << num << " on renderer " << m_Renderer.GetPointer(); if (m_Renderer.IsNotNull()) { unsigned int thickSlicesMode = 0; // determine the state of the thick-slice mode mitk::ResliceMethodProperty *resliceMethodEnumProperty = nullptr; if(m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty(resliceMethodEnumProperty, "reslice.thickslices") && resliceMethodEnumProperty) { thickSlicesMode = resliceMethodEnumProperty->GetValueAsId(); if(thickSlicesMode!=0) m_DefaultThickMode = thickSlicesMode; } if(thickSlicesMode==0 && num>0) //default mode only for single slices { thickSlicesMode = m_DefaultThickMode; //mip default m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.showarea", mitk::BoolProperty::New(true)); } if(num<1) { thickSlicesMode = 0; m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.showarea", mitk::BoolProperty::New(false)); } m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices", mitk::ResliceMethodProperty::New(thickSlicesMode)); m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.num", mitk::IntProperty::New(num)); m_TSLabel->setText(QString::number(num * 2 + 1)); m_Renderer->SendUpdateSlice(); m_Renderer->GetRenderingManager()->RequestUpdateAll(); } } -void QmitkRenderWindowMenu::OnCrossHairMenuAboutToShow() +void QmitkRenderWindowMenu::OnCrosshairMenuAboutToShow() { QMenu *crosshairModesMenu = m_CrosshairMenu; crosshairModesMenu->clear(); QAction *resetViewAction = new QAction(crosshairModesMenu); resetViewAction->setText("Reset view"); crosshairModesMenu->addAction(resetViewAction); - connect(resetViewAction, SIGNAL(triggered()), this, SIGNAL(ResetView())); + connect(resetViewAction, &QAction::triggered, this, &QmitkRenderWindowMenu::ResetView); // Show hide crosshairs { QAction *showHideCrosshairVisibilityAction = new QAction(crosshairModesMenu); showHideCrosshairVisibilityAction->setText("Show crosshair"); showHideCrosshairVisibilityAction->setCheckable(true); - showHideCrosshairVisibilityAction->setChecked(m_MultiWidget->GetCrosshairVisibility()); + showHideCrosshairVisibilityAction->setChecked(m_CrosshairVisibility); crosshairModesMenu->addAction(showHideCrosshairVisibilityAction); - connect(showHideCrosshairVisibilityAction, SIGNAL(toggled(bool)), this, SLOT(SetCrossHairVisibility(bool))); + connect(showHideCrosshairVisibilityAction, &QAction::toggled, this, &QmitkRenderWindowMenu::OnCrosshairVisibilityChanged); } // Rotation mode { QAction *rotationGroupSeparator = new QAction(crosshairModesMenu); rotationGroupSeparator->setSeparator(true); rotationGroupSeparator->setText("Rotation mode"); crosshairModesMenu->addAction(rotationGroupSeparator); QActionGroup *rotationModeActionGroup = new QActionGroup(crosshairModesMenu); rotationModeActionGroup->setExclusive(true); QAction *noCrosshairRotation = new QAction(crosshairModesMenu); noCrosshairRotation->setActionGroup(rotationModeActionGroup); noCrosshairRotation->setText("No crosshair rotation"); noCrosshairRotation->setCheckable(true); - noCrosshairRotation->setChecked(currentCrosshairRotationMode == 0); + noCrosshairRotation->setChecked(m_CrosshairRotationMode == 0); noCrosshairRotation->setData(0); crosshairModesMenu->addAction(noCrosshairRotation); QAction *singleCrosshairRotation = new QAction(crosshairModesMenu); singleCrosshairRotation->setActionGroup(rotationModeActionGroup); singleCrosshairRotation->setText("Crosshair rotation"); singleCrosshairRotation->setCheckable(true); - singleCrosshairRotation->setChecked(currentCrosshairRotationMode == 1); + singleCrosshairRotation->setChecked(m_CrosshairRotationMode == 1); singleCrosshairRotation->setData(1); crosshairModesMenu->addAction(singleCrosshairRotation); QAction *coupledCrosshairRotation = new QAction(crosshairModesMenu); coupledCrosshairRotation->setActionGroup(rotationModeActionGroup); coupledCrosshairRotation->setText("Coupled crosshair rotation"); coupledCrosshairRotation->setCheckable(true); - coupledCrosshairRotation->setChecked(currentCrosshairRotationMode == 2); + coupledCrosshairRotation->setChecked(m_CrosshairRotationMode == 2); coupledCrosshairRotation->setData(2); crosshairModesMenu->addAction(coupledCrosshairRotation); QAction *swivelMode = new QAction(crosshairModesMenu); swivelMode->setActionGroup(rotationModeActionGroup); swivelMode->setText("Swivel mode"); swivelMode->setCheckable(true); - swivelMode->setChecked(currentCrosshairRotationMode == 3); + swivelMode->setChecked(m_CrosshairRotationMode == 3); swivelMode->setData(3); crosshairModesMenu->addAction(swivelMode); - connect( - rotationModeActionGroup, SIGNAL(triggered(QAction *)), this, SLOT(OnCrosshairRotationModeSelected(QAction *))); + connect(rotationModeActionGroup, &QActionGroup::triggered, this, &QmitkRenderWindowMenu::OnCrosshairRotationModeSelected); } // auto rotation support if (m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard3D) { QAction *autoRotationGroupSeparator = new QAction(crosshairModesMenu); autoRotationGroupSeparator->setSeparator(true); crosshairModesMenu->addAction(autoRotationGroupSeparator); QAction *autoRotationAction = crosshairModesMenu->addAction("Auto Rotation"); autoRotationAction->setCheckable(true); - autoRotationAction->setChecked(m_AutoRotationTimer.isActive()); - connect(autoRotationAction, SIGNAL(triggered()), this, SLOT(OnAutoRotationActionTriggered())); + autoRotationAction->setChecked(m_AutoRotationTimer->isActive()); + connect(autoRotationAction, &QAction::triggered, this, &QmitkRenderWindowMenu::OnAutoRotationActionTriggered); } // Thickslices support if (m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard2D) { QAction *thickSlicesGroupSeparator = new QAction(crosshairModesMenu); thickSlicesGroupSeparator->setSeparator(true); thickSlicesGroupSeparator->setText("ThickSlices mode"); crosshairModesMenu->addAction(thickSlicesGroupSeparator); QActionGroup *thickSlicesActionGroup = new QActionGroup(crosshairModesMenu); thickSlicesActionGroup->setExclusive(true); int currentMode = 0; { mitk::ResliceMethodProperty::Pointer m = dynamic_cast( m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty("reslice.thickslices")); if (m.IsNotNull()) currentMode = m->GetValueAsId(); } int currentNum = 1; { mitk::IntProperty::Pointer m = dynamic_cast( m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty("reslice.thickslices.num")); if (m.IsNotNull()) { currentNum = m->GetValue(); } } if (currentMode == 0) currentNum = 0; QSlider *m_TSSlider = new QSlider(crosshairModesMenu); m_TSSlider->setMinimum(0); m_TSSlider->setMaximum(50); m_TSSlider->setValue(currentNum); m_TSSlider->setOrientation(Qt::Horizontal); - connect(m_TSSlider, SIGNAL(valueChanged(int)), this, SLOT(OnTSNumChanged(int))); + connect(m_TSSlider, &QSlider::valueChanged, this, &QmitkRenderWindowMenu::OnTSNumChanged); - QHBoxLayout *_TSLayout = new QHBoxLayout; - _TSLayout->setContentsMargins(4, 4, 4, 4); - _TSLayout->addWidget(new QLabel("TS: ")); - _TSLayout->addWidget(m_TSSlider); - _TSLayout->addWidget(m_TSLabel = new QLabel(QString::number(currentNum * 2 + 1), this)); + QHBoxLayout *tsLayout = new QHBoxLayout; + tsLayout->setContentsMargins(4, 4, 4, 4); + tsLayout->addWidget(new QLabel("TS: ")); + tsLayout->addWidget(m_TSSlider); + tsLayout->addWidget(m_TSLabel = new QLabel(QString::number(currentNum * 2 + 1), this)); - QWidget *_TSWidget = new QWidget; - _TSWidget->setLayout(_TSLayout); + QWidget *tsWidget = new QWidget; + tsWidget->setLayout(tsLayout); QWidgetAction *m_TSSliderAction = new QWidgetAction(crosshairModesMenu); - m_TSSliderAction->setDefaultWidget(_TSWidget); + m_TSSliderAction->setDefaultWidget(tsWidget); crosshairModesMenu->addAction(m_TSSliderAction); } } -void QmitkRenderWindowMenu::NotifyNewWidgetPlanesMode(int mode) +void QmitkRenderWindowMenu::OnCrosshairVisibilityChanged(bool visible) { - currentCrosshairRotationMode = mode; + m_CrosshairVisibility = visible; + emit CrosshairVisibilityChanged(visible); } -void QmitkRenderWindowMenu::OnAutoRotationActionTriggered() +void QmitkRenderWindowMenu::OnCrosshairRotationModeSelected(QAction *action) { - if (m_AutoRotationTimer.isActive()) + m_CrosshairRotationMode = action->data().toInt(); + emit CrosshairRotationModeChanged(m_CrosshairRotationMode); +} + +void QmitkRenderWindowMenu::OnFullScreenButton(bool /*checked*/) +{ + if (!m_FullScreenMode) { - m_AutoRotationTimer.stop(); - m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOff(); + m_FullScreenMode = true; + m_OldLayoutDesign = m_LayoutDesign; + + emit LayoutDesignChanged(LayoutDesign::ONE_BIG); } else { - m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOn(); - m_AutoRotationTimer.start(); + m_FullScreenMode = false; + emit LayoutDesignChanged(m_OldLayoutDesign); } + + MoveWidgetToCorrectPos(1.0f); + ChangeFullScreenIcon(); + + DeferredShowMenu(); } -void QmitkRenderWindowMenu::AutoRotateNextStep() +void QmitkRenderWindowMenu::OnLayoutDesignButton(bool /*checked*/) { - if (m_Renderer->GetCameraRotationController()) - m_Renderer->GetCameraRotationController()->GetSlice()->Next(); + if (nullptr == m_LayoutActionsMenu) + { + CreateSettingsWidget(); + } + + QPoint point = mapToGlobal(m_LayoutDesignButton->geometry().topLeft()); + m_LayoutActionsMenu->setVisible(true); + m_LayoutActionsMenu->exec(point); +} + +void QmitkRenderWindowMenu::OnSetLayout(LayoutDesign layoutDesign) +{ + m_FullScreenMode = false; + ChangeFullScreenIcon(); + + m_LayoutDesign = layoutDesign; + emit LayoutDesignChanged(m_LayoutDesign); + + DeferredShowMenu(); }