diff --git a/CMakeExternals/CTK.cmake b/CMakeExternals/CTK.cmake index 10b283c77b..cfc05a2b1a 100644 --- a/CMakeExternals/CTK.cmake +++ b/CMakeExternals/CTK.cmake @@ -1,93 +1,95 @@ #----------------------------------------------------------------------------- # CTK #----------------------------------------------------------------------------- if(MITK_USE_CTK) # Sanity checks if(DEFINED CTK_DIR AND NOT EXISTS ${CTK_DIR}) message(FATAL_ERROR "CTK_DIR variable is defined but corresponds to non-existing directory") endif() set(proj CTK) set(proj_DEPENDENCIES ) set(CTK_DEPENDS ${proj}) if(NOT DEFINED CTK_DIR) set(revision_tag f18114d2) #IF(${proj}_REVISION_TAG) # SET(revision_tag ${${proj}_REVISION_TAG}) #ENDIF() set(ctk_optional_cache_args ) if(MITK_USE_Python) list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=ON -DCTK_ENABLE_Python_Wrapping:BOOL=ON -DCTK_APP_ctkSimplePythonShell:BOOL=ON -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE} -DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR} -DPYTHON_INCLUDE_DIR2:PATH=${PYTHON_INCLUDE_DIR2} -DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY} ) else() list(APPEND ctk_optional_cache_args -DCTK_LIB_Scripting/Python/Widgets:BOOL=OFF -DCTK_ENABLE_Python_Wrapping:BOOL=OFF -DCTK_APP_ctkSimplePythonShell:BOOL=OFF ) endif() if(MITK_USE_DCMTK) list(APPEND ctk_optional_cache_args -DDCMTK_DIR:PATH=${DCMTK_DIR} ) list(APPEND proj_DEPENDENCIES DCMTK) else() list(APPEND ctk_optional_cache_args -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz ) endif() FOREACH(type RUNTIME ARCHIVE LIBRARY) IF(DEFINED CTK_PLUGIN_${type}_OUTPUT_DIRECTORY) LIST(APPEND mitk_optional_cache_args -DCTK_PLUGIN_${type}_OUTPUT_DIRECTORY:PATH=${CTK_PLUGIN_${type}_OUTPUT_DIRECTORY}) ENDIF() ENDFOREACH() ExternalProject_Add(${proj} SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj}-src BINARY_DIR ${proj}-build PREFIX ${proj}-cmake - URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_${revision_tag}.tar.gz - URL_MD5 03694d11d206a94284af6801aa9d8b5c +# URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_${revision_tag}.tar.gz + URL https://github.com/commontk/CTK/archive/master.tar.gz +# URL_MD5 03694d11d206a94284af6801aa9d8b5c UPDATE_COMMAND "" INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${ctk_optional_cache_args} -DDESIRED_QT_VERSION:STRING=4 -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DGit_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE} -DCTK_LIB_CommandLineModules/Backend/LocalProcess:BOOL=ON -DCTK_LIB_CommandLineModules/Frontend/QtGui:BOOL=ON -DCTK_LIB_PluginFramework:BOOL=ON -DCTK_LIB_DICOM/Widgets:BOOL=ON + -DCTK_LIB_XNAT/Core:BOOL=ON -DCTK_PLUGIN_org.commontk.eventadmin:BOOL=ON -DCTK_PLUGIN_org.commontk.configadmin:BOOL=ON -DCTK_USE_GIT_PROTOCOL:BOOL=OFF -DDCMTK_URL:STRING=${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/CTK_DCMTK_085525e6.tar.gz DEPENDS ${proj_DEPENDENCIES} ) set(CTK_DIR ${CMAKE_CURRENT_BINARY_DIR}/${proj}-build) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif() endif() diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionManager.h b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionManager.h index 1f435f66bc..893ed8aa4b 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionManager.h +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionManager.h @@ -1,46 +1,46 @@ /*=================================================================== 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 QMITKXNATCONNECTIONMANAGER_H_ #define QMITKXNATCONNECTIONMANAGER_H_ -#include +#include #include #include "ctkXnatSession.h" #include "ctkXnatLoginProfile.h" class QmitkXnatConnectionManager : public QObject { Q_OBJECT public: QmitkXnatConnectionManager(); ~QmitkXnatConnectionManager(); /// \brief Opens and tests a xnat session and returns it if the test was ok. ctkXnatSession* GetXnatConnection(); private: ctkXnatSession* m_Session; berry::IPreferencesService::WeakPtr m_PreferencesService; }; #endif /*QMITKXNATCONNECTIONMANAGER_H_*/ diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.cpp b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.cpp index 6d6c67255a..8e362440f3 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.cpp @@ -1,212 +1,212 @@ /*=================================================================== 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 "QmitkXnatConnectionPreferencePage.h" #include "berryIPreferencesService.h" #include "berryPlatform.h" #include #include #include #include #include #include #include #include "ctkXnatSession.h" #include "ctkXnatLoginProfile.h" #include "ctkXnatException.h" using namespace berry; QmitkXnatConnectionPreferencePage::QmitkXnatConnectionPreferencePage() : m_MainControl(0) { } void QmitkXnatConnectionPreferencePage::Init(berry::IWorkbench::Pointer ) { } void QmitkXnatConnectionPreferencePage::CreateQtControl(QWidget* parent) { IPreferencesService::Pointer prefService = Platform::GetServiceRegistry().GetServiceById(IPreferencesService::ID); berry::IPreferences::Pointer _XnatConnectionPreferencesNode = prefService->GetSystemPreferences()->Node("/XnatConnection"); m_XnatConnectionPreferencesNode = _XnatConnectionPreferencesNode; m_LineEditors[1] = qMakePair(QString("Server Address"), new QLineEdit("")); m_LineEditors[1].second->setObjectName("inHostAddress"); m_LineEditors[1].second->setToolTip("

Examples:

"http://localhost:8080/xnat"

"http://central.xnat.org:80"

"https://xnat.myserver.de:443"

"); m_LineEditors[2] = qMakePair(QString("Username"), new QLineEdit("")); m_LineEditors[2].second->setObjectName("inUser"); m_LineEditors[3] = qMakePair(QString("Password"), new QLineEdit("")); m_LineEditors[3].second->setObjectName("inPassword"); m_LineEditors[3].second->setEchoMode(QLineEdit::Password); m_LineEditors[4] = qMakePair(QString("Download Path"), new QLineEdit("")); m_LineEditors[4].second->setObjectName("inDownloadPath"); m_MainControl = new QWidget(parent); QGridLayout* layout = new QGridLayout; int i = 0; - for (QMap>::iterator it = m_LineEditors.begin(); + for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) { layout->addWidget(new QLabel(it.value().first), i,0); layout->addWidget(it.value().second, i,1); layout->setRowStretch(i,0); ++i; } layout->setRowStretch(i+1,10); m_MainControl->setLayout(layout); this->Update(); } QWidget* QmitkXnatConnectionPreferencePage::GetQtControl() const { return m_MainControl; } bool QmitkXnatConnectionPreferencePage::PerformOk() { IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock(); if(_XnatConnectionPreferencesNode.IsNotNull()) { // Regular Expression for uri and download path QRegExp uriregex("^(https?)://([a-zA-Z0-9\\.]+):?([0-9]+)?(/[^ /]+)*$"); QRegExp downloadPathRegex("([/|\\]?[^/|^\\])+[/|\\]?"); QString keyString; QString errString; - for (QMap>::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) + for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) { keyString = it.value().second->text(); if(keyString.isEmpty()) { if(it.value().first != QString("Download Path")) { errString += QString("No input for \"%1\"\n").arg(it.value().first); } } else { if(it.value().first == QString("Server Address") && !uriregex.exactMatch(m_MainControl->findChild("inHostAddress")->text())) { errString += QString("No valid input for \"Server Address\"\n"); } else if(it.value().first == QString("Download Path")) { if(!downloadPathRegex.exactMatch(m_MainControl->findChild("inDownloadPath")->text())) { errString += QString("No valid input for \"Download Path\"\n"); } else { QString downloadPath = m_MainControl->findChild("inDownloadPath")->text(); if(downloadPath.contains('\\')) { if(!downloadPath.endsWith('\\')) { downloadPath += '\\'; } } else if(downloadPath.contains('/')) { if(!downloadPath.endsWith('/')) { downloadPath += '/'; } } m_MainControl->findChild("inDownloadPath")->setText(downloadPath); } } } } if(!errString.isEmpty()) { QMessageBox::critical(QApplication::activeWindow(), "Error", errString); return false; } else { // Set up the session for the connection test ctkXnatLoginProfile profile; profile.setName("Default"); profile.setServerUrl(m_LineEditors[1].second->text()); profile.setUserName(m_LineEditors[2].second->text()); profile.setPassword(m_LineEditors[3].second->text()); profile.setDefault(true); ctkXnatSession* session = new ctkXnatSession(profile); // Testing the inputs by trying to create a session try { session->open(); } catch(const ctkXnatAuthenticationException& auth) { errString += QString("Test connection failed.\nAuthentication error: Wrong name or password.\nCode:\"%1\"").arg(auth.message()); delete session; QMessageBox::critical(QApplication::activeWindow(), "Error", errString); return false; } catch(const ctkException& e) { errString += QString("Test connection failed with error code:\n\"%1\"").arg(e.message()); delete session; QMessageBox::critical(QApplication::activeWindow(), "Error", errString); return false; } delete session; } // no error in the input - for (QMap>::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) + for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) _XnatConnectionPreferencesNode->Put(it.value().first.toStdString(), it.value().second->text().toStdString()); _XnatConnectionPreferencesNode->Flush(); return true; } return false; } void QmitkXnatConnectionPreferencePage::PerformCancel() { } void QmitkXnatConnectionPreferencePage::Update() { IPreferences::Pointer _XnatConnectionPreferencesNode = m_XnatConnectionPreferencesNode.Lock(); if(_XnatConnectionPreferencesNode.IsNotNull()) { - for (QMap>::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) + for (QMap >::iterator it = m_LineEditors.begin(); it != m_LineEditors.end(); ++it) { it.value().second->setText(QString::fromStdString(_XnatConnectionPreferencesNode->Get(it.value().first.toStdString(), it.value().second->text().toStdString()))); } } } diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.h b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.h index 802a47a7de..54e3559226 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.h +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatConnectionPreferencePage.h @@ -1,67 +1,67 @@ /*=================================================================== 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 QMITKXNATCONNECTIONPREFERENCEPAGE_H_ #define QMITKXNATCONNECTIONPREFERENCEPAGE_H_ #include "berryIQtPreferencePage.h" #include class QWidget; class QLineEdit; struct QmitkXnatConnectionPreferencePage : public QObject, public berry::IQtPreferencePage { Q_OBJECT Q_INTERFACES(berry::IPreferencePage) public: QmitkXnatConnectionPreferencePage(); void Init(berry::IWorkbench::Pointer workbench); void CreateQtControl(QWidget* widget); QWidget* GetQtControl() const; /// /// \see IPreferencePage::PerformOk() /// virtual bool PerformOk(); /// /// \see IPreferencePage::PerformCancel() /// virtual void PerformCancel(); /// /// \see IPreferencePage::Update() /// virtual void Update(); protected: QWidget* m_MainControl; berry::IPreferences::WeakPtr m_XnatConnectionPreferencesNode; /// /// Maps a label to lineedit (sorted) /// - QMap> m_LineEditors; + QMap > m_LineEditors; }; #endif /* QMITKXNATCONNECTIONPREFERENCEPAGE_H_ */ diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.cpp b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.cpp index 75dcd3d421..620b5aa04f 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.cpp +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.cpp @@ -1,451 +1,451 @@ /*=================================================================== 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 "QmitkXnatEditor.h" // Qmitk #include "QmitkXnatObjectEditorInput.h" #include "org_mitk_gui_qt_xnatinterface_Activator.h" // CTK XNAT Core #include "ctkXnatObject.h" #include "ctkXnatDataModel.h" #include "ctkXnatScanResource.h" #include "ctkXnatFile.h" // CTK XNAT Widgets #include "ctkXnatListModel.h" // Blueberry #include #include // Qt #include #include #include #include // MITK #include #include const std::string QmitkXnatEditor::EDITOR_ID = "org.mitk.editors.qmitkxnateditor"; QmitkXnatEditor::QmitkXnatEditor() : m_DataStorageServiceTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()), m_Session(0), m_ListModel(new ctkXnatListModel()), m_SelectionListener(new berry::SelectionChangedAdapter(this, &QmitkXnatEditor::SelectionChanged)), m_DownloadPath(berry::Platform::GetServiceRegistry(). GetServiceById(berry::IPreferencesService::ID)-> GetSystemPreferences()->Node("/XnatConnection")->Get("Download Path", "").c_str()) { m_DataStorageServiceTracker.open(); if(m_DownloadPath.isEmpty()) { QString xnatFolder = "XNAT_DOWNLOADS"; QDir dir(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetContext()->getDataFile("").absoluteFilePath()); dir.mkdir(xnatFolder); dir.setPath(dir.path() + "/" + xnatFolder); m_DownloadPath = dir.path() + "/"; } } QmitkXnatEditor::~QmitkXnatEditor() { delete m_ListModel; berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); s->RemoveSelectionListener(m_SelectionListener); m_DataStorageServiceTracker.close(); } bool QmitkXnatEditor::IsDirty() const { return false; } bool QmitkXnatEditor::IsSaveAsAllowed() const { return false; } void QmitkXnatEditor::Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input) { this->SetInput(input); this->SetSite(site); } void QmitkXnatEditor::DoSave() { } void QmitkXnatEditor::DoSaveAs() { } void QmitkXnatEditor::SetInput(berry::IEditorInput::Pointer input) { // If the input is not a QmitkXnatObjectEditorInput the semi global xnat session will be loaded. QmitkXnatObjectEditorInput::Pointer oPtr = input.Cast(); if(oPtr.IsNotNull()) { SetInputWithNotify(oPtr); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); } else { m_Session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatConnectionManager()->GetXnatConnection(); if(m_Session == 0) { MITK_INFO << "Please check your XNAT Connection Preferences!"; return; } QmitkXnatObjectEditorInput::Pointer xoPtr = QmitkXnatObjectEditorInput::New( m_Session->dataModel() ); berry::IEditorInput::Pointer editorInput( xoPtr ); SetInputWithNotify(editorInput); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); } } -const char* QmitkXnatEditor::GetClassNameA() const -{ - return QtEditorPart::GetClassNameA(); -} +//const char* QmitkXnatEditor::GetClassNameA() const +//{ +// return QtEditorPart::GetClassNameA(); +//} void QmitkXnatEditor::SetFocus() { } void QmitkXnatEditor::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); m_Controls.treeView->setModel(m_ListModel); GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener); connect( m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnObjectActivated(const QModelIndex&)) ); connect( m_Controls.buttonDownloadResource, SIGNAL(clicked()), this, SLOT(DownloadResource()) ); connect( m_Controls.buttonDownloadFile, SIGNAL(clicked()), this, SLOT(DownloadFile()) ); connect( m_Controls.buttonDataModel, SIGNAL(clicked()), this, SLOT(OnDataModelButtonClicked()) ); connect( m_Controls.buttonProject, SIGNAL(clicked()), this, SLOT(OnProjectButtonClicked()) ); connect( m_Controls.buttonSubject, SIGNAL(clicked()), this, SLOT(OnSubjectButtonClicked()) ); connect( m_Controls.buttonExperiment, SIGNAL(clicked()), this, SLOT(OnExperimentButtonClicked()) ); connect( m_Controls.buttonKindOfData, SIGNAL(clicked()), this, SLOT(OnKindOfDataButtonClicked()) ); connect( m_Controls.buttonSession, SIGNAL(clicked()), this, SLOT(OnSessionButtonClicked()) ); connect( m_Controls.buttonResource, SIGNAL(clicked()), this, SLOT(OnResourceButtonClicked()) ); // Makes the breadcrumb feature invisible for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(false); } for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i); child->widget()->setVisible(false); } UpdateList(); } void QmitkXnatEditor::UpdateList() { QmitkXnatObjectEditorInput::Pointer xoPtr(GetEditorInput().Cast()); - if( xoPtr == NULL ) + if( xoPtr.IsNull() ) return; ctkXnatObject* inputObject = xoPtr->GetXnatObject(); if( inputObject == NULL ) return; m_ListModel->setRootObject( inputObject ); m_Controls.treeView->reset(); // recursive method to check parents of the inputObject m_ParentCount = ParentChecker(inputObject); // breadcrumb labels for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(false); } for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i); child->widget()->setVisible(false); } ctkXnatObject* parent = NULL; for(int i = m_ParentCount*2; i >= 0; i--) { if(i > 12) break; m_Controls.breadcrumbDescriptionLayout->itemAt(i)->widget()->setVisible(true); QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(true); if(i>0) { m_Controls.breadcrumbHorizontalLayout->itemAt(i-1)->widget()->setVisible(true); m_Controls.breadcrumbDescriptionLayout->itemAt(i-1)->widget()->setVisible(true); } if(parent == NULL) { parent = inputObject; } // make breadcrumb button QPushButton* breadcrumbButton = dynamic_cast(child->widget()); breadcrumbButton->setText(parent->id()); parent = parent->parent(); i--; } } void QmitkXnatEditor::SelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection) { // check for null selection if (selection.IsNull()) { return; } // exclude own selection events and check whether this kind of selection can be handled if (sourcepart != this && selection.Cast()) { berry::IStructuredSelection::ConstPointer currentSelection = selection.Cast(); // iterates over the selection for (berry::IStructuredSelection::iterator itr = currentSelection->Begin(); itr != currentSelection->End(); ++itr) { if (berry::SmartPointer objectPointer = itr->Cast()) { // get object of selected ListWidgetElement ctkXnatObject* object = objectPointer->GetQModelIndex().data(Qt::UserRole).value(); // if a file is selected, don't change the input and list view if ( dynamic_cast(object) == NULL ){ QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( object ); berry::IEditorInput::Pointer editorInput( oPtr ); if ( !(editorInput == this->GetEditorInput()) ) this->SetInput(editorInput); UpdateList(); } } } } } void QmitkXnatEditor::DownloadResource() { if (!m_Controls.treeView->selectionModel()->hasSelection()) return; const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex(); QVariant variant = m_ListModel->data(index, Qt::UserRole); if ( variant.isValid() ) { ctkXnatScanResource* resource = dynamic_cast(variant.value()); if (resource != NULL) { MITK_INFO << "Download started ..."; MITK_INFO << "..."; QString resourcePath = m_DownloadPath + resource->id() + ".zip"; resource->download(resourcePath); // Testing if the path exists QDir downDir(m_DownloadPath); if( downDir.exists(resource->id() + ".zip") ) { MITK_INFO << "Download of " << resource->id().toStdString() << ".zip was completed!"; } else { MITK_INFO << "Download of " << resource->id().toStdString() << ".zip failed!"; } } else { MITK_INFO << "Selection was not a resource folder!"; } } } void QmitkXnatEditor::DownloadFile() { if (!m_Controls.treeView->selectionModel()->hasSelection()) return; const QModelIndex index = m_Controls.treeView->selectionModel()->currentIndex(); InternalFileDownload(index); } void QmitkXnatEditor::ToHigherLevel() { ctkXnatObject* parent = GetEditorInput().Cast()->GetXnatObject()->parent(); if( parent == NULL) { return; } QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( parent ); berry::IEditorInput::Pointer editorInput( oPtr ); SetInput(editorInput); UpdateList(); } void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index) { if (!index.isValid()) return; ctkXnatObject* child = GetEditorInput().Cast()->GetXnatObject()->children().at(index.row()); if( child != NULL ) { ctkXnatFile* file = dynamic_cast(child); if( file != NULL ) { // Download file and put into datamanager InternalFileDownload(index); mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); if(dsService != NULL) { mitk::DataNode::Pointer node = mitk::IOUtil::LoadDataNode((m_DownloadPath + file->id()).toStdString()); if ( ( node.IsNotNull() ) && ( node->GetData() != NULL ) ) { dsService->GetDataStorage()->GetDataStorage()->Add(node); mitk::BaseData::Pointer basedata = node->GetData(); mitk::RenderingManager::GetInstance()->InitializeViews( basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); } } } else { // Updates the root item QmitkXnatObjectEditorInput::Pointer oPtr = QmitkXnatObjectEditorInput::New( child ); berry::IEditorInput::Pointer editorInput( oPtr ); SetInput(editorInput); this->GetEditorInput().Cast()->GetXnatObject()->fetch(); UpdateList(); } } } void QmitkXnatEditor::InternalFileDownload(const QModelIndex& index) { QVariant variant = m_ListModel->data(index, Qt::UserRole); if ( variant.isValid() ) { ctkXnatFile* file = dynamic_cast(variant.value()); if (file != NULL) { MITK_INFO << "Download started ..."; MITK_INFO << "..."; QString filePath = m_DownloadPath + file->id(); file->download(filePath); // Testing if the file exists QDir downDir(m_DownloadPath); if( downDir.exists(file->id()) ) { MITK_INFO << "Download of " << file->id().toStdString() << " was completed!"; } else { MITK_INFO << "Download of " << file->id().toStdString() << " failed!"; } } else { MITK_INFO << "Selection was not a file!"; } } } int QmitkXnatEditor::ParentChecker(ctkXnatObject* child) { int sum; if( child->parent() == NULL ) { return 0; } else { sum = 1 + ParentChecker(child->parent()); } return sum; } void QmitkXnatEditor::OnDataModelButtonClicked() { for(int i = m_ParentCount; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnProjectButtonClicked() { for(int i = m_ParentCount-1; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnSubjectButtonClicked() { for(int i = m_ParentCount-2; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnExperimentButtonClicked() { for(int i = m_ParentCount-3; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnKindOfDataButtonClicked() { for(int i = m_ParentCount-4; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnSessionButtonClicked() { for(int i = m_ParentCount-5; i > 0; i--) { ToHigherLevel(); } } void QmitkXnatEditor::OnResourceButtonClicked() { for(int i = m_ParentCount-6; i > 0; i--) { ToHigherLevel(); } } diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.H b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.h similarity index 96% rename from Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.H rename to Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.h index bae83fa098..a46b22fd11 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.H +++ b/Plugins/org.mitk.gui.qt.xnatinterface/src/internal/QmitkXnatEditor.h @@ -1,123 +1,124 @@ /*=================================================================== 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 QMITKXNATEDITOR_h #define QMITKXNATEDITOR_h #include #include #include #include #include #include "ui_QmitkXnatEditorControls.h" #include "ctkXnatListModel.h" #include "ctkXnatSession.h" #include /*! \brief QmitkXnatEditor \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 QmitkXnatEditor : public berry::QtEditorPart, virtual public berry::IReusableEditor +class QmitkXnatEditor : public berry::QtEditorPart, public berry::IReusableEditor { // 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(QmitkXnatEditor); + berryObjectMacro(QmitkXnatEditor) + QmitkXnatEditor(); ~QmitkXnatEditor(); static const std::string EDITOR_ID; void CreateQtPartControl(QWidget *parent); void DoSave(/*IProgressMonitor monitor*/); void DoSaveAs(); void Init(berry::IEditorSite::Pointer site, berry::IEditorInput::Pointer input); bool IsDirty() const; bool IsSaveAsAllowed() const; void SetInput(berry::IEditorInput::Pointer input); const char* GetClassNameA() const; /** \brief Here the root object will be set and the view reset. Additionally the breadcrumbs will set visible. */ void UpdateList(); protected slots: /** \brief A resource folder will be downloaded to the chosen download path. */ void DownloadResource(); /** \brief A file will be downloaded to the chosen download path. */ void DownloadFile(); /** \brief Every time you activate a node in the list, the root item will be updated to a child of the previous parent.\ In exception of the node is a file. The file will be downloaded and loaded to the DataManager. */ void OnObjectActivated(const QModelIndex& index); // Breadcrumb button slots void OnDataModelButtonClicked(); void OnProjectButtonClicked(); void OnSubjectButtonClicked(); void OnExperimentButtonClicked(); void OnKindOfDataButtonClicked(); void OnSessionButtonClicked(); void OnResourceButtonClicked(); protected: virtual void SetFocus(); Ui::QmitkXnatEditorControls m_Controls; private: int m_ParentCount; QString m_DownloadPath; ctkServiceTracker m_DataStorageServiceTracker; void InternalFileDownload(const QModelIndex& index); int ParentChecker(ctkXnatObject* child); void ToHigherLevel(); ctkXnatListModel* m_ListModel; ctkXnatSession* m_Session; berry::ISelectionListener::Pointer m_SelectionListener; void SelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); }; #endif // QMITKXNATEDITOR_h diff --git a/Plugins/org.mitk.gui.qt.xnatinterface/target_libraries.cmake b/Plugins/org.mitk.gui.qt.xnatinterface/target_libraries.cmake index 173ab6e139..e18fde9a3e 100644 --- a/Plugins/org.mitk.gui.qt.xnatinterface/target_libraries.cmake +++ b/Plugins/org.mitk.gui.qt.xnatinterface/target_libraries.cmake @@ -1,9 +1,9 @@ # See CMake/ctkFunctionGetTargetLibraries.cmake # # This file should list the libraries required to build the current CTK plugin. # For specifying required plugins, see the manifest_headers.cmake file. # set(target_libraries - CTKXNATWidgets + CTKXNATCore )