Browse Source

Merge branch 'dah_master_merge' into dah

Ivo Wolf 14 years ago
parent
commit
f2731941c2

+ 1 - 1
Applications/ctkExampleHost/target_libraries.cmake

@@ -6,5 +6,5 @@
 
 SET(target_libraries
   org_commontk_dah_examplehost
-
+  CTKDICOMCore
   )

+ 44 - 2
Libs/DICOM/Core/ctkDICOMDataset.cpp

@@ -19,6 +19,8 @@ class ctkDICOMDatasetPrivate
     bool m_DICOMDataSetInitialized;
 
     static const QScopedPointer<const DcmDataDictionary> s_Dictionary;
+
+    DcmDataset* m_DcmDataset;
 };
 
 const QScopedPointer<const DcmDataDictionary> ctkDICOMDatasetPrivate::s_Dictionary(new DcmDataDictionary(OFTrue, OFTrue));
@@ -32,18 +34,32 @@ ctkDICOMDataset::ctkDICOMDataset()
 {
   Q_D(ctkDICOMDataset);
   d->m_DICOMDataSetInitialized = false;
+  d->m_DcmDataset = this;
 }
 
 ctkDICOMDataset::~ctkDICOMDataset() 
 {
+  Q_D(ctkDICOMDataset);
+  if(d->m_DcmDataset != this)
+  {
+    delete d->m_DcmDataset;
+  }
 }
 
 
 void ctkDICOMDataset::InitializeFromDataset(DcmDataset* dataset)
 {
   Q_D(ctkDICOMDataset);
+
+  if(d->m_DcmDataset != this)
+  {
+    delete d->m_DcmDataset;
+    d->m_DcmDataset = NULL;
+  }
+
   if (dataset)
   {
+    d->m_DcmDataset=dataset;
     if (!d->m_DICOMDataSetInitialized)
     {
       d->m_DICOMDataSetInitialized = true;
@@ -79,6 +95,27 @@ void ctkDICOMDataset::InitializeFromDataset(DcmDataset* dataset)
 }
 
 
+void ctkDICOMDataset::InitializeFromFile(const QString& filename,const E_TransferSyntax readXfer,
+                    const E_GrpLenEncoding groupLength,
+                    const Uint32 maxReadLength,
+                    const E_FileReadMode readMode)
+{
+  Q_D(ctkDICOMDataset);
+  DcmDataset *dataset;
+  
+  DcmFileFormat fileformat;
+  OFCondition status = fileformat.loadFile(filename.toAscii().data(), readXfer, groupLength, readMode);
+  dataset = fileformat.getAndRemoveDataset();
+
+  if (!status.good())
+  {
+    qDebug() << "Could not load " << filename << "\nDCMTK says: " << status.text();
+    delete dataset;
+    return;
+  }
+
+  InitializeFromDataset(dataset);
+}
 
 void ctkDICOMDataset::Serialize()
 {
@@ -174,17 +211,22 @@ void ctkDICOMDataset::Deserialize()
   }
 }
 
+DcmDataset& ctkDICOMDataset::GetDcmDataset() const
+{
+  const Q_D(ctkDICOMDataset);
+  return *d->m_DcmDataset;
+}
 
 OFCondition ctkDICOMDataset::findAndGetElement(const DcmTag& tag, DcmElement*& element, const OFBool searchIntoSub) const
 {
   // this one const_cast allows us to declare quite a lot of methods nicely with const
-  return ((DcmDataset&)(const_cast<ctkDICOMDataset&>(*this))).findAndGetElement(tag, element, searchIntoSub);
+  return GetDcmDataset().findAndGetElement(tag, element, searchIntoSub);
 }
 
 OFCondition ctkDICOMDataset::findAndGetOFString(const DcmTag& tag, OFString& value, const unsigned long pos, const OFBool searchIntoSub) const
 {
   // this second const_cast allows us to declare quite a lot of methods nicely with const
-  return ((DcmDataset&)(const_cast<ctkDICOMDataset&>(*this))).findAndGetOFString(tag, value, pos, searchIntoSub);
+  return GetDcmDataset().findAndGetOFString(tag, value, pos, searchIntoSub);
 }
 
 bool ctkDICOMDataset::CheckCondition(const OFCondition& condition)

+ 11 - 0
Libs/DICOM/Core/ctkDICOMDataset.h

@@ -80,6 +80,15 @@ public:
     virtual void InitializeFromDataset(DcmDataset* dataset);
 
     /**
+      \brief For initialization from file in a constructor / assignment.
+    */
+    virtual void InitializeFromFile(const QString& filename, 
+                    const E_TransferSyntax readXfer = EXS_Unknown,
+                    const E_GrpLenEncoding groupLength = EGL_noChange,
+                    const Uint32 maxReadLength = DCM_MaxReadLength,
+                    const E_FileReadMode readMode = ERM_autoDetect);
+
+    /**
      \brief Store a string representation of the object to a database field.
 
      The internal DcmDataset is serialized into a memory buffer using DcmDataset::write(..).
@@ -235,6 +244,8 @@ protected:
 
   QScopedPointer<ctkDICOMDatasetPrivate> d_ptr;
 
+  DcmDataset& GetDcmDataset() const;
+
 private:
   Q_DECLARE_PRIVATE(ctkDICOMDataset);
 };

+ 2 - 0
Plugins/org.commontk.dah.core/CMakeLists.txt

@@ -8,6 +8,8 @@ SET(PLUGIN_SRCS
   ctkDicomAppHostingTypes.cpp
   ctkDicomAppHostingTypesHelper.cpp
   ctkDicomAppInterface.h
+  ctkDicomAvailableDataHelper.cpp
+  ctkDicomAvailableDataHelper.h
   ctkDicomExchangeInterface.h
   ctkDicomExchangeService.cpp
   ctkDicomHostInterface.h

+ 1 - 3
Plugins/org.commontk.dah.core/ctkDicomAppHostingTypesHelper.cpp

@@ -207,7 +207,6 @@ QStringList ctkDicomSoapArrayOfStringType::getArray(const QtSoapType& type)
 
 //----------------------------------------------------------------------------
 ctkDicomSoapUUID::ctkDicomSoapUUID(const QString& name, const QUuid& uuid)
-//  : QtSoapArray(QtSoapQName(name), QtSoapType::String, array.size())
   : QtSoapStruct(QtSoapQName(name))
 {
   QString uuidstring(uuid.toString());
@@ -246,7 +245,7 @@ QList<QUuid> ctkDicomSoapArrayOfUUIDS::getArray(const QtSoapType& type)
   QList<QUuid> list;
   for (int i = 0; i < type.count(); i++)
     {
-    list << QUuid(type[i].value().toString());
+    list << ctkDicomSoapUUID::getUuid(type[i]);
     }
   return list;
 }
@@ -590,4 +589,3 @@ QList<ctkDicomAppHosting::ObjectLocator> ctkDicomSoapArrayOfObjectLocators::getA
     }
   return list;
 }
-

+ 245 - 0
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.cpp

@@ -0,0 +1,245 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+// CTK includes
+#include "ctkDicomAvailableDataHelper.h"
+#include "ctkDicomAvailableDataHelper.h"
+#include "ctkDicomObjectLocatorCache.h"
+#include <ctkDICOMDataset.h>
+
+// DCMTK includes
+#include <dcmtk/dcmdata/dcdeftag.h>
+
+namespace ctkDicomAvailableDataHelper {
+
+//------------------------------------------------------------------------------
+class ctkDicomAvailableDataAccessorPrivate
+{
+//  Q_DECLARE_PUBLIC(ctkDicomAvailableDataAccessor);
+protected:
+  
+public:
+  ctkDicomAvailableDataAccessorPrivate(ctkDicomAppHosting::AvailableData& availableData) : 
+      m_AvailableData(availableData) { };
+
+  ctkDicomAppHosting::AvailableData& m_AvailableData;
+};
+
+//----------------------------------------------------------------------------
+ctkDicomAvailableDataAccessor::ctkDicomAvailableDataAccessor(ctkDicomAppHosting::AvailableData& ad)
+  : d_ptr(new ctkDicomAvailableDataAccessorPrivate(ad))
+{
+}
+
+ctkDicomAvailableDataAccessor::~ctkDicomAvailableDataAccessor() {};
+
+//----------------------------------------------------------------------------
+ctkDicomAppHosting::Patient* ctkDicomAvailableDataAccessor::getPatient(const ctkDicomAppHosting::Patient& patient) const
+{
+  const Q_D(ctkDicomAvailableDataAccessor);
+  ctkDicomAppHosting::AvailableData & ad(d->m_AvailableData);
+  for (QList<ctkDicomAppHosting::Patient>::Iterator pit = ad.patients.begin();
+    pit < ad.patients.end(); pit++)
+    {
+      if(pit->id==patient.id)
+        return &(*pit);
+    }
+  return NULL;
+}
+
+//----------------------------------------------------------------------------
+ctkDicomAppHosting::Study* ctkDicomAvailableDataAccessor::getStudy(const QString& studyUID) const
+{
+  const Q_D(ctkDicomAvailableDataAccessor);
+  ctkDicomAppHosting::AvailableData & ad(d->m_AvailableData);
+  for (QList<ctkDicomAppHosting::Patient>::Iterator pit = ad.patients.begin();
+    pit < ad.patients.end(); pit++)
+    {
+    for (QList<ctkDicomAppHosting::Study>::Iterator sit = pit->studies.begin();
+      sit < pit->studies.end(); sit++)
+      {
+          if(sit->studyUID==studyUID)
+            return &(*sit);
+      }
+    }
+  return NULL;
+}
+
+//----------------------------------------------------------------------------
+ctkDicomAppHosting::Series* ctkDicomAvailableDataAccessor::getSeries(const QString& seriesUID) const
+{
+  const Q_D(ctkDicomAvailableDataAccessor);
+  ctkDicomAppHosting::AvailableData & ad(d->m_AvailableData);
+  for (QList<ctkDicomAppHosting::Patient>::Iterator pit = ad.patients.begin();
+    pit < ad.patients.end(); pit++)
+    {
+    for (QList<ctkDicomAppHosting::Study>::Iterator sit = pit->studies.begin();
+      sit < pit->studies.end(); sit++)
+      {
+      for (QList<ctkDicomAppHosting::Series>::Iterator seit = sit->series.begin();
+        seit < sit->series.end(); seit++)
+        {
+          if(seit->seriesUID==seriesUID)
+            return &(*seit);
+        }
+      }
+    }
+  return NULL;
+}
+
+//----------------------------------------------------------------------------
+void ctkDicomAvailableDataAccessor::find(const ctkDicomAppHosting::Patient& patient, 
+                                         const QString& studyUID, 
+                                         const QString& seriesUID,
+                                         ctkDicomAppHosting::Patient*& patientResult, 
+                                         ctkDicomAppHosting::Study*& studyResult, 
+                                         ctkDicomAppHosting::Series*& seriesResult) const
+{
+  const Q_D(ctkDicomAvailableDataAccessor);
+  ctkDicomAppHosting::AvailableData & ad(d->m_AvailableData);
+  patientResult=NULL;
+  studyResult=NULL;
+  seriesResult=NULL;
+  for (QList<ctkDicomAppHosting::Patient>::Iterator pit = ad.patients.begin();
+    pit < ad.patients.end(); pit++)
+    {
+    if(pit->id==patient.id)
+      {
+      patientResult = &(*pit);
+      for (QList<ctkDicomAppHosting::Study>::Iterator sit = pit->studies.begin();
+        sit < pit->studies.end(); sit++)
+        {
+        if(sit->studyUID==studyUID)
+          {
+          studyResult = &(*sit);
+          for (QList<ctkDicomAppHosting::Series>::Iterator seit = sit->series.begin();
+            seit < sit->series.end(); seit++)
+            {
+            if(seit->seriesUID==seriesUID)
+              {
+              seriesResult=&(*seit);
+              return;
+              }
+            }
+            return;
+          }
+        }
+      return;
+      }
+    }
+}
+
+//----------------------------------------------------------------------------
+bool addToAvailableData(ctkDicomAppHosting::AvailableData& data, 
+                        ctkDicomObjectLocatorCache* objectLocatorCache, 
+                        const ctkDICOMDataset& dataset, 
+                        long length, 
+                        long offset, 
+                        const QString& uri)
+{
+  if(objectLocatorCache == NULL)
+    return false;
+  ctkDicomAppHosting::ObjectDescriptor objectDescriptor;
+  ctkDicomAppHosting::Study study;
+  ctkDicomAppHosting::Series series;
+  ctkDicomAppHosting::Patient patient;
+  patient.name = dataset.GetElementAsString(DCM_PatientsName);
+qDebug()<<"Patient:  " << patient.name;
+  patient.id = dataset.GetElementAsString(DCM_PatientID);
+  patient.assigningAuthority = dataset.GetElementAsString(DCM_IssuerOfPatientID);
+  patient.sex = dataset.GetElementAsString(DCM_PatientsSex);
+  patient.birthDate = dataset.GetElementAsString(DCM_PatientsBirthDate);
+
+
+  study.studyUID = dataset.GetElementAsString(DCM_StudyInstanceUID);
+  series.seriesUID = dataset.GetElementAsString(DCM_SeriesInstanceUID);
+
+  QString uuid = QUuid::createUuid().toString();
+  objectDescriptor.descriptorUUID = uuid;
+  objectDescriptor.mimeType = "application/dicom";
+  objectDescriptor.classUID = dataset.GetElementAsString(DCM_SOPClassUID);
+  objectDescriptor.transferSyntaxUID = dataset.GetElementAsString(DCM_TransferSyntaxUID);
+  objectDescriptor.modality = dataset.GetElementAsString(DCM_Modality);
+  
+
+
+  ctkDicomAppHosting::Patient* ppatient;
+  ctkDicomAppHosting::Study* pstudy;
+  ctkDicomAppHosting::Series* pseries;
+  
+  ctkDicomAvailableDataAccessor(data).find(patient, study.studyUID, series.seriesUID,
+    ppatient, pstudy, pseries);
+
+  if(pseries==NULL)
+  {
+    series.objectDescriptors.append(objectDescriptor);
+    if(pstudy==NULL)
+    {
+      study.series.append(series);
+      if(ppatient==NULL)
+      {
+        patient.studies.append(study);
+        data.patients.append(patient);
+      }
+      else
+      {
+        ppatient->studies.append(study);
+      }
+    }
+    else
+    {
+      pstudy->series.append(series);
+    }
+  }
+  else
+  {
+    pseries->objectDescriptors.append(objectDescriptor);
+  }
+
+  ctkDicomAppHosting::ObjectLocator locator;
+  locator.locator = objectDescriptor.descriptorUUID;
+  locator.source = objectDescriptor.descriptorUUID;
+  locator.offset = offset;
+  locator.length = length;
+  locator.transferSyntax = objectDescriptor.transferSyntaxUID;
+  locator.URI = uri;
+
+  objectLocatorCache->insert(objectDescriptor.descriptorUUID, locator);
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool addToAvailableData(ctkDicomAppHosting::AvailableData& data,
+                        ctkDicomObjectLocatorCache* objectLocatorCache, 
+                        const QString& filename)
+{
+  QFileInfo fileinfo(filename);
+  qDebug() << filename << " " << fileinfo.exists();
+
+  ctkDICOMDataset ctkdataset;
+  ctkdataset.InitializeFromFile(filename, EXS_Unknown, EGL_noChange, 400);
+
+  QString uri("file:/");
+  uri.append(fileinfo.absoluteFilePath());
+  return addToAvailableData(data, objectLocatorCache, ctkdataset, fileinfo.size(), 0, uri);
+}
+
+}

+ 82 - 0
Plugins/org.commontk.dah.core/ctkDicomAvailableDataHelper.h

@@ -0,0 +1,82 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+
+#ifndef CTKDICOMAVAILABLEDATAHELPER_H
+#define CTKDICOMAVAILABLEDATAHELPER_H
+
+// Qt includes
+#include <QObject>
+#include <QString>
+
+// CTK includes
+#include <org_commontk_dah_core_Export.h>
+#include <ctkDicomAppHostingTypes.h>
+
+class ctkDicomObjectLocatorCache;
+class ctkDICOMDataset;
+
+namespace ctkDicomAvailableDataHelper {
+
+//----------------------------------------------------------------------------
+class ctkDicomAvailableDataAccessorPrivate;
+class org_commontk_dah_core_EXPORT ctkDicomAvailableDataAccessor : public QObject
+{
+public:
+  ctkDicomAvailableDataAccessor(ctkDicomAppHosting::AvailableData& ad);
+  virtual ~ctkDicomAvailableDataAccessor();
+
+  ctkDicomAppHosting::Patient* ctkDicomAvailableDataAccessor::getPatient(const ctkDicomAppHosting::Patient& patient) const;
+
+  ctkDicomAppHosting::Study* getStudy(const QString& studyUID) const;
+
+  ctkDicomAppHosting::Series* getSeries(const QString& seriesUID) const;
+
+  void ctkDicomAvailableDataAccessor::find(const ctkDicomAppHosting::Patient& patient, 
+                                         const QString& studyUID, 
+                                         const QString& seriesUID,
+                                         ctkDicomAppHosting::Patient*& patientResult, 
+                                         ctkDicomAppHosting::Study*& studyResult, 
+                                         ctkDicomAppHosting::Series*& seriesResult) const;
+
+protected:
+  QScopedPointer<ctkDicomAvailableDataAccessorPrivate> d_ptr;
+
+private:
+  Q_DECLARE_PRIVATE(ctkDicomAvailableDataAccessor);
+};
+
+//----------------------------------------------------------------------------
+bool org_commontk_dah_core_EXPORT addToAvailableData(ctkDicomAppHosting::AvailableData& data, 
+                        ctkDicomObjectLocatorCache* objectLocatorCache, 
+                        const ctkDICOMDataset& dataset, 
+                        long length, 
+                        long offset, 
+                        const QString& uri);
+
+//----------------------------------------------------------------------------
+bool org_commontk_dah_core_EXPORT addToAvailableData(ctkDicomAppHosting::AvailableData& data, 
+                        ctkDicomObjectLocatorCache* objectLocatorCache, 
+                        const QString& filename);
+
+}
+
+#endif // CTKDICOMAVAILABLEDATAHELPER_H

+ 1 - 1
Plugins/org.commontk.dah.core/ctkDicomExchangeInterface.h

@@ -27,7 +27,7 @@
 #include <QObject>
 #include "ctkDicomAppHostingTypes.h"
 
-class QUuid;
+struct QUuid;
 
 struct ctkDicomExchangeInterface
 {

+ 10 - 11
Plugins/org.commontk.dah.core/ctkDicomExchangeService.cpp

@@ -57,18 +57,17 @@ QList<ctkDicomAppHosting::ObjectLocator> ctkDicomExchangeService::getData(
   //Q_D(ctkDicomService);
   QList<QtSoapType*> list;
 
-  //list << new ctkDicomSoapArrayOfUUIDS("objectUUIDS",objectUUIDs);
-  //list << new ctkDicomSoapArrayOfStringType("UID","acceptableTransferSyntaxUIDs", acceptableTransferSyntaxUIDs);
-  //list << new ctkDicomSoapBool("includeBulkData", includeBulkData);
-  //const QtSoapType & result = submitSoapRequest("getData",list);
-  //const QtSoapType & result = submitSoapRequest("getData",list);
-QtSoapType *tt;
-  list << (tt=new ctkDicomSoapArrayOfUUIDS("uuids",objectUUIDs));
+  list << new ctkDicomSoapArrayOfUUIDS("objectUUIDS",objectUUIDs);
+  list << new ctkDicomSoapArrayOfStringType("UID","acceptableTransferSyntaxUIDs", acceptableTransferSyntaxUIDs);
+  list << new ctkDicomSoapBool("includeBulkData", includeBulkData);
+  const QtSoapType & result = submitSoapRequest("getData",list);
+//QtSoapType *tt;
+//  list << (tt=new ctkDicomSoapArrayOfUUIDS("uuids",objectUUIDs));
 extern void DumpAll(const QtSoapType& type, int indent=0);
-DumpAll(*tt);
-  list << (tt=new ctkDicomSoapBool("includeBulkData", includeBulkData));
-DumpAll(*tt);
-  const QtSoapType & result = submitSoapRequest("getDataAsFile",list);
+//DumpAll(*tt);
+//  list << (tt=new ctkDicomSoapBool("includeBulkData", includeBulkData));
+//DumpAll(*tt);
+//  const QtSoapType & result = submitSoapRequest("getDataAsFile",list);
 DumpAll(result); //xxx
 
   return ctkDicomSoapArrayOfObjectLocators::getArray(result);

+ 1 - 1
Plugins/org.commontk.dah.core/ctkDicomObjectLocatorCache.h

@@ -29,7 +29,7 @@
 #include <org_commontk_dah_core_Export.h>
 
 class ctkDicomObjectLocatorCachePrivate;
-class QUuid;
+struct QUuid;
 
 /**
   *

+ 2 - 4
Plugins/org.commontk.dah.core/ctkExchangeSoapMessageProcessor.cpp

@@ -91,11 +91,9 @@ void ctkExchangeSoapMessageProcessor::processGetData(
 {
   // extract arguments from input message
   const QtSoapType& inputType = message.method()["objectUUIDs"];
-  const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(
-    dynamic_cast<const QtSoapArray&>(inputType));
+  const QList<QUuid> objectUUIDs = ctkDicomSoapArrayOfUUIDS::getArray(inputType);
   const QtSoapType& inputType2 = message.method()["acceptableTransferSyntaxUIDs"];
-  const QStringList acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(
-    dynamic_cast<const QtSoapArray&>(inputType2));
+  const QStringList acceptableTransferSyntaxUIDs = ctkDicomSoapArrayOfStringType::getArray(inputType2);
   const QtSoapType& inputType3 = message.method()["includeBulkData"];
   const bool includeBulkData = ctkDicomSoapBool::getBool(inputType3);
   // query interface

+ 2 - 2
Plugins/org.commontk.dah.core/ctkSoapMessageProcessorList.cpp

@@ -45,8 +45,8 @@ bool ctkSoapMessageProcessorList::process(
     const QtSoapMessage& message,
     QtSoapMessage* reply ) const
 {
-  //extern void DumpAll(const QtSoapType& type, int indent=0);
-  //DumpAll(message.method());
+  extern void DumpAll(const QtSoapType& type, int indent=0);
+  DumpAll(message.method());
 
   foreach(ctkSoapMessageProcessor* processor, this->Processors)
   {

+ 1 - 0
Plugins/org.commontk.dah.core/target_libraries.cmake

@@ -8,4 +8,5 @@ SET(target_libraries
   CTKPluginFramework
   QT_LIBRARIES
   QTSOAP_LIBRARY
+  CTKDICOMCore
 )

+ 7 - 3
Plugins/org.commontk.dah.exampleapp/ctkExampleDicomAppLogic.cpp

@@ -96,9 +96,13 @@ void ctkExampleDicomAppLogic::do_something()
 void ctkExampleDicomAppLogic::onStartProgress()
 {
   setInternalState(ctkDicomAppHosting::INPROGRESS);
-  getHostInterface()->notifyStateChanged(ctkDicomAppHosting::INPROGRESS);
 
-  do_something();
+  // we need to create the button before we receive data from
+  // the host, which happens immediately after calling
+  // getHostInterface()->notifyStateChanged
+  do_something(); 
+
+  getHostInterface()->notifyStateChanged(ctkDicomAppHosting::INPROGRESS);
 }
 
 //----------------------------------------------------------------------------
@@ -220,7 +224,7 @@ void ctkExampleDicomAppLogic::buttonClicked()
   s=s+" loc.count:"+QString().setNum(locators.count());
   if(locators.count()>0)
   {
-    s=s+" URI: "+locators.begin()->URI;
+    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))

+ 10 - 59
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.cpp

@@ -27,6 +27,7 @@
 // CTK includes
 #include "ctkExampleDicomHost.h"
 #include "ctkDicomAppHostingTypesHelper.h"
+#include "ctkDicomAvailableDataHelper.h"
 
 // STD includes
 #include <iostream>
@@ -121,34 +122,18 @@ void ctkExampleDicomHost::onAppReady()
 //----------------------------------------------------------------------------
 void ctkExampleDicomHost::onStartProgress()
 {
-  ctkDicomAppHosting::ObjectDescriptor ourObjectDescriptor;
-  QList<ctkDicomAppHosting::Study> studies;
   ctkDicomAppHosting::AvailableData data;
-  ctkDicomAppHosting::Patient patient;
-
-  patient.name = "John Doe";
-  patient.id = "0000";
-  patient.assigningAuthority = "authority";
-  patient.sex = "male";
-  patient.birthDate = "today";
-  patient.objectDescriptors = QList<ctkDicomAppHosting::ObjectDescriptor>();
-
-  patient.studies = studies;
-
-  ourObjectDescriptor.descriptorUUID = QUuid("{11111111-1111-1111-1111-111111111111}");
-  ourObjectDescriptor.mimeType = "text/plain";
-  ourObjectDescriptor.classUID = "lovelyClass";
-  ourObjectDescriptor.transferSyntaxUID = "transSyntaxUId";
-  ourObjectDescriptor.modality = "modMod";
-
-  data.objectDescriptors =  QList<ctkDicomAppHosting::ObjectDescriptor>();
-  data.objectDescriptors.append (ourObjectDescriptor);
-  data.patients = QList<ctkDicomAppHosting::Patient>();
-  data.patients.append (patient);
+  ctkDicomAvailableDataHelper::addToAvailableData(data, 
+    this->objectLocatorCache(), 
+    "C:/XIP/XIPHost/dicom-dataset-demo/1.3.6.1.4.1.9328.50.1.10698.dcm");
 
   qDebug()<<"send dataDescriptors";
-  bool reply = getDicomAppService()->notifyDataAvailable (data,true);
-  qDebug() << "  notifyDataAvailable(1111) returned: " << reply;
+  bool success = this->publishData(data, true);
+  if(!success)
+  {
+    qCritical() << "Failed to publish data";
+  }
+  qDebug() << "  notifyDataAvailable(1111) returned: " << success;
 }
 
 //----------------------------------------------------------------------------
@@ -188,40 +173,6 @@ void ctkExampleDicomHost::onReleaseAvailableResources()
 }
 
 //----------------------------------------------------------------------------
-QList<ctkDicomAppHosting::ObjectLocator> ctkExampleDicomHost::getData(
-    const QList<QUuid>& objectUUIDs,
-    const QList<QString>& acceptableTransferSyntaxUIDs,
-    bool includeBulkData)
-{
-  Q_UNUSED(includeBulkData)
-  Q_UNUSED(acceptableTransferSyntaxUIDs)
-
-  //stupid test: only works with one uuid
-  QList<ctkDicomAppHosting::ObjectLocator> locators;
-  QUuid uuid;
-  QUuid testUuid("{11111111-1111-1111-1111-111111111111}");
-  foreach(uuid, objectUUIDs)
-    {
-    //stupid test: only works with one uuid
-    if (uuid == testUuid)
-      {
-      ctkDicomAppHosting::ObjectLocator objectLocator;
-      objectLocator.locator = QUuid();
-      objectLocator.source = QUuid();
-      //need to filter transfert syntax with acceptable ones
-      objectLocator.transferSyntax = "transSyntaxUId";
-      objectLocator.length = 0;
-      objectLocator.offset = 0;
-      objectLocator.URI = "testFile.txt";
-      locators.append (objectLocator);
-      }
-    return locators;
-    }
-
-  return QList<ctkDicomAppHosting::ObjectLocator>();
-}
-
-//----------------------------------------------------------------------------
 void ctkExampleDicomHost::releaseData(const QList<QUuid>& objectUUIDs)
 {
   Q_UNUSED(objectUUIDs)

+ 0 - 4
Plugins/org.commontk.dah.examplehost/ctkExampleDicomHost.h

@@ -52,10 +52,6 @@ public:
   virtual void notifyStatus(const ctkDicomAppHosting::Status& status);
   // exchange methods
   virtual bool notifyDataAvailable(const ctkDicomAppHosting::AvailableData& data, bool lastData);
-  virtual QList<ctkDicomAppHosting::ObjectLocator> getData(
-      const QList<QUuid>& objectUUIDs,
-      const QList<QString>& acceptableTransferSyntaxUIDs,
-      bool includeBulkData);
   virtual void releaseData(const QList<QUuid>& objectUUIDs);
 
   const QProcess& getAppProcess() const { return this->AppProcess; }