changeset 395:5f13809f3f76

rename ILayerSource::ImageReadyMessage to OrthancFrameLayerSource::FrameReadyMessage
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Nov 2018 09:14:12 +0100
parents 17d54c028805
children ed7146fa2c98
files Framework/Layers/ILayerSource.h Framework/Layers/LayerSourceBase.cpp Framework/Layers/LayerSourceBase.h Framework/Layers/OrthancFrameLayerSource.cpp Framework/Layers/OrthancFrameLayerSource.h Framework/SmartLoader.cpp Framework/SmartLoader.h Framework/StoneEnumerations.h
diffstat 8 files changed, 53 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Layers/ILayerSource.h	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/Layers/ILayerSource.h	Sat Nov 10 09:14:12 2018 +0100
@@ -116,43 +116,6 @@
     };
 
 
-    // TODO: Rename "ImageReadyMessage" as "SliceReadyMessage"
-    class ImageReadyMessage : public OriginMessage<MessageType_LayerSource_ImageReady, ILayerSource>
-    {
-    private:
-      const Orthanc::ImageAccessor&  image_;
-      SliceImageQuality              imageQuality_;
-      const Slice&                   slice_;
-
-    public:
-      ImageReadyMessage(ILayerSource& origin,
-                        const Orthanc::ImageAccessor& image,
-                        SliceImageQuality imageQuality,
-                        const Slice& slice) :
-        OriginMessage(origin),
-        image_(image),
-        imageQuality_(imageQuality),
-        slice_(slice)
-      {
-      }
-
-      const Orthanc::ImageAccessor& GetImage() const
-      {
-        return image_;
-      }
-
-      SliceImageQuality GetImageQuality() const
-      {
-        return imageQuality_;
-      }
-
-      const Slice& GetSlice() const
-      {
-        return slice_;
-      }
-    };
-
-    
     ILayerSource(MessageBroker& broker) :
       IObservable(broker)
     {
--- a/Framework/Layers/LayerSourceBase.cpp	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/Layers/LayerSourceBase.cpp	Sat Nov 10 09:14:12 2018 +0100
@@ -55,11 +55,4 @@
   {
     EmitMessage(ILayerSource::LayerErrorMessage(*this, slice));
   }
-
-  void LayerSourceBase::NotifyImageReady(const Orthanc::ImageAccessor& image,
-                                         SliceImageQuality imageQuality,
-                                         const Slice& slice)
-  {
-    EmitMessage(ILayerSource::ImageReadyMessage(*this, image, imageQuality, slice));
-  }
 }
--- a/Framework/Layers/LayerSourceBase.h	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/Layers/LayerSourceBase.h	Sat Nov 10 09:14:12 2018 +0100
@@ -44,12 +44,8 @@
 
     void NotifyLayerError(const CoordinateSystem3D& slice);
 
-    void NotifyImageReady(const Orthanc::ImageAccessor& image,
-                          SliceImageQuality imageQuality,
-                          const Slice& slice);
-
-    LayerSourceBase(MessageBroker& broker)
-      : ILayerSource(broker)
+    LayerSourceBase(MessageBroker& broker) :
+      ILayerSource(broker)
     {
     }
 
--- a/Framework/Layers/OrthancFrameLayerSource.cpp	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/Layers/OrthancFrameLayerSource.cpp	Sat Nov 10 09:14:12 2018 +0100
@@ -72,8 +72,9 @@
 
   void OrthancFrameLayerSource::OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message)
   {
-    // first notify that the image is ready (targeted to, i.e: an image cache)
-    LayerSourceBase::NotifyImageReady(message.GetImage(), message.GetEffectiveQuality(), message.GetSlice());
+    // first notify that the pixel data of the frame is ready (targeted to, i.e: an image cache)
+    EmitMessage(FrameReadyMessage(*this, message.GetImage(), 
+                                  message.GetEffectiveQuality(), message.GetSlice()));
 
     // then notify that the layer is ready for render
     RendererFactory factory(message);
@@ -85,6 +86,7 @@
     LayerSourceBase::NotifyLayerError(message.GetSlice().GetGeometry());
   }
 
+
   OrthancFrameLayerSource::OrthancFrameLayerSource(MessageBroker& broker, OrthancApiClient& orthanc) :
     LayerSourceBase(broker),
     IObserver(broker),
--- a/Framework/Layers/OrthancFrameLayerSource.h	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/Layers/OrthancFrameLayerSource.h	Sat Nov 10 09:14:12 2018 +0100
@@ -36,6 +36,44 @@
     public IObserver
     //private OrthancSlicesLoader::ISliceLoaderObserver
   {
+  public:
+    // TODO: Add "frame" and "instanceId"
+    class FrameReadyMessage : public OriginMessage<MessageType_OrthancFrameLayerSource_FrameReady, OrthancFrameLayerSource>
+    {
+    private:
+      const Orthanc::ImageAccessor&  frame_;
+      SliceImageQuality              imageQuality_;
+      const Slice&                   slice_;
+
+    public:
+      FrameReadyMessage(OrthancFrameLayerSource& origin,
+                        const Orthanc::ImageAccessor& frame,
+                        SliceImageQuality imageQuality,
+                        const Slice& slice) :
+        OriginMessage(origin),
+        frame_(frame),
+        imageQuality_(imageQuality),
+        slice_(slice)
+      {
+      }
+
+      const Orthanc::ImageAccessor& GetFrame() const
+      {
+        return frame_;
+      }
+
+      SliceImageQuality GetImageQuality() const
+      {
+        return imageQuality_;
+      }
+
+      const Slice& GetSlice() const
+      {
+        return slice_;
+      }
+    };
+
+    
   private:
     class RendererFactory;
     
--- a/Framework/SmartLoader.cpp	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/SmartLoader.cpp	Sat Nov 10 09:14:12 2018 +0100
@@ -153,7 +153,7 @@
       layerSource.reset(new OrthancFrameLayerSource(IObserver::GetBroker(), orthancApiClient_));
       dynamic_cast<OrthancFrameLayerSource*>(layerSource.get())->SetImageQuality(imageQuality_);
       layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::GeometryReadyMessage>(*this, &SmartLoader::OnLayerGeometryReady));
-      layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::ImageReadyMessage>(*this, &SmartLoader::OnImageReady));
+      layerSource->RegisterObserverCallback(new Callable<SmartLoader, OrthancFrameLayerSource::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady));
       layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady));
       dynamic_cast<OrthancFrameLayerSource*>(layerSource.get())->LoadFrame(instanceId, frame);
     }
@@ -202,7 +202,7 @@
 
     dynamic_cast<OrthancFrameLayerSource*>(layerSource.get())->SetImageQuality(imageQuality_);
     layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::GeometryReadyMessage>(*this, &SmartLoader::OnLayerGeometryReady));
-    layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::ImageReadyMessage>(*this, &SmartLoader::OnImageReady));
+    layerSource->RegisterObserverCallback(new Callable<SmartLoader, OrthancFrameLayerSource::FrameReadyMessage>(*this, &SmartLoader::OnFrameReady));
     layerSource->RegisterObserverCallback(new Callable<SmartLoader, ILayerSource::LayerReadyMessage>(*this, &SmartLoader::OnLayerReady));
     dynamic_cast<OrthancFrameLayerSource*>(layerSource.get())->LoadFrame(instanceId, frame);
 
@@ -245,19 +245,17 @@
   }
 
 
-  void SmartLoader::OnImageReady(const ILayerSource::ImageReadyMessage& message)
+  void SmartLoader::OnFrameReady(const OrthancFrameLayerSource::FrameReadyMessage& message)
   {
-    OrthancFrameLayerSource& source = dynamic_cast<OrthancFrameLayerSource&>(message.GetOrigin());
-
     // save/replace the slice in cache
-    const Slice& slice = source.GetSlice(0); // TODO handle GetSliceCount() ?
+    const Slice& slice = message.GetSlice();
     std::string sliceKeyId = (slice.GetOrthancInstanceId() + ":" + 
                               boost::lexical_cast<std::string>(slice.GetFrame()));
 
     LOG(WARNING) << "Image ready: " << sliceKeyId;
 
     boost::shared_ptr<CachedSlice> cachedSlice(new CachedSlice(IObserver::GetBroker()));
-    cachedSlice->image_.reset(Orthanc::Image::Clone(message.GetImage()));
+    cachedSlice->image_.reset(Orthanc::Image::Clone(message.GetFrame()));
     cachedSlice->effectiveQuality_ = message.GetImageQuality();
     cachedSlice->slice_.reset(message.GetSlice().Clone());
     cachedSlice->status_ = CachedSliceStatus_ImageLoaded;
--- a/Framework/SmartLoader.h	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/SmartLoader.h	Sat Nov 10 09:14:12 2018 +0100
@@ -22,7 +22,7 @@
 #pragma once
 #include <map>
 
-#include "Layers/ILayerSource.h"
+#include "Layers/OrthancFrameLayerSource.h"
 #include "Messages/IObservable.h"
 #include "Toolbox/OrthancApiClient.h"
 
@@ -59,7 +59,7 @@
 
   private:
     void OnLayerGeometryReady(const ILayerSource::GeometryReadyMessage& message);
-    void OnImageReady(const ILayerSource::ImageReadyMessage& message);
+    void OnFrameReady(const OrthancFrameLayerSource::FrameReadyMessage& message);
     void OnLayerReady(const ILayerSource::LayerReadyMessage& message);
 
   };
--- a/Framework/StoneEnumerations.h	Sat Nov 10 08:44:18 2018 +0100
+++ b/Framework/StoneEnumerations.h	Sat Nov 10 09:14:12 2018 +0100
@@ -124,10 +124,11 @@
     MessageType_LayerSource_GeometryError,
     MessageType_LayerSource_ContentChanged,
     MessageType_LayerSource_SliceChanged,
-    MessageType_LayerSource_ImageReady,      // instance pixels data have been loaded
     MessageType_LayerSource_LayerReady,      // layer is ready to be rendered
     MessageType_LayerSource_LayerError,
 
+    MessageType_OrthancFrameLayerSource_FrameReady,      // pixels data of the frame have been loaded
+
     MessageType_SliceLoader_GeometryReady,
     MessageType_SliceLoader_GeometryError,
     MessageType_SliceLoader_ImageReady,