diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp index 6d6c466570..a93f2d7737 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.cpp @@ -1,354 +1,357 @@ /*=================================================================== 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 "QmitkFastMarchingTool3DGUI.h" #include "QmitkConfirmSegmentationDialog.h" #include #include #include #include #include #include #include #include #include "mitkStepper.h" #include "mitkBaseRenderer.h" MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkFastMarchingTool3DGUI, "") QmitkFastMarchingTool3DGUI::QmitkFastMarchingTool3DGUI() :QmitkToolGUI(), m_TimeIsConnected(false) { this->setContentsMargins( 0, 0, 0, 0 ); // create the visible widgets QVBoxLayout *widgetLayout = new QVBoxLayout(this); widgetLayout->setContentsMargins(0, 0, 0, 0); QFont fntHelp; fntHelp.setBold(true); QLabel *lblHelp = new QLabel(this); lblHelp->setText("Press shift-click to add seeds repeatedly."); lblHelp->setFont(fntHelp); widgetLayout->addWidget(lblHelp); // Sigma controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Sigma: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addItem(hlayout); } m_slSigma = new ctkSliderWidget(this); m_slSigma->setMinimum(0.1); m_slSigma->setMaximum(5.0); m_slSigma->setPageStep(0.1); m_slSigma->setSingleStep(0.01); m_slSigma->setValue(1.0); m_slSigma->setDecimals(2); m_slSigma->setTracking(false); m_slSigma->setToolTip("The \"sigma\" parameter in the Gradient Magnitude filter."); connect( m_slSigma, SIGNAL(valueChanged(double)), this, SLOT(OnSigmaChanged(double))); widgetLayout->addWidget( m_slSigma ); // Alpha controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Alpha: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addItem(hlayout); } m_slAlpha = new ctkSliderWidget(this); m_slAlpha->setMinimum(-10); m_slAlpha->setMaximum(0); m_slAlpha->setPageStep(0.1); m_slAlpha->setSingleStep(0.01); m_slAlpha->setValue(-2.5); m_slAlpha->setDecimals(2); m_slAlpha->setTracking(false); m_slAlpha->setToolTip("The \"alpha\" parameter in the Sigmoid mapping filter."); connect( m_slAlpha, SIGNAL(valueChanged(double)), this, SLOT(OnAlphaChanged(double))); widgetLayout->addWidget( m_slAlpha ); // Beta controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Beta: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slBeta = new ctkSliderWidget(this); m_slBeta->setMinimum(0); m_slBeta->setMaximum(100); m_slBeta->setPageStep(0.1); m_slBeta->setSingleStep(0.01); m_slBeta->setValue(3.5); m_slBeta->setDecimals(2); m_slBeta->setTracking(false); m_slBeta->setToolTip("The \"beta\" parameter in the Sigmoid mapping filter."); connect( m_slBeta, SIGNAL(valueChanged(double)), this, SLOT(OnBetaChanged(double))); widgetLayout->addWidget( m_slBeta ); // stopping value controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Stopping value: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slStoppingValue = new ctkSliderWidget(this); m_slStoppingValue->setMinimum(0); m_slStoppingValue->setMaximum(10000); m_slStoppingValue->setPageStep(10); m_slStoppingValue->setSingleStep(1); m_slStoppingValue->setValue(2000); m_slStoppingValue->setDecimals(0); m_slStoppingValue->setTracking(false); m_slStoppingValue->setToolTip("The \"stopping value\" parameter in the fast marching 3D algorithm"); connect( m_slStoppingValue, SIGNAL(valueChanged(double)), this, SLOT(OnStoppingValueChanged(double))); widgetLayout->addWidget( m_slStoppingValue ); // threshold controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Threshold: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slwThreshold = new ctkRangeWidget(this); m_slwThreshold->setMinimum(-100); m_slwThreshold->setMaximum(5000); m_slwThreshold->setMinimumValue(-100); m_slwThreshold->setMaximumValue(2000); m_slwThreshold->setDecimals(0); m_slwThreshold->setTracking(false); m_slwThreshold->setToolTip("The lower and upper thresholds for the final thresholding"); connect( m_slwThreshold, SIGNAL(valuesChanged(double, double)), this, SLOT(OnThresholdChanged(double, double))); widgetLayout->addWidget( m_slwThreshold ); m_btClearSeeds = new QPushButton("Clear"); m_btClearSeeds->setToolTip("Clear current result and start over again"); widgetLayout->addWidget(m_btClearSeeds); connect( m_btClearSeeds, SIGNAL(clicked()), this, SLOT(OnClearSeeds()) ); m_btConfirm = new QPushButton("Accept"); m_btConfirm->setToolTip("Incorporate current result in your working session."); m_btConfirm->setEnabled(false); widgetLayout->addWidget(m_btConfirm); connect( m_btConfirm, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation()) ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); + + this->setEnabled(false); } QmitkFastMarchingTool3DGUI::~QmitkFastMarchingTool3DGUI() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); - m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::EnableConfirmButton) ); + m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::OnFastMarchingToolReady) ); } } void QmitkFastMarchingTool3DGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); - m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::EnableConfirmButton) ); + m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::OnFastMarchingToolReady) ); } m_FastMarchingTool = dynamic_cast( tool ); if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy += mitk::MessageDelegate1( this, &QmitkFastMarchingTool3DGUI::BusyStateChanged ); - m_FastMarchingTool->AddReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::EnableConfirmButton) ); + m_FastMarchingTool->AddReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingTool3DGUI::OnFastMarchingToolReady) ); //listen to timestep change events mitk::BaseRenderer::Pointer renderer; renderer = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1") ); if (renderer.IsNotNull() && !m_TimeIsConnected) { new QmitkStepperAdapter(this, renderer->GetSliceNavigationController()->GetTime(), "stepper"); // connect(m_TimeStepper, SIGNAL(Refetch()), this, SLOT(Refetch())); m_TimeIsConnected = true; } } } void QmitkFastMarchingTool3DGUI::Update() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLowerThreshold( this->m_slwThreshold->minimumValue()); m_FastMarchingTool->SetUpperThreshold( this->m_slwThreshold->maximumValue()); m_FastMarchingTool->SetStoppingValue( this->m_slStoppingValue->value()); m_FastMarchingTool->SetSigma( this->m_slSigma->value()); m_FastMarchingTool->SetAlpha( this->m_slAlpha->value()); m_FastMarchingTool->SetBeta( this->m_slBeta->value()); m_FastMarchingTool->Update(); } } void QmitkFastMarchingTool3DGUI::OnThresholdChanged(double lower, double upper) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLowerThreshold( lower ); m_FastMarchingTool->SetUpperThreshold( upper ); this->Update(); } } void QmitkFastMarchingTool3DGUI::OnBetaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetBeta( value ); this->Update(); } } void QmitkFastMarchingTool3DGUI::OnSigmaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetSigma( value ); this->Update(); } } void QmitkFastMarchingTool3DGUI::OnAlphaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetAlpha( value ); this->Update(); } } void QmitkFastMarchingTool3DGUI::OnStoppingValueChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetStoppingValue( value ); this->Update(); } } void QmitkFastMarchingTool3DGUI::OnConfirmSegmentation() { QmitkConfirmSegmentationDialog dialog; QString segName = QString::fromStdString(m_FastMarchingTool->GetCurrentSegmentationName()); dialog.SetSegmentationName(segName); int result = dialog.exec(); switch(result) { case QmitkConfirmSegmentationDialog::CREATE_NEW_SEGMENTATION: m_FastMarchingTool->SetOverwriteExistingSegmentation(false); break; case QmitkConfirmSegmentationDialog::OVERWRITE_SEGMENTATION: m_FastMarchingTool->SetOverwriteExistingSegmentation(true); break; case QmitkConfirmSegmentationDialog::CANCEL_SEGMENTATION: return; } if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->ConfirmSegmentation(); m_btConfirm->setEnabled(false); } } void QmitkFastMarchingTool3DGUI::SetStepper(mitk::Stepper *stepper) { this->m_TimeStepper = stepper; } void QmitkFastMarchingTool3DGUI::Refetch() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->SetCurrentTimeStep(m_TimeStepper->GetPos()); } void QmitkFastMarchingTool3DGUI::OnClearSeeds() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->ClearSeeds(); m_btConfirm->setEnabled(false); this->Update(); } void QmitkFastMarchingTool3DGUI::BusyStateChanged(bool value) { if (value) QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); else QApplication::restoreOverrideCursor(); } -void QmitkFastMarchingTool3DGUI::EnableConfirmButton() +void QmitkFastMarchingTool3DGUI::OnFastMarchingToolReady() { + this->setEnabled(true); this->m_btConfirm->setEnabled(true); } diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h index d195b9bce5..f03aa0b09f 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingTool3DGUI.h @@ -1,86 +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 QmitkFastMarchingTool3DGUI_h_Included #define QmitkFastMarchingTool3DGUI_h_Included #include "QmitkToolGUI.h" #include "SegmentationUIExports.h" #include "mitkFastMarchingTool3D.h" class ctkSliderWidget; class ctkRangeWidget; class QPushButton; #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ class SegmentationUI_EXPORT QmitkFastMarchingTool3DGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingTool3DGUI, QmitkToolGUI); itkNewMacro(QmitkFastMarchingTool3DGUI); void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool*); void OnThresholdChanged(double, double); void OnAlphaChanged(double); void OnBetaChanged(double); void OnSigmaChanged(double); void OnStoppingValueChanged(double); void OnConfirmSegmentation(); void Refetch(); void SetStepper(mitk::Stepper *); void OnClearSeeds(); protected: QmitkFastMarchingTool3DGUI(); virtual ~QmitkFastMarchingTool3DGUI(); void BusyStateChanged(bool); void Update(); ctkRangeWidget* m_slwThreshold; ctkSliderWidget* m_slStoppingValue; ctkSliderWidget* m_slSigma; ctkSliderWidget* m_slAlpha; ctkSliderWidget* m_slBeta; QPushButton* m_btConfirm; QPushButton* m_btClearSeeds; mitk::FastMarchingTool3D::Pointer m_FastMarchingTool; bool m_TimeIsConnected; mitk::Stepper::Pointer m_TimeStepper; - void EnableConfirmButton(); + void OnFastMarchingToolReady(); }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp index b62d8807b8..b82ca4e761 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.cpp @@ -1,334 +1,337 @@ /*=================================================================== 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 "QmitkFastMarchingToolGUI.h" #include "QmitkNewSegmentationDialog.h" #include #include #include #include #include #include #include #include #include "mitkStepper.h" #include "mitkBaseRenderer.h" MITK_TOOL_GUI_MACRO(SegmentationUI_EXPORT, QmitkFastMarchingToolGUI, "") QmitkFastMarchingToolGUI::QmitkFastMarchingToolGUI() :QmitkToolGUI(), m_TimeIsConnected(false) { this->setContentsMargins( 0, 0, 0, 0 ); // create the visible widgets QVBoxLayout *widgetLayout = new QVBoxLayout(this); widgetLayout->setContentsMargins(0, 0, 0, 0); QFont fntHelp; fntHelp.setBold(true); QLabel *lblHelp = new QLabel(this); lblHelp->setText("Press shift-click to add seeds repeatedly."); lblHelp->setFont(fntHelp); widgetLayout->addWidget(lblHelp); // Sigma controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Sigma: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addItem(hlayout); } m_slSigma = new ctkSliderWidget(this); m_slSigma->setMinimum(0.1); m_slSigma->setMaximum(5.0); m_slSigma->setPageStep(0.1); m_slSigma->setSingleStep(0.01); m_slSigma->setValue(1.0); m_slSigma->setDecimals(2); m_slSigma->setTracking(false); m_slSigma->setToolTip("The \"sigma\" parameter in the Gradient Magnitude filter."); connect( m_slSigma, SIGNAL(valueChanged(double)), this, SLOT(OnSigmaChanged(double))); widgetLayout->addWidget( m_slSigma ); // Alpha controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Alpha: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addItem(hlayout); } m_slAlpha = new ctkSliderWidget(this); m_slAlpha->setMinimum(-10); m_slAlpha->setMaximum(0); m_slAlpha->setPageStep(0.1); m_slAlpha->setSingleStep(0.01); m_slAlpha->setValue(-2.5); m_slAlpha->setDecimals(2); m_slAlpha->setTracking(false); m_slAlpha->setToolTip("The \"alpha\" parameter in the Sigmoid mapping filter."); connect( m_slAlpha, SIGNAL(valueChanged(double)), this, SLOT(OnAlphaChanged(double))); widgetLayout->addWidget( m_slAlpha ); // Beta controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Beta: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slBeta = new ctkSliderWidget(this); m_slBeta->setMinimum(0); m_slBeta->setMaximum(100); m_slBeta->setPageStep(0.1); m_slBeta->setSingleStep(0.01); m_slBeta->setValue(3.5); m_slBeta->setDecimals(2); m_slBeta->setTracking(false); m_slBeta->setToolTip("The \"beta\" parameter in the Sigmoid mapping filter."); connect( m_slBeta, SIGNAL(valueChanged(double)), this, SLOT(OnBetaChanged(double))); widgetLayout->addWidget( m_slBeta ); // stopping value controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Stopping value: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slStoppingValue = new ctkSliderWidget(this); m_slStoppingValue->setMinimum(0); m_slStoppingValue->setMaximum(10000); m_slStoppingValue->setPageStep(10); m_slStoppingValue->setSingleStep(1); m_slStoppingValue->setValue(2000); m_slStoppingValue->setDecimals(0); m_slStoppingValue->setTracking(false); m_slStoppingValue->setToolTip("The \"stopping value\" parameter in the fast marching 3D algorithm"); connect( m_slStoppingValue, SIGNAL(valueChanged(double)), this, SLOT(OnStoppingValueChanged(double))); widgetLayout->addWidget( m_slStoppingValue ); // threshold controls { QHBoxLayout *hlayout = new QHBoxLayout(); hlayout->setSpacing(2); QLabel *lbl = new QLabel(this); lbl->setText("Threshold: "); hlayout->addWidget(lbl); QSpacerItem* sp2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); hlayout->addItem(sp2); widgetLayout->addLayout(hlayout); } m_slwThreshold = new ctkRangeWidget(this); m_slwThreshold->setMinimum(-100); m_slwThreshold->setMaximum(5000); m_slwThreshold->setMinimumValue(-100); m_slwThreshold->setMaximumValue(2000); m_slwThreshold->setDecimals(0); m_slwThreshold->setTracking(false); m_slwThreshold->setToolTip("The lower and upper thresholds for the final thresholding"); connect( m_slwThreshold, SIGNAL(valuesChanged(double, double)), this, SLOT(OnThresholdChanged(double, double))); widgetLayout->addWidget( m_slwThreshold ); m_btClearSeeds = new QPushButton("Clear"); m_btClearSeeds->setToolTip("Clear current result and start over again"); widgetLayout->addWidget(m_btClearSeeds); connect( m_btClearSeeds, SIGNAL(clicked()), this, SLOT(OnClearSeeds()) ); m_btConfirm = new QPushButton("Accept"); m_btConfirm->setToolTip("Incorporate current result in your working session."); m_btConfirm->setEnabled(false); widgetLayout->addWidget(m_btConfirm); connect( m_btConfirm, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation()) ); connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) ); + + this->setEnabled(false); } QmitkFastMarchingToolGUI::~QmitkFastMarchingToolGUI() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingToolGUI::BusyStateChanged ); - m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::EnableConfirmButton) ); + m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::OnFastMarchingToolReady) ); } } void QmitkFastMarchingToolGUI::OnNewToolAssociated(mitk::Tool* tool) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy -= mitk::MessageDelegate1( this, &QmitkFastMarchingToolGUI::BusyStateChanged ); - m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::EnableConfirmButton) ); + m_FastMarchingTool->RemoveReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::OnFastMarchingToolReady) ); } m_FastMarchingTool = dynamic_cast( tool ); if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->CurrentlyBusy += mitk::MessageDelegate1( this, &QmitkFastMarchingToolGUI::BusyStateChanged ); - m_FastMarchingTool->AddReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::EnableConfirmButton) ); + m_FastMarchingTool->AddReadyListener(mitk::MessageDelegate(this, &QmitkFastMarchingToolGUI::OnFastMarchingToolReady) ); //listen to timestep change events mitk::BaseRenderer::Pointer renderer; renderer = mitk::BaseRenderer::GetInstance( mitk::BaseRenderer::GetRenderWindowByName("stdmulti.widget1") ); if (renderer.IsNotNull() && !m_TimeIsConnected) { new QmitkStepperAdapter(this, renderer->GetSliceNavigationController()->GetTime(), "stepper"); // connect(m_TimeStepper, SIGNAL(Refetch()), this, SLOT(Refetch())); m_TimeIsConnected = true; } } } void QmitkFastMarchingToolGUI::Update() { m_FastMarchingTool->SetLowerThreshold( this->m_slwThreshold->minimumValue()); m_FastMarchingTool->SetUpperThreshold( this->m_slwThreshold->maximumValue()); m_FastMarchingTool->SetStoppingValue( this->m_slStoppingValue->value()); m_FastMarchingTool->SetSigma( this->m_slSigma->value()); m_FastMarchingTool->SetAlpha( this->m_slAlpha->value()); m_FastMarchingTool->SetBeta( this->m_slBeta->value()); m_FastMarchingTool->Update(); } void QmitkFastMarchingToolGUI::OnThresholdChanged(double lower, double upper) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetLowerThreshold( lower ); m_FastMarchingTool->SetUpperThreshold( upper ); this->Update(); } } void QmitkFastMarchingToolGUI::OnBetaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetBeta( value ); this->Update(); } } void QmitkFastMarchingToolGUI::OnSigmaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetSigma( value ); this->Update(); } } void QmitkFastMarchingToolGUI::OnAlphaChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetAlpha( value ); this->Update(); } } void QmitkFastMarchingToolGUI::OnStoppingValueChanged(double value) { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->SetStoppingValue( value ); this->Update(); } } void QmitkFastMarchingToolGUI::OnConfirmSegmentation() { if (m_FastMarchingTool.IsNotNull()) { m_FastMarchingTool->ConfirmSegmentation(); m_btConfirm->setEnabled(false); } } void QmitkFastMarchingToolGUI::SetStepper(mitk::Stepper *stepper) { this->m_TimeStepper = stepper; } void QmitkFastMarchingToolGUI::Refetch() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->SetCurrentTimeStep(m_TimeStepper->GetPos()); } void QmitkFastMarchingToolGUI::OnClearSeeds() { //event from image navigator recieved - timestep has changed m_FastMarchingTool->ClearSeeds(); m_btConfirm->setEnabled(false); this->Update(); } void QmitkFastMarchingToolGUI::BusyStateChanged(bool value) { if (value) QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); else QApplication::restoreOverrideCursor(); } -void QmitkFastMarchingToolGUI::EnableConfirmButton() +void QmitkFastMarchingToolGUI::OnFastMarchingToolReady() { + this->setEnabled(true); this->m_btConfirm->setEnabled(true); } diff --git a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h index 4fbb7737f7..6f0669d89f 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h +++ b/Modules/SegmentationUI/Qmitk/QmitkFastMarchingToolGUI.h @@ -1,85 +1,85 @@ /*=================================================================== 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 QmitkFastMarchingToolGUI_h_Included #define QmitkFastMarchingToolGUI_h_Included #include "QmitkToolGUI.h" #include "SegmentationUIExports.h" #include "mitkFastMarchingTool.h" class ctkSliderWidget; class ctkRangeWidget; class QPushButton; #include "QmitkStepperAdapter.h" /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::FastMarchingTool. \sa mitk::FastMarchingTool */ class SegmentationUI_EXPORT QmitkFastMarchingToolGUI : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkFastMarchingToolGUI, QmitkToolGUI); itkNewMacro(QmitkFastMarchingToolGUI); void OnThresholdChanged(int current); protected slots: void OnNewToolAssociated(mitk::Tool*); void OnThresholdChanged(double, double); void OnAlphaChanged(double); void OnBetaChanged(double); void OnSigmaChanged(double); void OnStoppingValueChanged(double); void OnConfirmSegmentation(); void Refetch(); void SetStepper(mitk::Stepper *); void OnClearSeeds(); protected: QmitkFastMarchingToolGUI(); virtual ~QmitkFastMarchingToolGUI(); void Update(); void BusyStateChanged(bool); ctkRangeWidget* m_slwThreshold; ctkSliderWidget* m_slStoppingValue; ctkSliderWidget* m_slSigma; ctkSliderWidget* m_slAlpha; ctkSliderWidget* m_slBeta; QPushButton* m_btConfirm; QPushButton* m_btClearSeeds; mitk::FastMarchingTool::Pointer m_FastMarchingTool; bool m_TimeIsConnected; mitk::Stepper::Pointer m_TimeStepper; - void EnableConfirmButton(); + void OnFastMarchingToolReady(); }; #endif