diff --git a/Applications/FlowBench/MitkFlowBench.cpp b/Applications/FlowBench/MitkFlowBench.cpp index 68f548deb5..55cc928c43 100644 --- a/Applications/FlowBench/MitkFlowBench.cpp +++ b/Applications/FlowBench/MitkFlowBench.cpp @@ -1,42 +1,77 @@ /*=================================================================== 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 #include + +class FlowApplication : public mitk::BaseApplication +{ +public: + static const QString ARG_OUTPUTDIR; + static const QString ARG_OUTPUTFORMAT; + + FlowApplication(int argc, char **argv) : mitk::BaseApplication(argc, argv) + { + }; + + ~FlowApplication() = default; + +protected: + /** + * Define command line arguments + * @param options + */ + void defineOptions(Poco::Util::OptionSet &options) override + { + Poco::Util::Option outputDirOption(ARG_OUTPUTDIR.toStdString(), "", "the location for storing persistent application data"); + outputDirOption.argument("").binding(ARG_OUTPUTDIR.toStdString()); + options.addOption(outputDirOption); + + Poco::Util::Option outputFormatOption(ARG_OUTPUTFORMAT.toStdString(), "", "the location for storing persistent application data"); + outputFormatOption.argument("").binding(ARG_OUTPUTFORMAT.toStdString()); + options.addOption(outputFormatOption); + + mitk::BaseApplication::defineOptions(options); + }; +}; + +const QString FlowApplication::ARG_OUTPUTDIR = "flow.outputdir"; +const QString FlowApplication::ARG_OUTPUTFORMAT = "flow.outputformat"; + int main(int argc, char **argv) { - mitk::BaseApplication app(argc, argv); + FlowApplication app(argc, argv); app.setSingleMode(true); app.setApplicationName("MITK FlowBench"); app.setOrganizationName("DKFZ"); // Preload the org.mitk.gui.qt.application plug-in to speed // up a clean-cache start. This also works around bugs in older gcc and glibc implementations, // which have difficulties with multiple dynamic opening and closing of shared libraries with // many global static initializers. It also helps if dependent libraries have weird static // initialization methods and/or missing de-initialization code. QStringList preloadLibs; preloadLibs << "org_mitk_gui_qt_application"; app.setPreloadLibraries(preloadLibs); app.setProperty(mitk::BaseApplication::PROP_PRODUCT, "org.mitk.gui.qt.flowapplication.workbench"); // Run the workbench. return app.run(); } 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 fd2d75d944..11e344c603 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,126 +1,129 @@ /*=================================================================== 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 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_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(); break; } isFlagFound = arg.startsWith("--flow.outputdir"); } isFlagFound = false; for (auto arg : arguments) { if (isFlagFound) { m_FileExtension = arg.toStdString(); break; } isFlagFound = arg.startsWith("--flow.outputformat"); } } 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); } 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(); };