changeset 772:cfb4d39065a4 am-dev

fix windowing + save windowing
author Alain Mazy <alain@mazy.be>
date Fri, 24 May 2019 11:05:06 +0200
parents fe938bddb932
children 67d0a8da4afe
files Framework/Radiography/RadiographySceneReader.cpp Framework/Radiography/RadiographySceneWriter.cpp Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp
diffstat 3 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Radiography/RadiographySceneReader.cpp	Tue May 21 13:53:11 2019 +0200
+++ b/Framework/Radiography/RadiographySceneReader.cpp	Fri May 24 11:05:06 2019 +0200
@@ -60,6 +60,11 @@
     if (version != 1)
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
 
+    if (input.isMember("hasWindowing") && input["hasWindowing"].asBool())
+    {
+      scene_.SetWindowing(input["windowCenter"].asFloat(), input["windowWidth"].asFloat());
+    }
+
     RadiographyDicomLayer* dicomLayer = NULL;
     for(size_t layerIndex = 0; layerIndex < input["layers"].size(); layerIndex++)
     {
@@ -143,6 +148,11 @@
     if (version != 1)
       throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
 
+    if (input.isMember("hasWindowing") && input["hasWindowing"].asBool())
+    {
+      scene_.SetWindowing(input["windowCenter"].asFloat(), input["windowWidth"].asFloat());
+    }
+
     RadiographyDicomLayer* dicomLayer = NULL;
     for(size_t layerIndex = 0; layerIndex < input["layers"].size(); layerIndex++)
     {
--- a/Framework/Radiography/RadiographySceneWriter.cpp	Tue May 21 13:53:11 2019 +0200
+++ b/Framework/Radiography/RadiographySceneWriter.cpp	Fri May 24 11:05:06 2019 +0200
@@ -30,6 +30,14 @@
   void RadiographySceneWriter::Write(Json::Value& output, const RadiographyScene& scene)
   {
     output["version"] = 1;
+    float windowCenter, windowWidth;
+    bool hasWindowing = scene.GetWindowing(windowCenter, windowWidth);
+    output["hasWindowing"] = hasWindowing;
+    if (hasWindowing)
+    {
+      output["windowCenter"] = windowCenter;
+      output["windowWidth"] = windowWidth;
+    }
     output["layers"] = Json::arrayValue;
 
     std::vector<size_t> layersIndexes;
--- a/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Tue May 21 13:53:11 2019 +0200
+++ b/Framework/Scene2D/Internals/CairoFloatTextureRenderer.cpp	Fri May 24 11:05:06 2019 +0200
@@ -37,8 +37,8 @@
       float windowCenter, windowWidth;
       l.GetWindowing(windowCenter, windowWidth);
 
-      const float a = windowCenter - windowWidth;
-      const float slope = 256.0f / (2.0f * windowWidth);
+      const float a = windowCenter - windowWidth / 2.0f;
+      const float slope = 256.0f / windowWidth;
 
       const Orthanc::ImageAccessor& source = l.GetTexture();
       const unsigned int width = source.GetWidth();