diff --git a/Plugins/org.mitk.gui.qt.segmentation/files.cmake b/Plugins/org.mitk.gui.qt.segmentation/files.cmake index f63907b3ae..bb27b67836 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/files.cmake +++ b/Plugins/org.mitk.gui.qt.segmentation/files.cmake @@ -1,80 +1,81 @@ set(SRC_CPP_FILES QmitkSegmentationPreferencePage.cpp ) set(INTERNAL_CPP_FILES mitkPluginActivator.cpp QmitkSegmentationView.cpp QmitkAutocropAction.cpp QmitkAutocropLabelSetImageAction.cpp QmitkCreatePolygonModelAction.cpp QmitkLoadMultiLabelPresetAction.cpp QmitkSaveMultiLabelPresetAction.cpp Common/QmitkDataSelectionWidget.cpp Common/QmitkLabelsWidget.cpp Common/QmitkLayersWidget.cpp SegmentationUtilities/QmitkSegmentationUtilitiesView.cpp SegmentationUtilities/QmitkSegmentationUtilityWidget.cpp SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidget.cpp SegmentationUtilities/ImageMasking/QmitkImageMaskingWidget.cpp SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.cpp SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidget.cpp SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidget.cpp ) set(UI_FILES + src/QmitkSegmentationPreferencePageControls.ui src/internal/QmitkSegmentationViewControls.ui src/internal/Common/QmitkDataSelectionWidgetControls.ui src/internal/Common/QmitkLabelsWidgetControls.ui src/internal/Common/QmitkLayersWidgetControls.ui src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesViewControls.ui src/internal/SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidgetControls.ui src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidgetControls.ui src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui ) set(MOC_H_FILES src/QmitkSegmentationPreferencePage.h src/internal/mitkPluginActivator.h src/internal/QmitkSegmentationView.h src/internal/QmitkAutocropAction.h src/internal/QmitkAutocropLabelSetImageAction.h src/internal/QmitkCreatePolygonModelAction.h src/internal/QmitkLoadMultiLabelPresetAction.h src/internal/QmitkSaveMultiLabelPresetAction.h src/internal/Common/QmitkDataSelectionWidget.h src/internal/Common/QmitkLabelsWidget.h src/internal/Common/QmitkLayersWidget.h src/internal/SegmentationUtilities/QmitkSegmentationUtilitiesView.h src/internal/SegmentationUtilities/QmitkSegmentationUtilityWidget.h src/internal/SegmentationUtilities/BooleanOperations/QmitkBooleanOperationsWidget.h src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidget.h src/internal/SegmentationUtilities/ContourModelToImage/QmitkContourModelToImageWidget.h src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidget.h src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidget.h ) set(CACHED_RESOURCE_FILES resources/segmentation.svg resources/segmentation_utilities.svg plugin.xml ) set(QRC_FILES resources/segmentation.qrc resources/SegmentationUtilities.qrc resources/BooleanOperationsWidget.qrc resources/MorphologicalOperationsWidget.qrc ) set(CPP_FILES) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp index 964890809f..808a40582c 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.cpp @@ -1,209 +1,134 @@ /*============================================================================ 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 #include #include #include #include #include #include #include #include #include #include #include #include #include +#include + QmitkSegmentationPreferencePage::QmitkSegmentationPreferencePage() - : m_MainControl(nullptr), - m_SlimViewCheckBox(nullptr), - m_RadioOutline(nullptr), - m_RadioOverlay(nullptr), - m_SelectionModeCheckBox(nullptr), - m_SmoothingCheckBox(nullptr), - m_SmoothingSpinBox(nullptr), - m_DecimationSpinBox(nullptr), - m_ClosingSpinBox(nullptr), - m_LabelSetPresetLineEdit(nullptr), - m_LabelSetPresetToolButton(nullptr), + : 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_MainControl = new QWidget(parent); - - auto formLayout = new QFormLayout; - formLayout->setHorizontalSpacing(8); - formLayout->setVerticalSpacing(24); - - m_SlimViewCheckBox = new QCheckBox("Hide tool button texts and increase icon size", m_MainControl); - formLayout->addRow("Slim view", m_SlimViewCheckBox); - - auto displayOptionsLayout = new QVBoxLayout; - m_RadioOutline = new QRadioButton("Draw as outline", m_MainControl); - displayOptionsLayout->addWidget(m_RadioOutline); - m_RadioOverlay = new QRadioButton("Draw as transparent overlay", m_MainControl); - displayOptionsLayout->addWidget(m_RadioOverlay); - formLayout->addRow("2D display", displayOptionsLayout); - - m_SelectionModeCheckBox = new QCheckBox("Show only selected nodes", m_MainControl); - m_SelectionModeCheckBox->setToolTip("If checked the segmentation plugin ensures that only the selected segmentation" - "and the reference image are visible at one time."); - formLayout->addRow("Data node selection mode", m_SelectionModeCheckBox); - - auto surfaceLayout = new QFormLayout; - surfaceLayout->setSpacing(8); - - m_SmoothingCheckBox = new QCheckBox("Use image spacing as smoothing value hint", m_MainControl); - surfaceLayout->addRow(m_SmoothingCheckBox); - connect(m_SmoothingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSmoothingCheckboxChecked(int))); - - m_SmoothingSpinBox = new QDoubleSpinBox(m_MainControl); - m_SmoothingSpinBox->setMinimum(0.0); - m_SmoothingSpinBox->setSingleStep(0.5); - m_SmoothingSpinBox->setValue(1.0); - m_SmoothingSpinBox->setToolTip("The Smoothing value is used as variance for a gaussian blur."); - surfaceLayout->addRow("Smoothing value (mm)", m_SmoothingSpinBox); - - m_DecimationSpinBox = new QDoubleSpinBox(m_MainControl); - m_DecimationSpinBox->setMinimum(0.0); - m_DecimationSpinBox->setMaximum(0.99); - m_DecimationSpinBox->setSingleStep(0.1); - m_DecimationSpinBox->setValue(0.5); - m_DecimationSpinBox->setToolTip("Valid range is [0, 1). High values increase decimation, especially when very close " - "to 1. A value of 0 disables decimation."); - surfaceLayout->addRow("Decimation rate", m_DecimationSpinBox); - - m_ClosingSpinBox = new QDoubleSpinBox(m_MainControl); - m_ClosingSpinBox->setMinimum(0.0); - m_ClosingSpinBox->setMaximum(1.0); - m_ClosingSpinBox->setSingleStep(0.1); - m_ClosingSpinBox->setValue(0.0); - m_ClosingSpinBox->setToolTip("Valid range is [0, 1]. Higher values increase closing. A value of 0 disables closing."); - surfaceLayout->addRow("Closing Ratio", m_ClosingSpinBox); - - formLayout->addRow("Smoothed surface creation", surfaceLayout); - - m_LabelSetPresetLineEdit = new QLineEdit(m_MainControl); - m_LabelSetPresetLineEdit->setClearButtonEnabled(true); - m_LabelSetPresetLineEdit->setText("test"); - - m_LabelSetPresetToolButton = new QToolButton(m_MainControl); - m_LabelSetPresetToolButton->setText("..."); - - connect(m_LabelSetPresetToolButton, SIGNAL(clicked()), this, SLOT(OnLabelSetPresetButtonClicked())); - - auto LabelSetPresetLayout = new QHBoxLayout; - LabelSetPresetLayout->setSpacing(8); - LabelSetPresetLayout->addWidget(m_LabelSetPresetLineEdit); - LabelSetPresetLayout->addWidget(m_LabelSetPresetToolButton); - - formLayout->addRow("Default label set preset", LabelSetPresetLayout); - - m_MainControl->setLayout(formLayout); + 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_MainControl; + return m_Control; } bool QmitkSegmentationPreferencePage::PerformOk() { - m_SegmentationPreferencesNode->PutBool("slim view", m_SlimViewCheckBox->isChecked()); - m_SegmentationPreferencesNode->PutBool("draw outline", m_RadioOutline->isChecked()); - m_SegmentationPreferencesNode->PutBool("selection mode", m_SelectionModeCheckBox->isChecked()); - m_SegmentationPreferencesNode->PutBool("smoothing hint", m_SmoothingCheckBox->isChecked()); - m_SegmentationPreferencesNode->PutDouble("smoothing value", m_SmoothingSpinBox->value()); - m_SegmentationPreferencesNode->PutDouble("decimation rate", m_DecimationSpinBox->value()); - m_SegmentationPreferencesNode->PutDouble("closing ratio", m_ClosingSpinBox->value()); - m_SegmentationPreferencesNode->Put("label set preset", m_LabelSetPresetLineEdit->text()); + 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_SlimViewCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("slim view", false)); + m_Ui->slimViewCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("slim view", false)); if (m_SegmentationPreferencesNode->GetBool("draw outline", true)) { - m_RadioOutline->setChecked(true); + m_Ui->outlineRadioButton->setChecked(true); } else { - m_RadioOverlay->setChecked(true); + m_Ui->overlayRadioButton->setChecked(true); } - m_SelectionModeCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("selection mode", false)); + m_Ui->selectionModeCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("selection mode", false)); if (m_SegmentationPreferencesNode->GetBool("smoothing hint", true)) { - m_SmoothingCheckBox->setChecked(true); - m_SmoothingSpinBox->setDisabled(true); + m_Ui->smoothingCheckBox->setChecked(true); + m_Ui->smoothingSpinBox->setDisabled(true); } else { - m_SmoothingCheckBox->setChecked(false); - m_SmoothingSpinBox->setEnabled(true); + m_Ui->smoothingCheckBox->setChecked(false); + m_Ui->smoothingSpinBox->setEnabled(true); } - m_SmoothingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("smoothing value", 1.0)); - m_DecimationSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("decimation rate", 0.5)); - m_ClosingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("closing ratio", 0.0)); + 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_LabelSetPresetLineEdit->setText(m_SegmentationPreferencesNode->Get("label set preset", "")); + m_Ui->labelSetPresetLineEdit->setText(m_SegmentationPreferencesNode->Get("label set preset", "")); } void QmitkSegmentationPreferencePage::OnSmoothingCheckboxChecked(int state) { if (state != Qt::Unchecked) - m_SmoothingSpinBox->setDisabled(true); + m_Ui->smoothingSpinBox->setDisabled(true); else - m_SmoothingSpinBox->setEnabled(true); + m_Ui->smoothingSpinBox->setEnabled(true); } void QmitkSegmentationPreferencePage::OnLabelSetPresetButtonClicked() { - const auto filename = QFileDialog::getOpenFileName(m_MainControl, QStringLiteral("Load Label Set Preset"), QString(), QStringLiteral("Label set preset (*.lsetp)")); + const auto filename = QFileDialog::getOpenFileName(m_Control, QStringLiteral("Load Label Set Preset"), QString(), QStringLiteral("Label set preset (*.lsetp)")); if (!filename.isEmpty()) - m_LabelSetPresetLineEdit->setText(filename); + m_Ui->labelSetPresetLineEdit->setText(filename); } diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h index afc3b3cc8c..fc6406faa2 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePage.h @@ -1,73 +1,65 @@ /*============================================================================ 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. ============================================================================*/ #ifndef QMITKSEGMENTATIONPREFERENCEPAGE_H #define QMITKSEGMENTATIONPREFERENCEPAGE_H #include "org_mitk_gui_qt_segmentation_Export.h" #include #include -class QCheckBox; -class QRadioButton; -class QDoubleSpinBox; -class QLineEdit; -class QToolButton; +class QWidget; + +namespace Ui +{ + class QmitkSegmentationPreferencePageControls; +} class MITK_QT_SEGMENTATION QmitkSegmentationPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: QmitkSegmentationPreferencePage(); ~QmitkSegmentationPreferencePage() override; void Init(berry::IWorkbench::Pointer workbench) override; void CreateQtControl(QWidget* widget) override; QWidget* GetQtControl() const override; bool PerformOk() override; void PerformCancel() override; void Update() override; protected Q_SLOTS: void OnSmoothingCheckboxChecked(int); void OnLabelSetPresetButtonClicked(); protected: - QWidget* m_MainControl; - QCheckBox* m_SlimViewCheckBox; - QRadioButton* m_RadioOutline; - QRadioButton* m_RadioOverlay; - QCheckBox* m_SelectionModeCheckBox; - QCheckBox* m_SmoothingCheckBox; - QDoubleSpinBox* m_SmoothingSpinBox; - QDoubleSpinBox* m_DecimationSpinBox; - QDoubleSpinBox* m_ClosingSpinBox; - QLineEdit* m_LabelSetPresetLineEdit; - QToolButton* m_LabelSetPresetToolButton; + Ui::QmitkSegmentationPreferencePageControls* m_Ui; + QWidget* m_Control; bool m_Initializing; berry::IPreferences::Pointer m_SegmentationPreferencesNode; }; #endif // QMITKSEGMENTATIONPREFERENCEPAGE_H diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui new file mode 100644 index 0000000000..d0c13ebe70 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkSegmentationPreferencePageControls.ui @@ -0,0 +1,198 @@ + + + QmitkSegmentationPreferencePageControls + + + + 0 + 0 + 640 + 480 + + + + Form + + + + 8 + + + 24 + + + + + Slim view + + + + + + + Hide tool button texts and increase icon size + + + + + + + 2D display + + + + + + + + + Draw as outline + + + + + + + Draw as transparent overlay + + + + + + + + + Data node selection mode + + + + + + + If checked the segmentation plugin ensures that only the selected segmentation and the reference image are visible at one time. + + + Show only selected nodes + + + + + + + Smoothed surface creation + + + + + + + 8 + + + 8 + + + + + Smoothing value (mm) + + + + + + + The Smoothing value is used as variance for a gaussian blur. + + + 0.500000000000000 + + + 1.000000000000000 + + + + + + + Decimation rate + + + + + + + Valid range is [0, 1). High values increase decimation, especially when very close to 1. A value of 0 disables decimation. + + + 0.990000000000000 + + + 0.100000000000000 + + + 0.500000000000000 + + + + + + + Closing Ratio + + + + + + + Valid range is [0, 1]. Higher values increase closing. A value of 0 disables closing. + + + 1.000000000000000 + + + 0.100000000000000 + + + + + + + If checked the segmentation plugin ensures that only the selected segmentation and the reference image are visible at one time. + + + Use image spacing as smoothing value hint + + + + + + + + + Default label set preset + + + + + + + + + true + + + + + + + ... + + + + + + + + + +