diff --git a/Modules/QtWidgets/include/QmitkCustomMultiWidget.h b/Modules/QtWidgets/include/QmitkCustomMultiWidget.h index 618e937cfa..9e49fbdd66 100644 --- a/Modules/QtWidgets/include/QmitkCustomMultiWidget.h +++ b/Modules/QtWidgets/include/QmitkCustomMultiWidget.h @@ -1,216 +1,217 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. 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 QMITKCUSTOMMULTIWIDGET_H #define QMITKCUSTOMMULTIWIDGET_H // qt widgets module #include "MitkQtWidgetsExports.h" #include "QmitkRenderWindowWidget.h" // mitk core #include #include #include // qt #include class QHBoxLayout; class QVBoxLayout; class QGridLayout; class QSpacerItem; class QmitkLevelWindowWidget; class QmitkRenderWindow; class vtkCornerAnnotation; namespace mitk { class RenderingManager; } /** * @brief The 'QmitkCustomMultiWidget' is a 'QWidget' that is used to display multiple render windows at once. * * Render windows can dynamically be added and removed to change the layout of the multi widget. */ class MITKQTWIDGETS_EXPORT QmitkCustomMultiWidget : public QWidget { Q_OBJECT public: QmitkCustomMultiWidget(QWidget* parent = 0, Qt::WindowFlags f = 0, mitk::RenderingManager* renderingManager = nullptr, mitk::BaseRenderer::RenderingMode::Type renderingMode = mitk::BaseRenderer::RenderingMode::Standard, const QString& multiWidgetName = "custommulti"); virtual ~QmitkCustomMultiWidget(); void SetDataStorage(mitk::DataStorage* dataStorage); + void InitRenderWindowWidgets(); using RenderWindowWidgetMap = std::map; using RenderWindowHash = QHash; RenderWindowWidgetMap GetRenderWindowWidgets() const; QmitkRenderWindowWidget* GetRenderWindowWidget(const QString& widgetID) const; QmitkRenderWindow* GetRenderWindow(const QString& widgetID) const; QmitkRenderWindowWidget* GetActiveRenderWindowWidget() const; QmitkRenderWindowWidget* GetFirstRenderWindowWidget() const; QmitkRenderWindowWidget* GetLastRenderWindowWidget() const; unsigned int GetNumberOfRenderWindowWidgets() const; void RequestUpdate(const QString& widgetID); void RequestUpdateAll(); void ForceImmediateUpdate(const QString& widgetID); void ForceImmediateUpdateAll(); mitk::MouseModeSwitcher* GetMouseModeSwitcher(); const mitk::Point3D GetCrossPosition(const QString& widgetID) const; public slots: void ShowLevelWindowWidget(const QString& widgetID, bool show); void ShowAllLevelWindowWidgets(bool show); /** * @brief Set a background color gradient for a specific render window. * * If two different input colors are used, a gradient background is generated. * * @param upper The color of the gradient background. * @param lower The color of the gradient background. * @param widgetID The widget identifier. */ void SetBackgroundColorGradient(const mitk::Color& upper, const mitk::Color& lower, const QString& widgetID); /** * @brief Set a background color gradient for all available render windows. * * If two different input colors are used, a gradient background is generated. * * @param upper The color of the gradient background. * @param lower The color of the gradient background. */ // #TODO: 'backgroundgradientcolor' void SetAllBackgroundColorGradients(const mitk::Color& upper, const mitk::Color& lower); void FillAllBackgroundColorGradientsWithBlack(); void ShowBackgroundColorGradient(const QString& widgetID, bool show); void ShowAllBackgroundColorGradients(bool show); /** * @rief Return a render window (widget) specific background color gradient * * @param widgetID The widget identifier. * * @return A color gradient as a pair of colors. * First entry: upper color value * Second entry: lower color value */ std::pair GetBackgroundColorGradient(const QString& widgetID) const; bool GetBackgroundColorGradientFlag(const QString& widgetID) const; void SetDepartmentLogoPath(const char* path); void ShowDepartmentLogo(const QString& widgetID, bool show); void ShowAllDepartmentLogos(bool show); void SetDecorationColor(const QString& widgetID, const mitk::Color& color); mitk::Color GetDecorationColor(const QString& widgetID) const; void ShowColoredRectangle(const QString& widgetID, bool show); void ShowAllColoredRectangles(bool show); bool IsColoredRectangleVisible(const QString& widgetID) const; void ShowCornerAnnotation(const QString& widgetID, bool show); void ShowAllCornerAnnotations(bool show); bool IsCornerAnnotationVisible(const QString& widgetID) const; void SetCornerAnnotationText(const QString& widgetID, const std::string& cornerAnnotation); std::string GetCornerAnnotationText(const QString& widgetID) const; /** * @brief Listener to the CrosshairPositionEvent * * Ensures the CrosshairPositionEvent is handled only once and at the end of the Qt-Event loop */ void HandleCrosshairPositionEvent(); /** * @brief Receives the signal from HandleCrosshairPositionEvent, executes the StatusBar update * */ void HandleCrosshairPositionEventDelayed(); void Fit(); void EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p); void MoveCrossToPosition(const QString& widgetID, const mitk::Point3D& newPosition); void ResetCrosshair(); // mouse events void wheelEvent(QWheelEvent* e) override; void mousePressEvent(QMouseEvent* e) override; void moveEvent(QMoveEvent* e) override; signals: void WheelMoved(QWheelEvent *); void Moved(); public: enum { AXIAL, SAGITTAL, CORONAL, THREE_D }; private: void InitializeGUI(); void InitializeWidget(); void AddRenderWindowWidget(); // #TODO: see T24173 mitk::DataNode::Pointer GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes); QGridLayout* m_CustomMultiWidgetLayout; RenderWindowWidgetMap m_RenderWindowWidgets; QmitkRenderWindowWidget* m_ActiveRenderWindowWidget; int m_PlaneMode; mitk::RenderingManager* m_RenderingManager; mitk::BaseRenderer::RenderingMode::Type m_RenderingMode; QString m_MultiWidgetName; mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; mitk::SliceNavigationController *m_TimeNavigationController; mitk::DataStorage::Pointer m_DataStorage; bool m_PendingCrosshairPositionEvent; bool m_CrosshairNavigationEnabled; }; #endif // QMITKCUSTOMMULTIWIDGET_H diff --git a/Modules/QtWidgets/include/QmitkRenderWindowWidget.h b/Modules/QtWidgets/include/QmitkRenderWindowWidget.h index 18ad95ff2d..baa7bd5975 100644 --- a/Modules/QtWidgets/include/QmitkRenderWindowWidget.h +++ b/Modules/QtWidgets/include/QmitkRenderWindowWidget.h @@ -1,117 +1,117 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. 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 QMITKRENDERWINDOWWIDGET_H #define QMITKRENDERWINDOWWIDGET_H // qt widgets module #include "MitkQtWidgetsExports.h" #include #include // mitk core #include #include //#include #include #include // annotations module #include // qt #include #include /** * @brief * * */ class MITKQTWIDGETS_EXPORT QmitkRenderWindowWidget : public QWidget { Q_OBJECT public: QmitkRenderWindowWidget(QWidget* parent = nullptr, const QString& UID = "", mitk::DataStorage* dataStorage = nullptr); ~QmitkRenderWindowWidget() override; void SetDataStorage(mitk::DataStorage* dataStorage); QmitkRenderWindow* GetRenderWindow() const { return m_RenderWindow; }; QmitkLevelWindowWidget* GetlevelWindowWidget() const { return m_LevelWindowWidget; }; mitk::SliceNavigationController* GetSliceNavigationController() const; void RequestUpdate(); void ForceImmediateUpdate(); // #TODO: 'backroundgradientcolor' void SetBackgroundColorGradient(const mitk::Color& upper, const mitk::Color& lower); void ShowBackgroundColorGradient(bool enable); std::pair GetRendererBackgroundColorGradient() const { return m_BackgroundColorGradient; }; bool GetBackgroundColorGradientFlag() const { return m_BackgroundColorGradientFlag; }; void ShowLevelWindowWidget(bool enable); void ShowDepartmentLogo(bool show); void SetDecorationColor(const mitk::Color& color); mitk::Color GetDecorationColor() const { return m_DecorationColor; }; void ShowColoredRectangle(bool show); bool IsColoredRectangleVisible() const; void ShowCornerAnnotation(bool show); bool IsCornerAnnotationVisible() const; void SetCornerAnnotationText(const std::string& cornerAnnotation); std::string GetCornerAnnotationText() const; /** * @brief Create a corner annotation and a colored rectangle for this widget. * * @par text The text of the corner annotation. * @par color The color of the text and the rectangle. */ void SetDecorationProperties(std::string text, mitk::Color color); bool IsRenderWindowMenuActivated() const; private: void InitializeGUI(); void InitializeDecorations(); QString m_UID; QHBoxLayout* m_Layout; mitk::DataStorage* m_DataStorage; QmitkRenderWindow* m_RenderWindow; QmitkLevelWindowWidget* m_LevelWindowWidget; - mitk::RenderingManager* m_RenderingManager; + mitk::RenderingManager::Pointer m_RenderingManager; mitk::BaseRenderer::RenderingMode::Type m_RenderingMode; mitk::SliceNavigationController *m_TimeNavigationController; std::pair m_BackgroundColorGradient; bool m_BackgroundColorGradientFlag; mitk::LogoAnnotation::Pointer m_LogoAnnotation; mitk::Color m_DecorationColor; vtkSmartPointer m_RectangleProp; vtkSmartPointer m_CornerAnnotation; }; #endif // QMITKRENDERWINDOWWIDGET_H diff --git a/Modules/QtWidgets/src/QmitkCustomMultiWidget.cpp b/Modules/QtWidgets/src/QmitkCustomMultiWidget.cpp index 07c4579280..7210c243f8 100644 --- a/Modules/QtWidgets/src/QmitkCustomMultiWidget.cpp +++ b/Modules/QtWidgets/src/QmitkCustomMultiWidget.cpp @@ -1,728 +1,716 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. 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 "QmitkCustomMultiWidget.h" #include #include #include #include #include #include "mitkImagePixelReadAccessor.h" #include "mitkPixelTypeMultiplex.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // qt #include QmitkCustomMultiWidget::QmitkCustomMultiWidget(QWidget* parent, Qt::WindowFlags f/* = 0*/, mitk::RenderingManager* renderingManager/* = nullptr*/, mitk::BaseRenderer::RenderingMode::Type renderingMode/* = mitk::BaseRenderer::RenderingMode::Standard*/, const QString& multiWidgetName/* = "custommulti"*/) : QWidget(parent, f) , m_CustomMultiWidgetLayout(nullptr) , m_RenderingManager(renderingManager) , m_RenderingMode(renderingMode) , m_MultiWidgetName(multiWidgetName) - , m_TimeNavigationController(nullptr) , m_PendingCrosshairPositionEvent(false) , m_CrosshairNavigationEnabled(false) { - if (nullptr == m_RenderingManager) - { - m_RenderingManager = mitk::RenderingManager::GetInstance(); - } - m_TimeNavigationController = m_RenderingManager->GetTimeNavigationController(); - // create widget manually // create and set layout InitializeGUI(); - // create at least one render window initially - AddRenderWindowWidget(); resize(QSize(364, 477).expandedTo(minimumSizeHint())); InitializeWidget(); } QmitkCustomMultiWidget::~QmitkCustomMultiWidget() { - for (const auto& renderWindowWidget : m_RenderWindowWidgets) - { - m_TimeNavigationController->Disconnect(renderWindowWidget.second->GetRenderWindow()->GetSliceNavigationController()); - } + // nothing here } void QmitkCustomMultiWidget::SetDataStorage(mitk::DataStorage* dataStorage) { if (dataStorage == m_DataStorage) { return; } m_DataStorage = dataStorage; for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->SetDataStorage(m_DataStorage); } } +void QmitkCustomMultiWidget::InitRenderWindowWidgets() +{ + // create three render window (widgets) initially + AddRenderWindowWidget(); + AddRenderWindowWidget(); + AddRenderWindowWidget(); +} + QmitkCustomMultiWidget::RenderWindowWidgetMap QmitkCustomMultiWidget::GetRenderWindowWidgets() const { return m_RenderWindowWidgets; } QmitkRenderWindowWidget* QmitkCustomMultiWidget::GetRenderWindowWidget(const QString& widgetID) const { RenderWindowWidgetMap::const_iterator it = m_RenderWindowWidgets.find(widgetID); if (it == m_RenderWindowWidgets.end()) { return nullptr; } return it->second; } QmitkRenderWindow* QmitkCustomMultiWidget::GetRenderWindow(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { return renderWindowWidget->GetRenderWindow(); } return nullptr; } QmitkRenderWindowWidget* QmitkCustomMultiWidget::GetActiveRenderWindowWidget() const { //return m_ActiveRenderWindowWidget; return m_RenderWindowWidgets.begin()->second; } QmitkRenderWindowWidget* QmitkCustomMultiWidget::GetFirstRenderWindowWidget() const { return m_RenderWindowWidgets.begin()->second; } QmitkRenderWindowWidget* QmitkCustomMultiWidget::GetLastRenderWindowWidget() const { return m_RenderWindowWidgets.rbegin()->second; } unsigned int QmitkCustomMultiWidget::GetNumberOfRenderWindowWidgets() const { return m_RenderWindowWidgets.size(); } void QmitkCustomMultiWidget::RequestUpdate(const QString& widgetID) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { return renderWindowWidget->RequestUpdate(); } } void QmitkCustomMultiWidget::RequestUpdateAll() { // #TODO: Update only render windows that show the same image? // #TODO: Update only type specific render windows (2D / 3D)? for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->RequestUpdate(); } } void QmitkCustomMultiWidget::ForceImmediateUpdate(const QString& widgetID) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->ForceImmediateUpdate(); } } void QmitkCustomMultiWidget::ForceImmediateUpdateAll() { // #TODO: Update only render windows that show the same image? // #TODO: Update only type specific render windows (2D / 3D)? for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ForceImmediateUpdate(); } } mitk::MouseModeSwitcher* QmitkCustomMultiWidget::GetMouseModeSwitcher() { return m_MouseModeSwitcher; } const mitk::Point3D QmitkCustomMultiWidget::GetCrossPosition(const QString& widgetID) const { /* const mitk::PlaneGeometry *plane1 = mitkWidget1->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane2 = mitkWidget2->GetSliceNavigationController()->GetCurrentPlaneGeometry(); const mitk::PlaneGeometry *plane3 = mitkWidget3->GetSliceNavigationController()->GetCurrentPlaneGeometry(); mitk::Line3D line; if ((plane1 != NULL) && (plane2 != NULL) && (plane1->IntersectionLine(plane2, line))) { mitk::Point3D point; if ((plane3 != NULL) && (plane3->IntersectionPoint(line, point))) { return point; } } // TODO BUG POSITIONTRACKER; mitk::Point3D p; return p; // return m_LastLeftClickPositionSupplier->GetCurrentPoint(); */ return mitk::Point3D(); } ////////////////////////////////////////////////////////////////////////// // PUBLIC SLOTS ////////////////////////////////////////////////////////////////////////// void QmitkCustomMultiWidget::ShowLevelWindowWidget(const QString& widgetID, bool show) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->ShowLevelWindowWidget(show); return; } MITK_ERROR << "Level window widget can not be shown for an unknown widget."; } void QmitkCustomMultiWidget::ShowAllLevelWindowWidgets(bool show) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ShowLevelWindowWidget(show); } } void QmitkCustomMultiWidget::SetBackgroundColorGradient(const mitk::Color& upper, const mitk::Color& lower, const QString& widgetID) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->SetBackgroundColorGradient(upper, lower); return; } MITK_ERROR << "Background color gradient can not be set for an unknown widget."; } void QmitkCustomMultiWidget::SetAllBackgroundColorGradients(const mitk::Color& upper, const mitk::Color& lower) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->SetBackgroundColorGradient(upper, lower); } } void QmitkCustomMultiWidget::FillAllBackgroundColorGradientsWithBlack() { float black[3] = { 0.0f, 0.0f, 0.0f }; SetAllBackgroundColorGradients(black, black); } void QmitkCustomMultiWidget::ShowBackgroundColorGradient(const QString& widgetID, bool show) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->ShowBackgroundColorGradient(show); return; } MITK_ERROR << "Background color gradient can not be shown for an unknown widget."; } void QmitkCustomMultiWidget::ShowAllBackgroundColorGradients(bool show) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ShowBackgroundColorGradient(show); } } std::pair QmitkCustomMultiWidget::GetBackgroundColorGradient(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { return renderWindowWidget->GetRendererBackgroundColorGradient(); } MITK_ERROR << "Background color gradient can not be retrieved for an unknown widget. Returning black color pair."; float black[3] = { 0.0f, 0.0f, 0.0f }; return std::make_pair(mitk::Color(black), mitk::Color(black)); } bool QmitkCustomMultiWidget::GetBackgroundColorGradientFlag(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { return renderWindowWidget->GetBackgroundColorGradientFlag(); } MITK_ERROR << "Background color gradient flag can not be retrieved for an unknown widget. Returning 'false'."; return false; } void QmitkCustomMultiWidget::SetDepartmentLogoPath(const char* path) { /* old m_LogoRendering->SetLogoImagePath(path); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow()); m_LogoRendering->Update(renderer); RequestUpdate(); */ /* new QImage* qimage = new QImage(path); vtkSmartPointer qImageToVtk; qImageToVtk = vtkSmartPointer::New(); qImageToVtk->SetQImage(qimage); qImageToVtk->Update(); m_LogoRendering->SetLogoImage(qImageToVtk->GetOutput()); mitk::BaseRenderer *renderer = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow()); m_LogoRendering->Update(renderer); RequestUpdate(); */ } void QmitkCustomMultiWidget::ShowDepartmentLogo(const QString& widgetID, bool show) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { GetRenderWindowWidget(widgetID)->ShowDepartmentLogo(show); RequestUpdate(widgetID); } MITK_ERROR << "Department logo can not be shown for an unknown widget."; return; } void QmitkCustomMultiWidget::ShowAllDepartmentLogos(bool show) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ShowDepartmentLogo(show); } } void QmitkCustomMultiWidget::SetDecorationColor(const QString& widgetID, const mitk::Color& color) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->SetDecorationColor(color); } MITK_ERROR << "Decoration color can not be set for an unknown widget."; } mitk::Color QmitkCustomMultiWidget::GetDecorationColor(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->GetDecorationColor(); } MITK_ERROR << "Decoration color can not be retrieved for an unknown widget. Returning black color!"; float black[3] = { 0.0f, 0.0f, 0.0f }; return mitk::Color(black); } void QmitkCustomMultiWidget::ShowColoredRectangle(const QString& widgetID, bool show) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->ShowColoredRectangle(show); } MITK_ERROR << "Colored rectangle can not be set for an unknown widget."; } void QmitkCustomMultiWidget::ShowAllColoredRectangles(bool show) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ShowColoredRectangle(show); } } bool QmitkCustomMultiWidget::IsColoredRectangleVisible(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->IsColoredRectangleVisible(); } MITK_ERROR << "Colored rectangle visibility can not be retrieved for an unknown widget. Returning 'false'."; return false; } void QmitkCustomMultiWidget::SetCornerAnnotationText(const QString& widgetID, const std::string& cornerAnnotation) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->SetCornerAnnotationText(cornerAnnotation); } MITK_ERROR << "Corner annotation text can not be retrieved for an unknown widget."; } std::string QmitkCustomMultiWidget::GetCornerAnnotationText(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->GetCornerAnnotationText(); } MITK_ERROR << "Corner annotation text can not be retrieved for an unknown widget."; return ""; } void QmitkCustomMultiWidget::ShowCornerAnnotation(const QString& widgetID, bool show) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->ShowCornerAnnotation(show); } MITK_ERROR << "Corner annotation can not be set for an unknown widget."; } void QmitkCustomMultiWidget::ShowAllCornerAnnotations(bool show) { for (const auto& renderWindowWidget : m_RenderWindowWidgets) { renderWindowWidget.second->ShowCornerAnnotation(show); } } bool QmitkCustomMultiWidget::IsCornerAnnotationVisible(const QString& widgetID) const { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { renderWindowWidget->IsCornerAnnotationVisible(); } MITK_ERROR << "Corner annotation visibility can not be retrieved for an unknown widget. Returning 'false'."; return false; } void QmitkCustomMultiWidget::HandleCrosshairPositionEvent() { /* if (!m_PendingCrosshairPositionEvent) { m_PendingCrosshairPositionEvent = true; QTimer::singleShot(0, this, SLOT(HandleCrosshairPositionEventDelayed())); } */ } void QmitkCustomMultiWidget::HandleCrosshairPositionEventDelayed() { /* m_PendingCrosshairPositionEvent = false; // find image with highest layer mitk::TNodePredicateDataType::Pointer isImageData = mitk::TNodePredicateDataType::New(); mitk::DataStorage::SetOfObjects::ConstPointer nodes = this->m_DataStorage->GetSubset(isImageData).GetPointer(); mitk::DataNode::Pointer node; mitk::DataNode::Pointer topSourceNode; mitk::Image::Pointer image; bool isBinary = false; node = this->GetTopLayerNode(nodes); int component = 0; if (node.IsNotNull()) { node->GetBoolProperty("binary", isBinary); if (isBinary) { mitk::DataStorage::SetOfObjects::ConstPointer sourcenodes = m_DataStorage->GetSources(node, NULL, true); if (!sourcenodes->empty()) { topSourceNode = this->GetTopLayerNode(sourcenodes); } if (topSourceNode.IsNotNull()) { image = dynamic_cast(topSourceNode->GetData()); topSourceNode->GetIntProperty("Image.Displayed Component", component); } else { image = dynamic_cast(node->GetData()); node->GetIntProperty("Image.Displayed Component", component); } } else { image = dynamic_cast(node->GetData()); node->GetIntProperty("Image.Displayed Component", component); } } mitk::Point3D crosshairPos = this->GetCrossPosition(); std::string statusText; std::stringstream stream; itk::Index<3> p; mitk::BaseRenderer *baseRenderer = GetRenderWindow()->GetSliceNavigationController()->GetRenderer(); unsigned int timestep = baseRenderer->GetTimeStep(); if (image.IsNotNull() && (image->GetTimeSteps() > timestep)) { image->GetGeometry()->WorldToIndex(crosshairPos, p); stream.precision(2); stream << "Position: <" << std::fixed << crosshairPos[0] << ", " << std::fixed << crosshairPos[1] << ", " << std::fixed << crosshairPos[2] << "> mm"; stream << "; Index: <" << p[0] << ", " << p[1] << ", " << p[2] << "> "; mitk::ScalarType pixelValue; mitkPixelTypeMultiplex5(mitk::FastSinglePixelAccess, image->GetChannelDescriptor().GetPixelType(), image, image->GetVolumeData(baseRenderer->GetTimeStep()), p, pixelValue, component); if (fabs(pixelValue) > 1000000 || fabs(pixelValue) < 0.01) { stream << "; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: " << std::scientific << pixelValue << " "; } else { stream << "; Time: " << baseRenderer->GetTime() << " ms; Pixelvalue: " << pixelValue << " "; } } else { stream << "No image information at this position!"; } statusText = stream.str(); mitk::StatusBar::GetInstance()->DisplayGreyValueText(statusText.c_str()); */ } void QmitkCustomMultiWidget::Fit() { // #TODO: what is this function's purpose? /* vtkSmartPointer vtkrenderer; size_t numberOfRenderWindowWidgets = m_RenderWindowWidgets.size(); for (size_t i = 0; i < numberOfRenderWindowWidgets; ++i) { vtkRenderer* renderer = GetRenderWindow(widgetID)->GetRenderer()->GetVtkRenderer(); mitk::BaseRenderer* baseRenderer = mitk::BaseRenderer::GetInstance(GetRenderWindow(i)->GetRenderWindow()); vtkrenderer = baseRenderer->GetVtkRenderer(); if (nullptr != vtkrenderer) { vtkrenderer->ResetCamera(); } baseRenderer->GetCameraController()->Fit(); } int w = vtkObject::GetGlobalWarningDisplay(); vtkObject::GlobalWarningDisplayOff(); vtkObject::SetGlobalWarningDisplay(w); */ } void QmitkCustomMultiWidget::EnsureDisplayContainsPoint(mitk::BaseRenderer *renderer, const mitk::Point3D &p) { // #TODO: what is this function's purpose? /* mitk::Point2D pointOnDisplay; renderer->WorldToDisplay(p, pointOnDisplay); if (pointOnDisplay[0] < renderer->GetVtkRenderer()->GetOrigin()[0] || pointOnDisplay[1] < renderer->GetVtkRenderer()->GetOrigin()[1] || pointOnDisplay[0] > renderer->GetVtkRenderer()->GetOrigin()[0] + renderer->GetViewportSize()[0] || pointOnDisplay[1] > renderer->GetVtkRenderer()->GetOrigin()[1] + renderer->GetViewportSize()[1]) { mitk::Point2D pointOnPlane; renderer->GetCurrentWorldPlaneGeometry()->Map(p, pointOnPlane); renderer->GetCameraController()->MoveCameraToPoint(pointOnPlane); } */ } void QmitkCustomMultiWidget::MoveCrossToPosition(const QString& widgetID, const mitk::Point3D& newPosition) { QmitkRenderWindowWidget* renderWindowWidget = GetRenderWindowWidget(widgetID); if (nullptr != renderWindowWidget) { GetRenderWindowWidget(widgetID)->GetSliceNavigationController()->SelectSliceByPoint(newPosition); GetRenderWindowWidget(widgetID)->RequestUpdate(); } MITK_ERROR << "Geometry plane can not be shown for an unknown widget."; - } void QmitkCustomMultiWidget::ResetCrosshair() { // #TODO: new concept: we do not want to initialize all views; // we do not want to rely on the geometry planes /* if (m_DataStorage.IsNotNull()) { m_RenderingManager->InitializeViewsByBoundingObjects(m_DataStorage); // m_RenderingManager->InitializeViews( m_DataStorage->ComputeVisibleBoundingGeometry3D() ); // reset interactor to normal slicing SetWidgetPlaneMode(PLANE_MODE_SLICING); } */ } ////////////////////////////////////////////////////////////////////////// // MOUSE EVENTS ////////////////////////////////////////////////////////////////////////// void QmitkCustomMultiWidget::wheelEvent(QWheelEvent* e) { emit WheelMoved(e); } void QmitkCustomMultiWidget::mousePressEvent(QMouseEvent* e) { } void QmitkCustomMultiWidget::moveEvent(QMoveEvent* e) { QWidget::moveEvent(e); // it is necessary to readjust the position of the overlays as the StdMultiWidget has moved // unfortunately it's not done by QmitkRenderWindow::moveEvent -> must be done here emit Moved(); } ////////////////////////////////////////////////////////////////////////// // PRIVATE ////////////////////////////////////////////////////////////////////////// void QmitkCustomMultiWidget::InitializeGUI() { m_CustomMultiWidgetLayout = new QGridLayout(this); m_CustomMultiWidgetLayout->setContentsMargins(0, 0, 0, 0); setLayout(m_CustomMultiWidgetLayout); } void QmitkCustomMultiWidget::InitializeWidget() { // #TODO: some things have to be handled globally (hold for all render window (widgets) // analyse those things and design a controlling mechanism // necessary here? mouse mode is valid for all render windows (and also used in editor) m_MouseModeSwitcher = mitk::MouseModeSwitcher::New(); m_MouseModeSwitcher->SetInteractionScheme(mitk::MouseModeSwitcher::InteractionScheme::MITK); // setup the department logo rendering /* m_LogoRendering = mitk::LogoOverlay::New(); mitk::BaseRenderer::Pointer renderer4 = mitk::BaseRenderer::GetInstance(mitkWidget4->GetRenderWindow()); m_LogoRendering->SetOpacity(0.5); mitk::Point2D offset; offset.Fill(0.03); m_LogoRendering->SetOffsetVector(offset); m_LogoRendering->SetRelativeSize(0.15); m_LogoRendering->SetCornerPosition(1); m_LogoRendering->SetLogoImagePath("DefaultLogo"); renderer4->GetOverlayManager()->AddOverlay(m_LogoRendering.GetPointer(), renderer4); */ } void QmitkCustomMultiWidget::AddRenderWindowWidget() { // #TODO: add QSplitter? // #TODO: include technique, to set the image to level-slide on using the render window manager // create the render window widget and connect signals / slots mitk::UIDGenerator generator; std::string renderWindowUID = generator.GetUID(); QString UID = m_MultiWidgetName + "_" + QString::fromStdString(renderWindowUID); QmitkRenderWindowWidget* renderWindowWidget = new QmitkRenderWindowWidget(this, UID, m_DataStorage); // create connections connect(renderWindowWidget, SIGNAL(ResetView()), this, SLOT(ResetCrosshair())); connect(renderWindowWidget, SIGNAL(ChangeCrosshairRotationMode(int)), this, SLOT(SetWidgetPlaneMode(int))); // store the newly created render window widget with the UID m_RenderWindowWidgets.insert(std::pair(UID, renderWindowWidget)); - mitk::SliceNavigationController* sliceNavigationController = renderWindowWidget->GetSliceNavigationController(); - if (nullptr != sliceNavigationController) - { - m_TimeNavigationController->ConnectGeometryTimeEvent(sliceNavigationController, false); - sliceNavigationController->ConnectGeometryTimeEvent(m_TimeNavigationController, false); - } - // #TODO: define the grid cell to add the new render window widget // add the newly created render window widget to this multi widget m_CustomMultiWidgetLayout->addWidget(renderWindowWidget); } mitk::DataNode::Pointer QmitkCustomMultiWidget::GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes) { // #TODO: see T24173 return nodes->front(); } diff --git a/Modules/QtWidgets/src/QmitkRenderWindowWidget.cpp b/Modules/QtWidgets/src/QmitkRenderWindowWidget.cpp index ced3f61f5e..40371b8782 100644 --- a/Modules/QtWidgets/src/QmitkRenderWindowWidget.cpp +++ b/Modules/QtWidgets/src/QmitkRenderWindowWidget.cpp @@ -1,240 +1,235 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. 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 "QmitkRenderWindowWidget.h" // vtk #include // qt widgets module #include QmitkRenderWindowWidget::QmitkRenderWindowWidget(QWidget* parent/* = nullptr*/, const QString& UID/* = ""*/, mitk::DataStorage* dataStorage/* = nullptr*/) : QWidget(parent) , m_UID(UID) , m_DataStorage(dataStorage) , m_RenderWindow(nullptr) , m_LevelWindowWidget(nullptr) { InitializeGUI(); // TODO: signals / slots } QmitkRenderWindowWidget::~QmitkRenderWindowWidget() { // nothing here } void QmitkRenderWindowWidget::SetDataStorage(mitk::DataStorage* dataStorage) { if (dataStorage == m_DataStorage) { return; } m_DataStorage = dataStorage; if (nullptr != m_RenderWindow) { mitk::BaseRenderer::GetInstance(m_RenderWindow->GetRenderWindow())->SetDataStorage(dataStorage); } } mitk::SliceNavigationController* QmitkRenderWindowWidget::GetSliceNavigationController() const { if (nullptr == m_RenderWindow) { return nullptr; } return m_RenderWindow->GetSliceNavigationController(); } void QmitkRenderWindowWidget::RequestUpdate() { m_RenderingManager->RequestUpdate(m_RenderWindow->GetRenderWindow()); } void QmitkRenderWindowWidget::ForceImmediateUpdate() { m_RenderingManager->ForceImmediateUpdate(m_RenderWindow->GetRenderWindow()); } void QmitkRenderWindowWidget::SetBackgroundColorGradient(const mitk::Color& upper, const mitk::Color& lower) { vtkRenderer* vtkRenderer = m_RenderWindow->GetRenderer()->GetVtkRenderer(); if (nullptr == vtkRenderer) { return; } m_BackgroundColorGradient.first = upper; m_BackgroundColorGradient.second = lower; vtkRenderer->SetBackground(lower[0], lower[1], lower[2]); vtkRenderer->SetBackground2(upper[0], upper[1], upper[2]); ShowBackgroundColorGradient(true); } void QmitkRenderWindowWidget::ShowBackgroundColorGradient(bool show) { if (show) { m_RenderWindow->GetRenderer()->GetVtkRenderer()->GradientBackgroundOn(); } else { m_RenderWindow->GetRenderer()->GetVtkRenderer()->GradientBackgroundOff(); } m_BackgroundColorGradientFlag = show; } void QmitkRenderWindowWidget::ShowLevelWindowWidget(bool show) { m_LevelWindowWidget->disconnect(this); if (show) { m_LevelWindowWidget->SetDataStorage(m_DataStorage); m_LevelWindowWidget->show(); } else { m_LevelWindowWidget->disconnect(this); m_LevelWindowWidget->hide(); } } void QmitkRenderWindowWidget::ShowDepartmentLogo(bool show) { m_LogoAnnotation->SetVisibility(show); } void QmitkRenderWindowWidget::SetDecorationColor(const mitk::Color& color) { m_DecorationColor = color; m_RectangleProp->SetColor(m_DecorationColor[0], m_DecorationColor[1], m_DecorationColor[2]); m_CornerAnnotation->GetTextProperty()->SetColor(color[0], color[1], color[2]); } void QmitkRenderWindowWidget::ShowColoredRectangle(bool show) { m_RectangleProp->SetVisibility(show); } bool QmitkRenderWindowWidget::IsColoredRectangleVisible() const { return m_RectangleProp->GetVisibility() > 0; } void QmitkRenderWindowWidget::ShowCornerAnnotation(bool show) { m_CornerAnnotation->SetVisibility(show); } bool QmitkRenderWindowWidget::IsCornerAnnotationVisible() const { return m_CornerAnnotation->GetVisibility() > 0; } void QmitkRenderWindowWidget::SetCornerAnnotationText(const std::string& cornerAnnotation) { m_CornerAnnotation->SetText(0, cornerAnnotation.c_str()); } std::string QmitkRenderWindowWidget::GetCornerAnnotationText() const { return std::string(m_CornerAnnotation->GetText(0)); } bool QmitkRenderWindowWidget::IsRenderWindowMenuActivated() const { return m_RenderWindow->GetActivateMenuWidgetFlag(); } void QmitkRenderWindowWidget::InitializeGUI() { m_Layout = new QHBoxLayout(this); m_Layout->setMargin(0); setLayout(m_Layout); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // create render window for this render window widget - m_RenderingManager = mitk::RenderingManager::GetInstance(); // TODO: do not always use the standard global rendering manager + //m_RenderingManager = mitk::RenderingManager::GetInstance(); + m_RenderingManager = mitk::RenderingManager::New(); // TODO: allow external access to the different render window manager + m_RenderingManager->SetDataStorage(m_DataStorage); + m_RenderingMode = mitk::BaseRenderer::RenderingMode::Standard; // TODO: do not always use the standard rendering mode m_RenderWindow = new QmitkRenderWindow(this, m_UID, nullptr, m_RenderingManager, m_RenderingMode); m_RenderWindow->SetLayoutIndex(QmitkCustomMultiWidget::SAGITTAL); // TODO: allow to change layout type later m_RenderWindow->GetSliceNavigationController()->SetDefaultViewDirection(mitk::SliceNavigationController::Sagittal); + m_RenderWindow->GetSliceNavigationController()->SetRenderingManager(m_RenderingManager); + + mitk::TimeGeometry::Pointer timeGeometry = m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()); + m_RenderingManager->InitializeViews(timeGeometry); // create level window widget for this render window widget m_LevelWindowWidget = new QmitkLevelWindowWidget(this); //m_LevelWindowWidget->setObjectName(QString::fromUtf8("levelWindowWidget")); QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(m_LevelWindowWidget->sizePolicy().hasHeightForWidth()); m_LevelWindowWidget->setSizePolicy(sizePolicy); m_LevelWindowWidget->setMaximumWidth(50); m_Layout->addWidget(m_RenderWindow); m_Layout->addWidget(m_LevelWindowWidget); // set colors, add logo etc. InitializeDecorations(); - - if (m_RenderingManager == nullptr) - { - m_RenderingManager = mitk::RenderingManager::GetInstance(); - } - m_TimeNavigationController = m_RenderingManager->GetTimeNavigationController(); - - // connect to the "time navigation controller": send time via sliceNavigationControllers - m_TimeNavigationController->ConnectGeometryTimeEvent(GetRenderWindow()->GetSliceNavigationController(), false); - - // reverse connection between sliceNavigationControllers and m_TimeNavigationController - GetRenderWindow()->GetSliceNavigationController()->ConnectGeometryTimeEvent(m_TimeNavigationController, false); } void QmitkRenderWindowWidget::InitializeDecorations() { vtkRenderer* vtkRenderer = m_RenderWindow->GetRenderer()->GetVtkRenderer(); if (nullptr == vtkRenderer) { return; } // initialize background color gradients float black[3] = { 0.0f, 0.0f, 0.0f }; SetBackgroundColorGradient(black, black); // initialize decoration color, rectangle and annotation text float white[3] = { 1.0f, 1.0f, 1.0f }; m_DecorationColor = white; m_RectangleProp = vtkSmartPointer::New(); m_RectangleProp->SetColor(m_DecorationColor[0], m_DecorationColor[1], m_DecorationColor[2]); if (0 == vtkRenderer->HasViewProp(m_RectangleProp)) { vtkRenderer->AddViewProp(m_RectangleProp); } m_CornerAnnotation = vtkSmartPointer::New(); m_CornerAnnotation->SetText(0, "Sagittal"); m_CornerAnnotation->SetMaximumFontSize(12); m_CornerAnnotation->GetTextProperty()->SetColor(m_DecorationColor[0], m_DecorationColor[1], m_DecorationColor[2]); if (0 == vtkRenderer->HasViewProp(m_CornerAnnotation)) { vtkRenderer->AddViewProp(m_CornerAnnotation); } } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.custommultiwidgeteditor/src/QmitkCustomMultiWidgetEditor.cpp b/Plugins/org.mitk.gui.qt.custommultiwidgeteditor/src/QmitkCustomMultiWidgetEditor.cpp index f88f6cb5e8..ec033a1d0f 100644 --- a/Plugins/org.mitk.gui.qt.custommultiwidgeteditor/src/QmitkCustomMultiWidgetEditor.cpp +++ b/Plugins/org.mitk.gui.qt.custommultiwidgeteditor/src/QmitkCustomMultiWidgetEditor.cpp @@ -1,452 +1,449 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. 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 "QmitkCustomMultiWidgetEditor.h" #include #include #include #include #include #include #include #include #include #include #include const QString QmitkCustomMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.custommultiwidget"; QmitkCustomMultiWidgetEditor::QmitkCustomMultiWidgetEditor() : m_CustomMultiWidget(nullptr) , m_MouseModeSwitcher(nullptr) { // nothing here } QmitkCustomMultiWidgetEditor::~QmitkCustomMultiWidgetEditor() { // nothing here } void QmitkCustomMultiWidgetEditor::Activated() { // nothing here } void QmitkCustomMultiWidgetEditor::Deactivated() { // nothing here } void QmitkCustomMultiWidgetEditor::Visible() { // nothing here } void QmitkCustomMultiWidgetEditor::Hidden() { // nothing here } QmitkRenderWindow* QmitkCustomMultiWidgetEditor::GetActiveQmitkRenderWindow() const { if (nullptr != m_CustomMultiWidget) { return m_CustomMultiWidget->GetActiveRenderWindowWidget()->GetRenderWindow(); } return nullptr; } QHash QmitkCustomMultiWidgetEditor::GetQmitkRenderWindows() const { QHash result; if (nullptr == m_CustomMultiWidget) { return result; } // create QHash on demand QmitkCustomMultiWidget::RenderWindowWidgetMap renderWindowWidgets = m_CustomMultiWidget->GetRenderWindowWidgets(); for (const auto& renderWindowWidget : renderWindowWidgets) { result.insert(renderWindowWidget.first, renderWindowWidget.second->GetRenderWindow()); } return result; } QmitkRenderWindow* QmitkCustomMultiWidgetEditor::GetQmitkRenderWindow(const QString& id) const { if (nullptr == m_CustomMultiWidget) { return nullptr; } return m_CustomMultiWidget->GetRenderWindow(id); } mitk::Point3D QmitkCustomMultiWidgetEditor::GetSelectedPosition(const QString& id) const { if (nullptr == m_CustomMultiWidget) { return mitk::Point3D(); } return m_CustomMultiWidget->GetCrossPosition(id); } void QmitkCustomMultiWidgetEditor::SetSelectedPosition(const mitk::Point3D& pos, const QString& id) { if (nullptr != m_CustomMultiWidget) { m_CustomMultiWidget->MoveCrossToPosition(id, pos); } } void QmitkCustomMultiWidgetEditor::EnableDecorations(bool enable, const QStringList &decorations) { // #TODO: define: - for all render windows // - for the one, active render window // MOVE TO DECORATION MANAGER if (decorations.isEmpty() || decorations.contains(DECORATION_BORDER)) { m_CustomMultiWidget->ShowAllColoredRectangles(enable); } if (decorations.isEmpty() || decorations.contains(DECORATION_LOGO)) { m_CustomMultiWidget->ShowAllDepartmentLogos(enable); } if (decorations.isEmpty() || decorations.contains(DECORATION_MENU)) { //m_Impl->m_CustomMultiWidget->ActivateAllRenderWindowMenus(enable); } if (decorations.isEmpty() || decorations.contains(DECORATION_BACKGROUND)) { m_CustomMultiWidget->ShowAllBackgroundColorGradients(enable); } if (decorations.isEmpty() || decorations.contains(DECORATION_CORNER_ANNOTATION)) { m_CustomMultiWidget->ShowAllCornerAnnotations(enable); } } bool QmitkCustomMultiWidgetEditor::IsDecorationEnabled(const QString &decoration) const { // #TODO: define: - for all render windows // - for the one, active render window // MOVE TO DECORATION MANAGER /* if (decoration == DECORATION_BORDER) { return m_Impl->m_CustomMultiWidget->IsColoredRectanglesEnabled(); } else if (decoration == DECORATION_LOGO) { return m_Impl->m_CustomMultiWidget->IsColoredRectanglesEnabled(); } else if (decoration == DECORATION_MENU) { return m_Impl->m_CustomMultiWidget->IsRenderWindowWidgetMenuEnabled(); } else if (decoration == DECORATION_BACKGROUND) { return m_Impl->m_CustomMultiWidget->GetGradientBackgroundFlag(); } else if (decoration == DECORATION_CORNER_ANNOTATION) { return m_Impl->m_CustomMultiWidget->IsCornerAnnotationVisible(); } */ return false; } QStringList QmitkCustomMultiWidgetEditor::GetDecorations() const { // MOVE TO DECORATION MANAGER QStringList decorations; decorations << DECORATION_BORDER << DECORATION_LOGO << DECORATION_MENU << DECORATION_BACKGROUND << DECORATION_CORNER_ANNOTATION; return decorations; } void QmitkCustomMultiWidgetEditor::EnableSlicingPlanes(bool enable) { // #TODO: nothing here } bool QmitkCustomMultiWidgetEditor::IsSlicingPlanesEnabled() const { // #TODO: nothing here return false; } QmitkCustomMultiWidget* QmitkCustomMultiWidgetEditor::GetCustomMultiWidget() { return m_CustomMultiWidget; } void QmitkCustomMultiWidgetEditor::SetFocus() { if (nullptr != m_CustomMultiWidget) { m_CustomMultiWidget->setFocus(); } } void QmitkCustomMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* preferences) { // MOVE TO DECORATION MANAGER // Enable change of logo. If no DepartmentLogo was set explicitly, MBILogo is used. // Set new department logo by prefs->Set("DepartmentLogo", "PathToImage"); // If no logo was set for this plug-in specifically, walk the parent preference nodes // and lookup a logo value there. /* const berry::IPreferences* currentNode = preferences; while(currentNode) { bool logoFound = false; foreach (const QString& key, currentNode->Keys()) { if( key == "DepartmentLogo") { QString departmentLogoLocation = currentNode->Get("DepartmentLogo", ""); if (departmentLogoLocation.isEmpty()) { m_Impl->m_CustomMultiWidget->ShowDepartmentLogo(false); } else { // we need to disable the logo first, otherwise setting a new logo will have // no effect due to how mitkManufacturerLogo works... m_Impl->m_CustomMultiWidget->DisableDepartmentLogo(); m_Impl->m_CustomMultiWidget->SetDepartmentLogoPath(qPrintable(departmentLogoLocation)); m_Impl->m_CustomMultiWidget->EnableDepartmentLogo(); } logoFound = true; break; } } if (logoFound) { break; } currentNode = currentNode->Parent().GetPointer(); } */ // Update internal members FillMembersWithCurrentDecorations(); GetPreferenceDecorations(preferences); // MOVE TO DECORATION MANAGER /* // preferences for renderWindows for(unsigned int i = 0; i < 4; ++i) { // set background color gradient mitk::Color upper = HexColorToMitkColor(m_Impl->m_WidgetBackgroundColor1[i]); mitk::Color lower = HexColorToMitkColor(m_Impl->m_WidgetBackgroundColor2[i]); m_Impl->m_CustomMultiWidget->SetBackgroundColorGradient(upper, lower, i); m_Impl->m_CustomMultiWidget->ShowBackgroundColorGradient(i, true); // set decoration color and corner annotation text mitk::Color colorDecorationWidget = HexColorToMitkColor(m_Impl->m_WidgetDecorationColor[i]); m_Impl->m_CustomMultiWidget->SetDecorationColor(i, colorDecorationWidget); m_Impl->m_CustomMultiWidget->SetCornerAnnotationText(i, m_Impl->m_WidgetAnnotation[i].toStdString()); // enable colored rectangle m_Impl->m_CustomMultiWidget->ShowColoredRectangle(i, true); } */ // Set preferences respecting zooming and panning bool constrainedZooming = preferences->GetBool("Use constrained zooming and panning", true); mitk::RenderingManager::GetInstance()->SetConstrainedPanningZooming(constrainedZooming); mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(this->GetDataStorage()); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); // level window setting bool showLevelWindowWidget = preferences->GetBool("Show level-window widget", true); if (showLevelWindowWidget) { m_CustomMultiWidget->ShowAllLevelWindowWidgets(true); } else { m_CustomMultiWidget->ShowAllLevelWindowWidgets(false); } } void QmitkCustomMultiWidgetEditor::CreateQtPartControl(QWidget* parent) { if (nullptr == m_CustomMultiWidget) { QHBoxLayout* layout = new QHBoxLayout(parent); layout->setContentsMargins(0, 0, 0, 0); if (nullptr == m_MouseModeSwitcher) { m_MouseModeSwitcher = new QmitkMouseModeSwitcher(parent); layout->addWidget(m_MouseModeSwitcher); } berry::IPreferences::Pointer prefs = GetPreferences(); mitk::BaseRenderer::RenderingMode::Type renderingMode = static_cast(prefs->GetInt("Rendering Mode", 0)); m_CustomMultiWidget = new QmitkCustomMultiWidget(parent, 0, 0, renderingMode); layout->addWidget(m_CustomMultiWidget); m_MouseModeSwitcher->setMouseModeSwitcher(m_CustomMultiWidget->GetMouseModeSwitcher()); - mitk::DataStorage::Pointer dataStorage = GetDataStorage(); - m_CustomMultiWidget->SetDataStorage(dataStorage); - - mitk::TimeGeometry::Pointer timeGeometry = dataStorage->ComputeBoundingGeometry3D(dataStorage->GetAll()); - mitk::RenderingManager::GetInstance()->InitializeViews(timeGeometry); + m_CustomMultiWidget->SetDataStorage(GetDataStorage()); + m_CustomMultiWidget->InitRenderWindowWidgets(); m_CustomMultiWidget->ShowAllLevelWindowWidgets(true); // Store the initial visibility status of the menu widget. //m_Impl->m_MenuWidgetsEnabled = m_Impl->m_CustomMultiWidget->IsRenderWindowMenuActivated(0); berry::IBerryPreferences* berryprefs = dynamic_cast(prefs.GetPointer()); InitializePreferences(berryprefs); OnPreferencesChanged(berryprefs); RequestUpdate(); } } void QmitkCustomMultiWidgetEditor::InitializePreferences(berry::IBerryPreferences* preferences) { /* FillMembersWithCurrentDecorations(); // fill members GetPreferenceDecorations(preferences); // overwrite if preferences are defined //create new preferences preferences->Put("widget1 corner annotation", m_Impl->m_WidgetAnnotation[0]); preferences->Put("widget2 corner annotation", m_Impl->m_WidgetAnnotation[1]); preferences->Put("widget3 corner annotation", m_Impl->m_WidgetAnnotation[2]); preferences->Put("widget4 corner annotation", m_Impl->m_WidgetAnnotation[3]); preferences->Put("widget1 decoration color", m_Impl->m_WidgetDecorationColor[0]); preferences->Put("widget2 decoration color", m_Impl->m_WidgetDecorationColor[1]); preferences->Put("widget3 decoration color", m_Impl->m_WidgetDecorationColor[2]); preferences->Put("widget4 decoration color", m_Impl->m_WidgetDecorationColor[3]); preferences->Put("widget1 first background color", m_Impl->m_WidgetBackgroundColor1[0]); preferences->Put("widget2 first background color", m_Impl->m_WidgetBackgroundColor1[1]); preferences->Put("widget3 first background color", m_Impl->m_WidgetBackgroundColor1[2]); preferences->Put("widget4 first background color", m_Impl->m_WidgetBackgroundColor1[3]); preferences->Put("widget1 second background color", m_Impl->m_WidgetBackgroundColor2[0]); preferences->Put("widget2 second background color", m_Impl->m_WidgetBackgroundColor2[1]); preferences->Put("widget3 second background color", m_Impl->m_WidgetBackgroundColor2[2]); preferences->Put("widget4 second background color", m_Impl->m_WidgetBackgroundColor2[3]); */ } void QmitkCustomMultiWidgetEditor::FillMembersWithCurrentDecorations() { /* //fill members with current values (or default values) from the std multi widget for(unsigned int i = 0; i < 4; ++i) { m_Impl->m_WidgetDecorationColor[i] = MitkColorToHexColor(m_Impl->m_CustomMultiWidget->GetDecorationColor(i)); m_Impl->m_WidgetBackgroundColor1[i] = MitkColorToHexColor(m_Impl->m_CustomMultiWidget->GetBackgroundColorGradient(i).first); m_Impl->m_WidgetBackgroundColor2[i] = MitkColorToHexColor(m_Impl->m_CustomMultiWidget->GetBackgroundColorGradient(i).second); m_Impl->m_WidgetAnnotation[i] = QString::fromStdString(m_Impl->m_CustomMultiWidget->GetCornerAnnotationText(i)); } */ } void QmitkCustomMultiWidgetEditor::GetPreferenceDecorations(const berry::IBerryPreferences * preferences) { /* // MOVE TO DECORATION MANAGER //overwrite members with values from the preferences, if they the preference is defined m_Impl->m_WidgetBackgroundColor1[0] = preferences->Get("widget1 first background color", m_Impl->m_WidgetBackgroundColor1[0]); m_Impl->m_WidgetBackgroundColor2[0] = preferences->Get("widget1 second background color", m_Impl->m_WidgetBackgroundColor2[0]); m_Impl->m_WidgetBackgroundColor1[1] = preferences->Get("widget2 first background color", m_Impl->m_WidgetBackgroundColor1[1]); m_Impl->m_WidgetBackgroundColor2[1] = preferences->Get("widget2 second background color", m_Impl->m_WidgetBackgroundColor2[1]); m_Impl->m_WidgetBackgroundColor1[2] = preferences->Get("widget3 first background color", m_Impl->m_WidgetBackgroundColor1[2]); m_Impl->m_WidgetBackgroundColor2[2] = preferences->Get("widget3 second background color", m_Impl->m_WidgetBackgroundColor2[2]); m_Impl->m_WidgetBackgroundColor1[3] = preferences->Get("widget4 first background color", m_Impl->m_WidgetBackgroundColor1[3]); m_Impl->m_WidgetBackgroundColor2[3] = preferences->Get("widget4 second background color", m_Impl->m_WidgetBackgroundColor2[3]); m_Impl->m_WidgetDecorationColor[0] = preferences->Get("widget1 decoration color", m_Impl->m_WidgetDecorationColor[0]); m_Impl->m_WidgetDecorationColor[1] = preferences->Get("widget2 decoration color", m_Impl->m_WidgetDecorationColor[1]); m_Impl->m_WidgetDecorationColor[2] = preferences->Get("widget3 decoration color", m_Impl->m_WidgetDecorationColor[2]); m_Impl->m_WidgetDecorationColor[3] = preferences->Get("widget4 decoration color", m_Impl->m_WidgetDecorationColor[3]); m_Impl->m_WidgetAnnotation[0] = preferences->Get("widget1 corner annotation", m_Impl->m_WidgetAnnotation[0]); m_Impl->m_WidgetAnnotation[1] = preferences->Get("widget2 corner annotation", m_Impl->m_WidgetAnnotation[1]); m_Impl->m_WidgetAnnotation[2] = preferences->Get("widget3 corner annotation", m_Impl->m_WidgetAnnotation[2]); m_Impl->m_WidgetAnnotation[3] = preferences->Get("widget4 corner annotation", m_Impl->m_WidgetAnnotation[3]); */ } mitk::Color QmitkCustomMultiWidgetEditor::HexColorToMitkColor(const QString& hexColor) { // MOVE TO DECORATION MANAGER QColor qColor(hexColor); mitk::Color returnColor; float colorMax = 255.0f; if (hexColor.isEmpty()) // default value { returnColor[0] = 1.0; returnColor[1] = 1.0; returnColor[2] = 1.0; MITK_ERROR << "Using default color for unknown hex string " << qPrintable(hexColor); } else { returnColor[0] = qColor.red() / colorMax; returnColor[1] = qColor.green() / colorMax; returnColor[2] = qColor.blue() / colorMax; } return returnColor; } QString QmitkCustomMultiWidgetEditor::MitkColorToHexColor(const mitk::Color& mitkColor) { // MOVE TO DECORATION MANAGER QColor returnColor; float colorMax = 255.0f; returnColor.setRed(static_cast(mitkColor[0] * colorMax + 0.5)); returnColor.setGreen(static_cast(mitkColor[1] * colorMax + 0.5)); returnColor.setBlue(static_cast(mitkColor[2] * colorMax + 0.5)); return returnColor.name(); }