diff --git a/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h index afd7f19561..8f72eb2cb5 100644 --- a/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h +++ b/Plugins/org.mitk.gui.common/src/mitkIRenderWindowPartListener.h @@ -1,60 +1,65 @@ /*=================================================================== 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 MITKIRENDERWINDOWPARTLISTENER_H #define MITKIRENDERWINDOWPARTLISTENER_H #include namespace mitk { -struct IRenderWindowPart; - -/** - * \ingroup org_mitk_gui_common - * - * \brief Interface for berry::IViewPart implementations to be notified about mitk::IRenderWindowPart lifecycle changes. - * - * This interface is intended to be implemented by subclasses of berry::IWorkbenchPart. If implemented, - * the interface methods are called automatically if a Workbench part which implementes mitk::IRenderWindowPart - * is activated or deactivated. - * - * The notion of activated and deactivated is slightly different from the usual Workbench part lifecycle. - */ -struct MITK_GUI_COMMON_PLUGIN IRenderWindowPartListener -{ - virtual ~IRenderWindowPartListener(); + struct IRenderWindowPart; /** - * Called when a IRenderWindowPart is activated or if it becomes visible and no - * other IRenderWindowPart was activated before. + * \ingroup org_mitk_gui_common * - * \param renderWindowPart The newly activated IRenderWindowPart. - */ - virtual void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) = 0; - - /** - * Called when a IRenderWindowPart becomes invisible and if it was active before. + * \brief Interface for berry::IViewPart implementations to be notified about mitk::IRenderWindowPart lifecycle changes. * - * \param renderWindowPart The deactivated IRenderWindowPart. + * This interface is intended to be implemented by subclasses of berry::IWorkbenchPart. If implemented, + * the interface methods are called automatically if a Workbench part which implementes mitk::IRenderWindowPart + * is activated or deactivated. + * + * The notion of activated and deactivated is slightly different from the usual Workbench part lifecycle. */ - virtual void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) = 0; -}; + struct MITK_GUI_COMMON_PLUGIN IRenderWindowPartListener + { + virtual ~IRenderWindowPartListener(); + + /** + * Called when an IRenderWindowPart is activated or if it becomes visible and no + * other IRenderWindowPart was activated before. + * + * \param renderWindowPart The newly activated IRenderWindowPart. + */ + virtual void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) = 0; + + /** + * Called when an IRenderWindowPart becomes invisible and if it was active before. + * + * \param renderWindowPart The deactivated IRenderWindowPart. + */ + virtual void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) = 0; + /** + * Called when an IRenderWindowPart changes and if it was active before. + * + * \param renderWindowPart The modified IRenderWindowPart. + */ + virtual void RenderWindowPartInputChanged(mitk::IRenderWindowPart* /*renderWindowPart*/) {}; + }; } #endif // MITKIRENDERWINDOWPARTLISTENER_H diff --git a/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.cpp b/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.cpp index c753b3fcf2..42ee4ebd91 100644 --- a/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.cpp +++ b/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.cpp @@ -1,127 +1,135 @@ /*=================================================================== 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. ===================================================================*/ // render window manager plugin #include "QmitkRenderWindowManagerView.h" // blueberry #include #include // mitk core #include #include const std::string QmitkRenderWindowManagerView::VIEW_ID = "org.mitk.views.renderwindowmanager"; void QmitkRenderWindowManagerView::RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) { if (m_RenderWindowPart != renderWindowPart) { m_RenderWindowPart = renderWindowPart; } SetControlledRenderer(); } void QmitkRenderWindowManagerView::RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) { m_RenderWindowPart = nullptr; } +void QmitkRenderWindowManagerView::RenderWindowPartInputChanged(mitk::IRenderWindowPart* renderWindowPart) +{ + if (m_RenderWindowPart == renderWindowPart) + { + SetControlledRenderer(); + } +} + void QmitkRenderWindowManagerView::SetFocus() { // nothing here } void QmitkRenderWindowManagerView::CreateQtPartControl(QWidget* parent) { // create GUI widgets m_Controls.setupUi(parent); // add custom render window manager UI widget to the 'renderWindowManagerTab' m_RenderWindowManipulatorWidget = new QmitkRenderWindowManipulatorWidget(GetDataStorage(), parent); m_RenderWindowManipulatorWidget->setObjectName(QStringLiteral("m_RenderWindowManipulatorWidget")); m_Controls.verticalLayout->addWidget(m_RenderWindowManipulatorWidget); SetControlledRenderer(); connect(m_Controls.comboBoxRenderWindowSelection, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnRenderWindowSelectionChanged(const QString&))); connect(m_RenderWindowManipulatorWidget, SIGNAL(AddLayerButtonClicked()), this, SLOT(OnAddLayerButtonClicked())); } void QmitkRenderWindowManagerView::SetControlledRenderer() { m_Controls.comboBoxRenderWindowSelection->clear(); const mitk::RenderingManager::RenderWindowVector allRegisteredRenderWindows = mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows(); mitk::BaseRenderer* baseRenderer = nullptr; for (const auto &renderWindow : allRegisteredRenderWindows) { baseRenderer = mitk::BaseRenderer::GetInstance(renderWindow); if (nullptr != baseRenderer) { m_ControlledRenderer.push_back(baseRenderer); m_Controls.comboBoxRenderWindowSelection->addItem(baseRenderer->GetName()); } } m_RenderWindowManipulatorWidget->SetControlledRenderer(m_ControlledRenderer); OnRenderWindowSelectionChanged(m_Controls.comboBoxRenderWindowSelection->itemText(0)); } void QmitkRenderWindowManagerView::OnRenderWindowSelectionChanged(const QString &renderWindowId) { m_RenderWindowManipulatorWidget->SetActiveRenderWindow(renderWindowId); } void QmitkRenderWindowManagerView::OnAddLayerButtonClicked() { QList nodes = GetDataManagerSelection(); for (mitk::DataNode* dataNode : nodes) { if (nullptr != dataNode) { m_RenderWindowManipulatorWidget->AddLayer(dataNode); // get child nodes of the current node mitk::DataStorage::SetOfObjects::ConstPointer derivedNodes = GetDataStorage()->GetDerivations(dataNode, nullptr, false); for (mitk::DataStorage::SetOfObjects::ConstIterator it = derivedNodes->Begin(); it != derivedNodes->End(); ++it) { m_RenderWindowManipulatorWidget->AddLayer(it->Value()); } } } } void QmitkRenderWindowManagerView::NodeAdded(const mitk::DataNode* node) { bool global = false; node->GetBoolProperty("globalObject_RWM", global); if (global) { // initially insert new point set node into the node list of all render windows // the node object of a new point set won't be visible due to its "helper object" property set to true m_RenderWindowManipulatorWidget->AddLayerToAllRenderer(const_cast(node)); } else { // initially set new node as invisible in all render windows // this way, each single renderer overwrites the common renderer and the node is invisible // until it is inserted into the node list of a render windows m_RenderWindowManipulatorWidget->HideDataNodeInAllRenderer(node); } } diff --git a/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.h b/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.h index f2a4212271..a99325f429 100644 --- a/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.h +++ b/Plugins/org.mitk.gui.qt.renderwindowmanager/src/internal/QmitkRenderWindowManagerView.h @@ -1,90 +1,90 @@ /*=================================================================== 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 QMITKRENDERWINDOWMANAGERVIEW_H #define QMITKRENDERWINDOWMANAGERVIEW_H // render window manager plugin #include "ui_QmitkRenderWindowManagerControls.h" // render window manager UI module #include // blueberry #include #include // qt #include /** * @brief RenderWindowManager */ class QmitkRenderWindowManagerView : public QmitkAbstractView, public mitk::IRenderWindowPartListener { Q_OBJECT public: static const std::string VIEW_ID; virtual void RenderWindowPartActivated(mitk::IRenderWindowPart* renderWindowPart) override; - virtual void RenderWindowPartDeactivated(mitk::IRenderWindowPart* renderWindowPart) override; + virtual void RenderWindowPartInputChanged(mitk::IRenderWindowPart* renderWindowPart) override; protected: virtual void SetFocus() override; virtual void CreateQtPartControl(QWidget* parent) override; private Q_SLOTS: /** * @brief Called when the user changes the render window selection in the combo box. * * @param renderWindowId The text inside the combo box. */ void OnRenderWindowSelectionChanged(const QString &renderWindowId); /** * @brief Called when the 'AddLayer'-button of he render window manipulator widget has been pushed. */ void OnAddLayerButtonClicked(); private: void SetControlledRenderer(); /** * @brief Reacts to a node that has been added to the data storage. * 1. Insert new node into the node list of all render windows, if it is an "globalObject_RWM"-node. * or else * 2. Set data node invisible in all render windows, as soon as the node is added to the data storage. */ void NodeAdded(const mitk::DataNode* node) override; // the Qt parent of our GUI QWidget* m_Parent; Ui::QmitkRenderWindowManagerControls m_Controls; mitk::IRenderWindowPart* m_RenderWindowPart; QmitkRenderWindowManipulatorWidget* m_RenderWindowManipulatorWidget; RenderWindowLayerUtilities::RendererVector m_ControlledRenderer; }; #endif // QMITKRENDERWINDOWMANAGERVIEW_H