diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.cpp b/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.cpp index c07ece2100..58ea9d1b86 100644 --- a/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.cpp +++ b/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.cpp @@ -1,109 +1,104 @@ /*=================================================================== 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 "DicomView.h" #include "org_mitk_example_gui_customviewer_views_Activator.h" #include "mitkIDataStorageService.h" #include "mitkDicomSeriesReader.h" #include #include #include #include "QDockWidget" const std::string DicomView::VIEW_ID = "org.mitk.customviewer.views.dicomview"; DicomView::DicomView() : m_Parent(0) { } DicomView::~DicomView() { } // //! [DicomViewCreatePartControl] void DicomView::CreateQtPartControl(QWidget *parent) { // create GUI widgets m_Parent = parent; m_Controls.setupUi(parent); //remove unused widgets QPushButton* downloadButton = parent->findChild("downloadButton"); downloadButton->setVisible(false); - QDockWidget* searchWidget = parent->findChild("ExternalSearchDockWidget"); - searchWidget->setVisible(false); connect(m_Controls.importButton, SIGNAL(clicked()), m_Controls.widget, SLOT(OnFolderCDImport())); - connect(m_Controls.widget, SIGNAL(SignalDicomToDataManager(const QStringList&)), this, SLOT(AddDataNodeFromDICOM(const QStringList&))); + connect(m_Controls.widget, SIGNAL(SignalDicomToDataManager(const QHash&)), this, SLOT(AddDataNodeFromDICOM(const QHash&))); m_Parent->setEnabled(true); } // //! [DicomViewCreatePartControl] // //! [DicomViewCreateAddDataNodeInformation] -void DicomView::AddDataNodeFromDICOM(const QStringList& Properties) +void DicomView::AddDataNodeFromDICOM( QHash eventProperties) { - QString seriesUID = Properties.at(3); - QString path = Properties.at(5); -// //! [DicomViewCreateAddDataNodeInformation] -// //! [DicomViewCreateAddDataNodeLoadSeries] + QStringList listOfFilesForSeries; mitk::DicomSeriesReader::StringContainer seriesToLoad; - std::size_t found; - mitk::DicomSeriesReader::FileNamesGrouping dicomSeriesMap = mitk::DicomSeriesReader::GetSeries(path.toStdString(),false); - mitk::DicomSeriesReader::FileNamesGrouping::const_iterator qualifiedSeriesInstanceUIDIterator; + listOfFilesForSeries = eventProperties["FilesForSeries"].toStringList(); + + if (!listOfFilesForSeries.isEmpty()){ - for(qualifiedSeriesInstanceUIDIterator = dicomSeriesMap.begin(); - qualifiedSeriesInstanceUIDIterator != dicomSeriesMap.end(); - ++qualifiedSeriesInstanceUIDIterator) - { - found = qualifiedSeriesInstanceUIDIterator->second.GetSeriesInstanceUID().find(seriesUID.toStdString()); - if(found != std::string::npos) + QStringListIterator it(listOfFilesForSeries); + + while (it.hasNext()) { - seriesToLoad = qualifiedSeriesInstanceUIDIterator->second.GetFilenames(); + seriesToLoad.push_back(it.next().toStdString()); } - } - mitk::DataNode::Pointer node = mitk::DicomSeriesReader::LoadDicomSeries(seriesToLoad); -// //! [DicomViewCreateAddDataNodeLoadSeries] - if (node.IsNull()) - { - MITK_ERROR << "Could not load series: " << seriesUID.toStdString(); - } - else - { -// //! [DicomViewCreateAddDataNode] - this->GetDataStorage()->Add(node); -// //! [DicomViewCreateAddDataNode] - mitk::RenderingManager::GetInstance()->SetDataStorage(this->GetDataStorage()); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - -// //! [DicomViewCreateAddDataNodeActivatePersp] - berry::IWorkbenchWindow::Pointer window = this->GetSite()->GetWorkbenchWindow(); - std::string perspectiveId = "org.mitk.example.viewerperspective"; - window->GetWorkbench()->ShowPerspective(perspectiveId, berry::IWorkbenchWindow::Pointer(window)); -// //! [DicomViewCreateAddDataNodeActivatePersp] + mitk::DataNode::Pointer node = mitk::DicomSeriesReader::LoadDicomSeries(seriesToLoad); + if (node.IsNull()) + { + MITK_ERROR << "Error loading Dicom series"; + } + // //! [DicomViewCreateAddDataNodeLoadSeries] + else + { + // //! [DicomViewCreateAddDataNode] + mitk::DataStorage::Pointer ds = this->GetDataStorage(); + ds->Add(node); + // //! [DicomViewCreateAddDataNode] + mitk::RenderingManager::GetInstance()->SetDataStorage(ds); + mitk::TimeGeometry::Pointer geometry = ds->ComputeBoundingGeometry3D(ds->GetAll()); + mitk::RenderingManager::GetInstance()->InitializeViews(geometry); + + // //! [DicomViewCreateAddDataNodeActivatePersp] + berry::IWorkbenchWindow::Pointer window = this->GetSite()->GetWorkbenchWindow(); + std::string perspectiveId = "org.mitk.example.viewerperspective"; + window->GetWorkbench()->ShowPerspective(perspectiveId, berry::IWorkbenchWindow::Pointer(window)); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + // //! [DicomViewCreateAddDataNodeActivatePersp] + } } } void DicomView::SetFocus () { } diff --git a/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.h b/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.h index b598f82df1..6b8db32b3c 100644 --- a/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.h +++ b/Examples/Plugins/org.mitk.example.gui.customviewer.views/src/internal/DicomView.h @@ -1,82 +1,82 @@ /*=================================================================== 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 DICOMVIEW_H_ #define DICOMVIEW_H_ #include #include #include "ui_QmitkDicomViewControls.h" /** * \brief A view class suited for the DicomPerspective within the custom viewer plug-in. * * This view class contributes dicom import functionality to the DicomPerspective. * The view controls are provided within CreatePartControl() by the QmitkDicomExternalDataWidget * class. A DicomView instance is part of the DicomPerspective for Dicom import functionality. */ // //! [DicomViewDecl] class DicomView : public QmitkAbstractView // //! [DicomViewDecl] { Q_OBJECT public: /** * String based view identifier. */ static const std::string VIEW_ID; /** * Standard constructor. */ DicomView(); /** * Standard destructor. */ virtual ~DicomView(); /** * Creates the view control widgets provided by the QmitkDicomExternalDataWidget class. * Widgets associated with unused functionality are being removed and DICOM import and data * storage transfer funcionality being connected to the appropriate slots. */ virtual void CreateQtPartControl(QWidget *parent); protected Q_SLOTS: /** * Loads the DICOM series specified by the given string parameter and adds the resulting data * node to the data storage. Subsequently switches to the ViewerPerspective for further * data examination. */ - void AddDataNodeFromDICOM(const QStringList& Properties); + void AddDataNodeFromDICOM(QHash eventProperties); protected: void SetFocus(); Ui::QmitkDicomViewControls m_Controls; QWidget* m_Parent; }; #endif /*DICOMVIEW_H_*/