changeset 1476:4db187d29731

renamed SeriesMetadataLoader::SeriesLoadedMessage to SuccessMessage
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Jun 2020 18:21:26 +0200
parents 615035c2f3ba
children 5732edec7cbd
files Framework/Loaders/DicomVolumeLoader.cpp Framework/Loaders/DicomVolumeLoader.h Framework/Loaders/SeriesMetadataLoader.cpp Framework/Loaders/SeriesMetadataLoader.h Framework/Loaders/SeriesThumbnailsLoader.cpp Framework/Loaders/SeriesThumbnailsLoader.h
diffstat 6 files changed, 47 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Loaders/DicomVolumeLoader.cpp	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/DicomVolumeLoader.cpp	Wed Jun 17 18:21:26 2020 +0200
@@ -142,7 +142,7 @@
   {
   }
 
-  DicomVolumeLoader::Factory::Factory(const SeriesMetadataLoader::SeriesLoadedMessage& metadata) :
+  DicomVolumeLoader::Factory::Factory(const SeriesMetadataLoader::SuccessMessage& metadata) :
     framesFactory_(metadata.GetInstances()),
     computeRange_(false)
   {
--- a/Framework/Loaders/DicomVolumeLoader.h	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/DicomVolumeLoader.h	Wed Jun 17 18:21:26 2020 +0200
@@ -99,7 +99,7 @@
     public:
       Factory(LoadedDicomResources& instances);
 
-      Factory(const SeriesMetadataLoader::SeriesLoadedMessage& metadata);
+      Factory(const SeriesMetadataLoader::SuccessMessage& metadata);
 
       void SetComputeRange(bool computeRange)
       {
--- a/Framework/Loaders/SeriesMetadataLoader.cpp	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/SeriesMetadataLoader.cpp	Wed Jun 17 18:21:26 2020 +0200
@@ -69,8 +69,8 @@
         {
           series_[seriesInstanceUid] = message.GetResources();
 
-          SeriesLoadedMessage loadedMessage(*this, message.GetDicomSource(), studyInstanceUid,
-                                            seriesInstanceUid, *message.GetResources());
+          SuccessMessage loadedMessage(*this, message.GetDicomSource(), studyInstanceUid,
+                                       seriesInstanceUid, *message.GetResources());
           BroadcastMessage(loadedMessage);
         }
 
@@ -151,7 +151,7 @@
               else if (series->second->GetSize() == size->second)
               {
                 // The series is complete
-                SeriesLoadedMessage loadedMessage(
+                SuccessMessage loadedMessage(
                   *this, message.GetDicomSource(),
                   studyInstanceUid, seriesInstanceUid, *series->second);
                 loadedMessage.SetDicomDir(dicomDirPath_, dicomDir_);
@@ -170,7 +170,7 @@
   }
 
 
-  SeriesMetadataLoader::SeriesLoadedMessage::SeriesLoadedMessage(
+  SeriesMetadataLoader::SuccessMessage::SuccessMessage(
     const SeriesMetadataLoader& loader,
     const DicomSource& source,
     const std::string& studyInstanceUid,
@@ -187,7 +187,7 @@
   }
 
 
-  boost::shared_ptr<IObserver> SeriesMetadataLoader::Factory::Create(ILoadersContext::ILock& context)
+  boost::shared_ptr<SeriesMetadataLoader> SeriesMetadataLoader::Create(ILoadersContext::ILock& context)
   {
     boost::shared_ptr<DicomResourcesLoader> loader(DicomResourcesLoader::Create(context));
       
--- a/Framework/Loaders/SeriesMetadataLoader.h	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/SeriesMetadataLoader.h	Wed Jun 17 18:21:26 2020 +0200
@@ -56,7 +56,7 @@
     void Handle(const DicomResourcesLoader::SuccessMessage& message);
 
   public:
-    class SeriesLoadedMessage : public OriginMessage<SeriesMetadataLoader>
+    class SuccessMessage : public OriginMessage<SeriesMetadataLoader>
     {
       ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
 
@@ -69,11 +69,11 @@
       boost::shared_ptr<LoadedDicomResources>  dicomDir_;
 
     public:
-      SeriesLoadedMessage(const SeriesMetadataLoader& loader,
-                          const DicomSource& source,
-                          const std::string& studyInstanceUid,
-                          const std::string& seriesInstanceUid,
-                          LoadedDicomResources& instances);
+      SuccessMessage(const SeriesMetadataLoader& loader,
+                     const DicomSource& source,
+                     const std::string& studyInstanceUid,
+                     const std::string& seriesInstanceUid,
+                     LoadedDicomResources& instances);
 
       const DicomSource& GetDicomSource() const
       {
@@ -128,9 +128,15 @@
     class Factory : public ILoaderFactory
     {
     public:
-      virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& context);
+      virtual boost::shared_ptr<IObserver> Create(ILoadersContext::ILock& context)
+      {
+        return SeriesMetadataLoader::Create(context);
+      }
     };
 
+
+    static boost::shared_ptr<SeriesMetadataLoader> Create(ILoadersContext::ILock& context);
+
   
     class Accessor : public boost::noncopyable
     {
--- a/Framework/Loaders/SeriesThumbnailsLoader.cpp	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/SeriesThumbnailsLoader.cpp	Wed Jun 17 18:21:26 2020 +0200
@@ -279,12 +279,16 @@
     virtual void HandleError()
     {
       // The DICOMweb wasn't able to generate a thumbnail, try to
-      // retrieve the SopClassUID tag using a call to "/metadata"
+      // retrieve the SopClassUID tag using QIDO-RS
 
+      std::map<std::string, std::string> arguments, headers;
+      arguments["0020000D"] = GetStudyInstanceUid();
+      arguments["0020000E"] = GetSeriesInstanceUid();
+      arguments["includefield"] = "00080016";
+      
       std::unique_ptr<IOracleCommand> command(
         GetSource().CreateDicomWebCommand(
-          "/studies/" + GetStudyInstanceUid() + "/series/" + GetSeriesInstanceUid() + "/metadata",
-          new DicomWebSopClassHandler(
+          "/instances", arguments, headers, new DicomWebSopClassHandler(
             GetLoader(), GetSource(), GetStudyInstanceUid(), GetSeriesInstanceUid())));
       GetLoader()->Schedule(command.release());
     }
@@ -548,6 +552,11 @@
                                                      const std::string& studyInstanceUid,
                                                      const std::string& seriesInstanceUid)
   {
+    if (IsScheduledSeries(seriesInstanceUid))
+    {
+      return;
+    }
+    
     if (source.IsDicomWeb())
     {
       if (!source.HasDicomWebRendered())
@@ -574,6 +583,8 @@
           uri, arguments, headers, new DicomWebThumbnailHandler(
             shared_from_this(), source, studyInstanceUid, seriesInstanceUid)));
       Schedule(command.release());
+
+      scheduledSeries_.insert(seriesInstanceUid);
     }
     else if (source.IsOrthanc())
     {
@@ -585,6 +596,8 @@
       command->AcquirePayload(new SelectOrthancInstanceHandler(
                                 shared_from_this(), source, studyInstanceUid, seriesInstanceUid));
       Schedule(command.release());
+
+      scheduledSeries_.insert(seriesInstanceUid);
     }
     else
     {
--- a/Framework/Loaders/SeriesThumbnailsLoader.h	Tue Jun 16 10:21:43 2020 +0200
+++ b/Framework/Loaders/SeriesThumbnailsLoader.h	Wed Jun 17 18:21:26 2020 +0200
@@ -145,11 +145,12 @@
     // Maps a "Series Instance UID" to a thumbnail
     typedef std::map<std::string, Thumbnail*>  Thumbnails;
 
-    ILoadersContext&  context_;
-    Thumbnails      thumbnails_;
-    int             priority_;
-    unsigned int    width_;
-    unsigned int    height_;
+    ILoadersContext&       context_;
+    Thumbnails             thumbnails_;
+    int                    priority_;
+    unsigned int           width_;
+    unsigned int           height_;
+    std::set<std::string>  scheduledSeries_;
 
     void AcquireThumbnail(const DicomSource& source,
                           const std::string& studyInstanceUid,
@@ -215,5 +216,10 @@
                                const std::string& patientId,
                                const std::string& studyInstanceUid,
                                const std::string& seriesInstanceUid);
+
+    bool IsScheduledSeries(const std::string& seriesInstanceUid) const
+    {
+      return scheduledSeries_.find(seriesInstanceUid) != scheduledSeries_.end();
+    }
   };
 }