Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Radiography/RadiographyMaskLayer.h @ 1398:c5403d52078c
moved Radiography into Deprecated
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Wed, 29 Apr 2020 20:43:09 +0200 |
parents | Framework/Radiography/RadiographyMaskLayer.h@379c00958553 |
children | 30deba7bc8e2 |
comparison
equal
deleted
inserted
replaced
1397:1c2d065ba372 | 1398:c5403d52078c |
---|---|
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-2020 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 #include <Core/Compatibility.h> | |
27 #include <Core/Images/Image.h> | |
28 #include <Core/Images/ImageProcessing.h> | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 class RadiographyScene; | |
33 class RadiographyDicomLayer; | |
34 | |
35 class RadiographyMaskLayer : public RadiographyLayer | |
36 { | |
37 private: | |
38 std::vector<Orthanc::ImageProcessing::ImagePoint> corners_; | |
39 const RadiographyDicomLayer& dicomLayer_; | |
40 mutable bool invalidated_; | |
41 float foreground_; | |
42 | |
43 mutable std::unique_ptr<Orthanc::ImageAccessor> mask_; | |
44 public: | |
45 RadiographyMaskLayer(const RadiographyScene& scene, const RadiographyDicomLayer& dicomLayer, | |
46 float foreground) : | |
47 RadiographyLayer(scene), | |
48 dicomLayer_(dicomLayer), | |
49 invalidated_(true), | |
50 foreground_(foreground) | |
51 { | |
52 } | |
53 | |
54 virtual size_t GetApproximateMemoryUsage() const | |
55 { | |
56 size_t size = 0; | |
57 if (mask_.get() != NULL) | |
58 { | |
59 size += mask_->GetPitch() * mask_->GetHeight(); | |
60 } | |
61 | |
62 return size; | |
63 } | |
64 | |
65 | |
66 void SetCorners(const std::vector<Orthanc::ImageProcessing::ImagePoint>& corners); | |
67 void SetCorner(const Orthanc::ImageProcessing::ImagePoint& corner, size_t index); | |
68 | |
69 const std::vector<Orthanc::ImageProcessing::ImagePoint>& GetCorners() const | |
70 { | |
71 return corners_; | |
72 } | |
73 | |
74 float GetForeground() const | |
75 { | |
76 return foreground_; | |
77 } | |
78 | |
79 virtual void Render(Orthanc::ImageAccessor& buffer, | |
80 const AffineTransform2D& viewTransform, | |
81 ImageInterpolation interpolation, | |
82 float windowCenter, | |
83 float windowWidth, | |
84 bool applyWindowing) const; | |
85 | |
86 std::string GetInstanceId() const; | |
87 | |
88 virtual size_t GetControlPointCount() const | |
89 { | |
90 return corners_.size(); | |
91 } | |
92 | |
93 virtual void GetControlPoint(ControlPoint& cpScene, | |
94 size_t index) const | |
95 { | |
96 ControlPoint cp(corners_[index].GetX(), corners_[index].GetY(), index); | |
97 | |
98 // transforms image coordinates into scene coordinates | |
99 GetTransform().Apply(cp.x, cp.y); | |
100 cpScene = cp; | |
101 } | |
102 | |
103 virtual Extent2D GetSceneExtent(bool minimal) const; | |
104 | |
105 virtual bool GetDefaultWindowing(float& center, | |
106 float& width) const | |
107 { | |
108 return false; | |
109 } | |
110 | |
111 virtual bool GetRange(float& minValue, | |
112 float& maxValue) const | |
113 { | |
114 minValue = 0; | |
115 maxValue = 0; | |
116 | |
117 if (foreground_ < 0) | |
118 { | |
119 minValue = foreground_; | |
120 } | |
121 | |
122 if (foreground_ > 0) | |
123 { | |
124 maxValue = foreground_; | |
125 } | |
126 | |
127 return true; | |
128 | |
129 } | |
130 | |
131 virtual bool GetPixel(unsigned int& imageX, | |
132 unsigned int& imageY, | |
133 double sceneX, | |
134 double sceneY) const; | |
135 | |
136 protected: | |
137 virtual const AffineTransform2D& GetTransform() const; | |
138 | |
139 virtual const AffineTransform2D& GetTransformInverse() const; | |
140 | |
141 | |
142 private: | |
143 void DrawMask() const; | |
144 | |
145 }; | |
146 } |