diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/files.cmake b/Plugins/org.mitk.gui.qt.xnatinterface/files.cmake index ad289ff3eb..87d479c6ff 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/files.cmake +++ b/Plugins/org.mitk.gui.qt.xnatinterface/files.cmake @@ -1,43 +1,50 @@ set(SRC_CPP_FILES - + ) set(INTERNAL_CPP_FILES org_mitk_gui_qt_xnatinterface_Activator.cpp - XNATProjects.cpp + QmitkXnatEditor.cpp + QmitkXnatSimpleSearchView.cpp + QmitkXnatTreeBrowserView.cpp + QmitkXnatObjectEditorInput.cpp ) set(UI_FILES - src/internal/XNATProjectsControls.ui + src/internal/QmitkXnatEditorControls.ui + src/internal/QmitkXnatSimpleSearchViewControls.ui + src/internal/QmitkXnatTreeBrowserViewControls.ui ) set(MOC_H_FILES src/internal/org_mitk_gui_qt_xnatinterface_Activator.h - src/internal/XNATProjects.h + src/internal/QmitkXnatEditor.h + src/internal/QmitkXnatSimpleSearchView.h + src/internal/QmitkXnatTreeBrowserView.h + src/internal/QmitkXnatObjectEditorInput.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 - src/internal/images.qrc + src/internal/images.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.xnatinterface/plugin.xml b/Plugins/org.mitk.gui.qt.xnatinterface/plugin.xml index 2a449dc03a..0bc2f9528f 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/plugin.xml +++ b/Plugins/org.mitk.gui.qt.xnatinterface/plugin.xml @@ -1,11 +1,22 @@ - + + + + + diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.cpp b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.cpp deleted file mode 100644 index 6b5bd5b6f9..0000000000 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/*=================================================================== - -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 "XNATProjects.h" - -// Standard -#include -#include -#include - -// CTK Core -#include "ctkXnatServer.h" -#include "ctkXnatConnectionFactory.h" -#include "ctkXnatConnection.h" -#include "ctkXnatProject.h" -#include "ctkXnatSubject.h" -#include "ctkXnatListModel.h" -#include "ctkXnatScanFolder.h" -#include "ctkXnatScanResource.h" - -// Blueberry -#include -#include - -// Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Poco -#include "Poco/Net/HTTPClientSession.h" -#include "Poco/Net/HTTPRequest.h" -#include "Poco/Net/HTTPResponse.h" -#include "Poco/Net/HTTPBasicCredentials.h" -#include "Poco/DOM/NodeList.h" -#include "Poco/SAX/InputSource.h" -#include "Poco/URI.h" -#include "Poco/NumberParser.h" -#include "Poco/SAX/SAXParser.h" -#include "Poco/DOM/DOMParser.h" -#include "Poco/DOM/Document.h" -#include "Poco/DOM/NodeIterator.h" -#include "Poco/DOM/NodeFilter.h" -#include "Poco/DOM/AutoPtr.h" -#include "Poco/DOM/Node.h" -#include "Poco/StreamCopier.h" - -const std::string XNATProjects::EDITOR_ID = "org.mitk.editors.xnatprojects"; -const QString XNATProjects::DOWNLOAD_PATH = QString("C:/Users/knorr/Downloads/MITK_XNAT/"); - -XNATProjects::XNATProjects() : - m_ConnectionFactory(new ctkXnatConnectionFactory()), - m_Connection(0), - m_ProjectsModel(new ctkXnatListModel()), - m_SubjectsModel(new ctkXnatListModel()), - m_ExperimentsModel(new ctkXnatListModel()), - m_ScansModel(new ctkXnatListModel()), - m_ResourceModel(new ctkXnatListModel()), - m_FileModel(new ctkXnatListModel()) -{ - -} - -XNATProjects::~XNATProjects() -{ - if ( m_Connection ) delete m_Connection; - delete m_ConnectionFactory; - delete m_SubjectsModel; - delete m_ProjectsModel; - delete m_ExperimentsModel; - delete m_ScansModel; - delete m_ResourceModel; - delete m_FileModel; -} - -bool XNATProjects::IsDirty() const -{ - return false; -} - -bool XNATProjects::IsSaveAsAllowed() const -{ - return false; -} - -void XNATProjects::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) -{ - this->SetSite(site); - this->SetInput(input); -} - -void XNATProjects::DoSave() -{ -} - -void XNATProjects::DoSaveAs() -{ -} - -void XNATProjects::SetFocus() -{ - m_Controls.buttonGetAllProjects->setFocus(); - m_Controls.buttonDownloadResource->setFocus(); - m_Controls.buttonDownloadFile->setFocus(); -} - -void XNATProjects::CreateQtPartControl( QWidget *parent ) -{ - // create GUI widgets from the Qt Designer's .ui file - m_Controls.setupUi( parent ); - - m_Controls.projectTreeView->setModel(m_ProjectsModel); - m_Controls.subjectTreeView->setModel(m_SubjectsModel); - m_Controls.experimentTreeView->setModel(m_ExperimentsModel); - m_Controls.scanTreeView->setModel(m_ScansModel); - m_Controls.resourceTreeView->setModel(m_ResourceModel); - m_Controls.fileTreeView->setModel(m_FileModel); - - connect( m_Controls.buttonGetAllProjects, SIGNAL(clicked()), this, SLOT(GetAllProjects()) ); - connect( m_Controls.buttonDownloadResource, SIGNAL(clicked()), this, SLOT(DownloadResource()) ); - connect( m_Controls.buttonDownloadFile, SIGNAL(clicked()), this, SLOT(DownloadFile()) ); - - connect( m_Controls.projectTreeView, SIGNAL(clicked(QModelIndex)), SLOT(ProjectSelected(QModelIndex)) ); - connect( m_Controls.subjectTreeView, SIGNAL(clicked(QModelIndex)), SLOT(SubjectSelected(QModelIndex)) ); - connect( m_Controls.experimentTreeView, SIGNAL(clicked(QModelIndex)), SLOT(ExperimentSelected(QModelIndex)) ); - connect( m_Controls.scanTreeView, SIGNAL(clicked(QModelIndex)), SLOT(ScanSelected(QModelIndex)) ); - connect( m_Controls.resourceTreeView, SIGNAL(clicked(QModelIndex)), SLOT(ResourceSelected(QModelIndex)) ); -} - -void XNATProjects::OnSelectionChanged( berry::IWorkbenchPart::Pointer /*source*/, const QList& nodes ) -{ - // iterate all selected objects, adjust warning visibility - //foreach( mitk::DataNode::Pointer node, nodes ) - //{ - // if( node.IsNotNull() && dynamic_cast(node->GetData()) ) - // { - // m_Controls.labelWarning->setVisible( false ); - // m_Controls.buttonGetAllProjects->setEnabled( true ); - // return; - // } - //} - //m_Controls.labelWarning->setVisible( true ); - //m_Controls.buttonGetAllProjects->setEnabled( false ); -} - -/** -\brief To get all Projects -*/ -void XNATProjects::GetAllProjects() -{ - // Clear existing treeView - m_SubjectsModel->setRootObject(ctkXnatObject::Pointer()); - m_ExperimentsModel->setRootObject(ctkXnatObject::Pointer()); - m_ScansModel->setRootObject(ctkXnatObject::Pointer()); - m_ResourceModel->setRootObject(ctkXnatObject::Pointer()); - m_FileModel->setRootObject(ctkXnatObject::Pointer()); - m_Controls.subjectTreeView->reset(); - m_Controls.experimentTreeView->reset(); - m_Controls.scanTreeView->reset(); - m_Controls.resourceTreeView->reset(); - m_Controls.fileTreeView->reset(); - - // Validate user input - if ( m_Controls.inHostAddress->text().isEmpty() || m_Controls.inUser->text().isEmpty() || m_Controls.inPassword->text().isEmpty() ) { - if ( m_Controls.inHostAddress->text().isEmpty() ) - { - MITK_INFO << "No host address!"; - m_Controls.inHostAddress->setStyleSheet("QLineEdit{ background-color: rgb(255,0,0) }"); - } - - if ( m_Controls.inUser->text().isEmpty() ) { - MITK_INFO << "No user !"; - m_Controls.inUser->setStyleSheet("QLineEdit{ background-color: rgb(255,0,0) }"); - } - - if ( m_Controls.inPassword->text().isEmpty() ) { - MITK_INFO << "No password!"; - m_Controls.inPassword->setStyleSheet("QLineEdit{ background-color: rgb(255,0,0) }"); - } - return; - } - else - { - m_Controls.inHostAddress->setStyleSheet("QLineEdit{ background-color: rgb(255,255,255) }"); - m_Controls.inUser->setStyleSheet("QLineEdit{ background-color: rgb(255,255,255) }"); - m_Controls.inPassword->setStyleSheet("QLineEdit{ background-color: rgb(255,255,255) }"); - } - - // Regular Expression for uri - QRegExp uriregex("^(https?)://([a-zA-Z0-9\\.]+):([0-9]+)(/[^ /]+)*$"); - - // Validate address - if ( ! uriregex.exactMatch(m_Controls.inHostAddress->text()) ) - { - MITK_INFO << m_Controls.inHostAddress->text().toStdString(); - MITK_INFO << "Host address not valid"; - m_Controls.inHostAddress->setStyleSheet("QLineEdit{ background-color: rgb(255,0,0) }"); - return; - } - else - { - m_Controls.inHostAddress->setStyleSheet("QLineEdit{ background-color: rgb(255,255,255) }"); - } - - // create ctkXnatConnection - m_Connection = m_ConnectionFactory->makeConnection(m_Controls.inHostAddress->text(), m_Controls.inUser->text(), m_Controls.inPassword->text()); - ctkXnatServer::Pointer server(ctkXnatServer::Create(m_Connection)); - - // fetch projects from server - server->fetch(); - - // list projects - m_ProjectsModel->setRootObject(server); - - // Set tree visible - m_Controls.projectTreeView->reset(); -} - -/** -\brief ******** SEARCH ******** -*/ -void XNATProjects::SearchWithXmlFilePath(QString filepath) -{ - /* - bla.. blaa... blaaa.... - */ -} - -/** -\brief Converts a Poco::XML::XMLString to QString -*/ -QString XNATProjects::ConvertFromXMLString(const Poco::XML::XMLString xmlstr) -{ - const char* cstr = (Poco::XML::fromXMLString(xmlstr).c_str()); - QString qstr = cstr; - return qstr; -} - -/** -\brief *****fetchs subjects from chosen project***** -*/ -void XNATProjects::ProjectSelected(const QModelIndex& index) -{ - m_ExperimentsModel->setRootObject(ctkXnatObject::Pointer()); - m_ScansModel->setRootObject(ctkXnatObject::Pointer()); - m_ResourceModel->setRootObject(ctkXnatObject::Pointer()); - m_FileModel->setRootObject(ctkXnatObject::Pointer()); - m_Controls.experimentTreeView->reset(); - m_Controls.scanTreeView->reset(); - m_Controls.resourceTreeView->reset(); - m_Controls.fileTreeView->reset(); - QVariant variant = m_ProjectsModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer project = variant.value(); - project->fetch(); - m_SubjectsModel->setRootObject(project); - m_Controls.subjectTreeView->reset(); - } -} - -/** -\brief *****fetchs experiments from chosen subject***** -*/ -void XNATProjects::SubjectSelected(const QModelIndex& index) -{ - m_ScansModel->setRootObject(ctkXnatObject::Pointer()); - m_ResourceModel->setRootObject(ctkXnatObject::Pointer()); - m_FileModel->setRootObject(ctkXnatObject::Pointer()); - m_Controls.scanTreeView->reset(); - m_Controls.resourceTreeView->reset(); - m_Controls.fileTreeView->reset(); - QVariant variant = m_SubjectsModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer subject = variant.value(); - subject->fetch(); - m_ExperimentsModel->setRootObject(subject); - m_Controls.experimentTreeView->reset(); - } -} - -/** -\brief *****fetchs scans from chosen experiment***** -*/ -void XNATProjects::ExperimentSelected(const QModelIndex& index) -{ - m_ResourceModel->setRootObject(ctkXnatObject::Pointer()); - m_FileModel->setRootObject(ctkXnatObject::Pointer()); - m_Controls.resourceTreeView->reset(); - m_Controls.fileTreeView->reset(); - QVariant variant = m_ExperimentsModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer experiment = variant.value(); - experiment->fetch(); - if( !experiment->children().isEmpty() ) - { - ctkXnatObject::Pointer scanfolder = experiment->children().takeFirst(); - scanfolder->fetch(); - m_ScansModel->setRootObject(scanfolder); - m_Controls.scanTreeView->reset(); - } - } -} - -/** -\brief *****fetchs resource data from chosen experiment***** -*/ -void XNATProjects::ScanSelected(const QModelIndex& index) -{ - m_FileModel->setRootObject(ctkXnatObject::Pointer()); - m_Controls.fileTreeView->reset(); - QVariant variant = m_ScansModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer scan = variant.value(); - scan->fetch(); - m_ResourceModel->setRootObject(scan); - m_Controls.resourceTreeView->reset(); - } -} - -/** -\brief *****fetchs files data from chosen resource***** -*/ -void XNATProjects::ResourceSelected(const QModelIndex& index) -{ - QVariant variant = m_ResourceModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer resource = variant.value(); - resource->fetch(); - m_FileModel->setRootObject(resource); - m_Controls.fileTreeView->reset(); - } -} - -void XNATProjects::DownloadResource() -{ - if (!m_Controls.resourceTreeView->selectionModel()->hasSelection()) - return; - const QModelIndex index = m_Controls.resourceTreeView->selectionModel()->currentIndex(); - QVariant variant = m_ResourceModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer resource = variant.value(); - MITK_INFO << "Download started ..."; - MITK_INFO << "..."; - QString resourcePath = DOWNLOAD_PATH + resource->id() + ".zip"; - resource->download(resourcePath); - MITK_INFO << "Download finished!"; - } -} - -void XNATProjects::DownloadFile() -{ - if (!m_Controls.fileTreeView->selectionModel()->hasSelection()) - return; - const QModelIndex index = m_Controls.fileTreeView->selectionModel()->currentIndex(); - QVariant variant = m_FileModel->data(index, Qt::UserRole); - if ( variant.isValid() ) - { - ctkXnatObject::Pointer file = variant.value(); - MITK_INFO << "Download started ..."; - MITK_INFO << "..."; - QString filePath = DOWNLOAD_PATH + file->id(); - - file->download(filePath); - MITK_INFO << "Download finished!"; - } -} - -bool XNATProjects::DownloadExists(QString filename) -{ - std::ifstream fileTest(filename.toStdString().c_str()); - return (fileTest ? true : false); -} diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.h b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.h deleted file mode 100644 index d1dfe12686..0000000000 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjects.h +++ /dev/null @@ -1,110 +0,0 @@ -/*=================================================================== - -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 XNATProjects_h -#define XNATProjects_h - -#include -#include -#include "berryIEditorInput.h" -#include "berryIEditorSite.h" - -#include - -#include "ui_XNATProjectsControls.h" - -#include "Poco/DOM/Node.h" -#include "Poco/URI.h" - -#include -#include -#include - -#include "ctkXnatListModel.h" -#include "ctkXnatConnectionFactory.h" -#include "ctkXnatConnection.h" -#include "ctkXnatScanResource.h" - -/*! -\brief XNATProjects - -\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 XNATProjects : public berry::QtEditorPart -{ - // 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: - - XNATProjects(); - ~XNATProjects(); - static const std::string EDITOR_ID; - static const QString DOWNLOAD_PATH; - void CreateQtPartControl(QWidget *parent); - void SearchWithXmlFilePath(QString filepath); - - void DoSave(/*IProgressMonitor monitor*/); - void DoSaveAs(); - void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); - bool IsDirty() const; - bool IsSaveAsAllowed() const; - - protected slots: - - /// \brief Called when the user clicks the GUI button - void GetAllProjects(); - void DownloadResource(); - void DownloadFile(); - - void ProjectSelected(const QModelIndex& index); - void SubjectSelected(const QModelIndex& index); - void ExperimentSelected(const QModelIndex& index); - void ScanSelected(const QModelIndex& index); - void ResourceSelected(const QModelIndex& index); - -protected: - - virtual void SetFocus(); - - /// \brief called by QmitkFunctionality when DataManager's selection has changed - virtual void OnSelectionChanged( berry::IWorkbenchPart::Pointer source, - const QList& nodes ); - - Ui::XNATProjectsControls m_Controls; - - -private: - //QMap::QMap m_Profiles; - QString ConvertFromXMLString(const Poco::XML::XMLString); - bool DownloadExists(QString filename); - - ctkXnatConnectionFactory* m_ConnectionFactory; - ctkXnatConnection* m_Connection; - ctkXnatListModel* m_ProjectsModel; - ctkXnatListModel* m_SubjectsModel; - ctkXnatListModel* m_ExperimentsModel; - ctkXnatListModel* m_ScansModel; - ctkXnatListModel* m_ResourceModel; - ctkXnatListModel* m_FileModel; -}; - -#endif // XNATProjects_h diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjectsControls.ui b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjectsControls.ui deleted file mode 100644 index 7f42b3d7ed..0000000000 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/XNATProjectsControls.ui +++ /dev/null @@ -1,160 +0,0 @@ - - - XNATProjectsControls - - - - 0 - 0 - 838 - 975 - - - - - 0 - 0 - - - - QmitkTemplate - - - - xnat_icon.icoxnat_icon.ico - - - - - - QLabel { color: rgb(255, 0, 0) } - - - Please insert your XNAT host address: - - - - - - - - - - 230 - 0 - - - - <html><head/><body><p>Examples:</p><p>&quot;http://localhost:8080/xnat&quot;</p><p>&quot;http://central.xnat.org:80&quot;</p><p>&quot;https://xnat.myserver.de:443&quot;</p></body></html> - - - http://localhost:12345/xnat - - - http(s)://host:port/pathToXnatServerInstance - - - - - - - - - admin - - - User - - - - - - - - 53 - 0 - - - - admin - - - QLineEdit::Password - - - Password - - - - - - - - - - - true - - - Get all projects - - - Get all projects - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (no function) - - - - - - - Download Folder - - - - - - - Download File - - - - - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp index 8805dfc959..7e2b2c6579 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/org_mitk_gui_qt_xnatinterface_Activator.cpp @@ -1,39 +1,41 @@ -/*========================================================================= +/*=================================================================== -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. +The Medical Imaging Interaction Toolkit (MITK) -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. +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. -=========================================================================*/ +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ #include "org_mitk_gui_qt_xnatinterface_Activator.h" #include -#include "XNATProjects.h" +#include "QmitkXnatEditor.h" +#include "QmitkXnatSimpleSearchView.h" +#include "QmitkXnatTreeBrowserView.h" namespace mitk { void org_mitk_gui_qt_xnatinterface_Activator::start(ctkPluginContext* context) { - BERRY_REGISTER_EXTENSION_CLASS(XNATProjects, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatEditor, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatSimpleSearchView, context) + BERRY_REGISTER_EXTENSION_CLASS(QmitkXnatTreeBrowserView, context) } void org_mitk_gui_qt_xnatinterface_Activator::stop(ctkPluginContext* context) { Q_UNUSED(context) } } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_xnatinterface, mitk::org_mitk_gui_qt_xnatinterface_Activator)