diff --git a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt index 64c2cc07be..f19077c93f 100644 --- a/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.dicom/CMakeLists.txt @@ -1,13 +1,15 @@ project(org_mitk_gui_qt_dicom) set(QT_USE_QTSQL 1) include_directories(${CTK_INCLUDE_DIRS}) +MITK_INSTALL(PROGRAMS ${VAR_STORESCP}) + 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..5aba8d5012 100644 --- a/Plugins/org.mitk.gui.qt.dicom/files.cmake +++ b/Plugins/org.mitk.gui.qt.dicom/files.cmake @@ -1,55 +1,53 @@ 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 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/src/internal/QmitkDicomEditor.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp index a965c1f8a5..60cceb17c3 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp @@ -1,244 +1,244 @@ /*========================================================================= 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. =========================================================================*/ // Blueberry #include #include #include #include #include #include #include #include #include "berryFileEditorInput.h" // Qmitk #include "QmitkDicomEditor.h" #include "mitkPluginActivator.h" #include //#include "mitkProgressBar.h" // Qt #include #include #include #include #include #include #include #include #include #include #include #include #include #include //CTK #include #include #include #include #include const std::string QmitkDicomEditor::EDITOR_ID = "org.mitk.editors.dicomeditor"; QmitkDicomEditor::QmitkDicomEditor() : m_Thread(new QThread()) , m_DicomDirectoryListener(new QmitkDicomDirectoryListener()) , m_StoreSCPLauncher(new QmitkStoreSCPLauncher(&builder)) , m_Publisher(new QmitkDicomDataEventPublisher()) { } QmitkDicomEditor::~QmitkDicomEditor() { m_Thread->quit(); m_Thread->wait(1000); delete m_Handler; delete m_Publisher; delete m_StoreSCPLauncher; delete m_Thread; delete m_DicomDirectoryListener; } void QmitkDicomEditor::CreateQtPartControl(QWidget *parent ) { m_Controls.setupUi( parent ); TestHandler(); SetPluginDirectory(); SetDatabaseDirectory("DatabaseDirectory"); SetListenerDirectory("ListenerDirectory"); StartDicomDirectoryListener(); m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(false); m_Controls.StoreSCPLabel->setVisible(false); connect(m_Controls.externalDataWidget,SIGNAL(SignalAddDicomData(const QString&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QString&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalAddDicomData(const QStringList&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QStringList&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalDicomToDataManager(const QStringList&)),this,SLOT(OnViewButtonAddToDataManager(const QStringList&))); connect(m_Controls.externalDataWidget,SIGNAL(SignalChangePage(int)), this, SLOT(OnChangePage(int))); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QString&)),this,SLOT(OnDicomImportFinished(const QString&))); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QStringList&)),this,SLOT(OnDicomImportFinished(const QStringList&))); connect(m_Controls.internalDataWidget,SIGNAL(SignalDicomToDataManager(const QStringList&)),this,SLOT(OnViewButtonAddToDataManager(const QStringList&))); connect(m_Controls.CDButton, SIGNAL(clicked()), m_Controls.externalDataWidget, SLOT(OnFolderCDImport())); connect(m_Controls.FolderButton, SIGNAL(clicked()), m_Controls.externalDataWidget, SLOT(OnFolderCDImport())); connect(m_Controls.FolderButton, SIGNAL(clicked()), this, SLOT(OnFolderCDImport())); connect(m_Controls.QueryRetrieveButton, SIGNAL(clicked()), this, SLOT(OnQueryRetrieve())); connect(m_Controls.LocalStorageButton, SIGNAL(clicked()), this, SLOT(OnLocalStorage())); //connect(m_Controls.radioButton,SIGNAL(clicked()),this,SLOT(StartStopStoreSCP())); } void QmitkDicomEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) { this->SetSite(site); this->SetInput(input); } void QmitkDicomEditor::SetFocus() { } berry::IPartListener::Events::Types QmitkDicomEditor::GetPartEventTypes() const { return Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void QmitkDicomEditor::OnQueryRetrieve() { OnChangePage(2); QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString(); QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString(); if(!((builder.GetAETitle()->compare(storageAET,Qt::CaseSensitive)==0)&& (builder.GetPort()->compare(storagePort,Qt::CaseSensitive)==0))) { StopStoreSCP(); StartStoreSCP(); } m_Controls.StoreSCPLabel->setVisible(true); } void QmitkDicomEditor::OnFolderCDImport() { m_Controls.StoreSCPLabel->setVisible(false); } void QmitkDicomEditor::OnLocalStorage() { OnChangePage(0); m_Controls.StoreSCPLabel->setVisible(false); } void QmitkDicomEditor::OnChangePage(int page) { try{ m_Controls.stackedWidget->setCurrentIndex(page); }catch(std::exception e){ MITK_ERROR <<"error: "<< e.what(); return; } } void QmitkDicomEditor::OnDicomImportFinished(const QString& /*path*/) { } void QmitkDicomEditor::OnDicomImportFinished(const QStringList& /*path*/) { } void QmitkDicomEditor::StartDicomDirectoryListener() -{ +{ if(!m_Thread->isRunning()) { m_DicomDirectoryListener->SetDicomListenerDirectory(m_ListenerDirectory); connect(m_DicomDirectoryListener,SIGNAL(SignalAddDicomData(const QStringList&)),m_Controls.internalDataWidget,SLOT(StartDicomImport(const QStringList&)),Qt::DirectConnection); connect(m_Controls.internalDataWidget,SIGNAL(FinishedImport(const QStringList&)),m_DicomDirectoryListener,SLOT(OnDicomImportFinished(const QStringList&)),Qt::DirectConnection); m_DicomDirectoryListener->moveToThread(m_Thread); m_Thread->start(); } } //TODO Remove void QmitkDicomEditor::TestHandler() { m_Handler = new DicomEventHandler(); m_Handler->SubscribeSlots(); } void QmitkDicomEditor::OnViewButtonAddToDataManager(const QStringList& eventProperties) { ctkDictionary properties; properties["PatientName"] = eventProperties.at(0); properties["StudyUID"] = eventProperties.at(1); properties["StudyName"] = eventProperties.at(2); properties["SeriesUID"] = eventProperties.at(3); properties["SeriesName"] = eventProperties.at(4); properties["Path"] = eventProperties.at(5); m_Publisher->PublishSignals(mitk::PluginActivator::getContext()); m_Publisher->AddSeriesToDataManagerEvent(properties); } void QmitkDicomEditor::StartStoreSCP() { QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString(); QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString(); builder.AddPort(storagePort)->AddAETitle(storageAET)->AddTransferSyntax()->AddOtherNetworkOptions()->AddMode()->AddOutputDirectory(m_ListenerDirectory); m_StoreSCPLauncher = new QmitkStoreSCPLauncher(&builder); m_StoreSCPLauncher->StartStoreSCP(); m_Controls.StoreSCPLabel->setText("Storage provider is running on port: "+storagePort); } void QmitkDicomEditor::StopStoreSCP() { - delete m_StoreSCPLauncher; - m_Controls.StoreSCPLabel->setText(QString("Storage service provider is not running!")); + delete m_StoreSCPLauncher; + m_Controls.StoreSCPLabel->setText(QString("Storage service provider is not running!")); } void QmitkDicomEditor::SetPluginDirectory() { - m_PluginDirectory = mitk::PluginActivator::getContext()->getDataFile("").absolutePath(); - m_PluginDirectory.append("/"); + m_PluginDirectory = mitk::PluginActivator::getContext()->getDataFile("").absolutePath(); + m_PluginDirectory.append("/"); } void QmitkDicomEditor::SetDatabaseDirectory(const QString& databaseDirectory) { m_DatabaseDirectory.clear(); m_DatabaseDirectory.append(m_PluginDirectory); m_DatabaseDirectory.append(databaseDirectory); m_Controls.internalDataWidget->SetDatabaseDirectory(m_DatabaseDirectory); } void QmitkDicomEditor::SetListenerDirectory(const QString& listenerDirectory) { m_ListenerDirectory.clear(); m_ListenerDirectory.append(m_PluginDirectory); m_ListenerDirectory.append(listenerDirectory); } 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..38f04571a8 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,142 @@ /*========================================================================= 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 +#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); + FindPathToStoreSCP(); + MITK_INFO << m_PathToStoreSCP.toStdString(); + m_StoreSCP->start(m_PathToStoreSCP,m_ArgumentList); } -QString QmitkStoreSCPLauncher::GetPathToExecutable() +void QmitkStoreSCPLauncher::FindPathToStoreSCP() { - QDir root; - QString currentPath = root.currentPath(); - currentPath = currentPath.split("MITK").at(0); - currentPath.append("MITK/DCMTK-install/bin"); - return currentPath; + if(m_PathToStoreSCP.isEmpty()) + { + QString fileName; +#ifdef _WIN32 + fileName = "/storescp.exe"; +#else + fileName = "/storescp"; +#endif + + QString appPath= QCoreApplication::applicationDirPath(); + appPath; + m_PathToStoreSCP = appPath; + m_PathToStoreSCP.append(fileName); + //In developement the storescp isn't copied into bin directory + if(!QFile::exists(m_PathToStoreSCP)) + { + m_PathToStoreSCP.clear(); + appPath.append("/../../../DCMTK-install/bin"); + m_PathToStoreSCP = appPath; + m_PathToStoreSCP.append(fileName); + } + } } 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..22fbfb538d 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 FindPathToStoreSCP(); void SetArgumentList(QmitkStoreSCPLauncherBuilder* builder); QString ArgumentListToQString(); + QString m_PathToStoreSCP; QProcess* m_StoreSCP; QStringList m_ArgumentList; }; #endif //QmitkStoreSCPLauncher_h \ No newline at end of file