diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp index d9dfa42728..1dfbe7e3c4 100644 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.cpp @@ -1,104 +1,99 @@ #include "QmitkThresholdAction.h" -#include "mitkBinaryThresholdTool.h" -#include "mitkRenderingManager.h" +// MITK +#include +#include +#include -#include "QmitkToolGUI.h" -#include +// Qt +#include +#include +using namespace itk; +using namespace mitk; +using namespace std; QmitkThresholdAction::QmitkThresholdAction() + : m_ThresholdingDialog(NULL) { } QmitkThresholdAction::~QmitkThresholdAction() { } -void QmitkThresholdAction::Run(const std::vector &selectedNodes) +void QmitkThresholdAction::Run(const vector &selectedNodes) { - m_ThresholdingToolManager = mitk::ToolManager::New( m_DataStorage ); + m_ThresholdingToolManager = mitk::ToolManager::New(m_DataStorage); + m_ThresholdingToolManager->RegisterClient(); - m_ThresholdingToolManager->ActiveToolChanged += - mitk::MessageDelegate( this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified ); + m_ThresholdingToolManager->ActiveToolChanged += MessageDelegate(this, &QmitkThresholdAction::OnThresholdingToolManagerToolModified); - m_ThresholdingDialog = new QDialog(NULL); - connect( m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int)) ); + m_ThresholdingDialog = new QDialog; + connect(m_ThresholdingDialog, SIGNAL(finished(int)), this, SLOT(ThresholdingDone(int))); - QVBoxLayout* layout = new QVBoxLayout; + QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); - mitk::Tool* tool = m_ThresholdingToolManager->GetToolById( m_ThresholdingToolManager->GetToolIdByToolType() ); - if (tool) + mitk::Tool *binaryThresholdTool = m_ThresholdingToolManager->GetToolById(m_ThresholdingToolManager->GetToolIdByToolType()); + + if (binaryThresholdTool != NULL) { - itk::Object::Pointer possibleGUI = tool->GetGUI("Qmitk", "GUI"); - QmitkToolGUI* gui = dynamic_cast( possibleGUI.GetPointer() ); - if (gui) + QmitkToolGUI *gui = dynamic_cast(binaryThresholdTool->GetGUI("Qmitk", "GUI").GetPointer()); + + if (gui != NULL) { - gui->SetTool(tool); + gui->SetTool(binaryThresholdTool); gui->setParent(m_ThresholdingDialog); + layout->addWidget(gui); + m_ThresholdingDialog->setLayout(layout); - layout->activate(); - m_ThresholdingDialog->setFixedSize(300,80); + m_ThresholdingDialog->setFixedSize(300, 80); + m_ThresholdingDialog->open(); } - } - - for ( NodeList::const_iterator iter = selectedNodes.begin(); iter != selectedNodes.end(); ++iter ) - { - mitk::DataNode* node = *iter; - if (node) - { - m_ThresholdingToolManager->SetReferenceData( node ); - m_ThresholdingToolManager->ActivateTool( m_ThresholdingToolManager->GetToolIdByToolType() ); - } + m_ThresholdingToolManager->SetReferenceData(selectedNodes[0]); + m_ThresholdingToolManager->ActivateTool(m_ThresholdingToolManager->GetToolIdByToolType()); } } void QmitkThresholdAction::ThresholdingDone(int result) { if (result == QDialog::Rejected) - m_ThresholdingToolManager->ActivateTool(-1); - MITK_INFO << "Thresholding done, cleaning up"; + m_ThresholdingToolManager->ActivateTool(-1); + m_ThresholdingDialog->deleteLater(); m_ThresholdingDialog = NULL; - m_ThresholdingToolManager->SetReferenceData( NULL ); - m_ThresholdingToolManager->SetWorkingData( NULL ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + m_ThresholdingToolManager->SetReferenceData(NULL); + m_ThresholdingToolManager->SetWorkingData(NULL); + + RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkThresholdAction::OnThresholdingToolManagerToolModified() { - if ( m_ThresholdingToolManager.IsNull() ) return; - - //MITK_INFO << "Now got tool " << m_ThresholdingToolManager->GetActiveToolID(); - - if ( m_ThresholdingToolManager->GetActiveToolID() < 0) - { - if (m_ThresholdingDialog) - m_ThresholdingDialog->accept(); - } + if (m_ThresholdingToolManager.IsNotNull()) + if (m_ThresholdingToolManager->GetActiveToolID() < 0) + if (m_ThresholdingDialog != NULL) + m_ThresholdingDialog->accept(); } -void QmitkThresholdAction::SetDataStorage(mitk::DataStorage* dataStorage) +void QmitkThresholdAction::SetDataStorage(mitk::DataStorage *dataStorage) { this->m_DataStorage = dataStorage; } -void QmitkThresholdAction::SetSmoothed(bool smoothed) +void QmitkThresholdAction::SetSmoothed(bool) { - //not needed } -void QmitkThresholdAction::SetDecimated(bool decimated) +void QmitkThresholdAction::SetDecimated(bool) { - //not needed } -void QmitkThresholdAction::SetFunctionality(berry::QtViewPart* functionality) +void QmitkThresholdAction::SetFunctionality(berry::QtViewPart *functionality) { - //not needed -} \ No newline at end of file +} diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h index 692ccfd7f4..bc1780f49f 100644 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h +++ b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/QmitkThresholdAction.h @@ -1,57 +1,46 @@ -#ifndef QMITK_THRESHOLDACTION_H -#define QMITK_THRESHOLDACTION_H +#ifndef QMITKTHRESHOLDACTION_H +#define QMITKTHRESHOLDACTION_H -#include -#include "berryQtViewPart.h" +#include -#include "mitkIContextMenuAction.h" - -#include "mitkDataStorage.h" -#include "mitkToolManager.h" +// Parent classes +#include +#include -#include "org_mitk_gui_qt_segmentation_Export.h" +// Data members +#include +#include -#include -#include +class QDialog; -class MITK_QT_SEGMENTATION QmitkThresholdAction: public QObject, public mitk::IContextMenuAction +class MITK_QT_SEGMENTATION QmitkThresholdAction : public QObject, public mitk::IContextMenuAction { Q_OBJECT Q_INTERFACES(mitk::IContextMenuAction) public: - QmitkThresholdAction(); - QmitkThresholdAction(const QmitkThresholdAction& other) - { - Q_UNUSED(other) - throw std::runtime_error("Copy constructor not implemented"); - } - virtual ~QmitkThresholdAction(); - - //interface methods - void Run( const std::vector& selectedNodes ); - void SetDataStorage(mitk::DataStorage* dataStorage); + ~QmitkThresholdAction(); + + // IContextMenuAction + void Run(const std::vector &selectedNodes); + void SetDataStorage(mitk::DataStorage *dataStorage); void SetSmoothed(bool smoothed); void SetDecimated(bool decimated); - void SetFunctionality(berry::QtViewPart* functionality); + void SetFunctionality(berry::QtViewPart *functionality); - // for receiving messages void OnThresholdingToolManagerToolModified(); -protected: +private slots: + void ThresholdingDone(int); - typedef std::vector NodeList; +private: + QmitkThresholdAction(const QmitkThresholdAction &); + QmitkThresholdAction & operator=(const QmitkThresholdAction &); mitk::DataStorage::Pointer m_DataStorage; mitk::ToolManager::Pointer m_ThresholdingToolManager; - - QDialog* m_ThresholdingDialog; - -protected slots: - - // class internal slot - void ThresholdingDone(int); + QDialog *m_ThresholdingDialog; }; -#endif // QMITK_THRESHOLDACTION_H +#endif diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp index a731a4ffbc..d82241db30 100644 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.cpp @@ -1,30 +1,26 @@ #include "mitkPluginActivator.h" -#include #include "QmitkSegmentationView.h" #include "QmitkThresholdAction.h" #include "QmitkCreatePolygonModelAction.h" #include "QmitkStatisticsAction.h" #include "QmitkAutocropAction.h" #include "QmitkSegmentationPreferencePage.h" -namespace mitk { +using namespace mitk; -void PluginActivator::start(ctkPluginContext* context) +void PluginActivator::start(ctkPluginContext *context) { BERRY_REGISTER_EXTENSION_CLASS(QmitkSegmentationView, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkThresholdAction, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkCreatePolygonModelAction, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkStatisticsAction, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkAutocropAction, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkSegmentationPreferencePage, context); } -void PluginActivator::stop(ctkPluginContext* context) +void PluginActivator::stop(ctkPluginContext *) { - Q_UNUSED(context) -} - } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_segmentation, mitk::PluginActivator) diff --git a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h index a34be34be4..a14d585bbb 100644 --- a/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h +++ b/Modules/Bundles/org.mitk.gui.qt.segmentation/src/internal/mitkPluginActivator.h @@ -1,23 +1,21 @@ #ifndef MITKPLUGINACTIVATOR_H #define MITKPLUGINACTIVATOR_H +// Parent classes +#include #include -namespace mitk { - -class PluginActivator : - public QObject, public ctkPluginActivator +namespace mitk { - Q_OBJECT - Q_INTERFACES(ctkPluginActivator) - -public: - - void start(ctkPluginContext* context); - void stop(ctkPluginContext* context); - -}; // PluginActivator - + class PluginActivator : public QObject, public ctkPluginActivator + { + Q_OBJECT + Q_INTERFACES(ctkPluginActivator) + + public: + void start(ctkPluginContext *context); + void stop(ctkPluginContext *context); + }; } -#endif // MITKPLUGINACTIVATOR_H +#endif