diff --git a/Plugins/org.mitk.gui.qt.dicom/plugin.xml b/Plugins/org.mitk.gui.qt.dicom/plugin.xml
index 67d407e76a..5aa4809400 100644
--- a/Plugins/org.mitk.gui.qt.dicom/plugin.xml
+++ b/Plugins/org.mitk.gui.qt.dicom/plugin.xml
@@ -1,20 +1,20 @@
-
+
diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.cpp b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.cpp
index 9ef73190a8..d1813888b9 100644
--- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.cpp
+++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.cpp
@@ -1,212 +1,206 @@
/*===================================================================
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 "QmitkDicomBrowser.h"
#include "mitkPluginActivator.h"
#include "berryIQtPreferencePage.h"
#include
#include
#include
#include
const std::string QmitkDicomBrowser::EDITOR_ID = "org.mitk.editors.dicombrowser";
const QString QmitkDicomBrowser::TEMP_DICOM_FOLDER_SUFFIX="TmpDicomFolder";
QmitkDicomBrowser::QmitkDicomBrowser()
: m_Thread(new QThread())
, m_DicomDirectoryListener(new QmitkDicomDirectoryListener())
, m_StoreSCPLauncher(new QmitkStoreSCPLauncher(&m_Builder))
, m_Publisher(new QmitkDicomDataEventPublisher())
{
}
QmitkDicomBrowser::~QmitkDicomBrowser()
{
m_Thread.quit();
m_Thread.wait(1000);
delete m_DicomDirectoryListener;
delete m_StoreSCPLauncher;
delete m_Handler;
delete m_Publisher;
}
void QmitkDicomBrowser::CreateQtPartControl(QWidget *parent )
{
m_Controls.setupUi( parent );
m_Controls.StoreSCPStatusLabel->setTextFormat(Qt::RichText);
m_Controls.StoreSCPStatusLabel->setText("");
TestHandler();
- SetPluginDirectory();
- SetDatabaseDirectory("DatabaseDirectory");
+ OnPreferencesChanged(0);
CreateTemporaryDirectory();
StartDicomDirectoryListener();
m_Controls.m_ctkDICOMQueryRetrieveWidget->useProgressDialog(false);
connect(m_Controls.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int)));
connect(m_Controls.externalDataWidget,SIGNAL(SignalStartDicomImport(const QStringList&)),
m_Controls.internalDataWidget,SLOT(OnStartDicomImport(const QStringList&)));
connect(m_Controls.externalDataWidget,SIGNAL(SignalDicomToDataManager(const QHash&)),
this,SLOT(OnViewButtonAddToDataManager(const QHash&)));
connect(m_Controls.internalDataWidget,SIGNAL(SignalFinishedImport()),this, SLOT(OnDicomImportFinished()));
connect(m_Controls.internalDataWidget,SIGNAL(SignalDicomToDataManager(const QHash&)),
this,SLOT(OnViewButtonAddToDataManager(const QHash&)));
}
void QmitkDicomBrowser::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input)
{
this->SetSite(site);
this->SetInput(input);
}
void QmitkDicomBrowser::SetFocus()
{
}
berry::IPartListener::Events::Types QmitkDicomBrowser::GetPartEventTypes() const
{
return Events::CLOSED | Events::HIDDEN | Events::VISIBLE;
}
void QmitkDicomBrowser::OnTabChanged(int page)
{
if (page == 2)//Query/Retrieve is selected
{
QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString();
QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString();
if(!((m_Builder.GetAETitle()->compare(storageAET,Qt::CaseSensitive)==0)&&
(m_Builder.GetPort()->compare(storagePort,Qt::CaseSensitive)==0)))
{
StopStoreSCP();
StartStoreSCP();
}
}
}
void QmitkDicomBrowser::OnDicomImportFinished()
{
m_Controls.tabWidget->setCurrentIndex(0);
}
void QmitkDicomBrowser::StartDicomDirectoryListener()
{
if(!m_Thread.isRunning())
{
m_DicomDirectoryListener->SetDicomListenerDirectory(m_TempDirectory);
m_DicomDirectoryListener->SetDicomFolderSuffix(TEMP_DICOM_FOLDER_SUFFIX);
connect(m_DicomDirectoryListener,SIGNAL(SignalStartDicomImport(const QStringList&)),m_Controls.internalDataWidget,SLOT(OnStartDicomImport(const QStringList&)),Qt::DirectConnection);
//connect(m_Controls.internalDataWidget,SIGNAL(SignalFinishedImport()),m_DicomDirectoryListener,SLOT(OnImportFinished()),Qt::DirectConnection);
m_DicomDirectoryListener->moveToThread(&m_Thread);
m_Thread.start();
}
}
void QmitkDicomBrowser::TestHandler()
{
m_Handler = new DicomEventHandler();
m_Handler->SubscribeSlots();
}
void QmitkDicomBrowser::OnViewButtonAddToDataManager(QHash eventProperties)
{
ctkDictionary properties;
// properties["PatientName"] = eventProperties["PatientName"];
// properties["StudyUID"] = eventProperties["StudyUID"];
// properties["StudyName"] = eventProperties["StudyName"];
// properties["SeriesUID"] = eventProperties["SeriesUID"];
// properties["SeriesName"] = eventProperties["SeriesName"];
properties["FilesForSeries"] = eventProperties["FilesForSeries"];
m_Publisher->PublishSignals(mitk::PluginActivator::getContext());
m_Publisher->AddSeriesToDataManagerEvent(properties);
}
void QmitkDicomBrowser::StartStoreSCP()
{
QString storagePort = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StoragePort"].toString();
QString storageAET = m_Controls.m_ctkDICOMQueryRetrieveWidget->getServerParameters()["StorageAETitle"].toString();
m_Builder.AddPort(storagePort)->AddAETitle(storageAET)->AddTransferSyntax()->AddOtherNetworkOptions()->AddMode()->AddOutputDirectory(m_TempDirectory);
m_StoreSCPLauncher = new QmitkStoreSCPLauncher(&m_Builder);
connect(m_StoreSCPLauncher, SIGNAL(SignalStatusOfStoreSCP(const QString&)), this, SLOT(OnStoreSCPStatusChanged(const QString&)));
connect(m_StoreSCPLauncher ,SIGNAL(SignalStartImport(const QStringList&)),m_Controls.internalDataWidget,SLOT(OnStartDicomImport(const QStringList&)));
connect(m_StoreSCPLauncher ,SIGNAL(SignalStoreSCPError(const QString&)),m_DicomDirectoryListener,SLOT(OnDicomNetworkError(const QString&)),Qt::DirectConnection);
connect(m_StoreSCPLauncher ,SIGNAL(SignalStoreSCPError(const QString&)),this,SLOT(OnDicomNetworkError(const QString&)),Qt::DirectConnection);
m_StoreSCPLauncher->StartStoreSCP();
}
void QmitkDicomBrowser::OnStoreSCPStatusChanged(const QString& status)
{
m_Controls.StoreSCPStatusLabel->setText(" "+status);
}
void QmitkDicomBrowser::OnDicomNetworkError(const QString& status)
{
m_Controls.StoreSCPStatusLabel->setText(" "+status);
}
void QmitkDicomBrowser::StopStoreSCP()
{
delete m_StoreSCPLauncher;
}
void QmitkDicomBrowser::SetPluginDirectory()
{
m_PluginDirectory = mitk::PluginActivator::getContext()->getDataFile("").absolutePath();
m_PluginDirectory.append("/database");
}
-void QmitkDicomBrowser::SetDatabaseDirectory(const QString& databaseDirectory)
-{
- SetPluginDirectory();
- berry::IPreferencesService::Pointer prefService=
- berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID);
- std::string targetPath = prefService->GetSystemPreferences()->Node("/org.mitk.views.dicomreader")->Get("default dicom path", m_PluginDirectory.toStdString());
-
- m_DatabaseDirectory.clear();
- m_DatabaseDirectory.append(targetPath.c_str());
- m_Controls.internalDataWidget->SetDatabaseDirectory(m_DatabaseDirectory);
-}
-
void QmitkDicomBrowser::CreateTemporaryDirectory()
{
QDir tmp;
QString tmpPath = QDir::tempPath();
m_TempDirectory.clear();
m_TempDirectory.append(tmpPath);
m_TempDirectory.append(QString("/"));
m_TempDirectory.append(TEMP_DICOM_FOLDER_SUFFIX);
m_TempDirectory.append(QString("."));
m_TempDirectory.append(QTime::currentTime().toString("hhmmsszzz"));
m_TempDirectory.append(QString::number(QCoreApplication::applicationPid()));
tmp.mkdir(QDir::toNativeSeparators( m_TempDirectory ));
}
void QmitkDicomBrowser::OnPreferencesChanged(const berry::IBerryPreferences* prefs)
{
- this->SetDatabaseDirectory("");
+ SetPluginDirectory();
+ berry::IPreferencesService::Pointer prefService=
+ berry::Platform::GetServiceRegistry().GetServiceById(berry::IPreferencesService::ID);
+ std::string targetPath = prefService->GetSystemPreferences()->Node("/org.mitk.views.dicomreader")->Get("default dicom path", m_PluginDirectory.toStdString());
+
+ m_DatabaseDirectory.clear();
+ m_DatabaseDirectory.append(targetPath.c_str());
+ m_Controls.internalDataWidget->SetDatabaseDirectory(m_DatabaseDirectory);
}
\ No newline at end of file
diff --git a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.h b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.h
index 7783d695d9..1d8d38dffe 100644
--- a/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.h
+++ b/Plugins/org.mitk.gui.qt.dicom/src/internal/QmitkDicomBrowser.h
@@ -1,153 +1,150 @@
/*=========================================================================
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 QmitkDicomBrowser_h
#define QmitkDicomBrowser_h
// Blueberry
#include
#include
#include
#include
// MITK
#include "DicomEventHandler.h"
#include "QmitkDicomDataEventPublisher.h"
#include "QmitkDicomDirectoryListener.h"
#include "QmitkStoreSCPLauncher.h"
#include "QmitkStoreSCPLauncherBuilder.h"
#include "ui_QmitkDicomBrowserControls.h"
#include
// Qt
#include
#include
#include
#include
#include
/**
* \brief QmitkDicomBrowser is an editor providing functionality for dicom storage and import and query retrieve functionality.
*
* \sa berry::IPartListener
* \ingroup ${plugin_target}_internal
*/
class DICOM_EXPORT QmitkDicomBrowser : 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(QmitkDicomBrowser);
static const std::string EDITOR_ID;
static const QString TEMP_DICOM_FOLDER_SUFFIX;
/**
* \brief QmitkDicomBrowser constructor.
*/
QmitkDicomBrowser();
/**
* \brief QmitkDicomBrowser destructor.
*/
virtual ~QmitkDicomBrowser();
/**
* \brief Init initialize the editor.
*/
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; }
virtual void OnPreferencesChanged(const berry::IBerryPreferences* prefs);
signals:
/**
* \brief SignalStartDicomImport is enitted when dicom directory for import was selected.
*/
void SignalStartDicomImport(const QString&);
protected slots:
/// \brief Called when import is finished.
void OnDicomImportFinished();
/// \brief Called when Query Retrieve or Import Folder was clicked.
void OnTabChanged(int);
/// \brief Called when view button is clicked. Sends out an event for adding the current selected file to the mitkDataStorage.
void OnViewButtonAddToDataManager(QHash eventProperties);
/// \brief Called when status of dicom storage provider changes.
void OnStoreSCPStatusChanged(const QString& status);
/// \brief Called when dicom storage provider emits a network error.
void OnDicomNetworkError(const QString& status);
protected:
/// \brief StartStoreSCP starts dicom storage provider.
void StartStoreSCP();
/// \brief StopStoreSCP stops dicom storage provider.
void StopStoreSCP();
/// \brief TestHandler initializes event handler.
void TestHandler();
- /// \brief Sets database directory.
- void SetDatabaseDirectory(const QString& databaseDirectory);
-
/// \brief CreateTemporaryDirectory creates temporary directory in which temorary dicom objects are stored.
void CreateTemporaryDirectory();
/// \brief StartDicomDirectoryListener starts dicom directory listener.
void StartDicomDirectoryListener();
/**
* \brief CreateQtPartControl(QWidget *parent) sets the view objects from ui_QmitkDicomBrowserControls.h.
*
* \param parent is a pointer to the parent widget
*/
void CreateQtPartControl(QWidget *parent);
/// \brief SetPluginDirectory Sets plugin directory.
void SetPluginDirectory();
Events::Types GetPartEventTypes() const;
ctkFileDialog* m_ImportDialog;
Ui::QmitkDicomBrowserControls m_Controls;
QThread m_Thread;
QmitkDicomDirectoryListener* m_DicomDirectoryListener;
QmitkStoreSCPLauncherBuilder m_Builder;
QmitkStoreSCPLauncher* m_StoreSCPLauncher;
DicomEventHandler* m_Handler;
QmitkDicomDataEventPublisher* m_Publisher;
QString m_PluginDirectory;
QString m_TempDirectory;
QString m_DatabaseDirectory;
};
#endif // QmitkDicomBrowser_h