diff --git a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt index 64c2cc07be..0f65beb612 100644 --- a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt @@ -1,13 +1,19 @@ project(org_mitk_gui_qt_dicom) set(QT_USE_QTSQL 1) +find_program( StoreSCPExecutable storescp) + +message( STATUS ${StoreSCPExecutable} ) + +file(WRITE resources/config.ini ${StoreSCPExecutable} ) + include_directories(${CTK_INCLUDE_DIRS}) MACRO_CREATE_MITK_CTK_PLUGIN( EXPORT_DIRECTIVE DICOM_EXPORT EXPORTED_INCLUDE_SUFFIXES src MODULE_DEPENDENCIES QmitkExt mitkDicomUI ) target_link_libraries(${PLUGIN_TARGET} ${CTK_LIBRARIES}) diff --git a/Plugins/org.mitk.gui.qt.dicom/files.cmake b/Plugins/org.mitk.gui.qt.dicom/files.cmake index 602026e7de..ee72d491f9 100644 --- a/Plugins/org.mitk.gui.qt.dicom/files.cmake +++ b/Plugins/org.mitk.gui.qt.dicom/files.cmake @@ -1,55 +1,56 @@ set(SRC_CPP_FILES ) set(INTERNAL_CPP_FILES mitkPluginActivator.cpp QmitkDicomEditor.cpp QmitkDicomDirectoryListener.cpp QmitkStoreSCPLauncher.cpp QmitkStoreSCPLauncherBuilder.cpp QmitkDicomDataEventPublisher.cpp DicomEventHandler.cpp #QmitkDicomPreferencePage.cpp ) set(UI_FILES src/internal/QmitkDicomEditorControls.ui ) set(MOC_H_FILES src/internal/mitkPluginActivator.h src/internal/QmitkDicomEditor.h src/internal/QmitkDicomDirectoryListener.h src/internal/QmitkStoreSCPLauncher.h src/internal/QmitkStoreSCPLauncherBuilder.h src/internal/QmitkDicomDataEventPublisher.h src/internal/DicomEventHandler.h #src/internal/QmitkDicomPreferencePage.h ) # list of resource files which can be used by the plug-in # system without loading the plug-ins shared library, # for example the icon used in the menu and tabs for the # plug-in views in the workbench set(CACHED_RESOURCE_FILES resources/icon.xpm + resources/config.ini plugin.xml ) # list of Qt .qrc files which contain additional resources # specific to this plugin set(QRC_FILES ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/config.ini b/Plugins/org.mitk.gui.qt.dicom/resources/config.ini new file mode 100644 index 0000000000..87dd50eacf --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dicom/resources/config.ini @@ -0,0 +1 @@ +StoreSCPExecutable-NOTFOUND \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp index a37624561c..28aacb6f59 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp @@ -1,119 +1,150 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "QmitkStoreSCPLauncher.h" #include #include #include #include -//#include +#include +#include +#include +#include +#include QmitkStoreSCPLauncher::QmitkStoreSCPLauncher(QmitkStoreSCPLauncherBuilder* builder) : m_StoreSCP(new QProcess()) { connect( m_StoreSCP, SIGNAL(error(QProcess::ProcessError)),this, SLOT(OnProcessError(QProcess::ProcessError))); connect( m_StoreSCP, SIGNAL(stateChanged(QProcess::ProcessState)),this, SLOT(OnStateChanged(QProcess::ProcessState))); SetArgumentList(builder); } QmitkStoreSCPLauncher::~QmitkStoreSCPLauncher() { m_StoreSCP->kill(); delete m_StoreSCP; } void QmitkStoreSCPLauncher::StartStoreSCP() { - QString storeSCP; - storeSCP.append(GetPathToExecutable()); - storeSCP.append(QString("/storescp.exe")); - m_StoreSCP->start(storeSCP,m_ArgumentList); + SetPathToStoreSCP(); + m_StoreSCP->start(m_PathToStoreSCP,m_ArgumentList); } -QString QmitkStoreSCPLauncher::GetPathToExecutable() +void QmitkStoreSCPLauncher::SetPathToStoreSCP() { - QDir root; - QString currentPath = root.currentPath(); - currentPath = currentPath.split("MITK").at(0); - currentPath.append("MITK/DCMTK-install/bin"); - return currentPath; + std::string line; + std::ifstream myfile("text.ini"); + if (myfile.is_open()) + { + while ( myfile.good() ) + { + std::getline (myfile,line); + MITK_INFO << line << endl; + } + myfile.close(); + }else{ + MITK_INFO << "Unable to open file"; + } + m_PathToStoreSCP.fromStdString(line); + MITK_INFO << m_PathToStoreSCP.toStdString(); + //if(QFile::exists("config.ini")){ + + + // if (!file.open(QIODevice::ReadWrite)) + // { + // MITK_INFO << "cannot find file"; + // } + // QTextStream stream(&file); + + // while( !stream.atEnd() ) { + // m_PathToStoreSCP = stream.readLine().split("-").at(1); + // } + // file.close(); + // MITK_INFO << m_PathToStoreSCP.toStdString(); + // if(m_PathToStoreSCP.compare("NOTFOUND")) + // { + // MITK_INFO << "cannot find binary"; + // } + //} } void QmitkStoreSCPLauncher::OnProcessError(QProcess::ProcessError err) { switch(err) { case QProcess::FailedToStart: MITK_INFO << QString("Failed to start storage provider: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::Crashed: MITK_INFO << QString("Storage provider crashed: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::Timedout: MITK_INFO << QString("Storage provider timeout: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::WriteError: MITK_INFO << QString("Storage provider write error: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::ReadError: MITK_INFO << QString("Storage provider read error: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::UnknownError: MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); break; default: MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); break; } } void QmitkStoreSCPLauncher::OnStateChanged(QProcess::ProcessState status) { switch(status) { case QProcess::NotRunning: MITK_INFO << QString("Storage provider not running: ").append(m_StoreSCP->errorString()).toStdString(); break; case QProcess::Starting: MITK_INFO << QString("Starting storage provider").toStdString(); break; case QProcess::Running: MITK_INFO << QString("Running storage provider").toStdString(); break; default: MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); break; } } void QmitkStoreSCPLauncher::SetArgumentList(QmitkStoreSCPLauncherBuilder* builder) { m_ArgumentList << *builder->GetPort() << QString("-aet") <<*builder->GetAETitle() << *builder->GetTransferSyntax() << *builder->GetOtherNetworkOptions() << *builder->GetMode() << QString("-od") << *builder->GetOutputDirectory(); } QString QmitkStoreSCPLauncher::ArgumentListToQString() { QString argumentString; QStringListIterator argumentIterator(m_ArgumentList); while(argumentIterator.hasNext()) { argumentString.append(" "); argumentString.append(argumentIterator.next()); } return argumentString; } diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.h b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.h index 816c1a5392..2b56c3e3cb 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.h +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.h @@ -1,47 +1,48 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef QmitkStoreSCPLauncher_h #define QmitkStoreSCPLauncher_h #include #include #include "QmitkStoreSCPLauncherBuilder.h" class QmitkStoreSCPLauncher : public QObject { Q_OBJECT public: QmitkStoreSCPLauncher(QmitkStoreSCPLauncherBuilder* builder); virtual ~QmitkStoreSCPLauncher(); public slots: void StartStoreSCP(); void OnProcessError(QProcess::ProcessError error); void OnStateChanged(QProcess::ProcessState status); private: - QString GetPathToExecutable(); + void SetPathToStoreSCP(); void SetArgumentList(QmitkStoreSCPLauncherBuilder* builder); QString ArgumentListToQString(); + QString m_PathToStoreSCP; QProcess* m_StoreSCP; QStringList m_ArgumentList; }; #endif //QmitkStoreSCPLauncher_h \ No newline at end of file