comparison Framework/Radiography/RadiographyMaskLayer.h @ 475:3c28542229a3 am-touch-events

added a mask layer in the RadiographyWidget (to be cleaned)
author am@osimis.io
date Tue, 12 Feb 2019 12:22:13 +0100
parents
children a95090305dd4
comparison
equal deleted inserted replaced
467:22b80f5c3a1c 475:3c28542229a3
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 #include "Core/Images/Image.h"
26
27 namespace OrthancStone
28 {
29 class RadiographyScene;
30 class RadiographyDicomLayer;
31
32 struct MaskPoint
33 {
34 unsigned int x;
35 unsigned int y;
36
37 MaskPoint(unsigned int x, unsigned int y)
38 : x(x),
39 y(y)
40 {}
41 };
42
43 class RadiographyMaskLayer : public RadiographyLayer
44 {
45 private:
46 std::vector<MaskPoint> corners_;
47 const RadiographyDicomLayer& dicomLayer_;
48 mutable bool invalidated_;
49 float foreground_;
50
51 mutable std::auto_ptr<Orthanc::ImageAccessor> mask_;
52 public:
53 RadiographyMaskLayer(const RadiographyScene& scene, const RadiographyDicomLayer& dicomLayer,
54 float foreground) :
55 RadiographyLayer(),
56 dicomLayer_(dicomLayer),
57 invalidated_(true),
58 foreground_(foreground)
59 {
60 }
61
62 void SetCorners(const std::vector<MaskPoint>& corners);
63
64 virtual void Render(Orthanc::ImageAccessor& buffer,
65 const AffineTransform2D& viewTransform,
66 ImageInterpolation interpolation) const;
67
68 virtual bool GetDefaultWindowing(float& center,
69 float& width) const
70 {
71 return false;
72 }
73
74 virtual bool GetRange(float& minValue,
75 float& maxValue) const
76 {
77 minValue = 0;
78 maxValue = 0;
79
80 if (foreground_ < 0)
81 {
82 minValue = foreground_;
83 }
84
85 if (foreground_ > 0)
86 {
87 maxValue = foreground_;
88 }
89
90 return true;
91
92 }
93
94 private:
95 void DrawMask() const;
96 };
97 }