diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp index 21b7a7935c..3634682cbd 100644 --- a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.cpp @@ -1,274 +1,278 @@ /*=================================================================== 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 #include #include #include #include #include #include "QmitkStdMultiWidgetEditorPreferencePage.h" #include QmitkStdMultiWidgetEditorPreferencePage::QmitkStdMultiWidgetEditorPreferencePage() : m_Preferences(NULL), m_Ui(new Ui::QmitkStdMultiWidgetEditorPreferencePage), m_Control(NULL) { } QmitkStdMultiWidgetEditorPreferencePage::~QmitkStdMultiWidgetEditorPreferencePage() { } void QmitkStdMultiWidgetEditorPreferencePage::CreateQtControl(QWidget* parent) { m_Control = new QWidget(parent); m_Ui->setupUi(m_Control); berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); m_Preferences = prefService->GetSystemPreferences()->Node(QmitkStdMultiWidgetEditor::EDITOR_ID); QObject::connect( m_Ui->m_ColorButton1, SIGNAL( clicked() ) , this, SLOT( ColorChooserButtonClicked() ) ); QObject::connect( m_Ui->m_ColorButton2, SIGNAL( clicked() ) , this, SLOT( ColorChooserButtonClicked() ) ); QObject::connect( m_Ui->m_ResetButton, SIGNAL( clicked() ) , this, SLOT( ResetColors() ) ); QObject::connect( m_Ui->m_RenderingMode, SIGNAL(activated(int) ) , this, SLOT( ChangeRenderingMode(int) ) ); QObject::connect( m_Ui->m_RenderWindowDecorationColor, SIGNAL( clicked() ) , this, SLOT( ColorChooserButtonClicked() ) ); QObject::connect( m_Ui->m_RenderWindowChooser, SIGNAL(activated(int) ) , this, SLOT( OnWidgetComboBoxChanged(int) ) ); QObject::connect( m_Ui->m_RenderWindowDecorationText, SIGNAL(textChanged(QString) ) , this, SLOT( AnnotationTextChanged(QString) ) ); this->Update(); } QWidget* QmitkStdMultiWidgetEditorPreferencePage::GetQtControl() const { return m_Control; } void QmitkStdMultiWidgetEditorPreferencePage::Init(berry::IWorkbench::Pointer) { } void QmitkStdMultiWidgetEditorPreferencePage::PerformCancel() { } bool QmitkStdMultiWidgetEditorPreferencePage::PerformOk() { m_Preferences->PutByteArray("widget1 corner annotation", m_WidgetAnnotation[0]); m_Preferences->PutByteArray("widget2 corner annotation", m_WidgetAnnotation[1]); m_Preferences->PutByteArray("widget3 corner annotation", m_WidgetAnnotation[2]); m_Preferences->PutByteArray("widget4 corner annotation", m_WidgetAnnotation[3]); m_Preferences->PutByteArray("widget1 decoration color", m_WidgetDecorationColor[0]); m_Preferences->PutByteArray("widget2 decoration color", m_WidgetDecorationColor[1]); m_Preferences->PutByteArray("widget3 decoration color", m_WidgetDecorationColor[2]); m_Preferences->PutByteArray("widget4 decoration color", m_WidgetDecorationColor[3]); m_Preferences->PutByteArray("widget1 first background color", m_WidgetBackgroundColor1[0]); m_Preferences->PutByteArray("widget2 first background color", m_WidgetBackgroundColor1[1]); m_Preferences->PutByteArray("widget3 first background color", m_WidgetBackgroundColor1[2]); m_Preferences->PutByteArray("widget4 first background color", m_WidgetBackgroundColor1[3]); m_Preferences->PutByteArray("widget1 second background color", m_WidgetBackgroundColor2[0]); m_Preferences->PutByteArray("widget2 second background color", m_WidgetBackgroundColor2[1]); m_Preferences->PutByteArray("widget3 second background color", m_WidgetBackgroundColor2[2]); m_Preferences->PutByteArray("widget4 second background color", m_WidgetBackgroundColor2[3]); m_Preferences->PutInt("crosshair gap size", m_Ui->m_CrosshairGapSize->value()); m_Preferences->PutBool("Use constrained zooming and padding" , m_Ui->m_EnableFlexibleZooming->isChecked()); m_Preferences->PutBool("Show level/window widget", m_Ui->m_ShowLevelWindowWidget->isChecked()); m_Preferences->PutBool("PACS like mouse interaction", m_Ui->m_PACSLikeMouseMode->isChecked()); m_Preferences->PutInt("Rendering Mode", m_Ui->m_RenderingMode->currentIndex()); return true; } void QmitkStdMultiWidgetEditorPreferencePage::Update() { //gradient background colors m_WidgetBackgroundColor1[0] = m_Preferences->GetByteArray("widget1 first background color", "#000000"); m_WidgetBackgroundColor2[0] = m_Preferences->GetByteArray("widget1 second background color", "#000000"); m_WidgetBackgroundColor1[1] = m_Preferences->GetByteArray("widget2 first background color", "#000000"); m_WidgetBackgroundColor2[1] = m_Preferences->GetByteArray("widget2 second background color", "#000000"); m_WidgetBackgroundColor1[2] = m_Preferences->GetByteArray("widget3 first background color", "#000000"); m_WidgetBackgroundColor2[2] = m_Preferences->GetByteArray("widget3 second background color", "#000000"); m_WidgetBackgroundColor1[3] = m_Preferences->GetByteArray("widget4 first background color", "#191919"); m_WidgetBackgroundColor2[3] = m_Preferences->GetByteArray("widget4 second background color", "#7F7F7F"); //decoration colors m_WidgetDecorationColor[0] = m_Preferences->GetByteArray("widget1 decoration color", "#FF0000"); m_WidgetDecorationColor[1] = m_Preferences->GetByteArray("widget2 decoration color", "#00FF00"); m_WidgetDecorationColor[2] = m_Preferences->GetByteArray("widget3 decoration color", "#0000FF"); m_WidgetDecorationColor[3] = m_Preferences->GetByteArray("widget4 decoration color", "#FFFF00"); //annotation text m_WidgetAnnotation[0] = m_Preferences->GetByteArray("widget1 corner annotation", "Axial"); m_WidgetAnnotation[1] = m_Preferences->GetByteArray("widget2 corner annotation", "Sagittal"); m_WidgetAnnotation[2] = m_Preferences->GetByteArray("widget3 corner annotation", "Coronal"); m_WidgetAnnotation[3] = m_Preferences->GetByteArray("widget4 corner annotation", "3D"); //Ui stuff QColor firstBackgroundColor = this->HexStringToQtColor(m_WidgetBackgroundColor1[0]); QColor secondBackgroundColor = this->HexStringToQtColor(m_WidgetBackgroundColor2[0]); QColor widgetColor = this->HexStringToQtColor(m_WidgetDecorationColor[0]); this->SetStyleSheetToColorChooserButton(firstBackgroundColor, m_Ui->m_ColorButton1); this->SetStyleSheetToColorChooserButton(secondBackgroundColor, m_Ui->m_ColorButton2); this->SetStyleSheetToColorChooserButton(widgetColor, m_Ui->m_RenderWindowDecorationColor); m_Ui->m_RenderWindowDecorationText->setText(QString::fromStdString(m_WidgetAnnotation[0])); m_Ui->m_EnableFlexibleZooming->setChecked(m_Preferences->GetBool("Use constrained zooming and padding", true)); m_Ui->m_ShowLevelWindowWidget->setChecked(m_Preferences->GetBool("Show level/window widget", true)); m_Ui->m_PACSLikeMouseMode->setChecked(m_Preferences->GetBool("PACS like mouse interaction", false)); int index= m_Preferences->GetInt("Rendering Mode",0); m_Ui->m_RenderingMode->setCurrentIndex(index); m_Ui->m_CrosshairGapSize->setValue(m_Preferences->GetInt("crosshair gap size", 32)); } QColor QmitkStdMultiWidgetEditorPreferencePage::HexStringToQtColor(std::string colorInHex) { QColor returncol; returncol.setNamedColor(QString::fromStdString(colorInHex)); return returncol; } void QmitkStdMultiWidgetEditorPreferencePage::ColorChooserButtonClicked() { unsigned int widgetIndex = m_Ui->m_RenderWindowChooser->currentIndex(); if(widgetIndex > 3) { MITK_ERROR << "Selected index for unknown."; return; } QObject *senderObj = sender(); // This will give Sender button //find out last used color and set it QColor initialColor; if( senderObj->objectName() == m_Ui->m_ColorButton1->objectName()) { initialColor = HexStringToQtColor(m_WidgetBackgroundColor1[widgetIndex]); }else if( senderObj->objectName() == m_Ui->m_ColorButton2->objectName()) { initialColor = HexStringToQtColor(m_WidgetBackgroundColor2[widgetIndex]); }else if( senderObj->objectName() == m_Ui->m_RenderWindowDecorationColor->objectName()) { initialColor = HexStringToQtColor(m_WidgetDecorationColor[widgetIndex]); } //get the new color - QColor color = QColorDialog::getColor(initialColor); - this->SetStyleSheetToColorChooserButton(color, static_cast(senderObj)); + QColor newcolor = QColorDialog::getColor(initialColor); + if(!newcolor.isValid()) + { + newcolor = initialColor; + } + this->SetStyleSheetToColorChooserButton(newcolor, static_cast(senderObj)); //convert it to std string and apply it if( senderObj->objectName() == m_Ui->m_ColorButton1->objectName()) { - m_WidgetBackgroundColor1[widgetIndex] = color.name().toStdString(); + m_WidgetBackgroundColor1[widgetIndex] = newcolor.name().toStdString(); }else if( senderObj->objectName() == m_Ui->m_ColorButton2->objectName()) { - m_WidgetBackgroundColor2[widgetIndex] = color.name().toStdString(); + m_WidgetBackgroundColor2[widgetIndex] = newcolor.name().toStdString(); }else if( senderObj->objectName() == m_Ui->m_RenderWindowDecorationColor->objectName()) { - m_WidgetDecorationColor[widgetIndex] = color.name().toStdString(); + m_WidgetDecorationColor[widgetIndex] = newcolor.name().toStdString(); } } void QmitkStdMultiWidgetEditorPreferencePage::SetStyleSheetToColorChooserButton(QColor backgroundcolor, QPushButton* button) { button->setAutoFillBackground(true); QString styleSheet = "background-color:rgb("; styleSheet.append(QString::number(backgroundcolor.red())); styleSheet.append(","); styleSheet.append(QString::number(backgroundcolor.green())); styleSheet.append(","); styleSheet.append(QString::number(backgroundcolor.blue())); styleSheet.append(")"); button->setStyleSheet(styleSheet); } void QmitkStdMultiWidgetEditorPreferencePage::AnnotationTextChanged(QString text) { unsigned int widgetIndex = m_Ui->m_RenderWindowChooser->currentIndex(); if( widgetIndex > 3) { MITK_INFO << "Selected index for unknown widget."; return; } m_WidgetAnnotation[widgetIndex] = text.toStdString(); } void QmitkStdMultiWidgetEditorPreferencePage::ResetColors() { //default gradient background values // m_FirstColor = "#191919"; // m_SecondColor = "#7F7F7F"; // QColor firstColor = this->StringToColor(m_FirstColor); // this->SetStyleSheetToColorChooserButton(firstColor, m_Ui->m_ColorButton1); // QColor secondColor = this->StringToColor(m_SecondColor); // this->SetStyleSheetToColorChooserButton(secondColor, m_Ui->m_ColorButton2); } void QmitkStdMultiWidgetEditorPreferencePage::OnWidgetComboBoxChanged(int i) { if( i > 3) { MITK_ERROR << "Selected unknown widget."; return; } QColor widgetColor, gradientBackground1, gradientBackground2; widgetColor = HexStringToQtColor(m_WidgetDecorationColor[i]); gradientBackground1 = HexStringToQtColor(m_WidgetBackgroundColor1[i]); gradientBackground2 = HexStringToQtColor(m_WidgetBackgroundColor2[i]); this->SetStyleSheetToColorChooserButton(widgetColor, m_Ui->m_RenderWindowDecorationColor); this->SetStyleSheetToColorChooserButton(gradientBackground1, m_Ui->m_ColorButton1); this->SetStyleSheetToColorChooserButton(gradientBackground2, m_Ui->m_ColorButton2); m_Ui->m_RenderWindowDecorationText->setText(QString::fromStdString(m_WidgetAnnotation[i])); } void QmitkStdMultiWidgetEditorPreferencePage::ChangeRenderingMode(int i) { if( i == 0 ) { m_CurrentRenderingMode = "Standard"; } else if( i == 1 ) { m_CurrentRenderingMode = "Multisampling"; } else if( i == 2 ) { m_CurrentRenderingMode = "DepthPeeling"; } } diff --git a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.ui b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.ui index 1eac31d2a0..601de5bf17 100644 --- a/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.ui +++ b/Plugins/org.mitk.gui.qt.stdmultiwidgeteditor/src/internal/QmitkStdMultiWidgetEditorPreferencePage.ui @@ -1,205 +1,207 @@ QmitkStdMultiWidgetEditorPreferencePage 0 0 518 431 External Programs stdmulti.widget1 stdmulti.widget2 stdmulti.widget3 stdmulti.widget4 Background color Reset preferences Standard Rendering Enable Multisampling (Antialiasing) Enable Depth Peeling * Changes require restart of MITK. Depth Peeling is only supported by Windows. For other OS, use Standard Rendering and enable the property 'Depth Sorting' in the property list of the surface data node. 32 Qt::Horizontal - Text + Corner annotation Crosshair gap size Decoration color Render windows Qt::LeftToRight Show level/window widget true Qt::LeftToRight Use PACS like mouse interaction (select left mouse button action) false Qt::Horizontal Rendering Mode* Qt::LeftToRight Use constraint zooming and padding true - + + +