changeset 1152:78b8bfe154bc broker

GetOrthancImageCommand::SetFrameUri()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Nov 2019 17:52:12 +0100
parents 48befc2bf66d
children 113131100638
files Framework/Oracle/GetOrthancImageCommand.cpp Framework/Oracle/GetOrthancImageCommand.h
diffstat 2 files changed, 25 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Oracle/GetOrthancImageCommand.cpp	Fri Nov 15 17:34:19 2019 +0100
+++ b/Framework/Oracle/GetOrthancImageCommand.cpp	Fri Nov 15 17:52:12 2019 +0100
@@ -44,31 +44,41 @@
   }
 
 
-  void GetOrthancImageCommand::SetInstanceUri(const std::string& instance,
-                                              Orthanc::PixelFormat pixelFormat)
+  static std::string GetFormatSuffix(Orthanc::PixelFormat pixelFormat)
   {
-    uri_ = "/instances/" + instance;
-          
     switch (pixelFormat)
     {
       case Orthanc::PixelFormat_RGB24:
-        uri_ += "/preview";
-        break;
+        return "preview";
       
       case Orthanc::PixelFormat_Grayscale16:
-        uri_ += "/image-uint16";
-        break;
+        return "image-uint16";
       
       case Orthanc::PixelFormat_SignedGrayscale16:
-        uri_ += "/image-int16";
-        break;
+        return "image-int16";
       
       default:
         throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
   }
 
-  
+
+  void GetOrthancImageCommand::SetInstanceUri(const std::string& instance,
+                                              Orthanc::PixelFormat pixelFormat)
+  {
+    uri_ = "/instances/" + instance + "/" + GetFormatSuffix(pixelFormat);
+  }
+
+
+  void GetOrthancImageCommand::SetFrameUri(const std::string& instance,
+                                           unsigned int frame,
+                                           Orthanc::PixelFormat pixelFormat)
+  {
+    uri_ = ("/instances/" + instance + "/frames/" +
+            boost::lexical_cast<std::string>(frame) + "/" + GetFormatSuffix(pixelFormat));
+  }
+
+
   void GetOrthancImageCommand::ProcessHttpAnswer(boost::weak_ptr<IObserver> receiver,
                                                  IMessageEmitter& emitter,
                                                  const std::string& answer,
--- a/Framework/Oracle/GetOrthancImageCommand.h	Fri Nov 15 17:34:19 2019 +0100
+++ b/Framework/Oracle/GetOrthancImageCommand.h	Fri Nov 15 17:52:12 2019 +0100
@@ -104,6 +104,10 @@
     void SetInstanceUri(const std::string& instance,
                         Orthanc::PixelFormat pixelFormat);
 
+    void SetFrameUri(const std::string& instance,
+                     unsigned int frame,
+                     Orthanc::PixelFormat pixelFormat);
+
     void SetHttpHeader(const std::string& key,
                        const std::string& value)
     {