Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Layers/RenderStyle.cpp @ 1307:8a28a9bf8876 broker
ViewportController now gets a ref to its parent viewport for proper lock usage
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 04 Mar 2020 10:07:37 +0100 |
parents | 2d8ab34c8c91 |
children | 30deba7bc8e2 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
734
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 8 * modify it under the terms of the GNU Affero General Public License |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
0 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "RenderStyle.h" | |
23 | |
734
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
24 #include "../../Volumes/ImageBuffer3D.h" |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
25 #include "../Toolbox/DicomFrameConverter.h" |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
26 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
27 #include <Core/OrthancException.h> |
0 | 28 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
589
diff
changeset
|
29 namespace Deprecated |
0 | 30 { |
31 RenderStyle::RenderStyle() | |
32 { | |
33 visible_ = true; | |
34 reverse_ = false; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
589
diff
changeset
|
35 windowing_ = OrthancStone::ImageWindowing_Custom; |
0 | 36 alpha_ = 1; |
37 applyLut_ = false; | |
38 lut_ = Orthanc::EmbeddedResources::COLORMAP_HOT; | |
39 drawGrid_ = false; | |
40 drawColor_[0] = 255; | |
41 drawColor_[1] = 255; | |
42 drawColor_[2] = 255; | |
43 customWindowCenter_ = 128; | |
44 customWindowWidth_ = 256; | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
589
diff
changeset
|
45 interpolation_ = OrthancStone::ImageInterpolation_Nearest; |
0 | 46 fontSize_ = 14; |
47 } | |
48 | |
49 | |
50 void RenderStyle::ComputeWindowing(float& targetCenter, | |
51 float& targetWidth, | |
52 float defaultCenter, | |
53 float defaultWidth) const | |
54 { | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
589
diff
changeset
|
55 if (windowing_ == OrthancStone::ImageWindowing_Custom) |
0 | 56 { |
142
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
57 targetCenter = customWindowCenter_; |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
58 targetWidth = customWindowWidth_; |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
59 } |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
60 else |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
61 { |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
62 return ::OrthancStone::ComputeWindowing |
f19194a11c1d
ComputeWindowing in Enumerations.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
63 (targetCenter, targetWidth, windowing_, defaultCenter, defaultWidth); |
0 | 64 } |
65 } | |
66 | |
67 | |
68 void RenderStyle::SetColor(uint8_t red, | |
69 uint8_t green, | |
70 uint8_t blue) | |
71 { | |
72 drawColor_[0] = red; | |
73 drawColor_[1] = green; | |
74 drawColor_[2] = blue; | |
75 } | |
734
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
76 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
77 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
78 bool RenderStyle::FitRange(const OrthancStone::ImageBuffer3D& image, |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
79 const DicomFrameConverter& converter) |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
80 { |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
81 float minValue, maxValue; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
82 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
83 windowing_ = OrthancStone::ImageWindowing_Custom; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
84 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
85 if (image.GetRange(minValue, maxValue)) |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
86 { |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
87 // casting the narrower type to wider before calling the + operator |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
88 // will prevent overflowing (this is why the cast to double is only |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
89 // done on the first operand) |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
90 customWindowCenter_ = static_cast<float>( |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
91 converter.Apply((static_cast<double>(minValue) + maxValue) / 2.0)); |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
92 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
93 customWindowWidth_ = static_cast<float>( |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
94 converter.Apply(static_cast<double>(maxValue) - minValue)); |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
95 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
96 if (customWindowWidth_ > 1) |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
97 { |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
98 return true; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
99 } |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
100 } |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
101 |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
102 customWindowCenter_ = 128.0; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
103 customWindowWidth_ = 256.0; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
104 return false; |
be3671662eec
moved FitWindowingToRange() from ImageBuffer3D to RenderStyle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
105 } |
0 | 106 } |