annotate Framework/Radiography/RadiographyMaskLayer.h @ 1298:8a0a62189f46

replacing std::auto_ptr by std::unique_ptr
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Mar 2020 16:31:30 +0100
parents 1c7ae79c426d
children 257f2c9a02ac d4e6cd35107b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
1 /**
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
2 * Stone of Orthanc
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1280
1c7ae79c426d fix copyright years
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1196
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
6 *
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
10 * the License, or (at your option) any later version.
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
11 *
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
15 * Affero General Public License for more details.
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
16 *
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
19 **/
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
20
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
21
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
22 #pragma once
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
23
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
24 #include "RadiographyLayer.h"
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
25
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
26 #include <Core/Compatibility.h>
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
27 #include <Core/Images/Image.h>
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
28 #include <Core/Images/ImageProcessing.h>
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
29
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
30 namespace OrthancStone
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
31 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
32 class RadiographyScene;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
33 class RadiographyDicomLayer;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
34
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
35 class RadiographyMaskLayer : public RadiographyLayer
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
36 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
37 private:
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 481
diff changeset
38 std::vector<Orthanc::ImageProcessing::ImagePoint> corners_;
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
39 const RadiographyDicomLayer& dicomLayer_;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
40 mutable bool invalidated_;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
41 float foreground_;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
42
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1280
diff changeset
43 mutable std::unique_ptr<Orthanc::ImageAccessor> mask_;
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
44 public:
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 488
diff changeset
45 RadiographyMaskLayer(MessageBroker& broker, const RadiographyScene& scene, const RadiographyDicomLayer& dicomLayer,
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
46 float foreground) :
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 488
diff changeset
47 RadiographyLayer(broker, scene),
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
48 dicomLayer_(dicomLayer),
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
49 invalidated_(true),
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
50 foreground_(foreground)
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
51 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
52 }
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
53
876
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
54 virtual size_t GetApproximateMemoryUsage() const
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
55 {
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
56 size_t size = 0;
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
57 if (mask_.get() != NULL)
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
58 {
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
59 size += mask_->GetPitch() * mask_->GetHeight();
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
60 }
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
61
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
62 return size;
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
63 }
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
64
580dd82e13f5 added GetApproximateMemoryUsage
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
65
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 481
diff changeset
66 void SetCorners(const std::vector<Orthanc::ImageProcessing::ImagePoint>& corners);
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 481
diff changeset
67 void SetCorner(const Orthanc::ImageProcessing::ImagePoint& corner, size_t index);
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
68
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 481
diff changeset
69 const std::vector<Orthanc::ImageProcessing::ImagePoint>& GetCorners() const
481
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
70 {
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
71 return corners_;
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
72 }
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
73
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
74 float GetForeground() const
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
75 {
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
76 return foreground_;
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
77 }
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
78
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
79 virtual void Render(Orthanc::ImageAccessor& buffer,
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
80 const AffineTransform2D& viewTransform,
1196
a5f2a6b04a31 RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents: 876
diff changeset
81 ImageInterpolation interpolation,
a5f2a6b04a31 RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents: 876
diff changeset
82 float windowCenter,
a5f2a6b04a31 RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents: 876
diff changeset
83 float windowWidth,
a5f2a6b04a31 RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents: 876
diff changeset
84 bool applyWindowing) const;
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
85
481
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
86 std::string GetInstanceId() const;
159a465e27bd reworked RadiographyScene export to export to an Orthanc::Image too
am@osimis.io
parents: 480
diff changeset
87
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
88 virtual size_t GetControlPointCount() const
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
89 {
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
90 return corners_.size();
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
91 }
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
92
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
93 virtual void GetControlPoint(ControlPoint& cpScene,
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
94 size_t index) const
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
95 {
488
aede9b042cb7 now using ImageProcessing::FillPolygon
am@osimis.io
parents: 481
diff changeset
96 ControlPoint cp(corners_[index].GetX(), corners_[index].GetY(), index);
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
97
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
98 // transforms image coordinates into scene coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
99 GetTransform().Apply(cp.x, cp.y);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
100 cpScene = cp;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
101 }
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
102
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
103 virtual bool GetDefaultWindowing(float& center,
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
104 float& width) const
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
105 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
106 return false;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
107 }
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
108
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
109 virtual bool GetRange(float& minValue,
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
110 float& maxValue) const
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
111 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
112 minValue = 0;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
113 maxValue = 0;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
114
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
115 if (foreground_ < 0)
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
116 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
117 minValue = foreground_;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
118 }
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
119
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
120 if (foreground_ > 0)
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
121 {
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
122 maxValue = foreground_;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
123 }
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
124
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
125 return true;
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
126
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
127 }
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
128
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
129 virtual bool GetPixel(unsigned int& imageX,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
130 unsigned int& imageY,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
131 double sceneX,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
132 double sceneY) const;
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 479
diff changeset
133
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
134 protected:
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
135 virtual const AffineTransform2D& GetTransform() const;
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
136
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
137 virtual const AffineTransform2D& GetTransformInverse() const;
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
138
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
139
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
140 private:
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
141 void DrawMask() const;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 475
diff changeset
142
475
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
143 };
3c28542229a3 added a mask layer in the RadiographyWidget (to be cleaned)
am@osimis.io
parents:
diff changeset
144 }