430
|
1 /**
|
|
2 * Stone of Orthanc
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
|
|
6 *
|
|
7 * This program is free software: you can redistribute it and/or
|
|
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.
|
|
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
|
|
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
|
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19 **/
|
|
20
|
|
21
|
|
22 #pragma once
|
|
23
|
|
24 #include "RadiographyLayer.h"
|
|
25
|
|
26 namespace OrthancStone
|
|
27 {
|
|
28 class RadiographyScene;
|
|
29
|
|
30 // creates a transparent layer whose alpha channel is provided as a UINT8 image to SetAlpha.
|
|
31 // The color of the "mask" is either defined by a ForegroundValue or by the center value of the
|
|
32 // windowing from the scene.
|
|
33 class RadiographyAlphaLayer : public RadiographyLayer
|
|
34 {
|
|
35 private:
|
|
36 const RadiographyScene& scene_;
|
|
37 std::auto_ptr<Orthanc::ImageAccessor> alpha_; // Grayscale8
|
|
38 bool useWindowing_;
|
|
39 float foreground_;
|
|
40
|
|
41 public:
|
|
42 RadiographyAlphaLayer(const RadiographyScene& scene) :
|
|
43 scene_(scene),
|
|
44 useWindowing_(true),
|
|
45 foreground_(0)
|
|
46 {
|
|
47 }
|
|
48
|
|
49
|
|
50 void SetForegroundValue(float foreground)
|
|
51 {
|
|
52 useWindowing_ = false;
|
|
53 foreground_ = foreground;
|
|
54 }
|
|
55
|
|
56 float GetForegroundValue() const
|
|
57 {
|
|
58 return foreground_;
|
|
59 }
|
|
60
|
|
61 bool IsUsingWindowing() const
|
|
62 {
|
|
63 return useWindowing_;
|
|
64 }
|
|
65
|
|
66 void SetAlpha(Orthanc::ImageAccessor* image);
|
|
67
|
|
68 virtual bool GetDefaultWindowing(float& center,
|
|
69 float& width) const
|
|
70 {
|
|
71 return false;
|
|
72 }
|
|
73
|
|
74
|
|
75 virtual void Render(Orthanc::ImageAccessor& buffer,
|
|
76 const AffineTransform2D& viewTransform,
|
|
77 ImageInterpolation interpolation) const;
|
|
78
|
|
79 virtual bool GetRange(float& minValue,
|
|
80 float& maxValue) const;
|
|
81
|
|
82 const Orthanc::ImageAccessor& GetAlpha() const
|
|
83 {
|
|
84 return *(alpha_.get());
|
|
85 }
|
|
86
|
|
87
|
|
88 };
|
|
89 }
|