Example #1
0
void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index)
{
  if (!index.isValid()) return;

  ctkXnatObject* child = GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->children().at(index.row());
  if( child != NULL )
  {
    ctkXnatFile* file = dynamic_cast<ctkXnatFile*>(child);
    if( file != NULL )
    {
      // Download file and put into datamanager
      InternalFileDownload(index);
      mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService();
      if(dsService != NULL)
      {
        mitk::IOUtil::Load((m_DownloadPath + file->id()).toStdString(),
                           *dsService->GetDataStorage()->GetDataStorage());
        mitk::RenderingManager::GetInstance()->InitializeViews();
      }
    }
    else
    {
      // Updates the root item
      QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(child));
      berry::IEditorInput::Pointer editorInput( oPtr );
      this->SetInput(editorInput);

      this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->fetch();

      UpdateList();
    }
  }
}
Example #2
0
void QmitkXnatEditor::OnObjectActivated(const QModelIndex &index)
{
  if (!index.isValid()) return;

  ctkXnatObject* child = GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->children().at(index.row());
  if (child != NULL)
  {
    ctkXnatFile* file = dynamic_cast<ctkXnatFile*>(child);
    if (file != NULL)
    {
      // Download file and put into datamanager
      InternalFileDownload(index);
      mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService();
      if (dsService != NULL)
      {
        QString name = file->property("Name");
        QString filePath = m_DownloadPath + name;

        if (file->property("collection") == "DICOM")
        {
          QDirIterator it(m_DownloadPath, QStringList() << name, QDir::Files, QDirIterator::Subdirectories);
          while (it.hasNext()) {
            it.next();
            filePath = it.filePath();
          }
        }

        mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService();
        mitk::DataStorage::Pointer dataStorage = dsService->GetDataStorage()->GetDataStorage();
        QStringList list;
        list << filePath;
        try
        {
          QmitkIOUtil::Load(list, *dataStorage);
        }
        catch (const mitk::Exception& e)
        {
          MITK_INFO << e;
          return;
        }
        mitk::RenderingManager::GetInstance()->InitializeViewsByBoundingObjects(
          dsService->GetDataStorage()->GetDataStorage());
      }
    }
    else
    {
      // Updates the root item
      QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(child));
      berry::IEditorInput::Pointer editorInput(oPtr);
      this->SetInput(editorInput);

      this->GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->fetch();

      UpdateList();
    }
  }
}
Example #3
0
void QmitkXnatEditor::ToHigherLevel()
{
  ctkXnatObject* parent = GetEditorInput().Cast<QmitkXnatObjectEditorInput>()->GetXnatObject()->parent();
  if( parent ==  NULL)
  {
    return;
  }
  QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput(parent));
  berry::IEditorInput::Pointer editorInput( oPtr );
  this->SetInput(editorInput);
  UpdateList();
}
Example #4
0
void QmitkXnatEditor::SelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart,
                                       const 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<const berry::IStructuredSelection>())
  {
    berry::IStructuredSelection::ConstPointer currentSelection = selection.Cast<const berry::IStructuredSelection>();
    // iterates over the selection
    for (berry::IStructuredSelection::iterator itr = currentSelection->Begin();
      itr != currentSelection->End(); ++itr)
    {
      if (berry::SmartPointer<berry::QModelIndexObject> objectPointer = itr->Cast<berry::QModelIndexObject>())
      {
        // get object of selected ListWidgetElement
        ctkXnatObject* object = objectPointer->GetQModelIndex().data(Qt::UserRole).value<ctkXnatObject*>();

        // if a file is selected, don't change the input and list view
        if ( dynamic_cast<ctkXnatFile*>(object) == NULL )
        {
          QmitkXnatObjectEditorInput::Pointer oPtr(new QmitkXnatObjectEditorInput( object ));
          berry::IEditorInput::Pointer editorInput( oPtr );
          if ( !(editorInput == this->GetEditorInput()) )
            this->SetInput(editorInput);

          UpdateList();
        }
      }
    }
  }
}