changeset 7:39730d6727f3

public enumerations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jun 2015 10:34:41 +0200
parents c584c25a74fd
children 6d59828e2662
files CppClient/Instance.cpp CppClient/Instance.h CppClient/OrthancConnection.h CppClient/PublicEnumerations.h CppClient/Series.cpp CppClient/Series.h
diffstat 6 files changed, 66 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/CppClient/Instance.cpp	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/Instance.cpp	Tue Jun 02 10:34:41 2015 +0200
@@ -45,19 +45,19 @@
       const char* suffix;
       switch (mode_)
       {
-        case Orthanc::ImageExtractionMode_Preview:
+        case ImageExtractionMode_Preview:
           suffix = "preview";
           break;
           
-        case Orthanc::ImageExtractionMode_UInt8:
+        case ImageExtractionMode_UInt8:
           suffix = "image-uint8";
           break;
           
-        case Orthanc::ImageExtractionMode_UInt16:
+        case ImageExtractionMode_UInt16:
           suffix = "image-uint16";
           break;
           
-        case Orthanc::ImageExtractionMode_Int16:
+        case ImageExtractionMode_Int16:
           suffix = "image-int16";
           break;
           
@@ -99,7 +99,7 @@
                      const char* id) :
     connection_(connection),
     id_(id),
-    mode_(Orthanc::ImageExtractionMode_Int16)
+    mode_(ImageExtractionMode_Int16)
   {
     Orthanc::HttpClient client(connection_.GetHttpClient());
             
@@ -169,10 +169,10 @@
     return reader_->GetPitch();
   }
 
-  Orthanc::PixelFormat Instance::GetPixelFormat()
+  PixelFormat Instance::GetPixelFormat()
   {
     DownloadImage();
-    return reader_->GetFormat();
+    return static_cast<PixelFormat>(reader_->GetFormat());
   }
 
   const void* Instance::GetBuffer()
@@ -198,7 +198,7 @@
   }
 
 
-  void Instance::SetImageExtractionMode(Orthanc::ImageExtractionMode mode)
+  void Instance::SetImageExtractionMode(ImageExtractionMode mode)
   {
     if (mode_ == mode)
     {
--- a/CppClient/Instance.h	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/Instance.h	Tue Jun 02 10:34:41 2015 +0200
@@ -35,6 +35,7 @@
 #include <string>
 #include <json/value.h>
 
+#include "PublicEnumerations.h"
 #include "OrthancClientException.h"
 #include "../Orthanc/Core/IDynamicObject.h"
 #include "../Orthanc/Core/ImageFormats/PngReader.h"
@@ -55,7 +56,7 @@
     std::string id_;
     Json::Value tags_;
     std::auto_ptr<Orthanc::PngReader> reader_;
-    Orthanc::ImageExtractionMode mode_;
+    ImageExtractionMode mode_;
     std::auto_ptr<std::string> dicom_;
     std::string content_;
 
@@ -87,13 +88,13 @@
      * {summary}{Set the extraction mode for the 2D image corresponding to this instance.}
      * {param}{mode The extraction mode.}
      **/
-    void SetImageExtractionMode(Orthanc::ImageExtractionMode mode);
+    void SetImageExtractionMode(ImageExtractionMode mode);
 
     /**
      * {summary}{Get the extraction mode for the 2D image corresponding to this instance.}
      * {returns}{The extraction mode.}
      **/
-    Orthanc::ImageExtractionMode GetImageExtractionMode() const
+    ImageExtractionMode GetImageExtractionMode() const
     {
       return mode_;
     }
@@ -147,7 +148,7 @@
      * {description}{Return the memory layout that is used for the 2D image that is encoded by this DICOM instance. This value depends on the extraction mode for the image.}
      * {returns}{The pixel format.}
      **/
-    Orthanc::PixelFormat GetPixelFormat();
+    PixelFormat GetPixelFormat();
 
     /**
      * {summary}{Access the memory buffer in which the raw pixels of the 2D image are stored.}
--- a/CppClient/OrthancConnection.h	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/OrthancConnection.h	Tue Jun 02 10:34:41 2015 +0200
@@ -34,6 +34,7 @@
 
 #include "../Orthanc/Core/HttpClient.h"
 
+#include "PublicEnumerations.h"
 #include "Patient.h"
 
 namespace OrthancClient
--- a/CppClient/PublicEnumerations.h	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/PublicEnumerations.h	Tue Jun 02 10:34:41 2015 +0200
@@ -32,11 +32,13 @@
 
 #pragma once
 
+#include "../Orthanc/Core/Enumerations.h"
+
 #include <laaw/laaw.h>
 
-namespace Orthanc
+namespace OrthancClient
 {
-    /**
+  /**
    * {summary}{The memory layout of the pixels (resp. voxels) of a 2D (resp. 3D) image.}
    **/
   enum LAAW_API PixelFormat
@@ -46,33 +48,33 @@
      * {description}{This format describes a color image. The pixels are stored in 3
      * consecutive bytes. The memory layout is RGB.}
      **/
-    PixelFormat_RGB24 = 1,
+    PixelFormat_RGB24 = Orthanc::PixelFormat_RGB24,
 
-    /**
-     * {summary}{Color image in RGBA32 format.}
-     * {description}{This format describes a color image. The pixels are stored in 4
-     * consecutive bytes. The memory layout is RGBA.}
-     **/
-    PixelFormat_RGBA32 = 2,
+      /**
+       * {summary}{Color image in RGBA32 format.}
+       * {description}{This format describes a color image. The pixels are stored in 4
+       * consecutive bytes. The memory layout is RGBA.}
+       **/
+      PixelFormat_RGBA32 = Orthanc::PixelFormat_RGBA32,
 
-    /**
-     * {summary}{Graylevel 8bpp image.}
-     * {description}{The image is graylevel. Each pixel is unsigned and stored in one byte.}
-     **/
-    PixelFormat_Grayscale8 = 3,
+      /**
+       * {summary}{Graylevel 8bpp image.}
+       * {description}{The image is graylevel. Each pixel is unsigned and stored in one byte.}
+       **/
+      PixelFormat_Grayscale8 = Orthanc::PixelFormat_Grayscale8,
       
-    /**
-     * {summary}{Graylevel, unsigned 16bpp image.}
-     * {description}{The image is graylevel. Each pixel is unsigned and stored in two bytes.}
-     **/
-    PixelFormat_Grayscale16 = 4,
+      /**
+       * {summary}{Graylevel, unsigned 16bpp image.}
+       * {description}{The image is graylevel. Each pixel is unsigned and stored in two bytes.}
+       **/
+      PixelFormat_Grayscale16 = Orthanc::PixelFormat_Grayscale16,
       
-    /**
-     * {summary}{Graylevel, signed 16bpp image.}
-     * {description}{The image is graylevel. Each pixel is signed and stored in two bytes.}
-     **/
-    PixelFormat_SignedGrayscale16 = 5
-  };
+      /**
+       * {summary}{Graylevel, signed 16bpp image.}
+       * {description}{The image is graylevel. Each pixel is signed and stored in two bytes.}
+       **/
+      PixelFormat_SignedGrayscale16 = Orthanc::PixelFormat_SignedGrayscale16
+      };
 
 
   /**
@@ -84,23 +86,21 @@
      * {summary}{Rescaled to 8bpp.}
      * {description}{The minimum value of the image is set to 0, and its maximum value is set to 255.}
      **/
-    ImageExtractionMode_Preview = 1,
+    ImageExtractionMode_Preview = Orthanc::ImageExtractionMode_Preview,
 
-    /**
-     * {summary}{Truncation to the [0, 255] range.}
-     **/
-    ImageExtractionMode_UInt8 = 2,
+      /**
+       * {summary}{Truncation to the [0, 255] range.}
+       **/
+      ImageExtractionMode_UInt8 = Orthanc::ImageExtractionMode_UInt8,
 
-    /**
-     * {summary}{Truncation to the [0, 65535] range.}
-     **/
-    ImageExtractionMode_UInt16 = 3,
+      /**
+       * {summary}{Truncation to the [0, 65535] range.}
+       **/
+      ImageExtractionMode_UInt16 = Orthanc::ImageExtractionMode_UInt16,
 
-    /**
-     * {summary}{Truncation to the [-32768, 32767] range.}
-     **/
-    ImageExtractionMode_Int16 = 4
-  };
-
-
+      /**
+       * {summary}{Truncation to the [-32768, 32767] range.}
+       **/
+      ImageExtractionMode_Int16 = Orthanc::ImageExtractionMode_Int16
+      };
 }
--- a/CppClient/Series.cpp	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/Series.cpp	Tue Jun 02 10:34:41 2015 +0200
@@ -96,16 +96,16 @@
     class ImageDownloadCommand : public Orthanc::ICommand
     {
     private:
-      Orthanc::PixelFormat format_;
-      Orthanc::ImageExtractionMode mode_;
+      PixelFormat format_;
+      ImageExtractionMode mode_;
       Instance& instance_;
       void* target_;
       size_t lineStride_;
 
     public:
       ImageDownloadCommand(Instance& instance, 
-                           Orthanc::PixelFormat format,
-                           Orthanc::ImageExtractionMode mode,
+                           PixelFormat format,
+                           ImageExtractionMode mode,
                            void* target,
                            size_t lineStride) :
         format_(format),
@@ -129,7 +129,7 @@
 
           if (instance_.GetPixelFormat() == format_)
           {
-            memcpy(p, instance_.GetBuffer(y), GetBytesPerPixel(instance_.GetPixelFormat()) * instance_.GetWidth());
+            memcpy(p, instance_.GetBuffer(y), GetBytesPerPixel(static_cast<Orthanc::PixelFormat>(instance_.GetPixelFormat())) * instance_.GetWidth());
           }
           else if (instance_.GetPixelFormat() == PixelFormat_Grayscale8 &&
                    format_ == PixelFormat_RGB24)
@@ -384,7 +384,7 @@
 
   
   void Series::Load3DImageInternal(void* target,
-                                   Orthanc::PixelFormat format,
+                                   PixelFormat format,
                                    size_t lineStride,
                                    size_t stackStride,
                                    ThreadedCommandProcessor::IListener* listener)
@@ -514,7 +514,7 @@
   }
 
   void Series::Load3DImage(void* target,
-                           Orthanc::PixelFormat format,
+                           PixelFormat format,
                            int64_t lineStride,
                            int64_t stackStride,
                            float* progress)
--- a/CppClient/Series.h	Tue Jun 02 10:22:49 2015 +0200
+++ b/CppClient/Series.h	Tue Jun 02 10:34:41 2015 +0200
@@ -81,7 +81,7 @@
     virtual Orthanc::IDynamicObject* GetFillerItem(size_t index);
 
     void Load3DImageInternal(void* target,
-                             Orthanc::PixelFormat format,
+                             PixelFormat format,
                              size_t lineStride,
                              size_t stackStride,
                              ThreadedCommandProcessor::IListener* listener);
@@ -195,7 +195,7 @@
     float GetSliceThickness();
 
     LAAW_API_INTERNAL void Load3DImage(void* target,
-                                       Orthanc::PixelFormat format,
+                                       PixelFormat format,
                                        int64_t lineStride,
                                        int64_t stackStride,
                                        ThreadedCommandProcessor::IListener& listener)
@@ -213,7 +213,7 @@
      * {param}{stackStride The number of bytes between two 2D slices in the target memory buffer.}
      **/
     void Load3DImage(void* target,
-                     Orthanc::PixelFormat format,
+                     PixelFormat format,
                      int64_t lineStride,
                      int64_t stackStride)
     {
@@ -231,7 +231,7 @@
      * {param}{progress A pointer to a floating-point number that is continuously updated by the download threads to reflect the percentage of completion (between 0 and 1). This value can be read from a separate thread.}
      **/
     void Load3DImage(void* target,
-                     Orthanc::PixelFormat format,
+                     PixelFormat format,
                      int64_t lineStride,
                      int64_t stackStride,
                      float* progress);