diff --git a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.cpp b/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.cpp deleted file mode 100644 index 505e1f4059..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*============================================================================ - -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 "QmitkNewSegmentationDialog.h" -#include - -#include - -#include -#include -#include -#include - -QmitkNewSegmentationDialog::QmitkNewSegmentationDialog(QWidget *parent, Mode mode) - : QDialog(parent), - m_Ui(new Ui::QmitkNewSegmentationDialog), - m_Color(Qt::red) -{ - m_Ui->setupUi(this); - - if (RenameLabel == mode) - { - this->setWindowTitle("Rename Label"); - m_Ui->label->setText("New name and color of the label"); - m_Ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Rename label"); - } - else - { - m_Ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Create label"); - } - - auto* completer = new QCompleter(QStringList()); - completer->setCaseSensitivity(Qt::CaseInsensitive); - - m_Ui->nameLineEdit->setCompleter(completer); - m_Ui->nameLineEdit->setFocus(); - - connect(completer, qOverload(&QCompleter::activated), this, qOverload(&QmitkNewSegmentationDialog::OnSuggestionSelected)); - connect(m_Ui->colorButton, &QToolButton::clicked, this, &QmitkNewSegmentationDialog::OnColorButtonClicked); - connect(m_Ui->buttonBox, &QDialogButtonBox::accepted, this, &QmitkNewSegmentationDialog::OnAccept); - - this->UpdateColorButtonBackground(); - this->SetSuggestionList(mitk::OrganNamesHandling::GetDefaultOrganColorString()); -} - -QmitkNewSegmentationDialog::~QmitkNewSegmentationDialog() -{ -} - -void QmitkNewSegmentationDialog::UpdateColorButtonBackground() -{ - m_Ui->colorButton->setStyleSheet("background-color:" + m_Color.name()); -} - -QString QmitkNewSegmentationDialog::GetName() const -{ - return m_Name; -} - -mitk::Color QmitkNewSegmentationDialog::GetColor() const -{ - mitk::Color color; - - if (m_Color.isValid()) - { - color.SetRed(m_Color.redF()); - color.SetGreen(m_Color.greenF()); - color.SetBlue(m_Color.blueF()); - } - else - { - color.Set(1.0f, 0.0f, 0.0f); - } - - return color; -} - -void QmitkNewSegmentationDialog::SetName(const QString& name) -{ - m_Ui->nameLineEdit->setText(name); -} - -void QmitkNewSegmentationDialog::SetColor(const mitk::Color& color) -{ - m_Color.setRgbF(color.GetRed(), color.GetGreen(), color.GetBlue()); - this->UpdateColorButtonBackground(); -} - -void QmitkNewSegmentationDialog::SetSuggestionList(const QStringList& suggestionList) -{ - for (const auto& suggestion : suggestionList) - { - m_NameSuggestions.push_back(suggestion.left(suggestion.length() - 7)); - m_ColorSuggestions.push_back(suggestion.right(7)); - } - - auto* completerModel = static_cast(m_Ui->nameLineEdit->completer()->model()); - completerModel->setStringList(m_NameSuggestions); -} - -void QmitkNewSegmentationDialog::OnAccept() -{ - m_Name = m_Ui->nameLineEdit->text(); - this->accept(); -} - -void QmitkNewSegmentationDialog::OnColorButtonClicked() -{ - auto color = QColorDialog::getColor(m_Color); - - if (color.isValid()) - { - m_Color = color; - this->UpdateColorButtonBackground(); - } -} - -void QmitkNewSegmentationDialog::OnSuggestionSelected(const QString &name) -{ - auto i = m_NameSuggestions.indexOf(name); - - if (-1 != i) - { - m_Color = m_ColorSuggestions[i]; - this->UpdateColorButtonBackground(); - } -} diff --git a/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.cpp b/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.cpp deleted file mode 100644 index 143b6b5b43..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*============================================================================ - -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 "QmitkSegmentationOrganNamesHandling.h" - -#include -#include - -namespace mitk -{ - namespace OrganNamesHandling - { - QStringList GetDefaultOrganColorString() - { - QStringList organColors; - - auto presets = vtkSmartPointer::New(); - presets->LoadPreset(); - - for (const auto& preset : presets->GetColorPresets()) - { - auto organName = preset.first.c_str(); - auto color = QColor(preset.second.GetRed(), preset.second.GetGreen(), preset.second.GetBlue()); - - AppendToOrganList(organColors, organName, color); - } - return organColors; - } - - void UpdateOrganList(QStringList& organColors, const QString& organname, mitk::Color color) - { - QString listElement(organname + QColor(color.GetRed() * 255, color.GetGreen() * 255, color.GetBlue() * 255).name()); - - // remove previous definition if necessary - int oldIndex = organColors.indexOf(QRegExp(QRegExp::escape(organname) + "#......", Qt::CaseInsensitive)); - if (oldIndex < 0 || organColors.at(oldIndex) != listElement) - { - if (oldIndex >= 0) - { - organColors.removeAt(oldIndex); - } - - // add colored organ name AND sort list - organColors.append(listElement); - organColors.sort(); - } - } - - void AppendToOrganList(QStringList& organColors, const QString& organname, const QColor& color) - { - organColors.append(organname + color.name()); - } - } -} diff --git a/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.h b/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.h deleted file mode 100644 index 00e3dc7c07..0000000000 --- a/Modules/SegmentationUI/Qmitk/QmitkSegmentationOrganNamesHandling.h +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - -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 QmitkSegmentationOrganNamesHandling_h -#define QmitkSegmentationOrganNamesHandling_h - -#include - -#include - -#include -#include -#include - -namespace mitk -{ - namespace OrganNamesHandling - { - MITKSEGMENTATIONUI_EXPORT QStringList GetDefaultOrganColorString(); - MITKSEGMENTATIONUI_EXPORT void UpdateOrganList(QStringList& organColors, const QString& organname, Color color); - MITKSEGMENTATIONUI_EXPORT void AppendToOrganList(QStringList& organColors, const QString& organname, const QColor& color); - }; -} - -#endif diff --git a/Modules/SegmentationUI/files.cmake b/Modules/SegmentationUI/files.cmake index f18406bb58..54b348aa7c 100644 --- a/Modules/SegmentationUI/files.cmake +++ b/Modules/SegmentationUI/files.cmake @@ -1,89 +1,79 @@ set( CPP_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUI.cpp Qmitk/QmitkAutoSegmentationToolGUIBase.cpp Qmitk/QmitkAutoMLSegmentationToolGUIBase.cpp Qmitk/QmitkBinaryThresholdToolGUIBase.cpp Qmitk/QmitkBinaryThresholdToolGUI.cpp Qmitk/QmitkBinaryThresholdULToolGUI.cpp Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.cpp Qmitk/QmitkConfirmSegmentationDialog.cpp Qmitk/QmitkCopyToClipBoardDialog.cpp Qmitk/QmitkDrawPaintbrushToolGUI.cpp Qmitk/QmitkErasePaintbrushToolGUI.cpp Qmitk/QmitkLiveWireTool2DGUI.cpp -Qmitk/QmitkNewSegmentationDialog.cpp Qmitk/QmitkOtsuTool3DGUI.cpp Qmitk/QmitkPaintbrushToolGUI.cpp Qmitk/QmitkPickingToolGUI.cpp Qmitk/QmitkPixelManipulationToolGUI.cpp Qmitk/QmitkSlicesInterpolator.cpp Qmitk/QmitkToolGUI.cpp Qmitk/QmitkToolGUIArea.cpp Qmitk/QmitkToolSelectionBox.cpp Qmitk/QmitknnUNetToolGUI.cpp Qmitk/QmitknnUNetToolSlots.cpp -Qmitk/QmitkSegmentationOrganNamesHandling.cpp -#Added from ML -Qmitk/QmitkLabelSetWidget.cpp Qmitk/QmitkSurfaceStampWidget.cpp Qmitk/QmitkMaskStampWidget.cpp Qmitk/QmitkSliceBasedInterpolatorWidget.cpp Qmitk/QmitkStaticDynamicSegmentationDialog.cpp Qmitk/QmitkSurfaceBasedInterpolatorWidget.cpp Qmitk/QmitkSimpleLabelSetListWidget.cpp ) set(MOC_H_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUI.h Qmitk/QmitkAutoSegmentationToolGUIBase.h Qmitk/QmitkAutoMLSegmentationToolGUIBase.h Qmitk/QmitkBinaryThresholdToolGUIBase.h Qmitk/QmitkBinaryThresholdToolGUI.h Qmitk/QmitkBinaryThresholdULToolGUI.h Qmitk/QmitkCalculateGrayValueStatisticsToolGUI.h Qmitk/QmitkConfirmSegmentationDialog.h Qmitk/QmitkCopyToClipBoardDialog.h Qmitk/QmitkDrawPaintbrushToolGUI.h Qmitk/QmitkErasePaintbrushToolGUI.h Qmitk/QmitkLiveWireTool2DGUI.h -Qmitk/QmitkNewSegmentationDialog.h Qmitk/QmitkOtsuTool3DGUI.h Qmitk/QmitkPaintbrushToolGUI.h Qmitk/QmitkPickingToolGUI.h Qmitk/QmitkPixelManipulationToolGUI.h Qmitk/QmitkSlicesInterpolator.h Qmitk/QmitkToolGUI.h Qmitk/QmitkToolGUIArea.h Qmitk/QmitkToolSelectionBox.h Qmitk/QmitknnUNetToolGUI.h Qmitk/QmitknnUNetGPU.h Qmitk/QmitknnUNetEnsembleLayout.h Qmitk/QmitknnUNetFolderParser.h -#Added from ML -Qmitk/QmitkLabelSetWidget.h Qmitk/QmitkSurfaceStampWidget.h Qmitk/QmitkMaskStampWidget.h Qmitk/QmitkSliceBasedInterpolatorWidget.h Qmitk/QmitkStaticDynamicSegmentationDialog.h Qmitk/QmitkSurfaceBasedInterpolatorWidget.h Qmitk/QmitkSimpleLabelSetListWidget.h ) set(UI_FILES Qmitk/QmitkAdaptiveRegionGrowingToolGUIControls.ui Qmitk/QmitkConfirmSegmentationDialog.ui Qmitk/QmitkOtsuToolWidgetControls.ui Qmitk/QmitkLiveWireTool2DGUIControls.ui -Qmitk/QmitkNewSegmentationDialog.ui -#Added from ML -Qmitk/QmitkLabelSetWidgetControls.ui Qmitk/QmitkSurfaceStampWidgetGUIControls.ui Qmitk/QmitkMaskStampWidgetGUIControls.ui Qmitk/QmitkSliceBasedInterpolatorWidgetGUIControls.ui Qmitk/QmitkSurfaceBasedInterpolatorWidgetGUIControls.ui Qmitk/QmitknnUNetToolGUIControls.ui ) set(QRC_FILES resources/SegmentationUI.qrc ) diff --git a/Plugins/org.mitk.gui.qt.multilabelsegmentation/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.multilabelsegmentation/manifest_headers.cmake index 54eb90ad33..97ba4ee1c4 100644 --- a/Plugins/org.mitk.gui.qt.multilabelsegmentation/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.multilabelsegmentation/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK MultiLabelSegmentation") set(Plugin-Version "1.0.0") set(Plugin-Vendor "German Cancer Research Center (DKFZ)") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.datamanager) +set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.datamanager org.mitk.gui.qt.segmentation) diff --git a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui index 1f2ad71121..2d8cf565c5 100644 --- a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui +++ b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/ImageMasking/QmitkImageMaskingWidgetControls.ui @@ -1,274 +1,274 @@ QmitkImageMaskingWidgetControls 0 0 179 296 2 4 0 Masks 3 4 0 0 Masking Mode Image Masking true Surface Masking Mask make output binary overwrite foreground overwrite background Background Value: Qt::Horizontal 40 20 50 0 50 16777215 0.0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Foreground Value: Qt::Horizontal 40 20 50 0 50 16777215 1.0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Qt::Vertical 20 40 Labels 4 0 0 0 50 Qt::Vertical 20 40 QmitkDataSelectionWidget QWidget
internal/Common/QmitkDataSelectionWidget.h
QmitkLabelSetWidget QWidget -
Qmitk/QmitkLabelSetWidget.h
+
QmitkLabelSetWidget.h
1
QmitkMaskStampWidget QWidget
QmitkMaskStampWidget.h
1
diff --git a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui index 976fffbdc3..0e8a3c92b5 100644 --- a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui +++ b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/MorphologicalOperations/QmitkMorphologicalOperationsWidgetControls.ui @@ -1,427 +1,427 @@ QmitkMorphologicalOperationsWidgetControls 0 0 155 414 0 0 0 Masks 3 4 0 0 Structuring Element Ball true Cross Radius 1 20 1 Qt::Horizontal 1 20 false 0 0 Dilatation :/SegmentationUtilities/MorphologicalOperations/Dilate_48x48.png:/SegmentationUtilities/MorphologicalOperations/Dilate_48x48.png 32 32 Qt::ToolButtonTextUnderIcon false 0 0 Globally fills holes in segmentation (radius not required) Fill Holes :/SegmentationUtilities/MorphologicalOperations/FillHoles_48x48.png:/SegmentationUtilities/MorphologicalOperations/FillHoles_48x48.png 32 32 Qt::ToolButtonTextUnderIcon false 0 0 Erosion :/SegmentationUtilities/MorphologicalOperations/Erode_48x48.png:/SegmentationUtilities/MorphologicalOperations/Erode_48x48.png 32 32 Qt::ToolButtonTextUnderIcon false 0 0 Closing :/SegmentationUtilities/MorphologicalOperations/Closing_48x48.png:/SegmentationUtilities/MorphologicalOperations/Closing_48x48.png 32 32 Qt::ToolButtonTextUnderIcon false 0 0 Opening :/SegmentationUtilities/MorphologicalOperations/Opening_48x48.png:/SegmentationUtilities/MorphologicalOperations/Opening_48x48.png 32 32 Qt::ToolButtonTextUnderIcon Qt::Vertical 20 40 Labels 3 4 0 0 0 50 0 0 15 0 50 false 0 0 0 15 50 false Qt::Vertical 20 40 QmitkDataSelectionWidget QWidget
internal/Common/QmitkDataSelectionWidget.h
1
QmitkToolSelectionBox QWidget
QmitkToolSelectionBox.h
QmitkToolGUIArea QWidget
QmitkToolGUIArea.h
QmitkLabelSetWidget QWidget -
Qmitk/QmitkLabelSetWidget.h
+
QmitkLabelSetWidget.h
1
sliderMorphFactor valueChanged(int) spinBoxMorphFactor setValue(int) 240 27 766 36 spinBoxMorphFactor valueChanged(int) sliderMorphFactor setValue(int) 784 38 657 38
diff --git a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui index 511fcc381f..52b7fc86e4 100644 --- a/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui +++ b/Plugins/org.mitk.gui.qt.multilabelsegmentation/src/internal/SegmentationUtilities/SurfaceToImage/QmitkSurfaceToImageWidgetControls.ui @@ -1,252 +1,252 @@ QmitkSurfaceToImageWidgetControls 0 0 179 183 3 4 0 Masks 3 4 0 0 make output binary overwrite background Background Value: Qt::Horizontal 40 20 50 0 50 16777215 0.0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Foreground Value: Qt::Horizontal 40 20 50 0 50 16777215 1.0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Convert Qt::Vertical 20 40 Labels 2 2 0 0 0 50 0 20 Qt::Vertical 20 40 QmitkDataSelectionWidget QWidget
internal/Common/QmitkDataSelectionWidget.h
1
QmitkLabelSetWidget QWidget -
Qmitk/QmitkLabelSetWidget.h
+
QmitkLabelSetWidget.h
1
QmitkSurfaceStampWidget QWidget
QmitkSurfaceStampWidget.h
1
diff --git a/Plugins/org.mitk.gui.qt.segmentation/files.cmake b/Plugins/org.mitk.gui.qt.segmentation/files.cmake index bb27b67836..584a0cf103 100644 --- a/Plugins/org.mitk.gui.qt.segmentation/files.cmake +++ b/Plugins/org.mitk.gui.qt.segmentation/files.cmake @@ -1,81 +1,87 @@ set(SRC_CPP_FILES QmitkSegmentationPreferencePage.cpp + QmitkNewSegmentationDialog.cpp + QmitkLabelSetWidget.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/QmitkNewSegmentationDialog.ui + src/QmitkLabelSetWidgetControls.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/QmitkNewSegmentationDialog.h + src/QmitkLabelSetWidget.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/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidget.cpp similarity index 100% rename from Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.cpp rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidget.cpp diff --git a/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidget.h similarity index 95% rename from Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidget.h index 727e02f34a..9fb7a1c0e8 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidget.h +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidget.h @@ -1,165 +1,165 @@ /*============================================================================ 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 QmitkLabelSetWidget_h #define QmitkLabelSetWidget_h -#include "MitkSegmentationUIExports.h" +#include -#include "mitkColorSequenceRainbow.h" -#include "mitkLabel.h" -#include "mitkNumericTypes.h" +#include +#include +#include #include class QmitkDataStorageComboBox; class QCompleter; namespace mitk { class LabelSetImage; class LabelSet; class Label; class DataStorage; class ToolManager; class DataNode; } -class MITKSEGMENTATIONUI_EXPORT QmitkLabelSetWidget : public QWidget +class MITK_QT_SEGMENTATION QmitkLabelSetWidget : public QWidget { Q_OBJECT public: explicit QmitkLabelSetWidget(QWidget *parent = nullptr); ~QmitkLabelSetWidget() override; void SetDataStorage(mitk::DataStorage *storage); void UpdateControls(); virtual void setEnabled(bool enabled); QStringList &GetLabelStringList(); signals: /// \brief Send a signal when it was requested to go to a label. void goToLabel(const mitk::Point3D &); void LabelSetWidgetReset(); public slots: /** * @brief Updates the current labels in the label set widget table. For each label (widget item) the 'UpdateTableWidgetItem' is called. * * Updating means setting the color box of the table, setting the column with and fill it with the label name. * Furthermore the two push buttons for locking and showing/hiding the layer are checked/unchecked. * This functions only changes the appearance of the table widget and no render window update is necessary. */ void UpdateAllTableWidgetItems(); /** * @brief Resets the current labels in the label set widget table. For each label a widget item is inserted into the table. * * Resetting means removing all rows of the widget table and inserting new rows (labels) from the active label set (= layer) of the current working node. * The currently active label is selected and 'Number of labels' is set. * As this function is typically used after one label has been removed or the reference node has been changed (e.g.) the render windows have to be updated. */ void ResetAllTableWidgetItems(); void SelectLabelByPixelValue(mitk::Label::PixelType pixelValue); private slots: // LabelSet dependent void OnOpacityChanged(int); void OnUnlockAllLabels(bool); void OnLockAllLabels(bool); void OnSetAllLabelsVisible(bool); void OnSetAllLabelsInvisible(bool); void OnSetOnlyActiveLabelVisible(bool); void OnRandomColor(bool); void OnRemoveLabel(bool); void OnRemoveLabels(bool); void OnRenameLabel(bool); void OnLockedButtonClicked(); void OnVisibleButtonClicked(); void OnColorButtonClicked(); void OnItemClicked(QTableWidgetItem *item); void OnItemDoubleClicked(QTableWidgetItem *item); void OnTableViewContextMenuRequested(const QPoint &); void InsertTableWidgetItem(mitk::Label *label); void UpdateTableWidgetItem(QTableWidgetItem *item); // reaction to "returnPressed" signal from ... void OnSearchLabel(); // reaction to the button "Change Label" void OnActiveLabelChanged(int pixelValue); // LabelSetImage Dependet void OnCreateDetailedSurface(bool); void OnCreateSmoothedSurface(bool); // reaction to the signal "createMask" from QmitkLabelSetTableWidget void OnCreateMask(bool); void OnCreateMasks(bool); // reaction to the signal "createCroppedMask" from QmitkLabelSetTableWidget void OnCreateCroppedMask(bool); void OnCombineAndCreateMask(bool); void OnCombineAndCreateSurface(bool); void OnEraseLabel(bool); void OnEraseLabels(bool); void OnMergeLabels(bool); // reaction to signal "labelListModified" from QmitkLabelSetTableWidget void OnLabelListModified(const QStringList &list); // reaction to the signal "toggleOutline" from QmitkLabelSetTableWidget void OnToggleOutline(bool); private: enum TableColumns { NAME_COL = 0, LOCKED_COL, COLOR_COL, VISIBLE_COL }; void WaitCursorOn(); void WaitCursorOff(); void RestoreOverrideCursor(); void OnThreadedCalculationDone(); void InitializeTableWidget(); int GetPixelValueOfSelectedItem(); mitk::LabelSetImage *GetWorkingImage(); mitk::DataNode *GetWorkingNode(); Ui::QmitkLabelSetWidgetControls m_Controls; mitk::ColorSequenceRainbow m_ColorSequenceRainbow; mitk::DataStorage *m_DataStorage; QCompleter *m_Completer; mitk::ToolManager *m_ToolManager; QStringList m_OrganColors; QStringList m_LabelStringList; bool m_ProcessingManualSelection; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkLabelSetWidgetControls.ui b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidgetControls.ui similarity index 100% rename from Modules/SegmentationUI/Qmitk/QmitkLabelSetWidgetControls.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkLabelSetWidgetControls.ui diff --git a/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.cpp b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.cpp new file mode 100644 index 0000000000..4b88755b47 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.cpp @@ -0,0 +1,276 @@ +/*============================================================================ + +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 "QmitkNewSegmentationDialog.h" +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + // Get standard label name and color suggestions from embedded XML preset file for anatomical structures. + std::map GetStandardSuggestions() + { + std::map standardSuggestions; + + vtkNew presets; + presets->LoadPreset(); + + for (const auto& preset : presets->GetColorPresets()) + { + auto name = QString::fromStdString(preset.first); + auto color = QColor::fromRgbF(preset.second.GetRed(), preset.second.GetGreen(), preset.second.GetBlue()); + standardSuggestions.emplace(name, color); + } + + return standardSuggestions; + } + + // Parse label name and color suggestions from a JSON file. An array of objects is expected, each consisting + // of a "name" string and an optional "color" string. If present, the "color" string must follow the conventions + // of QColor::setNamedColor(), i.e., #rrggbb or any SVG color keyword name like CornflowerBlue. Everything else + // in the JSON file is simply ignored. In case of any error, an empty map is returned. + std::map ParseSuggestions(const QString& filename) + { + std::map parsedSuggestions; + QFile file(filename); + + if (!file.open(QIODevice::ReadOnly)) + { + MITK_ERROR << "Could not open \"" << filename.toStdString() << "\"!"; + return parsedSuggestions; + } + + auto json = file.readAll(); + auto doc = QJsonDocument::fromJson(json); + + if (doc.isNull() || !doc.isArray()) + { + MITK_ERROR << "Could not parse \"" << filename.toStdString() << "\" as JSON array!"; + return parsedSuggestions; + } + + auto array = doc.array(); + + for (auto valueRef : array) + { + if (valueRef.isObject()) + { + auto object = valueRef.toObject(); + + if (object.contains("name") && object["name"].isString()) + { + auto name = object["name"].toString(); + auto color = object.contains("color") && object["color"].isString() + ? QColor(object["color"].toString()) + : QColor(QColor::Invalid); + + parsedSuggestions.emplace(name, color); + } + } + } + + if (parsedSuggestions.empty()) + MITK_WARN << "Could not parse any suggestions from \"" << filename.toStdString() << "\"!"; + + return parsedSuggestions; + } + + struct Preferences + { + QString labelSuggestions; + bool replaceStandardSuggestions; + bool suggestOnce; + }; + + Preferences GetPreferences() + { + auto nodePrefs = berry::Platform::GetPreferencesService()->GetSystemPreferences()->Node("/org.mitk.views.segmentation"); + + Preferences prefs; + + prefs.labelSuggestions = QString::fromStdString(mitk::BaseApplication::instance().config().getString(mitk::BaseApplication::ARG_SEGMENTATION_LABEL_SUGGESTIONS.toStdString(), "")); + + if (prefs.labelSuggestions.isEmpty()) + prefs.labelSuggestions = nodePrefs->Get("label suggestions", ""); + + prefs.replaceStandardSuggestions = nodePrefs->GetBool("replace standard suggestions", true); + prefs.suggestOnce = nodePrefs->GetBool("suggest once", true); + + return prefs; + } +} + +QmitkNewSegmentationDialog::QmitkNewSegmentationDialog(QWidget *parent, Mode mode) + : QDialog(parent), + m_Ui(new Ui::QmitkNewSegmentationDialog), + m_SuggestOnce(true), + m_Color(Qt::red) +{ + m_Ui->setupUi(this); + + if (RenameLabel == mode) + { + this->setWindowTitle("Rename Label"); + m_Ui->label->setText("New name and color of the label"); + m_Ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Rename label"); + } + else + { + m_Ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Create label"); + } + + auto* completer = new QCompleter(QStringList()); + completer->setCaseSensitivity(Qt::CaseInsensitive); + + m_Ui->nameLineEdit->setCompleter(completer); + m_Ui->nameLineEdit->setFocus(); + + connect(completer, qOverload(&QCompleter::activated), this, qOverload(&QmitkNewSegmentationDialog::OnSuggestionSelected)); + connect(m_Ui->colorButton, &QToolButton::clicked, this, &QmitkNewSegmentationDialog::OnColorButtonClicked); + connect(m_Ui->buttonBox, &QDialogButtonBox::accepted, this, &QmitkNewSegmentationDialog::OnAccept); + + this->UpdateColorButtonBackground(); + + auto prefs = GetPreferences(); + + if (!prefs.labelSuggestions.isEmpty()) + { + auto suggestions = ParseSuggestions(prefs.labelSuggestions); + this->SetSuggestions(suggestions, prefs.replaceStandardSuggestions && !suggestions.empty()); + } + else + { + this->SetSuggestions(GetStandardSuggestions(), true); + } + + if (prefs.suggestOnce) + { + // TODO: Remove suggestions for label names that are already preset in the label set image + } +} + +QmitkNewSegmentationDialog::~QmitkNewSegmentationDialog() +{ +} + +void QmitkNewSegmentationDialog::UpdateColorButtonBackground() +{ + m_Ui->colorButton->setStyleSheet("background-color:" + m_Color.name()); +} + +QString QmitkNewSegmentationDialog::GetName() const +{ + return m_Name; +} + +mitk::Color QmitkNewSegmentationDialog::GetColor() const +{ + mitk::Color color; + + if (m_Color.isValid()) + { + color.SetRed(m_Color.redF()); + color.SetGreen(m_Color.greenF()); + color.SetBlue(m_Color.blueF()); + } + else + { + color.Set(1.0f, 0.0f, 0.0f); + } + + return color; +} + +void QmitkNewSegmentationDialog::SetName(const QString& name) +{ + m_Ui->nameLineEdit->setText(name); +} + +void QmitkNewSegmentationDialog::SetColor(const mitk::Color& color) +{ + m_Color.setRgbF(color.GetRed(), color.GetGreen(), color.GetBlue()); + this->UpdateColorButtonBackground(); +} + +void QmitkNewSegmentationDialog::SetSuggestions(const std::map suggestions, bool replaceStandardSuggestions) +{ + if (replaceStandardSuggestions) + { + m_Suggestions = suggestions; + } + else + { + m_Suggestions = GetStandardSuggestions(); + + for (const auto& [name, color] : suggestions) + { + if (m_Suggestions.end() == m_Suggestions.find(name)) + m_Suggestions[name] = color; + } + } + + QStringList names; + + for (const auto& [name, color] : m_Suggestions) + names << name; + + auto* completerModel = static_cast(m_Ui->nameLineEdit->completer()->model()); + completerModel->setStringList(names); +} + +void QmitkNewSegmentationDialog::OnAccept() +{ + m_Name = m_Ui->nameLineEdit->text(); + this->accept(); +} + +void QmitkNewSegmentationDialog::OnColorButtonClicked() +{ + auto color = QColorDialog::getColor(m_Color); + + if (color.isValid()) + { + m_Color = color; + this->UpdateColorButtonBackground(); + } +} + +void QmitkNewSegmentationDialog::OnSuggestionSelected(const QString &name) +{ + auto color = m_Suggestions[name]; + + if (color.isValid()) + { + m_Color = color; + this->UpdateColorButtonBackground(); + } +} diff --git a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.h similarity index 72% rename from Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.h index 3b9f4bc4a3..4a612ff313 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.h +++ b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.h @@ -1,68 +1,72 @@ /*============================================================================ 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 QmitkNewSegmentationDialog_h_Included -#define QmitkNewSegmentationDialog_h_Included +#ifndef QmitkNewSegmentationDialog_h +#define QmitkNewSegmentationDialog_h + +#include #include -#include -#include +#include +#include #include +#include namespace Ui { class QmitkNewSegmentationDialog; } /** \brief Dialog for naming labels. */ -class MITKSEGMENTATIONUI_EXPORT QmitkNewSegmentationDialog : public QDialog +class MITK_QT_SEGMENTATION QmitkNewSegmentationDialog : public QDialog { Q_OBJECT public: enum Mode { NewLabel, RenameLabel }; explicit QmitkNewSegmentationDialog(QWidget *parent = nullptr, Mode mode = NewLabel); ~QmitkNewSegmentationDialog() override; QString GetName() const; mitk::Color GetColor() const; void SetName(const QString& name); void SetColor(const mitk::Color& color); - void SetSuggestionList(const QStringList& suggestionList); private: void OnAccept(); void OnSuggestionSelected(const QString& name); void OnColorButtonClicked(); + void SetSuggestions(const std::map suggestions, bool replaceStandardSuggestions = false); void UpdateColorButtonBackground(); Ui::QmitkNewSegmentationDialog* m_Ui; + bool m_SuggestOnce; + QString m_Name; QColor m_Color; - QStringList m_NameSuggestions; - QList m_ColorSuggestions; + std::map m_Suggestions; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.ui b/Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.ui similarity index 100% rename from Modules/SegmentationUI/Qmitk/QmitkNewSegmentationDialog.ui rename to Plugins/org.mitk.gui.qt.segmentation/src/QmitkNewSegmentationDialog.ui diff --git a/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake index 9da36a3fbc..a413decc69 100644 --- a/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.semanticrelations/manifest_headers.cmake @@ -1,5 +1,5 @@ set(Plugin-Name "MITK Semantic relations") set(Plugin-Version "0.1") set(Plugin-Vendor "DKFZ") set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.application) +set(Require-Plugin org.mitk.gui.qt.common org.mitk.gui.qt.application org.mitk.gui.qt.segmentation)