changeset 142:f19194a11c1d wasm

ComputeWindowing in Enumerations.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Jan 2018 18:12:42 +0100
parents 88bca952cb17
children 58c545177c1c
files Framework/Enumerations.cpp Framework/Enumerations.h Framework/Layers/RenderStyle.cpp
diffstat 3 files changed, 44 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Enumerations.cpp	Thu Jan 18 17:23:21 2018 +0100
+++ b/Framework/Enumerations.cpp	Fri Jan 19 18:12:42 2018 +0100
@@ -22,6 +22,7 @@
 #include "Enumerations.h"
 
 #include <Core/Logging.h>
+#include <Core/OrthancException.h>
 
 namespace OrthancStone
 {  
@@ -39,4 +40,33 @@
       return false;
     }
   }  
+
+
+  void ComputeWindowing(float& targetCenter,
+                        float& targetWidth,
+                        ImageWindowing windowing,
+                        float defaultCenter,
+                        float defaultWidth)
+  {
+    switch (windowing)
+    {
+      case ImageWindowing_Default:
+        targetCenter = defaultCenter;
+        targetWidth = defaultWidth;
+        break;
+
+      case ImageWindowing_Bone:
+        targetCenter = 300;
+        targetWidth = 2000;
+        break;
+
+      case ImageWindowing_Lung:
+        targetCenter = -600;
+        targetWidth = 1600;
+        break;
+
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+  }
 }
--- a/Framework/Enumerations.h	Thu Jan 18 17:23:21 2018 +0100
+++ b/Framework/Enumerations.h	Fri Jan 19 18:12:42 2018 +0100
@@ -91,4 +91,10 @@
 
   bool StringToSopClassUid(SopClassUid& result,
                            const std::string& source);
+
+  void ComputeWindowing(float& targetCenter,
+                        float& targetWidth,
+                        ImageWindowing windowing,
+                        float defaultCenter,
+                        float defaultWidth);
 }
--- a/Framework/Layers/RenderStyle.cpp	Thu Jan 18 17:23:21 2018 +0100
+++ b/Framework/Layers/RenderStyle.cpp	Fri Jan 19 18:12:42 2018 +0100
@@ -49,30 +49,15 @@
                                      float defaultCenter,
                                      float defaultWidth) const
   {
-    switch (windowing_)
+    if (windowing_ == ImageWindowing_Custom)
     {
-      case ImageWindowing_Default:
-        targetCenter = defaultCenter;
-        targetWidth = defaultWidth;
-        break;
-
-      case ImageWindowing_Bone:
-        targetCenter = 300;
-        targetWidth = 2000;
-        break;
-
-      case ImageWindowing_Lung:
-        targetCenter = -600;
-        targetWidth = 1600;
-        break;
-
-      case ImageWindowing_Custom:
-        targetCenter = customWindowCenter_;
-        targetWidth = customWindowWidth_;
-        break;
-
-      default:
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+      targetCenter = customWindowCenter_;
+      targetWidth = customWindowWidth_;
+    }
+    else
+    {
+      return ::OrthancStone::ComputeWindowing
+        (targetCenter, targetWidth, windowing_, defaultCenter, defaultWidth);
     }
   }