diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp index 4a1fa3f810..8ee17e9bae 100644 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp +++ b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditor.cpp @@ -1,272 +1,288 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkStdMultiWidgetEditor.h" #include #include #include #include #include #include #include #include #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" const std::string QmitkStdMultiWidgetEditor::EDITOR_ID = "org.mitk.editors.stdmultiwidget"; QmitkStdMultiWidgetEditor::QmitkStdMultiWidgetEditor() : m_StdMultiWidget(0) { } QmitkStdMultiWidgetEditor::QmitkStdMultiWidgetEditor(const QmitkStdMultiWidgetEditor& other) { Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } QmitkStdMultiWidgetEditor::~QmitkStdMultiWidgetEditor() { // we need to wrap the RemovePartListener call inside a // register/unregister block to prevent infinite recursion // due to the destruction of temporary smartpointer to this this->Register(); this->GetSite()->GetPage()->RemovePartListener(berry::IPartListener::Pointer(this)); this->UnRegister(false); } QmitkStdMultiWidget* QmitkStdMultiWidgetEditor::GetStdMultiWidget() { return m_StdMultiWidget; } void QmitkStdMultiWidgetEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) { if (input.Cast().IsNull()) throw berry::PartInitException("Invalid Input: Must be IFileEditorInput"); this->SetSite(site); this->SetInput(input); } void QmitkStdMultiWidgetEditor::CreateQtPartControl(QWidget* parent) { if (m_StdMultiWidget == 0) { m_DndFrameWidget = new QmitkDnDFrameWidget(parent); QVBoxLayout* layout = new QVBoxLayout(parent); layout->addWidget(m_DndFrameWidget); layout->setContentsMargins(0,0,0,0); m_StdMultiWidget = new QmitkStdMultiWidget(m_DndFrameWidget); QVBoxLayout* layout2 = new QVBoxLayout(m_DndFrameWidget); layout2->addWidget(m_StdMultiWidget); layout2->setContentsMargins(0,0,0,0); mitk::DataStorage::Pointer ds = this->GetEditorInput().Cast() ->GetDataStorageReference()->GetDataStorage(); // Tell the multiWidget which (part of) the tree to render m_StdMultiWidget->SetDataStorage(ds); // Initialize views as transversal, sagittal, coronar to all data objects in DataStorage // (from top-left to bottom) mitk::TimeSlicedGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll()); mitk::RenderingManager::GetInstance()->InitializeViews(geo); // Initialize bottom-right view as 3D view m_StdMultiWidget->GetRenderWindow4()->GetRenderer()->SetMapperID( mitk::BaseRenderer::Standard3D ); // Enable standard handler for levelwindow-slider m_StdMultiWidget->EnableStandardLevelWindow(); // Add the displayed views to the tree to see their positions // in 2D and 3D m_StdMultiWidget->AddDisplayPlaneSubTree(); m_StdMultiWidget->EnableNavigationControllerEventListening(); mitk::GlobalInteraction::GetInstance()->AddListener( m_StdMultiWidget->GetMoveAndZoomInteractor() ); this->GetSite()->GetPage()->AddPartListener(berry::IPartListener::Pointer(this)); // enable change of logo berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer logoPref = prefService->GetSystemPreferences()->Node("DepartmentLogo"); std::string departmentLogoLocation = logoPref->Get("DepartmentLogo",""); //# Preferences berry::IBerryPreferences::Pointer prefs = (prefService->GetSystemPreferences()->Node(EDITOR_ID)) .Cast(); assert( prefs ); prefs->OnChanged.AddListener( berry::MessageDelegate1( this , &QmitkStdMultiWidgetEditor::OnPreferencesChanged ) ); bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); + if (!showLevelWindowWidget) + { + m_StdMultiWidget->DisableStandardLevelWindow(); + } + m_StdMultiWidget->SetDepartmentLogoPath(departmentLogoLocation.c_str()); m_StdMultiWidget->DisableDepartmentLogo(); m_StdMultiWidget->EnableDepartmentLogo(); this->OnPreferencesChanged(prefs.GetPointer()); } } void QmitkStdMultiWidgetEditor::OnPreferencesChanged(const berry::IBerryPreferences* prefs) { // preferences for gradient background float color = 255.0; QString firstColorName = QString::fromStdString (prefs->GetByteArray("first background color", "")); QColor firstColor(firstColorName); mitk::Color upper; if (firstColorName=="") // default values { upper[0] = 0.1; upper[1] = 0.1; upper[2] = 0.1; } else { upper[0] = firstColor.red() / color; upper[1] = firstColor.green() / color; upper[2] = firstColor.blue() / color; } QString secondColorName = QString::fromStdString (prefs->GetByteArray("second background color", "")); QColor secondColor(secondColorName); mitk::Color lower; if (secondColorName=="") // default values { lower[0] = 0.5; lower[1] = 0.5; lower[2] = 0.5; } else { lower[0] = secondColor.red() / color; lower[1] = secondColor.green() / color; lower[2] = secondColor.blue() / color; } m_StdMultiWidget->SetGradientBackgroundColors(upper, lower); m_StdMultiWidget->EnableGradientBackground(); // Set preferences respecting zooming and padding bool constrainedZooming = prefs->GetBool("Use constrained zooming and padding", false); mitk::RenderingManager::GetInstance()->SetConstrainedPaddingZooming(constrainedZooming); mitk::NodePredicateNot::Pointer pred = mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("includeInBoundingBox" , mitk::BoolProperty::New(false))); mitk::DataStorage::SetOfObjects::ConstPointer rs = this->GetDataStorage()->GetSubset(pred); // calculate bounding geometry of these nodes mitk::TimeSlicedGeometry::Pointer bounds = this->GetDataStorage()->ComputeBoundingGeometry3D(rs, "visible"); // initialize the views to the bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(bounds); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + // level window setting + bool showLevelWindowWidget = prefs->GetBool("Show level/window widget", true); + if (showLevelWindowWidget) + { + m_StdMultiWidget->EnableStandardLevelWindow(); + } + else + { + m_StdMultiWidget->DisableStandardLevelWindow(); + } } mitk::DataStorage::Pointer QmitkStdMultiWidgetEditor::GetDataStorage() const { mitk::IDataStorageService::Pointer service = berry::Platform::GetServiceRegistry().GetServiceById(mitk::IDataStorageService::ID); if (service.IsNotNull()) { return service->GetDefaultDataStorage()->GetDataStorage(); } return 0; } berry::IPartListener::Events::Types QmitkStdMultiWidgetEditor::GetPartEventTypes() const { return Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void QmitkStdMultiWidgetEditor::PartClosed( berry::IWorkbenchPartReference::Pointer partRef ) { if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) { QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) { m_StdMultiWidget->RemovePlanesFromDataStorage(); } } } void QmitkStdMultiWidgetEditor::PartVisible( berry::IWorkbenchPartReference::Pointer partRef ) { if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) { QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) { m_StdMultiWidget->AddPlanesToDataStorage(); } } } void QmitkStdMultiWidgetEditor::PartHidden( berry::IWorkbenchPartReference::Pointer partRef ) { if (partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID) { QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); if (m_StdMultiWidget == stdMultiWidgetEditor->GetStdMultiWidget()) { m_StdMultiWidget->RemovePlanesFromDataStorage(); } } } void QmitkStdMultiWidgetEditor::SetFocus() { if (m_StdMultiWidget != 0) m_StdMultiWidget->setFocus(); } diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.cpp b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.cpp index a2646f0401..8c962e04d2 100644 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.cpp +++ b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.cpp @@ -1,220 +1,224 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-07-07 16:57:15 +0200 (Di, 07 Jul 2009) $ Version: $Revision: 18019 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkStdMultiWidgetEditorPreferencePage.h" #include "QmitkStdMultiWidgetEditor.h" #include #include #include #include #include #include #include QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage() : m_MainControl(0) { } QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage(const QmitkStdMultiWidgetEditorPreferencePage& other) { Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } void QmitkStdMultiWidgetEditorPreferencePage::Init(berry::IWorkbench::Pointer ) { } void QmitkStdMultiWidgetEditorPreferencePage::CreateQtControl(QWidget* parent) { berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); m_StdMultiWidgetEditorPreferencesNode = prefService->GetSystemPreferences()->Node(QmitkStdMultiWidgetEditor::EDITOR_ID); m_MainControl = new QWidget(parent); - m_EnableFlexibleZooming = new QCheckBox; + m_EnableFlexibleZooming = new QCheckBox; + m_ShowLevelWindowWidget = new QCheckBox; QFormLayout *formLayout = new QFormLayout; formLayout->addRow("&Use constrained zooming and padding", m_EnableFlexibleZooming); + formLayout->addRow("&Show level/window widget", m_ShowLevelWindowWidget); // gradient background QLabel* gBName = new QLabel; gBName->setText("Gradient background"); formLayout->addRow(gBName); // color m_ColorButton1 = new QPushButton; m_ColorButton1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); m_ColorButton2 = new QPushButton; m_ColorButton2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); QPushButton* resetButton = new QPushButton; resetButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum); resetButton->setText("Reset"); QLabel* colorLabel1 = new QLabel("first color : "); colorLabel1->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); QLabel* colorLabel2 = new QLabel("second color: "); colorLabel2->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); QHBoxLayout* colorWidgetLayout = new QHBoxLayout; colorWidgetLayout->setContentsMargins(4,4,4,4); colorWidgetLayout->addWidget(colorLabel1); colorWidgetLayout->addWidget(m_ColorButton1); colorWidgetLayout->addWidget(colorLabel2); colorWidgetLayout->addWidget(m_ColorButton2); colorWidgetLayout->addWidget(resetButton); QWidget* colorWidget = new QWidget; colorWidget->setLayout(colorWidgetLayout); //spacer QSpacerItem *spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); QVBoxLayout* vBoxLayout = new QVBoxLayout; vBoxLayout->addLayout(formLayout); vBoxLayout->addWidget(colorWidget); vBoxLayout->addSpacerItem(spacer); m_MainControl->setLayout(vBoxLayout); QObject::connect( m_ColorButton1, SIGNAL( clicked() ) , this, SLOT( FirstColorChanged() ) ); QObject::connect( m_ColorButton2, SIGNAL( clicked() ) , this, SLOT( SecondColorChanged() ) ); QObject::connect( resetButton, SIGNAL( clicked() ) , this, SLOT( ResetColors() ) ); this->Update(); } QWidget* QmitkStdMultiWidgetEditorPreferencePage::GetQtControl() const { return m_MainControl; } bool QmitkStdMultiWidgetEditorPreferencePage::PerformOk() { m_StdMultiWidgetEditorPreferencesNode->Put("first background color style sheet", m_FirstColorStyleSheet.toStdString()); m_StdMultiWidgetEditorPreferencesNode->Put("second background color style sheet", m_SecondColorStyleSheet.toStdString()); m_StdMultiWidgetEditorPreferencesNode->PutByteArray("first background color", m_FirstColor); m_StdMultiWidgetEditorPreferencesNode->PutByteArray("second background color", m_SecondColor); m_StdMultiWidgetEditorPreferencesNode->PutBool("Use constrained zooming and padding" , m_EnableFlexibleZooming->isChecked()); + m_StdMultiWidgetEditorPreferencesNode->PutBool("Show level/window widget", m_ShowLevelWindowWidget->isChecked()); return true; } void QmitkStdMultiWidgetEditorPreferencePage::PerformCancel() { } void QmitkStdMultiWidgetEditorPreferencePage::Update() { m_EnableFlexibleZooming->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Use constrained zooming and padding", true)); + m_ShowLevelWindowWidget->setChecked(m_StdMultiWidgetEditorPreferencesNode->GetBool("Show level/window widget", true)); m_FirstColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("first background color style sheet", "")); m_SecondColorStyleSheet = QString::fromStdString(m_StdMultiWidgetEditorPreferencesNode->Get("second background color style sheet", "")); m_FirstColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("first background color", ""); m_SecondColor = m_StdMultiWidgetEditorPreferencesNode->GetByteArray("second background color", ""); if (m_FirstColorStyleSheet=="") { m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; } if (m_SecondColorStyleSheet=="") { m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; } if (m_FirstColor=="") { m_FirstColor = "#191919"; } if (m_SecondColor=="") { m_SecondColor = "#7F7F7F"; } m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); } void QmitkStdMultiWidgetEditorPreferencePage::FirstColorChanged() { QColor color = QColorDialog::getColor(); m_ColorButton1->setAutoFillBackground(true); QString styleSheet = "background-color:rgb("; styleSheet.append(QString::number(color.red())); styleSheet.append(","); styleSheet.append(QString::number(color.green())); styleSheet.append(","); styleSheet.append(QString::number(color.blue())); styleSheet.append(")"); m_ColorButton1->setStyleSheet(styleSheet); m_FirstColorStyleSheet = styleSheet; QStringList firstColor; firstColor << color.name(); m_FirstColor = firstColor.replaceInStrings(";","\\;").join(";").toStdString(); } void QmitkStdMultiWidgetEditorPreferencePage::SecondColorChanged() { QColor color = QColorDialog::getColor(); m_ColorButton2->setAutoFillBackground(true); QString styleSheet = "background-color:rgb("; styleSheet.append(QString::number(color.red())); styleSheet.append(","); styleSheet.append(QString::number(color.green())); styleSheet.append(","); styleSheet.append(QString::number(color.blue())); styleSheet.append(")"); m_ColorButton2->setStyleSheet(styleSheet); m_SecondColorStyleSheet = styleSheet; QStringList secondColor; secondColor << color.name(); m_SecondColor = secondColor.replaceInStrings(";","\\;").join(";").toStdString(); } void QmitkStdMultiWidgetEditorPreferencePage::ResetColors() { m_FirstColorStyleSheet = "background-color:rgb(25,25,25)"; m_SecondColorStyleSheet = "background-color:rgb(127,127,127)"; m_FirstColor = "#191919"; m_SecondColor = "#7F7F7F"; m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet); m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet); } void QmitkStdMultiWidgetEditorPreferencePage::UseGradientBackgroundSelected() { } void QmitkStdMultiWidgetEditorPreferencePage::ColorActionChanged() { } diff --git a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.h b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.h index 61b0aa7bd0..6fb09e9652 100644 --- a/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.h +++ b/CoreUI/Bundles/org.mitk.gui.qt.common/src/QmitkStdMultiWidgetEditorPreferencePage.h @@ -1,86 +1,87 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date: 2009-02-10 14:14:32 +0100 (Di, 10 Feb 2009) $ Version: $Revision: 16224 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ #define QMITKSTDMULTIWIDGETEDITORPREFERENCEPAGE_H_ #include "berryIQtPreferencePage.h" #include #include class QWidget; class QCheckBox; class QPushButton; class QWidgetAction; struct MITK_QT_COMMON QmitkStdMultiWidgetEditorPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: QmitkStdMultiWidgetEditorPreferencePage(); QmitkStdMultiWidgetEditorPreferencePage(const QmitkStdMultiWidgetEditorPreferencePage& other); void Init(berry::IWorkbench::Pointer workbench); void CreateQtControl(QWidget* widget); QWidget* GetQtControl() const; /// /// \see IPreferencePage::PerformOk() /// virtual bool PerformOk(); /// /// \see IPreferencePage::PerformCancel() /// virtual void PerformCancel(); /// /// \see IPreferencePage::Update() /// virtual void Update(); public slots: void FirstColorChanged(); void SecondColorChanged(); void UseGradientBackgroundSelected(); void ColorActionChanged(); void ResetColors(); protected: QWidget* m_MainControl; - QCheckBox* m_EnableFlexibleZooming; + QCheckBox* m_EnableFlexibleZooming; + QCheckBox* m_ShowLevelWindowWidget; QCheckBox* m_UseGradientBackground; QCheckBox* m_ChangeBackgroundColors; QPushButton* m_ColorButton1; QPushButton* m_ColorButton2; std::string m_FirstColor; std::string m_SecondColor; QString m_FirstColorStyleSheet; QString m_SecondColorStyleSheet; berry::IPreferences::Pointer m_StdMultiWidgetEditorPreferencesNode; }; #endif /* QMITKDATAMANAGERPREFERENCEPAGE_H_ */