Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Layers/RenderStyle.cpp @ 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 | c35e98d22764 |
children | 2d8ab34c8c91 |
comparison
equal
deleted
inserted
replaced
733:717eabfa749a | 734:be3671662eec |
---|---|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #include "RenderStyle.h" | 22 #include "RenderStyle.h" |
23 | |
24 #include "../../Volumes/ImageBuffer3D.h" | |
25 #include "../Toolbox/DicomFrameConverter.h" | |
23 | 26 |
24 #include <Core/OrthancException.h> | 27 #include <Core/OrthancException.h> |
25 | 28 |
26 namespace Deprecated | 29 namespace Deprecated |
27 { | 30 { |
68 { | 71 { |
69 drawColor_[0] = red; | 72 drawColor_[0] = red; |
70 drawColor_[1] = green; | 73 drawColor_[1] = green; |
71 drawColor_[2] = blue; | 74 drawColor_[2] = blue; |
72 } | 75 } |
76 | |
77 | |
78 bool RenderStyle::FitRange(const OrthancStone::ImageBuffer3D& image, | |
79 const DicomFrameConverter& converter) | |
80 { | |
81 float minValue, maxValue; | |
82 | |
83 windowing_ = OrthancStone::ImageWindowing_Custom; | |
84 | |
85 if (image.GetRange(minValue, maxValue)) | |
86 { | |
87 // casting the narrower type to wider before calling the + operator | |
88 // will prevent overflowing (this is why the cast to double is only | |
89 // done on the first operand) | |
90 customWindowCenter_ = static_cast<float>( | |
91 converter.Apply((static_cast<double>(minValue) + maxValue) / 2.0)); | |
92 | |
93 customWindowWidth_ = static_cast<float>( | |
94 converter.Apply(static_cast<double>(maxValue) - minValue)); | |
95 | |
96 if (customWindowWidth_ > 1) | |
97 { | |
98 return true; | |
99 } | |
100 } | |
101 | |
102 customWindowCenter_ = 128.0; | |
103 customWindowWidth_ = 256.0; | |
104 return false; | |
105 } | |
73 } | 106 } |