diff --git a/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.cpp b/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.cpp index 15cb4647b8..727cc2b6af 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.cpp +++ b/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.cpp @@ -1,100 +1,101 @@ /*============================================================================ 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 "QmitkEditableContourToolGUIBase.h" +#include +#include -QmitkEditableContourToolGUIBase::QmitkEditableContourToolGUIBase() : QmitkToolGUI() +#include + +QmitkEditableContourToolGUIBase::QmitkEditableContourToolGUIBase() + : QmitkToolGUI(), + m_Controls(new Ui::QmitkEditableContourToolGUIControls) { - m_Controls.setupUi(this); - m_Controls.m_Information->hide(); - m_Controls.m_AutoCheck->setChecked(true); - m_Controls.m_ConfirmButton->hide(); - m_Controls.m_AddMode->setChecked(true); - m_Controls.m_SubtractMode->hide(); - m_Controls.m_AddMode->hide(); - - m_Controls.m_ClearButton->hide(); - - connect(m_Controls.m_ConfirmButton, SIGNAL(clicked()), this, SLOT(OnConfirmSegmentation())); - connect(m_Controls.m_ClearButton, SIGNAL(clicked()), this, SLOT(OnClearContour())); - connect(this, SIGNAL(NewToolAssociated(mitk::Tool *)), this, SLOT(OnNewToolAssociated(mitk::Tool *))); - connect(m_Controls.m_InformationCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnShowInformation(bool))); - connect(m_Controls.m_AutoCheck, SIGNAL(toggled(bool)), this, SLOT(OnAutoConfirm(bool))); - connect(m_Controls.m_AddMode, SIGNAL(toggled(bool)), this, SLOT(OnAddModeToogled(bool))); + m_Controls->setupUi(this); + + m_Controls->m_Information->hide(); + m_Controls->m_AutoCheck->setChecked(true); + m_Controls->m_ConfirmButton->hide(); + m_Controls->m_AddMode->setChecked(true); + m_Controls->m_SubtractMode->hide(); + m_Controls->m_AddMode->hide(); + m_Controls->m_ClearButton->hide(); + + connect(m_Controls->m_ConfirmButton, &QPushButton::clicked, this, &Self::OnConfirmSegmentation); + connect(m_Controls->m_ClearButton, &QPushButton::clicked, this, &Self::OnClearContour); + connect(this, &Self::NewToolAssociated, this, &Self::OnNewToolAssociated); + connect(m_Controls->m_InformationCheckBox, &QCheckBox::toggled, this, &Self::OnShowInformation); + connect(m_Controls->m_AutoCheck, &QCheckBox::toggled, this, &Self::OnAutoConfirm); + connect(m_Controls->m_AddMode, &QRadioButton::toggled, this, &Self::OnAddModeToogled); } QmitkEditableContourToolGUIBase::~QmitkEditableContourToolGUIBase() { } -void QmitkEditableContourToolGUIBase::OnNewToolAssociated(mitk::Tool *tool) +void QmitkEditableContourToolGUIBase::OnNewToolAssociated(mitk::Tool* tool) { - m_NewTool = dynamic_cast(tool); + m_NewTool = dynamic_cast(tool); + if (m_NewTool.IsNull()) - { mitkThrow() << "Tool is in an invalid state. QmitkEditableContourToolGUIBase needs tools based on EditableContourTool."; - } const auto autoConfirm = m_NewTool->GetAutoConfirm(); - m_Controls.m_AutoCheck->setChecked(autoConfirm); + m_Controls->m_AutoCheck->setChecked(autoConfirm); + const auto addMode = m_NewTool->GetAddMode(); - m_Controls.m_AddMode->setChecked(addMode); + m_Controls->m_AddMode->setChecked(addMode); + this->OnAutoConfirm(autoConfirm); } void QmitkEditableContourToolGUIBase::OnConfirmSegmentation() { if (m_NewTool.IsNotNull()) - { m_NewTool->ConfirmSegmentation(); - } } void QmitkEditableContourToolGUIBase::OnClearContour() { if (m_NewTool.IsNotNull()) m_NewTool->ClearContour(); } void QmitkEditableContourToolGUIBase::OnShowInformation(bool on) { - m_Controls.m_Information->setVisible(on); + m_Controls->m_Information->setVisible(on); } void QmitkEditableContourToolGUIBase::OnAutoConfirm(bool on) { - m_Controls.m_ConfirmButton->setVisible(!on); - m_Controls.m_ClearButton->setVisible(!on); - m_Controls.m_AddMode->setVisible(!on); + m_Controls->m_ConfirmButton->setVisible(!on); + m_Controls->m_ClearButton->setVisible(!on); + m_Controls->m_AddMode->setVisible(!on); + if (on) - { - m_Controls.m_AddMode->setChecked(true); - } - m_Controls.m_SubtractMode->setVisible(!on); + m_Controls->m_AddMode->setChecked(true); + + m_Controls->m_SubtractMode->setVisible(!on); if (m_NewTool.IsNotNull()) { if (on && m_NewTool->IsEditingContour()) - { this->OnConfirmSegmentation(); - } + m_NewTool->SetAutoConfirm(on); } } void QmitkEditableContourToolGUIBase::OnAddModeToogled(bool on) { if (m_NewTool.IsNotNull()) - { m_NewTool->SetAddMode(on); - } } diff --git a/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.h b/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.h index 28e89d4fb9..e8858114a4 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.h +++ b/Modules/SegmentationUI/Qmitk/QmitkEditableContourToolGUIBase.h @@ -1,59 +1,59 @@ /*============================================================================ 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 QmitkEditableContourToolGUIBase_h #define QmitkEditableContourToolGUIBase_h -#include "QmitkToolGUI.h" -#include "mitkEditableContourTool.h" -#include "ui_QmitkEditableContourToolGUIControls.h" +#include #include -class QmitkEditableContourToolGUIBaseControls; +namespace mitk +{ + class EditableContourTool; +} + +namespace Ui +{ + class QmitkEditableContourToolGUIControls; +} /** \ingroup org_mitk_gui_qt_interactivesegmentation_internal \brief GUI for mitk::EditableContourTool based classes. \sa mitk::LassoTool */ class MITKSEGMENTATIONUI_EXPORT QmitkEditableContourToolGUIBase : public QmitkToolGUI { Q_OBJECT public: mitkClassMacro(QmitkEditableContourToolGUIBase, QmitkToolGUI); itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - -protected slots : - void OnNewToolAssociated(mitk::Tool *); +protected slots: + void OnNewToolAssociated(mitk::Tool*); void OnConfirmSegmentation(); - void OnClearContour(); - void OnAutoConfirm(bool on); void OnAddModeToogled(bool on); - void OnShowInformation(bool on); protected: QmitkEditableContourToolGUIBase(); ~QmitkEditableContourToolGUIBase() override; - Ui::QmitkEditableContourToolGUIControls m_Controls; - - mitk::EditableContourTool::Pointer m_NewTool; + Ui::QmitkEditableContourToolGUIControls* m_Controls; + itk::SmartPointer m_NewTool; }; #endif