changeset 734:be3671662eec

moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 21 May 2019 15:20:04 +0200
parents 717eabfa749a
children c3bbb130abc4
files Framework/Deprecated/Layers/RenderStyle.cpp Framework/Deprecated/Layers/RenderStyle.h Framework/Volumes/ImageBuffer3D.cpp Framework/Volumes/ImageBuffer3D.h
diffstat 4 files changed, 38 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Deprecated/Layers/RenderStyle.cpp	Tue May 21 14:27:52 2019 +0200
+++ b/Framework/Deprecated/Layers/RenderStyle.cpp	Tue May 21 15:20:04 2019 +0200
@@ -21,6 +21,9 @@
 
 #include "RenderStyle.h"
 
+#include "../../Volumes/ImageBuffer3D.h"
+#include "../Toolbox/DicomFrameConverter.h"
+
 #include <Core/OrthancException.h>
 
 namespace Deprecated
@@ -70,4 +73,34 @@
     drawColor_[1] = green;
     drawColor_[2] = blue;
   }
+
+
+  bool RenderStyle::FitRange(const OrthancStone::ImageBuffer3D& image,
+                             const DicomFrameConverter& converter)
+  {
+    float minValue, maxValue;
+
+    windowing_ = OrthancStone::ImageWindowing_Custom;
+
+    if (image.GetRange(minValue, maxValue))
+    {  
+      // casting the narrower type to wider before calling the + operator
+      // will prevent overflowing (this is why the cast to double is only 
+      // done on the first operand)
+      customWindowCenter_ = static_cast<float>(
+        converter.Apply((static_cast<double>(minValue) + maxValue) / 2.0));
+      
+      customWindowWidth_ = static_cast<float>(
+        converter.Apply(static_cast<double>(maxValue) - minValue));
+      
+      if (customWindowWidth_ > 1)
+      {
+        return true;
+      }
+    }
+
+    customWindowCenter_ = 128.0;
+    customWindowWidth_ = 256.0;
+    return false;
+  }
 }
--- a/Framework/Deprecated/Layers/RenderStyle.h	Tue May 21 14:27:52 2019 +0200
+++ b/Framework/Deprecated/Layers/RenderStyle.h	Tue May 21 15:20:04 2019 +0200
@@ -22,6 +22,8 @@
 #pragma once
 
 #include "../../StoneEnumerations.h"
+#include "../../Volumes/ImageBuffer3D.h"
+#include "../Toolbox/DicomFrameConverter.h"
 
 #include <EmbeddedResources.h>
 
@@ -54,5 +56,8 @@
     void SetColor(uint8_t red,
                   uint8_t green,
                   uint8_t blue);
+
+    bool FitRange(const OrthancStone::ImageBuffer3D& image,
+                  const DicomFrameConverter& converter);
   };
 }
--- a/Framework/Volumes/ImageBuffer3D.cpp	Tue May 21 14:27:52 2019 +0200
+++ b/Framework/Volumes/ImageBuffer3D.cpp	Tue May 21 15:20:04 2019 +0200
@@ -258,35 +258,6 @@
   }
 
 
-  bool ImageBuffer3D::FitWindowingToRange(Deprecated::RenderStyle& style,
-                                          const Deprecated::DicomFrameConverter& converter) const
-  {
-    if (hasRange_)
-    {
-      style.windowing_ = ImageWindowing_Custom;
-      
-      // casting the narrower type to wider before calling the + operator
-      // will prevent overflowing (this is why the cast to double is only 
-      // done on the first operand)
-      style.customWindowCenter_ = static_cast<float>(
-        converter.Apply((static_cast<double>(minValue_) + maxValue_) / 2.0));
-      
-      style.customWindowWidth_ = static_cast<float>(
-        converter.Apply(static_cast<double>(maxValue_) - minValue_));
-      
-      if (style.customWindowWidth_ > 1)
-      {
-        return true;
-      }
-    }
-
-    style.windowing_ = ImageWindowing_Custom;
-    style.customWindowCenter_ = 128.0;
-    style.customWindowWidth_ = 256.0;
-    return false;
-  }
-
-
   ImageBuffer3D::SliceReader::SliceReader(const ImageBuffer3D& that,
                                           VolumeProjection projection,
                                           unsigned int slice)
--- a/Framework/Volumes/ImageBuffer3D.h	Tue May 21 14:27:52 2019 +0200
+++ b/Framework/Volumes/ImageBuffer3D.h	Tue May 21 15:20:04 2019 +0200
@@ -21,8 +21,6 @@
 
 #pragma once
 
-#include "../Deprecated/Layers/RenderStyle.h"
-#include "../Deprecated/Toolbox/DicomFrameConverter.h"
 #include "../StoneEnumerations.h"
 #include "../Toolbox/ParallelSlices.h"
 #include "../Toolbox/VolumeImageGeometry.h"
@@ -121,9 +119,6 @@
     bool GetRange(float& minValue,
                   float& maxValue) const;
 
-    bool FitWindowingToRange(Deprecated::RenderStyle& style,
-                             const Deprecated::DicomFrameConverter& converter) const;
-
     uint8_t GetVoxelGrayscale8Unchecked(unsigned int x,
                                         unsigned int y,
                                         unsigned int z) const