diff --git a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp index 7069b5e2bf..f110e6e786 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp +++ b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.cpp @@ -1,222 +1,241 @@ /*=================================================================== 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 // Qmitk #include "QmitkDicomExternalDataWidget.h" #include // Qt #include #include #include #include // CTK #include const std::string QmitkDicomExternalDataWidget::Widget_ID = "org.mitk.Widgets.QmitkDicomExternalDataWidget"; QmitkDicomExternalDataWidget::QmitkDicomExternalDataWidget(QWidget *parent) : m_Controls( 0 ) , m_DirectoryName(new QString()) { Initialize(); CreateQtPartControl(this); } QmitkDicomExternalDataWidget::~QmitkDicomExternalDataWidget() { delete m_ImportDialog; delete m_ExternalDatabase; delete m_ExternalModel; delete m_ExternalIndexer; delete m_Controls; delete m_DirectoryName; + delete m_ProgressDialogLabel; } void QmitkDicomExternalDataWidget::CreateQtPartControl( QWidget *parent ) { // build up qt Widget, unless already done if ( !m_Controls ) { // create GUI widgets from the Qt Designer's .ui file m_Controls = new Ui::QmitkDicomExternalDataWidgetControls; m_Controls->setupUi( parent ); - + m_Controls->cancelButton->setVisible(false); + m_Controls->viewExternalDataButton->setVisible(false); // m_Controls->ExternalDataTreeView->setSortingEnabled(true); m_Controls->ExternalDataTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls->ExternalDataTreeView->setModel(m_ExternalModel); + //connect Buttons + connect(m_Controls->downloadButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); + connect(m_Controls->viewExternalDataButton, SIGNAL(clicked()),this,SLOT(OnViewButtonClicked())); + connect(m_Controls->cancelButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); + //Initialize import widget m_ImportDialog = new ctkFileDialog(); QCheckBox* importCheckbox = new QCheckBox("Copy on import", m_ImportDialog); m_ImportDialog->setBottomWidget(importCheckbox); m_ImportDialog->setFileMode(QFileDialog::Directory); m_ImportDialog->setLabelText(QFileDialog::Accept,"Import"); m_ImportDialog->setWindowTitle("Import DICOM files from directory ..."); m_ImportDialog->setWindowModality(Qt::ApplicationModal); connect(m_ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(OnFileSelectedAddExternalData(QString))); - //connect Buttons - connect(m_Controls->downloadButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); - connect(m_Controls->viewExternalDataButton, SIGNAL(clicked()),this,SLOT(OnViewButtonClicked())); - connect(m_Controls->cancelButton, SIGNAL(clicked()),this,SLOT(OnDownloadButtonClicked())); - - connect(m_Controls->SearchOption_2, SIGNAL(parameterChanged()), this, SLOT(OnSearchParameterChanged())); + m_ProgressDialog= new QProgressDialog ("DICOM Import", "Cancel", 0, 100, this,Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + // We don't want the m_ProgressDialog dialog to resize itself, so we bypass the label + // by creating our own + m_ProgressDialogLabel = new QLabel(tr("Initialization...")); + m_ProgressDialog->setLabel(m_ProgressDialogLabel); + #ifdef Q_WS_MAC + // BUG: avoid deadlock of dialogs on mac + m_ProgressDialog->setWindowModality(Qt::NonModal); + #else + m_ProgressDialog->setWindowModality(Qt::ApplicationModal); + #endif + + connect(m_ProgressDialog, SIGNAL(canceled()), m_ExternalIndexer, SLOT(cancel())); + connect(m_ExternalIndexer, SIGNAL(indexingFilePath(QString)), + m_ProgressDialogLabel, SLOT(setText(QString))); + connect(m_ExternalIndexer, SIGNAL(progress(int)), + m_ProgressDialog, SLOT(setValue(int))); + connect(m_ExternalIndexer, SIGNAL(progress(int)), + this, SLOT(OnProgress(int))); } } void QmitkDicomExternalDataWidget::Initialize() { m_ExternalDatabase = new ctkDICOMDatabase(); //m_ExternalDatabase->initializeDatabase(); try{ m_ExternalDatabase->openDatabase(QString(":memory:"),QString( "EXTERNAL-DB")); }catch(std::exception e){ MITK_ERROR <<"Database error: "<< m_ExternalDatabase->lastError().toStdString(); m_ExternalDatabase->closeDatabase(); return; } m_ExternalModel = new ctkDICOMModel(); m_ExternalModel->setDatabase(m_ExternalDatabase->database()); m_ExternalModel->setEndLevel(ctkDICOMModel::SeriesType); m_ExternalIndexer = new ctkDICOMIndexer(); } void QmitkDicomExternalDataWidget::OnFolderCDImport() { m_ImportDialog->show(); m_ImportDialog->raise(); } void QmitkDicomExternalDataWidget::OnFileSelectedAddExternalData(QString directory) { if (QDir(directory).exists()) { m_DirectoryName = new QString(directory); QCheckBox* copyOnImport = qobject_cast(m_ImportDialog->bottomWidget()); if (copyOnImport->isChecked()) { - //targetDirectory = d->DICOMDatabase->databaseDirectory(); - MBI_DEBUG<ExternalDataTreeView->currentIndex(); if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { QString seriesUID = m_ExternalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); QString seriesName = m_ExternalModel->data(currentIndex).toString(); QModelIndex studyIndex = m_ExternalModel->parent(currentIndex); QString studyUID = m_ExternalModel->data(studyIndex,ctkDICOMModel::UIDRole).toString(); QString studyName = m_ExternalModel->data(studyIndex).toString(); QModelIndex patientIndex = m_ExternalModel->parent(studyIndex); QString patientName = m_ExternalModel->data(patientIndex).toString(); QStringList eventProperties; eventProperties << patientName << studyUID << studyName << seriesUID << seriesName << *m_DirectoryName; - MITK_INFO << m_DirectoryName->toStdString(); - emit SignalDicomToDataManager(eventProperties); } } void QmitkDicomExternalDataWidget::OnCancelButtonClicked() { m_Watcher.cancel(); m_Watcher.waitForFinished(); } void QmitkDicomExternalDataWidget::GetFileNamesFromIndex(QStringList& filePaths) { QModelIndex currentIndex = m_Controls->ExternalDataTreeView->currentIndex(); QString currentUID = m_ExternalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { filePaths.append(m_ExternalDatabase->filesForSeries(currentUID)); } else if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::StudyType)) { QStringList seriesList; seriesList.append( m_ExternalDatabase->seriesForStudy(currentUID) ); QStringList::Iterator serieIt; for(serieIt=seriesList.begin();serieIt!=seriesList.end();++serieIt) { filePaths.append(m_ExternalDatabase->filesForSeries(*serieIt)); } } else if(m_ExternalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::PatientType)) { QStringList studiesList,seriesList; studiesList.append( m_ExternalDatabase->studiesForPatient(currentUID) ); QStringList::Iterator studyIt,serieIt; for(studyIt=studiesList.begin();studyIt!=studiesList.end();++studyIt) { seriesList.append( m_ExternalDatabase->seriesForStudy(*studyIt) ); for(serieIt=seriesList.begin();serieIt!=seriesList.end();++serieIt) { filePaths.append(m_ExternalDatabase->filesForSeries(*serieIt)); } } } } void QmitkDicomExternalDataWidget::AddDicomTemporary(QString directory) { + m_ProgressDialog->setMinimumDuration(0); + m_ProgressDialog->setValue(0); + m_ProgressDialog->show(); m_ExternalIndexer->addDirectory(*m_ExternalDatabase,directory); m_ExternalModel->reset(); } +void QmitkDicomExternalDataWidget::OnProgress(int progress) +{ + Q_UNUSED(progress); + QApplication::processEvents(); +} + void QmitkDicomExternalDataWidget::OnSearchParameterChanged() { m_ExternalModel->setDatabase(m_ExternalDatabase->database(),m_Controls->SearchOption_2->parameters()); } diff --git a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.h b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.h index ac7cac6e5d..3ec7a98203 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.h +++ b/Modules/DicomUI/Qmitk/QmitkDicomExternalDataWidget.h @@ -1,122 +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. ===================================================================*/ #ifndef QmitkDicomExternalDataWidget_h #define QmitkDicomExternalDataWidget_h // #include #include "ui_QmitkDicomExternalDataWidgetControls.h" #include "mitkDicomUIExports.h" // include ctk #include #include #include #include //include QT #include #include #include #include //For running dicom import in background #include #include #include #include +#include +#include /*! \brief QmitkDicomExternalDataWidget \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class MITK_DICOMUI_EXPORT QmitkDicomExternalDataWidget : public QWidget { // 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 Widget_ID; QmitkDicomExternalDataWidget(QWidget *parent); virtual ~QmitkDicomExternalDataWidget(); virtual void CreateQtPartControl(QWidget *parent); /* @brief Initializes the widget. This method has to be called before widget can start. * @param dataStorage The data storage the widget should work with. * @param multiWidget The corresponding multiwidget were the ct Image is displayed and the user should define his path. * @param imageNode The image node which will be the base of mitral processing */ void Initialize(); signals: void SignalChangePage(int); void SignalAddDicomData(const QString&); void SignalAddDicomData(const QStringList&); void SignalDicomToDataManager(const QStringList&); public slots: /// @brief Called when import CD or import Folder was clicked. void OnFolderCDImport(); /// @brief Called when import directory was selected. void OnFileSelectedAddExternalData(QString); /// @brief Called when download button was clicked. void OnDownloadButtonClicked(); /// @brief Called when view button was clicked. void OnViewButtonClicked(); /// @brief Called when cancel button was clicked. void OnCancelButtonClicked(); /// @brief Called when search parameters change. void OnSearchParameterChanged(); + /// @brief Called when import progress change. + void OnProgress(int progress); + protected: /// \brief Get the list of filepath from current selected index in TreeView. All file paths referring to the index will be returned. void GetFileNamesFromIndex(QStringList& filePaths); void AddDicomTemporary(QString directory); ctkDICOMDatabase* m_ExternalDatabase; ctkDICOMModel* m_ExternalModel; ctkDICOMIndexer* m_ExternalIndexer; ctkFileDialog* m_ImportDialog; + QProgressDialog* m_ProgressDialog; + QLabel* m_ProgressDialogLabel; Ui::QmitkDicomExternalDataWidgetControls* m_Controls; QFuture m_Future; QFutureWatcher m_Watcher; QTimer* m_Timer; QString* m_DirectoryName; }; #endif // _QmitkDicomExternalDataWidget_H_INCLUDED diff --git a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp index c4b30c38e5..7ed05ee4e6 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp +++ b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.cpp @@ -1,192 +1,220 @@ /*=================================================================== 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. ===================================================================*/ // Qmitk #include "QmitkDicomLocalStorageWidget.h" #include #include +#include // Qt #include #include #include #include - - const std::string QmitkDicomLocalStorageWidget::Widget_ID = "org.mitk.Widgets.QmitkDicomLocalStorageWidget"; QmitkDicomLocalStorageWidget::QmitkDicomLocalStorageWidget(QWidget *parent) : m_Controls( 0 ) ,m_LocalIndexer(new ctkDICOMIndexer()) ,m_LocalModel(new ctkDICOMModel()) { CreateQtPartControl(this); } QmitkDicomLocalStorageWidget::~QmitkDicomLocalStorageWidget() { m_LocalDatabase->closeDatabase(); delete m_LocalDatabase; delete m_LocalIndexer; delete m_LocalModel; delete m_Controls; } void QmitkDicomLocalStorageWidget::CreateQtPartControl( QWidget *parent ) { if ( !m_Controls ) { m_Controls = new Ui::QmitkDicomLocalStorageWidgetControls; m_Controls->setupUi( parent ); m_Controls->groupBox->setVisible(false); + m_Controls->CancelButton->setVisible(false); m_Controls->addSortingTagButton_2->setVisible(false); m_Controls->deleteSortingTagButton_2->setVisible(false); m_Controls->InternalDataTreeView->setSortingEnabled(true); m_Controls->InternalDataTreeView->setSelectionBehavior(QAbstractItemView::SelectRows); m_Controls->InternalDataTreeView->setModel(m_LocalModel); connect(m_Controls->deleteButton,SIGNAL(clicked()),this,SLOT(OnDeleteButtonClicked())); connect(m_Controls->CancelButton, SIGNAL(clicked()), this , SLOT(OnCancelButtonClicked())); connect(m_Controls->viewInternalDataButton, SIGNAL(clicked()), this , SLOT(OnViewButtonClicked())); connect(m_Controls->SearchOption, SIGNAL(parameterChanged()), this, SLOT(OnSearchParameterChanged())); } } void QmitkDicomLocalStorageWidget::StartDicomImport(const QString& dicomData) { if (m_Watcher.isRunning()){ m_Watcher.waitForFinished(); } - mitk::ProgressBar::GetInstance()->AddStepsToDo(2); + SetupProgressDialog(); m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QString&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); m_Watcher.setFuture(m_Future); } void QmitkDicomLocalStorageWidget::StartDicomImport(const QStringList& dicomData) { + mitk::ProgressBar::GetInstance()->AddStepsToDo(dicomData.count()); if (m_Watcher.isRunning()) { m_Watcher.waitForFinished(); } - mitk::ProgressBar::GetInstance()->AddStepsToDo(dicomData.count()); m_Future = QtConcurrent::run(this,(void (QmitkDicomLocalStorageWidget::*)(const QStringList&)) &QmitkDicomLocalStorageWidget::AddDICOMData,dicomData); m_Watcher.setFuture(m_Future); } void QmitkDicomLocalStorageWidget::AddDICOMData(const QString& directory) { if(m_LocalDatabase->isOpen()) { - mitk::ProgressBar::GetInstance()->Progress(); m_LocalIndexer->addDirectory(*m_LocalDatabase,directory,m_LocalDatabase->databaseDirectory()); } m_LocalModel->setDatabase(m_LocalDatabase->database()); - mitk::ProgressBar::GetInstance()->Progress(); emit FinishedImport(directory); } void QmitkDicomLocalStorageWidget::AddDICOMData(const QStringList& patientFiles) { if(m_LocalDatabase->isOpen()) { QStringListIterator fileIterator(patientFiles); while(fileIterator.hasNext()) { m_LocalIndexer->addFile(*m_LocalDatabase,fileIterator.next(),m_LocalDatabase->databaseDirectory()); mitk::ProgressBar::GetInstance()->Progress(); } } m_LocalModel->setDatabase(m_LocalDatabase->database()); emit FinishedImport(patientFiles); } +void QmitkDicomLocalStorageWidget::SetupProgressDialog() +{ + m_ProgressDialog = new QProgressDialog("DICOM Import", "Cancel", 0, 100, this,Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + m_ProgressDialogLabel = new QLabel(tr("Initialization...")); + m_ProgressDialog->setLabel(m_ProgressDialogLabel); +#ifdef Q_WS_MAC + // BUG: avoid deadlock of dialogs on mac + m_ProgressDialog->setWindowModality(Qt::NonModal); +#else + m_ProgressDialog->setWindowModality(Qt::ApplicationModal); +#endif + + m_ProgressDialog->setMinimumDuration(0); + m_ProgressDialog->setValue(0); + m_ProgressDialog->show(); + + connect(m_ProgressDialog, SIGNAL(canceled()), m_LocalIndexer, SLOT(cancel())); + connect(m_LocalIndexer, SIGNAL(indexingFilePath(QString)), + m_ProgressDialogLabel, SLOT(setText(QString))); + connect(m_LocalIndexer, SIGNAL(progress(int)), + m_ProgressDialog, SLOT(setValue(int))); + connect(m_LocalIndexer, SIGNAL(progress(int)), + this, SLOT(OnProgress(int))); +} + +void QmitkDicomLocalStorageWidget::OnProgress(int progress) +{ + Q_UNUSED(progress); + QApplication::processEvents(); +} + void QmitkDicomLocalStorageWidget::OnDeleteButtonClicked() { QModelIndex currentIndex = m_Controls->InternalDataTreeView->currentIndex(); QString currentUID = m_LocalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { m_LocalDatabase->removeSeries(currentUID); } else if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::StudyType)) { m_LocalDatabase->removeStudy(currentUID); } else if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::PatientType)) { m_LocalDatabase->removePatient(currentUID); } m_LocalModel->reset(); } void QmitkDicomLocalStorageWidget::OnCancelButtonClicked() { m_Watcher.cancel(); m_Watcher.waitForFinished(); m_LocalDatabase->closeDatabase(); } void QmitkDicomLocalStorageWidget::OnViewButtonClicked() { QModelIndex currentIndex = m_Controls->InternalDataTreeView->currentIndex(); if(m_LocalModel->data(currentIndex,ctkDICOMModel::TypeRole)==static_cast(ctkDICOMModel::SeriesType)) { QString seriesUID = m_LocalModel->data(currentIndex,ctkDICOMModel::UIDRole).toString(); QString seriesName = m_LocalModel->data(currentIndex).toString(); - + QModelIndex studyIndex = m_LocalModel->parent(currentIndex); QString studyUID = m_LocalModel->data(studyIndex,ctkDICOMModel::UIDRole).toString(); QString studyName = m_LocalModel->data(studyIndex).toString(); QModelIndex patientIndex = m_LocalModel->parent(studyIndex); QString patientName = m_LocalModel->data(patientIndex).toString(); QString filePath; filePath.append(m_LocalDatabase->databaseDirectory()); filePath.append("/dicom/"); filePath.append(studyUID); filePath.append("/"); filePath.append(seriesUID); filePath.append("/"); QStringList eventProperties; eventProperties << patientName << studyUID <setDatabase(m_LocalDatabase->database(),m_Controls->SearchOption->parameters()); } void QmitkDicomLocalStorageWidget::SetDatabaseDirectory(QString newDatatbaseDirectory) { QDir databaseDirecory = QDir(newDatatbaseDirectory); if(!databaseDirecory.exists()) { databaseDirecory.mkpath(databaseDirecory.absolutePath()); } QString newDatatbaseFile = databaseDirecory.absolutePath() + QString("/ctkDICOM.sql"); this->SetDatabase(newDatatbaseFile); } void QmitkDicomLocalStorageWidget::SetDatabase(QString databaseFile) { m_LocalDatabase = new ctkDICOMDatabase(databaseFile); m_LocalModel->setEndLevel(ctkDICOMModel::SeriesType); m_LocalModel->setDatabase(m_LocalDatabase->database()); } diff --git a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h index 36528eb66f..c103241b2e 100644 --- a/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h +++ b/Modules/DicomUI/Qmitk/QmitkDicomLocalStorageWidget.h @@ -1,114 +1,119 @@ /*=================================================================== 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 QmitkDicomLocalStorageWidget_h #define QmitkDicomLocalStorageWidget_h // #include #include "ui_QmitkDicomLocalStorageWidgetControls.h" #include "mitkDicomUIExports.h" // include ctk #include #include #include #include //include QT #include #include #include //For running dicom import in background #include #include #include #include - -#include -#include +#include +#include /*! \brief QmitkDicomLocalStorageWidget \warning This application module is not yet documented. Use "svn blame/praise/annotate" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup Functionalities */ class MITK_DICOMUI_EXPORT QmitkDicomLocalStorageWidget : public QWidget { // 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 Widget_ID; QmitkDicomLocalStorageWidget(QWidget *parent); virtual ~QmitkDicomLocalStorageWidget(); virtual void CreateQtPartControl(QWidget *parent); void SetDatabaseDirectory(QString newDatabaseDirectory); signals: void FinishedImport(const QString&); void FinishedImport(const QStringList&); void SignalDicomToDataManager(const QStringList&); public slots: /// @brief Called when cancel button was clicked. void OnViewButtonClicked(); /// @brief Called when cancel button was clicked. void OnCancelButtonClicked(); /// @brief Called delete button was clicked. void OnDeleteButtonClicked(); /// @brief Called when adding a dicom directory. Starts a thread adding the directory. void StartDicomImport(const QString& dicomData); /// @brief Called when adding a list of dicom files. Starts a thread adding the dicom files. void StartDicomImport(const QStringList& dicomData); /// @brief Called when search parameters change. void OnSearchParameterChanged(); + void OnProgress(int progress); protected: // adds dicom files from a directory containing dicom files to the local storage. void AddDICOMData(const QString& dicomDirectory); // adds dicom files from a string list containing the filepath to the local storage. void AddDICOMData(const QStringList& dicomFiles); void SetDatabase(QString databaseFile); + void SetupProgressDialog(); + + QProgressDialog* m_ProgressDialog; + QLabel* m_ProgressDialogLabel; + ctkDICOMDatabase* m_LocalDatabase; ctkDICOMModel* m_LocalModel; ctkDICOMIndexer* m_LocalIndexer; Ui::QmitkDicomLocalStorageWidgetControls* m_Controls; QFuture m_Future; QFutureWatcher m_Watcher; }; #endif // _QmitkDicomLocalStorageWidget_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.dicom./resources/dicom.qrc b/Plugins/org.mitk.gui.qt.dicom./resources/dicom.qrc new file mode 100644 index 0000000000..bf16525381 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dicom./resources/dicom.qrc @@ -0,0 +1,10 @@ + + + drive-harddisk_32.png + folder_32.png + media-optical_32.png + network-workgroup_32.png + network-idle_16.png + network-offline_16.png + + diff --git a/Plugins/org.mitk.gui.qt.dicom/files.cmake b/Plugins/org.mitk.gui.qt.dicom/files.cmake index 5aba8d5012..a250736622 100644 --- a/Plugins/org.mitk.gui.qt.dicom/files.cmake +++ b/Plugins/org.mitk.gui.qt.dicom/files.cmake @@ -1,53 +1,54 @@ 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 +resources/dicom.qrc ) 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/dicom.qrc b/Plugins/org.mitk.gui.qt.dicom/resources/dicom.qrc new file mode 100644 index 0000000000..bf16525381 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.dicom/resources/dicom.qrc @@ -0,0 +1,10 @@ + + + drive-harddisk_32.png + folder_32.png + media-optical_32.png + network-workgroup_32.png + network-idle_16.png + network-offline_16.png + + diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/drive-harddisk_32.png b/Plugins/org.mitk.gui.qt.dicom/resources/drive-harddisk_32.png new file mode 100644 index 0000000000..b34d8b7794 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/drive-harddisk_32.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/folder_32.png b/Plugins/org.mitk.gui.qt.dicom/resources/folder_32.png new file mode 100644 index 0000000000..472484f112 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/folder_32.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/media-optical_32.png b/Plugins/org.mitk.gui.qt.dicom/resources/media-optical_32.png new file mode 100644 index 0000000000..5853a754e4 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/media-optical_32.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-error_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-error_16.png new file mode 100644 index 0000000000..3f18ed0f7b Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-error_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-idle_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-idle_16.png new file mode 100644 index 0000000000..0efee57e59 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-idle_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-offline_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-offline_16.png new file mode 100644 index 0000000000..1f210fc3e9 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-offline_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-receive_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-receive_16.png new file mode 100644 index 0000000000..b57c65c86a Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-receive_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit-receive_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit-receive_16.png new file mode 100644 index 0000000000..271d37d0f3 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit-receive_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit_16.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit_16.png new file mode 100644 index 0000000000..08aa28b099 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-transmit_16.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/resources/network-workgroup_32.png b/Plugins/org.mitk.gui.qt.dicom/resources/network-workgroup_32.png new file mode 100644 index 0000000000..4137b3c3b7 Binary files /dev/null and b/Plugins/org.mitk.gui.qt.dicom/resources/network-workgroup_32.png differ diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp index f92f90138b..07de69a223 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.cpp @@ -1,124 +1,116 @@ /*=================================================================== 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 "QmitkDicomDirectoryListener.h" #include #include - +#include #include QmitkDicomDirectoryListener::QmitkDicomDirectoryListener() : m_FileSystemWatcher(new QFileSystemWatcher()) -, m_FilesToImport(new QStringList()) -, m_ImportingFiles(new QStringList()) -, m_DicomListenerDirectory(QString()) { connect(m_FileSystemWatcher,SIGNAL(directoryChanged(const QString&)),this,SLOT(OnDirectoryChanged(const QString&))); } QmitkDicomDirectoryListener::~QmitkDicomDirectoryListener() { - delete m_FilesToImport; - delete m_ImportingFiles; delete m_FileSystemWatcher; } void QmitkDicomDirectoryListener::OnDirectoryChanged(const QString&) { - //m_Mutex.lock(); SetFilesToImport(); - m_ImportingFiles->append(*m_FilesToImport); - emit SignalAddDicomData(*m_FilesToImport); - //m_Mutex.unlock(); + m_ImportingFiles.append(m_FilesToImport); + emit SignalAddDicomData(m_FilesToImport); } void QmitkDicomDirectoryListener::OnDicomImportFinished(const QStringList& finishedFiles) { - //m_Mutex.lock(); RemoveFilesFromDirectoryAndImportingFilesList(finishedFiles); - //m_Mutex.unlock(); } void QmitkDicomDirectoryListener::SetFilesToImport() { - m_FilesToImport->clear(); + m_FilesToImport.clear(); QDir listenerDirectory(m_DicomListenerDirectory); QFileInfoList entries = listenerDirectory.entryInfoList(QDir::Files); if(!entries.isEmpty()) { QFileInfoList::const_iterator file; for(file = entries.constBegin(); file != entries.constEnd(); ++file ) { - if(!m_ImportingFiles->contains((*file).absoluteFilePath())) + if(!m_ImportingFiles.contains((*file).absoluteFilePath())) { - m_FilesToImport->append((*file).absoluteFilePath()); + m_FilesToImport.append((*file).absoluteFilePath()); } } } } void QmitkDicomDirectoryListener::RemoveFilesFromDirectoryAndImportingFilesList(const QStringList& files) { QStringListIterator fileToDeleteIterator(files); while(fileToDeleteIterator.hasNext()) { QFile file(fileToDeleteIterator.next()); - if(m_ImportingFiles->contains(file.fileName())) + if(m_ImportingFiles.contains(file.fileName())) { - m_ImportingFiles->removeOne(file.fileName()); + m_ImportingFiles.removeOne(file.fileName()); file.remove(); } } } void QmitkDicomDirectoryListener::SetDicomListenerDirectory(const QString& directory) { if(isOnlyListenedDirectory(directory)) { QDir listenerDirectory = QDir(directory); CreateListenerDirectory(listenerDirectory); m_DicomListenerDirectory=listenerDirectory.absolutePath(); m_FileSystemWatcher->addPath(m_DicomListenerDirectory); + MITK_INFO << m_DicomListenerDirectory.toStdString(); } } const QString& QmitkDicomDirectoryListener::GetDicomListenerDirectory() { return m_DicomListenerDirectory; } void QmitkDicomDirectoryListener::CreateListenerDirectory(const QDir& directory) { if(!directory.exists()) { directory.mkpath(directory.absolutePath()); } } bool QmitkDicomDirectoryListener::isOnlyListenedDirectory(const QString& directory) { bool isOnlyListenedDirectory = false; if(m_FileSystemWatcher->directories().count()==0||m_FileSystemWatcher->directories().count()==1) { if(!m_FileSystemWatcher->directories().contains(directory)) { isOnlyListenedDirectory = true; } } return isOnlyListenedDirectory; } \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h index a8f694ebee..010cda4e90 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomDirectoryListener.h @@ -1,80 +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 QmitkDicomDirectoryListener_h #define QmitkDicomDirectoryListener_h #include #include #include #include #include -#include #include class QmitkDicomDirectoryListener : public QObject { Q_OBJECT public: QmitkDicomDirectoryListener(); virtual ~QmitkDicomDirectoryListener(); /// @brief sets listened directory, note that only one directory can be set. void SetDicomListenerDirectory(const QString&); /// @brief get filepath to the listened directory. const QString& GetDicomListenerDirectory(); signals: /// @brief signal starts the dicom import of the given file (the QStringList will only contain one file here). void SignalAddDicomData(const QStringList&); public slots: /// \brief called when listener directory changes void OnDirectoryChanged(const QString&); /// \brief called when import is finished void OnDicomImportFinished(const QStringList&); protected: /// \brief creates directory if it's not already existing. void CreateListenerDirectory(const QDir& directory); /// \brief checks wheter the given directory is the only directory that is listened. bool isOnlyListenedDirectory(const QString& directory); /// \brief Composes the filename and initializes m_LastRetrievedFile with it void SetFilesToImport(); /// \brief removes files from void RemoveFilesFromDirectoryAndImportingFilesList(const QStringList& files); QFileSystemWatcher* m_FileSystemWatcher; - QStringList* m_FilesToImport; - QStringList* m_ImportingFiles; + QStringList m_FilesToImport; + QStringList m_ImportingFiles; QString m_DicomListenerDirectory; - QMutex m_Mutex; }; #endif // QmitkDicomListener_h \ No newline at end of file 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 50e1a090a3..b2039387f9 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.cpp @@ -1,242 +1,249 @@ /*=================================================================== 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. ===================================================================*/ // 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_StoreSCPLauncher(new QmitkStoreSCPLauncher(&m_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 ); + m_Controls.LocalStorageButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/drive-harddisk_32.png")); + m_Controls.FolderButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/folder_32.png")); + m_Controls.CDButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/media-optical_32.png")); + m_Controls.QueryRetrieveButton->setIcon(QIcon(":/org.mitk.gui.qt.dicom/network-workgroup_32.png")); + m_Controls.StoreSCPStatusLabel->setTextFormat(Qt::RichText); + m_Controls.StoreSCPStatusLabel->setText(""); + + TestHandler(); SetPluginDirectory(); SetDatabaseDirectory("DatabaseDirectory"); SetListenerDirectory("ListenerDirectory"); StartDicomDirectoryListener(); - m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(false); - m_Controls.StoreSCPLabel->setVisible(false); + m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(true); 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))) + if(!((m_Builder.GetAETitle()->compare(storageAET,Qt::CaseSensitive)==0)&& + (m_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 QString&) { } -void QmitkDicomEditor::OnDicomImportFinished(const QStringList& /*path*/) +void QmitkDicomEditor::OnDicomImportFinished(const QStringList&) { } 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_Builder.AddPort(storagePort)->AddAETitle(storageAET)->AddTransferSyntax()->AddOtherNetworkOptions()->AddMode()->AddOutputDirectory(m_ListenerDirectory); + m_StoreSCPLauncher = new QmitkStoreSCPLauncher(&m_Builder); + connect(m_StoreSCPLauncher, SIGNAL(SignalStatusOfStoreSCP(const QString&)), this, SLOT(OnStoreSCPStatusChanged(const QString&))); m_StoreSCPLauncher->StartStoreSCP(); - m_Controls.StoreSCPLabel->setText("Storage provider is running on port: "+storagePort); } +void QmitkDicomEditor::OnStoreSCPStatusChanged(const QString& status) +{ + m_Controls.StoreSCPStatusLabel->setText(" "+status); +} void QmitkDicomEditor::StopStoreSCP() { 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("/"); } 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/QmitkDicomEditor.h b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.h index bb5a35d6b4..7493e1c02e 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.h +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditor.h @@ -1,133 +1,135 @@ -/*=================================================================== +/*========================================================================= 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 QmitkDicomEditor_h #define QmitkDicomEditor_h #include #include #include #include "ui_QmitkDicomEditorControls.h" #include "QmitkDicomDirectoryListener.h" #include "QmitkStoreSCPLauncher.h" #include "QmitkStoreSCPLauncherBuilder.h" #include "DicomEventHandler.h" #include "QmitkDicomDataEventPublisher.h" #include #include #include #include #include #include #include #include #include #include /*! \brief QmitkDicomEditor \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation. \sa QmitkFunctionality \ingroup ${plugin_target}_internal */ class DICOM_EXPORT QmitkDicomEditor : public berry::QtEditorPart, virtual public berry::IPartListener { // 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: berryObjectMacro(QmitkDicomEditor) static const std::string EDITOR_ID; QmitkDicomEditor(); virtual ~QmitkDicomEditor(); void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); void SetFocus(); void DoSave() {} void DoSaveAs() {} bool IsDirty() const { return false; } bool IsSaveAsAllowed() const { return false; } signals: protected slots: /// \brief Called when StoreSCP shold start void StartStoreSCP(); /// \brief Called when StoreSCP should stop void StopStoreSCP(); /// \brief Called when import is finished void OnDicomImportFinished(const QString& path); /// \brief Called when import is finished void OnDicomImportFinished(const QStringList& path); /// \brief Called when Query Retrieve or Import Folder was clicked. void OnQueryRetrieve(); /// \brief Called when LocalStorageButton was clicked. void OnLocalStorage(); /// \brief Called when FolderCDButton was clicked. void OnFolderCDImport(); /// \brief Called when view button is clicked. Sends out an event for adding the current selected file to the mitkDataStorage. void OnViewButtonAddToDataManager(const QStringList& eventProperties); void StartDicomDirectoryListener(); void OnChangePage(int); + void OnStoreSCPStatusChanged(const QString& status); + void TestHandler(); void SetDatabaseDirectory(const QString& databaseDirectory); void SetListenerDirectory(const QString& listenerDirectory); protected: void CreateQtPartControl(QWidget *parent); void SetPluginDirectory(); Events::Types GetPartEventTypes() const; Ui::QmitkDicomEditorControls m_Controls; QThread* m_Thread; QmitkDicomDirectoryListener* m_DicomDirectoryListener; - QmitkStoreSCPLauncherBuilder builder; + QmitkStoreSCPLauncherBuilder m_Builder; QmitkStoreSCPLauncher* m_StoreSCPLauncher; DicomEventHandler* m_Handler; QmitkDicomDataEventPublisher* m_Publisher; QString m_PluginDirectory; QString m_ListenerDirectory; QString m_DatabaseDirectory; }; #endif // QmitkDicomEditor_h diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditorControls.ui b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditorControls.ui index c4d1a85be9..ec8d717b6f 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditorControls.ui +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomEditorControls.ui @@ -1,157 +1,264 @@ QmitkDicomEditorControls 0 0 752 696 0 0 + + false + QmitkTemplate QFrame::StyledPanel QFrame::Raised - QFrame::StyledPanel + QFrame::NoFrame QFrame::Plain + + 0 + + + 0 + + + Local storage you can find your dicom data here. + Local Storage + + + 32 + 32 + + + + false + + + true + + + Imports dicom data to your local storage from CD. + Import CD + + + 32 + 32 + + + + true + + + Imports dicom data to your local storage from a folder. + Import Folder + + + 32 + 32 + + + + true + + + Query dicom data from a PACS and retrieve it to your system. + Query Retrieve + + + 32 + 32 + + + + true + Qt::Horizontal 40 20 true 0 - - - Storage provider is not running! + + + QFrame::StyledPanel - - Qt::NoTextInteraction + + QFrame::Raised + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 4 + 20 + + + + + + + + + + + Qt::RichText + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + ctkDICOMQueryRetrieveWidget QWidget
ctkDICOMQueryRetrieveWidget.h
1
QmitkDicomLocalStorageWidget QWidget
Qmitk/QmitkDicomLocalStorageWidget.h
1
QmitkDicomExternalDataWidget QWidget
Qmitk/QmitkDicomExternalDataWidget.h
1
OnChangePage(int)
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 f70107e5b0..56f786bc14 100644 --- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp +++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkStoreSCPLauncher.cpp @@ -1,140 +1,146 @@ /*=================================================================== 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 "QmitkStoreSCPLauncher.h" #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(); + m_StoreSCP->close(); + m_StoreSCP->waitForFinished(1000); delete m_StoreSCP; } void QmitkStoreSCPLauncher::StartStoreSCP() { FindPathToStoreSCP(); MITK_INFO << m_PathToStoreSCP.toStdString(); + MITK_INFO << m_ArgumentList[7].toStdString(); m_StoreSCP->start(m_PathToStoreSCP,m_ArgumentList); } void QmitkStoreSCPLauncher::FindPathToStoreSCP() { 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(); + m_ErrorText = QString("Failed to start storage provider: ").append(m_StoreSCP->errorString()); break; case QProcess::Crashed: - MITK_INFO << QString("Storage provider crashed: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider crashed: ").append(m_StoreSCP->errorString()); break; case QProcess::Timedout: - MITK_INFO << QString("Storage provider timeout: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider timeout: ").append(m_StoreSCP->errorString()); break; case QProcess::WriteError: - MITK_INFO << QString("Storage provider write error: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider write error: ").append(m_StoreSCP->errorString()); break; case QProcess::ReadError: - MITK_INFO << QString("Storage provider read error: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider read error: ").append(m_StoreSCP->errorString()); break; case QProcess::UnknownError: - MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()); break; default: - MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); + m_ErrorText = QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()); break; } } void QmitkStoreSCPLauncher::OnStateChanged(QProcess::ProcessState status) { switch(status) { case QProcess::NotRunning: - MITK_INFO << QString("Storage provider not running: ").append(m_StoreSCP->errorString()).toStdString(); + m_StatusText = QString("Storage provider not running: "); + emit SignalStatusOfStoreSCP(m_StatusText); break; case QProcess::Starting: - MITK_INFO << QString("Starting storage provider").toStdString(); + m_StatusText = QString("Starting ").append(m_ArgumentList[2]).append(" on port ").append(m_ArgumentList[0]); + emit SignalStatusOfStoreSCP(m_StatusText); break; case QProcess::Running: - MITK_INFO << QString("Running storage provider").toStdString(); + m_StatusText = QString("Running ").append(m_ArgumentList[2]).append(" on port ").append(m_ArgumentList[0]);; + emit SignalStatusOfStoreSCP(m_StatusText); break; default: - MITK_INFO << QString("Storage provider unknown error: ").append(m_StoreSCP->errorString()).toStdString(); + m_StatusText = QString("Storage provider unknown error: "); + emit SignalStatusOfStoreSCP(m_StatusText); 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 1aa4ba7a19..bcfe057920 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,51 @@ /*=================================================================== 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 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); +public slots: + void StartStoreSCP(); + void OnProcessError(QProcess::ProcessError error); + void OnStateChanged(QProcess::ProcessState status); +signals: + void SignalStatusOfStoreSCP(const QString&); private: void FindPathToStoreSCP(); void SetArgumentList(QmitkStoreSCPLauncherBuilder* builder); QString ArgumentListToQString(); QString m_PathToStoreSCP; + QString m_ErrorText; + QString m_StatusText; QProcess* m_StoreSCP; QStringList m_ArgumentList; }; #endif //QmitkStoreSCPLauncher_h \ No newline at end of file