# HG changeset patch # User Sebastien Jodogne # Date 1516381962 -3600 # Node ID f19194a11c1dc45a8af1df9f8cc42c0a544d6c41 # Parent 88bca952cb1783615a4f19e6876ad0cbc08a65e2 ComputeWindowing in Enumerations.h diff -r 88bca952cb17 -r f19194a11c1d Framework/Enumerations.cpp --- 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 +#include 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); + } + } } diff -r 88bca952cb17 -r f19194a11c1d Framework/Enumerations.h --- 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); } diff -r 88bca952cb17 -r f19194a11c1d Framework/Layers/RenderStyle.cpp --- 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); } }