diff --git a/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.cpp b/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.cpp index f76633cded..55797b35eb 100644 --- a/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.cpp +++ b/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.cpp @@ -1,177 +1,180 @@ /*============================================================================ 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 "org_mitk_gui_qt_flow_segmentation_Activator.h" // Blueberry #include #include #include //MITK #include #include #include #include #include #include #include // Qmitk #include "QmitkSegmentationFlowControlView.h" +#include + // Qt #include #include #include const std::string QmitkSegmentationFlowControlView::VIEW_ID = "org.mitk.views.flow.control"; QmitkSegmentationFlowControlView::QmitkSegmentationFlowControlView() - : m_Parent(nullptr) + : m_Parent(nullptr), + m_Controls(new Ui::SegmentationFlowControlView) { auto notHelperObject = mitk::NodePredicateNot::New( mitk::NodePredicateProperty::New("helper object")); m_SegmentationPredicate = mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), notHelperObject); m_SegmentationTaskListPredicate = mitk::NodePredicateAnd::New( mitk::TNodePredicateDataType::New(), notHelperObject); } void QmitkSegmentationFlowControlView::SetFocus() { - m_Controls.btnStoreAndAccept->setFocus(); + m_Controls->btnStoreAndAccept->setFocus(); } void QmitkSegmentationFlowControlView::CreateQtPartControl(QWidget* parent) { // create GUI widgets from the Qt Designer's .ui file - m_Controls.setupUi(parent); + m_Controls->setupUi(parent); m_Parent = parent; using Self = QmitkSegmentationFlowControlView; - connect(m_Controls.btnStoreAndAccept, &QPushButton::clicked, this, &Self::OnAcceptButtonPushed); - connect(m_Controls.segmentationTaskListWidget, &QmitkSegmentationTaskListWidget::ActiveTaskChanged, this, &Self::OnActiveTaskChanged); - connect(m_Controls.segmentationTaskListWidget, &QmitkSegmentationTaskListWidget::CurrentTaskChanged, this, &Self::OnCurrentTaskChanged); + connect(m_Controls->btnStoreAndAccept, &QPushButton::clicked, this, &Self::OnAcceptButtonPushed); + connect(m_Controls->segmentationTaskListWidget, &QmitkSegmentationTaskListWidget::ActiveTaskChanged, this, &Self::OnActiveTaskChanged); + connect(m_Controls->segmentationTaskListWidget, &QmitkSegmentationTaskListWidget::CurrentTaskChanged, this, &Self::OnCurrentTaskChanged); - m_Controls.segmentationTaskListWidget->setVisible(false); - m_Controls.labelStored->setVisible(false); + m_Controls->segmentationTaskListWidget->setVisible(false); + m_Controls->labelStored->setVisible(false); UpdateControls(); m_OutputDir = QString::fromStdString(mitk::BaseApplication::instance().config().getString("flow.outputdir", itksys::SystemTools::GetCurrentWorkingDirectory())); m_OutputDir = QDir::fromNativeSeparators(m_OutputDir); m_FileExtension = QString::fromStdString(mitk::BaseApplication::instance().config().getString("flow.outputextension", "nrrd")); } void QmitkSegmentationFlowControlView::OnAcceptButtonPushed() { - if (m_Controls.segmentationTaskListWidget->isVisible()) + if (m_Controls->segmentationTaskListWidget->isVisible()) { - auto* taskList = m_Controls.segmentationTaskListWidget->GetTaskList(); + auto* taskList = m_Controls->segmentationTaskListWidget->GetTaskList(); if (taskList != nullptr) { - auto activeTaskIndex = m_Controls.segmentationTaskListWidget->GetActiveTaskIndex(); + auto activeTaskIndex = m_Controls->segmentationTaskListWidget->GetActiveTaskIndex(); if (activeTaskIndex.has_value()) { - auto segmentationNode = m_Controls.segmentationTaskListWidget->GetSegmentationDataNode(activeTaskIndex.value()); + auto segmentationNode = m_Controls->segmentationTaskListWidget->GetSegmentationDataNode(activeTaskIndex.value()); if (segmentationNode != nullptr) { QApplication::setOverrideCursor(Qt::BusyCursor); try { taskList->SaveTask(activeTaskIndex.value(), segmentationNode->GetData()); - m_Controls.segmentationTaskListWidget->OnUnsavedChangesSaved(); + m_Controls->segmentationTaskListWidget->OnUnsavedChangesSaved(); } catch (const mitk::Exception& e) { MITK_ERROR << e; } QApplication::restoreOverrideCursor(); } } } } else { auto nodes = this->GetDataStorage()->GetSubset(m_SegmentationPredicate); for (auto node : *nodes) { QString outputpath = m_OutputDir + "/" + QString::fromStdString(node->GetName()) + "." + m_FileExtension; outputpath = QDir::toNativeSeparators(QDir::cleanPath(outputpath)); mitk::IOUtil::Save(node->GetData(), outputpath.toStdString()); } - m_Controls.labelStored->setVisible(true); + m_Controls->labelStored->setVisible(true); } } void QmitkSegmentationFlowControlView::OnActiveTaskChanged(const std::optional&) { this->UpdateControls(); } void QmitkSegmentationFlowControlView::OnCurrentTaskChanged(const std::optional&) { this->UpdateControls(); } void QmitkSegmentationFlowControlView::UpdateControls() { auto dataStorage = this->GetDataStorage(); auto hasTaskList = !dataStorage->GetSubset(m_SegmentationTaskListPredicate)->empty(); - m_Controls.segmentationTaskListWidget->setVisible(hasTaskList); + m_Controls->segmentationTaskListWidget->setVisible(hasTaskList); if (hasTaskList) { - auto activeTaskIsShown = m_Controls.segmentationTaskListWidget->ActiveTaskIsShown(); - m_Controls.btnStoreAndAccept->setEnabled(activeTaskIsShown); + auto activeTaskIsShown = m_Controls->segmentationTaskListWidget->ActiveTaskIsShown(); + m_Controls->btnStoreAndAccept->setEnabled(activeTaskIsShown); } else { auto hasSegmentation = !dataStorage->GetSubset(m_SegmentationPredicate)->empty(); - m_Controls.btnStoreAndAccept->setEnabled(hasSegmentation); + m_Controls->btnStoreAndAccept->setEnabled(hasSegmentation); } } void QmitkSegmentationFlowControlView::NodeAdded(const mitk::DataNode* node) { if (dynamic_cast(node->GetData()) != nullptr) this->UpdateControls(); } void QmitkSegmentationFlowControlView::NodeChanged(const mitk::DataNode* node) { if (dynamic_cast(node->GetData()) != nullptr) this->UpdateControls(); } void QmitkSegmentationFlowControlView::NodeRemoved(const mitk::DataNode* node) { if (dynamic_cast(node->GetData()) != nullptr) this->UpdateControls(); } diff --git a/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.h b/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.h index 4a1bc826ce..49335b6def 100644 --- a/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.h +++ b/Plugins/org.mitk.gui.qt.flow.segmentation/src/internal/QmitkSegmentationFlowControlView.h @@ -1,79 +1,82 @@ /*============================================================================ 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 __Q_MITK_MATCHPOINT_MAPPER_H #define __Q_MITK_MATCHPOINT_MAPPER_H #include #include #include "mitkNodePredicateBase.h" -#include "ui_QmitkSegmentationFlowControlView.h" - #include +namespace Ui +{ + class SegmentationFlowControlView; +} + /*! \brief QmitkSegmentationFlowControlView Class that "controls" the segmentation view. It offers the possibility to accept a segmentation. Accepting the segmentation stores the segmentation to the given working directory. The working directory is specified by command line arguments. If no commandline flag is set the current working directory will be used. */ class QmitkSegmentationFlowControlView : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkSegmentationFlowControlView) QmitkSegmentationFlowControlView(); void CreateQtPartControl(QWidget *parent) override; protected slots: void OnAcceptButtonPushed(); void OnActiveTaskChanged(const std::optional& index); void OnCurrentTaskChanged(const std::optional& index); protected: void SetFocus() override; void NodeAdded(const mitk::DataNode* node) override; void NodeChanged(const mitk::DataNode* node) override; void NodeRemoved(const mitk::DataNode* node) override; void UpdateControls(); - Ui::SegmentationFlowControlView m_Controls; + Ui::SegmentationFlowControlView* m_Controls; private: QWidget *m_Parent; mitk::NodePredicateBase::Pointer m_SegmentationPredicate; mitk::NodePredicateBase::Pointer m_SegmentationTaskListPredicate; QString m_OutputDir; QString m_FileExtension; }; #endif // MatchPoint_h