diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp index 808a40582c..f77ebd2f21 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp @@ -1,134 +1,135 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkSegmentationPreferencePage.h" -#include <QLabel> -#include <QPushButton> -#include <QFormLayout> -#include <QHBoxLayout> -#include <QCheckBox> -#include <QGroupBox> -#include <QRadioButton> -#include <QMessageBox> -#include <QDoubleSpinBox> -#include <QLineEdit> -#include <QToolButton> -#include <QFileDialog> - #include <berryIPreferencesService.h> #include <berryPlatform.h> +#include <mitkBaseApplication.h> + +#include <QFileDialog> + #include <ui_QmitkSegmentationPreferencePageControls.h> QmitkSegmentationPreferencePage::QmitkSegmentationPreferencePage() : m_Ui(new Ui::QmitkSegmentationPreferencePageControls), m_Control(nullptr), m_Initializing(false) { } QmitkSegmentationPreferencePage::~QmitkSegmentationPreferencePage() { } void QmitkSegmentationPreferencePage::Init(berry::IWorkbench::Pointer) { } void QmitkSegmentationPreferencePage::CreateQtControl(QWidget* parent) { m_Initializing = true; berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); m_SegmentationPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation"); m_Control = new QWidget(parent); m_Ui->setupUi(m_Control); connect(m_Ui->smoothingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSmoothingCheckboxChecked(int))); connect(m_Ui->labelSetPresetToolButton, SIGNAL(clicked()), this, SLOT(OnLabelSetPresetButtonClicked())); this->Update(); m_Initializing = false; } QWidget* QmitkSegmentationPreferencePage::GetQtControl() const { return m_Control; } bool QmitkSegmentationPreferencePage::PerformOk() { m_SegmentationPreferencesNode->PutBool("slim view", m_Ui->slimViewCheckBox->isChecked()); m_SegmentationPreferencesNode->PutBool("draw outline", m_Ui->outlineRadioButton->isChecked()); m_SegmentationPreferencesNode->PutBool("selection mode", m_Ui->selectionModeCheckBox->isChecked()); m_SegmentationPreferencesNode->PutBool("smoothing hint", m_Ui->smoothingCheckBox->isChecked()); m_SegmentationPreferencesNode->PutDouble("smoothing value", m_Ui->smoothingSpinBox->value()); m_SegmentationPreferencesNode->PutDouble("decimation rate", m_Ui->decimationSpinBox->value()); m_SegmentationPreferencesNode->PutDouble("closing ratio", m_Ui->closingSpinBox->value()); m_SegmentationPreferencesNode->Put("label set preset", m_Ui->labelSetPresetLineEdit->text()); return true; } void QmitkSegmentationPreferencePage::PerformCancel() { } void QmitkSegmentationPreferencePage::Update() { m_Ui->slimViewCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("slim view", false)); if (m_SegmentationPreferencesNode->GetBool("draw outline", true)) { m_Ui->outlineRadioButton->setChecked(true); } else { m_Ui->overlayRadioButton->setChecked(true); } m_Ui->selectionModeCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("selection mode", false)); if (m_SegmentationPreferencesNode->GetBool("smoothing hint", true)) { m_Ui->smoothingCheckBox->setChecked(true); m_Ui->smoothingSpinBox->setDisabled(true); } else { m_Ui->smoothingCheckBox->setChecked(false); m_Ui->smoothingSpinBox->setEnabled(true); } m_Ui->smoothingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("smoothing value", 1.0)); m_Ui->decimationSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("decimation rate", 0.5)); m_Ui->closingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("closing ratio", 0.0)); - m_Ui->labelSetPresetLineEdit->setText(m_SegmentationPreferencesNode->Get("label set preset", "")); + auto labelSetPreset = mitk::BaseApplication::instance().config().getString(mitk::BaseApplication::ARG_SEGMENTATION_LABELSET_PRESET.toStdString(), ""); + bool isOverridenByCmdLineArg = !labelSetPreset.empty(); + + if (!isOverridenByCmdLineArg) + labelSetPreset = m_SegmentationPreferencesNode->Get("label set preset", "").toStdString(); + + m_Ui->labelSetPresetLineEdit->setDisabled(isOverridenByCmdLineArg); + m_Ui->labelSetPresetToolButton->setDisabled(isOverridenByCmdLineArg); + m_Ui->labelSetPresetCmdLineArgLabel->setVisible(isOverridenByCmdLineArg); + + m_Ui->labelSetPresetLineEdit->setText(QString::fromStdString(labelSetPreset)); } void QmitkSegmentationPreferencePage::OnSmoothingCheckboxChecked(int state) { if (state != Qt::Unchecked) m_Ui->smoothingSpinBox->setDisabled(true); else m_Ui->smoothingSpinBox->setEnabled(true); } void QmitkSegmentationPreferencePage::OnLabelSetPresetButtonClicked() { const auto filename = QFileDialog::getOpenFileName(m_Control, QStringLiteral("Load Label Set Preset"), QString(), QStringLiteral("Label set preset (*.lsetp)")); if (!filename.isEmpty()) m_Ui->labelSetPresetLineEdit->setText(filename); } diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui index d0c13ebe70..7728e50e20 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui @@ -1,198 +1,205 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>QmitkSegmentationPreferencePageControls</class> <widget class="QWidget" name="QmitkSegmentationPreferencePageControls"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>640</width> <height>480</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> <layout class="QFormLayout" name="formLayout"> - <property name="horizontalSpacing"> - <number>8</number> - </property> - <property name="verticalSpacing"> - <number>24</number> - </property> <item row="0" column="0"> <widget class="QLabel" name="slimViewLabel"> <property name="text"> <string>Slim view</string> </property> </widget> </item> <item row="0" column="1"> <widget class="QCheckBox" name="slimViewCheckBox"> <property name="text"> <string>Hide tool button texts and increase icon size</string> </property> </widget> </item> <item row="1" column="0"> <widget class="QLabel" name="displayLabel"> <property name="text"> <string>2D display</string> </property> </widget> </item> <item row="1" column="1"> <layout class="QVBoxLayout" name="displayOptionsLayout"> <item> <widget class="QRadioButton" name="outlineRadioButton"> <property name="text"> <string>Draw as outline</string> </property> </widget> </item> <item> <widget class="QRadioButton" name="overlayRadioButton"> <property name="text"> <string>Draw as transparent overlay</string> </property> </widget> </item> </layout> </item> <item row="2" column="0"> <widget class="QLabel" name="selectionModeLabel"> <property name="text"> <string>Data node selection mode</string> </property> </widget> </item> <item row="2" column="1"> <widget class="QCheckBox" name="selectionModeCheckBox"> <property name="toolTip"> <string>If checked the segmentation plugin ensures that only the selected segmentation and the reference image are visible at one time.</string> </property> <property name="text"> <string>Show only selected nodes</string> </property> </widget> </item> <item row="3" column="0"> <widget class="QLabel" name="surfaceCreationLabel"> <property name="text"> <string>Smoothed surface creation</string> </property> </widget> </item> <item row="3" column="1"> <layout class="QFormLayout" name="surfaceLayout"> <property name="horizontalSpacing"> <number>8</number> </property> <property name="verticalSpacing"> <number>8</number> </property> <item row="1" column="0"> <widget class="QLabel" name="smoothingLabel"> <property name="text"> <string>Smoothing value (mm)</string> </property> </widget> </item> <item row="1" column="1"> <widget class="QDoubleSpinBox" name="smoothingSpinBox"> <property name="toolTip"> <string>The Smoothing value is used as variance for a gaussian blur.</string> </property> <property name="singleStep"> <double>0.500000000000000</double> </property> <property name="value"> <double>1.000000000000000</double> </property> </widget> </item> <item row="2" column="0"> <widget class="QLabel" name="decimationLabel"> <property name="text"> <string>Decimation rate</string> </property> </widget> </item> <item row="2" column="1"> <widget class="QDoubleSpinBox" name="decimationSpinBox"> <property name="toolTip"> <string>Valid range is [0, 1). High values increase decimation, especially when very close to 1. A value of 0 disables decimation.</string> </property> <property name="maximum"> <double>0.990000000000000</double> </property> <property name="singleStep"> <double>0.100000000000000</double> </property> <property name="value"> <double>0.500000000000000</double> </property> </widget> </item> <item row="3" column="0"> <widget class="QLabel" name="closingLabel"> <property name="text"> <string>Closing Ratio</string> </property> </widget> </item> <item row="3" column="1"> <widget class="QDoubleSpinBox" name="closingSpinBox"> <property name="toolTip"> <string>Valid range is [0, 1]. Higher values increase closing. A value of 0 disables closing.</string> </property> <property name="maximum"> <double>1.000000000000000</double> </property> <property name="singleStep"> <double>0.100000000000000</double> </property> </widget> </item> <item row="0" column="0" colspan="2"> <widget class="QCheckBox" name="smoothingCheckBox"> <property name="toolTip"> <string>If checked the segmentation plugin ensures that only the selected segmentation and the reference image are visible at one time.</string> </property> <property name="text"> <string>Use image spacing as smoothing value hint</string> </property> </widget> </item> </layout> </item> <item row="4" column="0"> <widget class="QLabel" name="labelSetPresetLabel"> <property name="text"> <string>Default label set preset</string> </property> </widget> </item> <item row="4" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> <widget class="QLineEdit" name="labelSetPresetLineEdit"> <property name="clearButtonEnabled"> <bool>true</bool> </property> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QToolButton" name="labelSetPresetToolButton"> <property name="text"> <string>...</string> </property> </widget> </item> + <item row="1" column="0" colspan="2"> + <widget class="QLabel" name="labelSetPresetCmdLineArgLabel"> + <property name="text"> + <string><html><head/><body><p><span style=" color:#ff0000;">The default label set preset is currently overriden by the </span><span style=" font-family:'Courier New'; color:#ff0000;">Segmentation.labelSetPreset</span><span style=" color:#ff0000;"> command-line argument.</span></p></body></html></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </item> </layout> </widget> <resources/> <connections/> </ui>