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 11e344c603..cec04ea841 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,129 +1,131 @@ /*=================================================================== 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 "org_mitk_gui_qt_flow_segmentation_Activator.h" // Blueberry #include #include -#include #include //MITK #include "mitkLabelSetImage.h" #include "mitkNodePredicateAnd.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateProperty.h" #include "mitkNodePredicateDataType.h" #include "mitkIOUtil.h" // Qmitk #include "QmitkSegmentationFlowControlView.h" // Qt #include +#include const std::string QmitkSegmentationFlowControlView::VIEW_ID = "org.mitk.views.flow.control"; QmitkSegmentationFlowControlView::QmitkSegmentationFlowControlView() : m_Parent(nullptr) { auto nodePredicate = mitk::NodePredicateAnd::New(); nodePredicate->AddPredicate(mitk::TNodePredicateDataType::New()); nodePredicate->AddPredicate(mitk::NodePredicateNot::New(mitk::NodePredicateProperty::New("helper object"))); m_SegmentationPredicate = nodePredicate; - m_OutputDir = itksys::SystemTools::GetCurrentWorkingDirectory(); + m_OutputDir = QString::fromStdString(itksys::SystemTools::GetCurrentWorkingDirectory()); m_FileExtension = "nrrd"; } void QmitkSegmentationFlowControlView::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_Parent = parent; connect(m_Controls.btnStoreAndAccept, SIGNAL(clicked()), this, SLOT(OnAcceptButtonPushed())); m_Controls.labelStored->setVisible(false); UpdateControls(); - auto arguments = QCoreApplication::arguments(); bool isFlagFound = false; for (auto arg : arguments) { std::cout << "arg: " << arg << std::endl; if (isFlagFound) { - m_OutputDir = arg.toStdString(); + m_OutputDir = arg; break; } isFlagFound = arg.startsWith("--flow.outputdir"); } isFlagFound = false; for (auto arg : arguments) { if (isFlagFound) { - m_FileExtension = arg.toStdString(); + m_FileExtension = arg; break; } isFlagFound = arg.startsWith("--flow.outputformat"); } + + m_OutputDir = QDir::fromNativeSeparators(m_OutputDir); } void QmitkSegmentationFlowControlView::OnAcceptButtonPushed() { auto nodes = this->GetDataStorage()->GetSubset(m_SegmentationPredicate); for (auto node : *nodes) { - std::string outputpath = m_OutputDir + "\\" + node->GetName() + "." + m_FileExtension; - mitk::IOUtil::Save(node->GetData(), outputpath); + 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); } void QmitkSegmentationFlowControlView::UpdateControls() { auto nodes = this->GetDataStorage()->GetSubset(m_SegmentationPredicate); m_Controls.btnStoreAndAccept->setEnabled(!nodes->empty()); }; void QmitkSegmentationFlowControlView::NodeAdded(const mitk::DataNode* /*node*/) { UpdateControls(); }; void QmitkSegmentationFlowControlView::NodeChanged(const mitk::DataNode* /*node*/) { UpdateControls(); }; void QmitkSegmentationFlowControlView::NodeRemoved(const mitk::DataNode* /*node*/) { 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 2602fd06bf..869adf6ff3 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,78 +1,78 @@ /*=================================================================== 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 __Q_MITK_MATCHPOINT_MAPPER_H #define __Q_MITK_MATCHPOINT_MAPPER_H #include #include #include "mitkNodePredicateBase.h" #include "ui_QmitkSegmentationFlowControlView.h" /*! \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(); 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; private: QWidget *m_Parent; mitk::NodePredicateBase::Pointer m_SegmentationPredicate; - std::string m_OutputDir; - std::string m_FileExtension; + QString m_OutputDir; + QString m_FileExtension; }; #endif // MatchPoint_h