diff --git a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp index ab73908250..e4d6db1064 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.cpp @@ -1,154 +1,165 @@ /*=================================================================== 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 "QmitkOtsuTool3DGUI.h" #include "QmitkConfirmSegmentationDialog.h" #include #include #include #include #include #include MITK_TOOL_GUI_MACRO(MitkSegmentationUI_EXPORT, QmitkOtsuTool3DGUI, "") QmitkOtsuTool3DGUI::QmitkOtsuTool3DGUI() :QmitkToolGUI(), m_NumberOfRegions(0) { m_Controls.setupUi(this); connect( m_Controls.previewButton, SIGNAL(clicked()), this, SLOT(OnSpinboxValueAccept())); connect(m_Controls.m_selectionListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnItemSelectionChanged())); connect( m_Controls.m_ConfSegButton, SIGNAL(clicked()), this, SLOT(OnSegmentationRegionAccept())); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); + connect(m_Controls.advancedSettingsButton, SIGNAL(toggled(bool)), this, SLOT(OnAdvancedSettingsButtonToggled(bool))); + + this->OnAdvancedSettingsButtonToggled(false); } QmitkOtsuTool3DGUI::~QmitkOtsuTool3DGUI() { } void QmitkOtsuTool3DGUI::OnItemSelectionChanged() { m_SelectedItems = m_Controls.m_selectionListWidget->selectedItems(); if (m_SelectedItems.size() == 0) { m_Controls.m_ConfSegButton->setEnabled( false ); m_OtsuTool3DTool->ShowMultiLabelResultNode(true); return; } if (m_OtsuTool3DTool.IsNotNull()) { // update preview of region QList::Iterator it; std::vector regionIDs; for (it = m_SelectedItems.begin(); it != m_SelectedItems.end(); ++it) regionIDs.push_back((*it)->text().toInt()); m_OtsuTool3DTool->UpdateBinaryPreview(regionIDs); + m_Controls.m_ConfSegButton->setEnabled( true ); } } +void QmitkOtsuTool3DGUI::OnAdvancedSettingsButtonToggled(bool toggled) +{ + m_Controls.m_ValleyCheckbox->setVisible(toggled); + m_Controls.binLabel->setVisible(toggled); + m_Controls.m_BinsSpinBox->setVisible(toggled); +} + void QmitkOtsuTool3DGUI::OnNewToolAssociated(mitk::Tool* tool) { m_OtsuTool3DTool = dynamic_cast( tool ); } void QmitkOtsuTool3DGUI::OnSegmentationRegionAccept() { QmitkConfirmSegmentationDialog dialog; QString segName = QString::fromStdString(m_OtsuTool3DTool->GetCurrentSegmentationName()); dialog.SetSegmentationName(segName); int result = dialog.exec(); switch(result) { case QmitkConfirmSegmentationDialog::CREATE_NEW_SEGMENTATION: m_OtsuTool3DTool->SetOverwriteExistingSegmentation(false); break; case QmitkConfirmSegmentationDialog::OVERWRITE_SEGMENTATION: m_OtsuTool3DTool->SetOverwriteExistingSegmentation(true); break; case QmitkConfirmSegmentationDialog::CANCEL_SEGMENTATION: return; } if (m_OtsuTool3DTool.IsNotNull() && m_Controls.m_selectionListWidget->currentItem() != NULL) { m_OtsuTool3DTool->ConfirmSegmentation(); } } void QmitkOtsuTool3DGUI::OnSpinboxValueAccept() { if( m_NumberOfRegions == m_Controls.m_Spinbox->value() && m_UseValleyEmphasis == m_Controls.m_ValleyCheckbox->isChecked() && m_NumberOfBins == m_Controls.m_BinsSpinBox->value() ) return; if (m_OtsuTool3DTool.IsNotNull()) { try { m_NumberOfRegions = m_Controls.m_Spinbox->value(); m_UseValleyEmphasis = m_Controls.m_ValleyCheckbox->isChecked(); m_NumberOfBins = m_Controls.m_BinsSpinBox->value(); int proceed; QMessageBox* messageBox = new QMessageBox(QMessageBox::Question, NULL, "The otsu segmentation computation may take several minutes depending on the number of Regions you selected. Proceed anyway?", QMessageBox::Ok | QMessageBox::Cancel); if (m_NumberOfRegions >= 5) { proceed = messageBox->exec(); if (proceed != QMessageBox::Ok) return; } this->setCursor(Qt::WaitCursor); m_OtsuTool3DTool->RunSegmentation( m_NumberOfRegions, m_UseValleyEmphasis, m_NumberOfBins ); this->setCursor(Qt::ArrowCursor); } catch( ... ) { this->setCursor(Qt::ArrowCursor); QMessageBox* messageBox = new QMessageBox(QMessageBox::Critical, NULL, "itkOtsuFilter error: image dimension must be in {2, 3} and no RGB images can be handled."); messageBox->exec(); delete messageBox; return; } //insert regions into widget QString itemName; QListWidgetItem* item; m_Controls.m_selectionListWidget->clear(); for(int i=0; ivalue(); ++i) { itemName = QString::number(i); item = new QListWidgetItem(itemName); m_Controls.m_selectionListWidget->addItem(item); } //deactivate 'confirm segmentation'-button m_Controls.m_ConfSegButton->setEnabled(false); } } void QmitkOtsuTool3DGUI::OnVolumePreviewChecked(int state) { if (state == 1) { } } diff --git a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h index 963448e38f..c855b7dd7f 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuTool3DGUI.h @@ -1,82 +1,86 @@ /*=================================================================== 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. ===================================================================*/ #ifndef QmitkOtsuTool3DGUI_h_Included #define QmitkOtsuTool3DGUI_h_Included #include "QmitkToolGUI.h" #include #include "mitkOtsuTool3D.h" #include #include #include "ui_QmitkOtsuToolWidgetControls.h" class QSpinBox; class QLabel; /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::. \sa mitk:: This GUI shows ... Last contributor: $Author$ */ class MitkSegmentationUI_EXPORT QmitkOtsuTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkOtsuTool3DGUI, QmitkToolGUI); itkFactorylessNewMacro(Self) itkCloneMacro(Self) signals: public slots: protected slots: void OnNewToolAssociated(mitk::Tool*); void OnSpinboxValueAccept(); void OnSegmentationRegionAccept(); void OnItemSelectionChanged(); void OnVolumePreviewChecked(int); + private slots: + + void OnAdvancedSettingsButtonToggled(bool toggled); + protected: QmitkOtsuTool3DGUI(); virtual ~QmitkOtsuTool3DGUI(); mitk::OtsuTool3D::Pointer m_OtsuTool3DTool; Ui_QmitkOtsuToolWidgetControls m_Controls; int m_NumberOfRegions; bool m_UseValleyEmphasis; int m_NumberOfBins; QList m_SelectedItems; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkOtsuToolWidgetControls.ui b/Modules/SegmentationUI/Qmitk/QmitkOtsuToolWidgetControls.ui index cf2c978876..0866bc4432 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkOtsuToolWidgetControls.ui +++ b/Modules/SegmentationUI/Qmitk/QmitkOtsuToolWidgetControls.ui @@ -1,192 +1,214 @@ QmitkOtsuToolWidgetControls 0 0 192 - 239 + 293 0 0 100 0 100000 100000 QmitkOtsuToolWidget Move to adjust the segmentation - - QLayout::SetDefaultConstraint - - - 0 - QLayout::SetNoConstraint 0 0 Number of Regions: 0 0 40 16777215 2 32 - - + + + + 0 + 0 + + + + + 0 + 32 + + + + Advanced settings + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + Use Valley Emphasis - - - - - - + + Number of Histogram Bins: - + 2 2048 128 0 0 10000000 100 0 QAbstractItemView::MultiSelection QListView::Adjust 0 0 100000 16777215 Preview false 0 0 100000 16777215 Confirm Segmentation + + + ctkExpandButton + QToolButton +
ctkExpandButton.h
+
+