Bladeren bron

Function to construct uuid list for all data

Ivo Wolf 13 jaren geleden
bovenliggende
commit
2adfae52b3

+ 31 - 0
Applications/ctkDICOMHost/ctkDICOMHostMainLogic.cpp

@@ -39,6 +39,8 @@ ctkDICOMHostMainLogic::ctkDICOMHostMainLogic(ctkHostedAppPlaceholderWidget* plac
   QItemSelectionModel* selectionmodel = treeview->selectionModel();
   connect(selectionmodel, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
     this, SLOT(onTreeSelectionChanged(const QItemSelection &, const QItemSelection &)));
+
+  connect(this->Host, SIGNAL(dataAvailable()), this, SLOT(onDataAvailable()));
 }
 
 ctkDICOMHostMainLogic::~ctkDICOMHostMainLogic()
@@ -152,4 +154,33 @@ void ctkDICOMHostMainLogic::placeHolderResized()
   //  QRect rect (this->PlaceHolderForHostedApp->getAbsolutePosition());
   //  this->Host->getDicomAppService()->bringToFront(rect);
   //}
+}
+
+//----------------------------------------------------------------------------
+void ctkDICOMHostMainLogic::onDataAvailable()
+{
+  const ctkDicomAppHosting::AvailableData& data = this->Host->getIncomingAvailableData();
+  QList<QUuid> uuidlist = ctkDicomAvailableDataHelper::getAllUuids(data);
+
+  if(uuidlist.count()==0)
+    return;
+
+  QString transfersyntax("1.2.840.10008.1.2.1");
+  QList<QUuid> transfersyntaxlist;
+  transfersyntaxlist.append(transfersyntax);
+  QList<ctkDicomAppHosting::ObjectLocator> locators;
+  locators = this->Host->getOtherSideExchangeService()->getData(uuidlist, transfersyntaxlist, false);
+  qDebug() << "got locators! " << QString().setNum(locators.count());
+
+  QString s;
+  s=s+" loc.count:"+QString().setNum(locators.count());
+  if(locators.count()>0)
+  {
+    s=s+" URI: "+locators.begin()->URI +" locatorUUID: "+locators.begin()->locator+" sourceUUID: "+locators.begin()->source;
+    qDebug() << "URI: " << locators.begin()->URI;
+    QString filename = locators.begin()->URI;
+    if(filename.startsWith("file:/",Qt::CaseInsensitive))
+      filename=filename.remove(0,8);
+    qDebug()<<filename;
+  }
 }

+ 1 - 0
Applications/ctkDICOMHost/ctkDICOMHostMainLogic.h

@@ -27,6 +27,7 @@ protected slots:
   void publishSelectedData();
   void onAppReady();
   void placeHolderResized();
+  void onDataAvailable();
 signals:
   void TreeSelectionChanged(const QString &);
   void SelectionValid(bool);

+ 46 - 11
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.cpp

@@ -320,23 +320,58 @@ bool appendToAvailableData(ctkDicomAppHosting::AvailableData& dest,
 }
 
 //----------------------------------------------------------------------------
-QList<QUuid> getAllUuids(const ctkDicomAppHosting::Patient& patient)
+void appendAllUuids(const ctkDicomAppHosting::Patient& patient, QList<QUuid> & uuidlist)
 {
-  QList<QUuid> uuidlist;
+  // Loop over patient level object descriptors
+  foreach(const ctkDicomAppHosting::ObjectDescriptor& objectDescriptor, patient.objectDescriptors)
+    {
+    uuidlist.append(objectDescriptor.descriptorUUID);
+    }
 
-  for (QList<ctkDicomAppHosting::Study>::ConstIterator sit = patient.studies.begin();
-    sit < patient.studies.end(); sit++)
+  // Loop over studies
+  foreach(const ctkDicomAppHosting::Study& study, patient.studies)
     {
-    for (QList<ctkDicomAppHosting::Series>::ConstIterator seit = sit->series.begin();
-      seit < sit->series.end(); seit++)
+    // Loop over study level object descriptors
+    foreach(const ctkDicomAppHosting::ObjectDescriptor& objectDescriptor, study.objectDescriptors)
       {
-        for (QList<ctkDicomAppHosting::ObjectDescriptor>::ConstIterator oit = seit->objectDescriptors.begin();
-          oit < seit->objectDescriptors.end(); oit++)
-          {
-            uuidlist.append(oit->descriptorUUID);
-          }
+      uuidlist.append(objectDescriptor.descriptorUUID);
+      }
+    // Loop over series
+    foreach(const ctkDicomAppHosting::Series& series, study.series)
+      {
+      // Loop over series level object descriptors
+      foreach(const ctkDicomAppHosting::ObjectDescriptor& objectDescriptor, series.objectDescriptors)
+        {
+        uuidlist.append(objectDescriptor.descriptorUUID);
+        }
       }
     }
+}
+
+//----------------------------------------------------------------------------
+QList<QUuid> getAllUuids(const ctkDicomAppHosting::Patient& patient)
+{
+  QList<QUuid> uuidlist;
+  appendAllUuids(patient, uuidlist);
+  return uuidlist;
+}
+
+//----------------------------------------------------------------------------
+QList<QUuid> getAllUuids(const ctkDicomAppHosting::AvailableData& availableData)
+{
+  QList<QUuid> uuidlist;
+
+  // Loop over top level object descriptors
+  foreach(const ctkDicomAppHosting::ObjectDescriptor& objectDescriptor, availableData.objectDescriptors)
+    {
+    uuidlist.append(objectDescriptor.descriptorUUID);
+    }
+
+   // Loop over patients
+  foreach(const ctkDicomAppHosting::Patient& patient, availableData.patients)
+    {
+    appendAllUuids(patient, uuidlist);
+    }
   return uuidlist;
 }
 

+ 9 - 1
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.h

@@ -114,7 +114,15 @@ bool org_commontk_dah_core_EXPORT appendToAvailableData(ctkDicomAppHosting::Avai
  */
 QList<QUuid> org_commontk_dah_core_EXPORT getAllUuids(const ctkDicomAppHosting::Patient& patient);
 
-
+//----------------------------------------------------------------------------
+/**
+ * \brief Build list of all UUIDs of available data.
+ *
+ * Result can be used to retrieve data by calling ctkDicomExchangeInterface::getData.
+ *
+ * \return alls UUIDs of all data inside available data, otherwise empty.
+ */
+QList<QUuid> org_commontk_dah_core_EXPORT getAllUuids(const ctkDicomAppHosting::AvailableData& availableData);
 
 } //end namespace ctkDicomAvailableDataHelper