comparison Framework/Radiography/RadiographyLayer.h @ 410:6decc0ba9da5

rename RadiographyScene::Layer as RadiographyLayer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 12 Nov 2018 15:52:03 +0100
parents
children b85f635f1eb5 b70e9be013e4
comparison
equal deleted inserted replaced
409:99c9b3238008 410:6decc0ba9da5
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 "../Toolbox/AffineTransform2D.h"
25 #include "../Toolbox/Extent2D.h"
26 #include "../Viewport/CairoContext.h"
27
28 namespace OrthancStone
29 {
30 class RadiographyLayer : public boost::noncopyable
31 {
32 friend class RadiographyScene;
33
34 private:
35 size_t index_;
36 bool hasSize_;
37 unsigned int width_;
38 unsigned int height_;
39 bool hasCrop_;
40 unsigned int cropX_;
41 unsigned int cropY_;
42 unsigned int cropWidth_;
43 unsigned int cropHeight_;
44 AffineTransform2D transform_;
45 AffineTransform2D transformInverse_;
46 double pixelSpacingX_;
47 double pixelSpacingY_;
48 double panX_;
49 double panY_;
50 double angle_;
51 bool resizeable_;
52
53 protected:
54 const AffineTransform2D& GetTransform() const
55 {
56 return transform_;
57 }
58
59 private:
60 void UpdateTransform();
61
62 void AddToExtent(Extent2D& extent,
63 double x,
64 double y) const;
65
66 void GetCornerInternal(double& x,
67 double& y,
68 Corner corner,
69 unsigned int cropX,
70 unsigned int cropY,
71 unsigned int cropWidth,
72 unsigned int cropHeight) const;
73
74 void SetIndex(size_t index)
75 {
76 index_ = index;
77 }
78
79 bool Contains(double x,
80 double y) const;
81
82 void DrawBorders(CairoContext& context,
83 double zoom);
84
85 public:
86 RadiographyLayer();
87
88 virtual ~RadiographyLayer()
89 {
90 }
91
92 size_t GetIndex() const
93 {
94 return index_;
95 }
96
97 void ResetCrop()
98 {
99 hasCrop_ = false;
100 }
101
102 void SetCrop(unsigned int x,
103 unsigned int y,
104 unsigned int width,
105 unsigned int height);
106
107 void GetCrop(unsigned int& x,
108 unsigned int& y,
109 unsigned int& width,
110 unsigned int& height) const;
111
112 void SetAngle(double angle);
113
114 double GetAngle() const
115 {
116 return angle_;
117 }
118
119 void SetSize(unsigned int width,
120 unsigned int height);
121
122 unsigned int GetWidth() const
123 {
124 return width_;
125 }
126
127 unsigned int GetHeight() const
128 {
129 return height_;
130 }
131
132 Extent2D GetExtent() const;
133
134 bool GetPixel(unsigned int& imageX,
135 unsigned int& imageY,
136 double sceneX,
137 double sceneY) const;
138
139 void SetPan(double x,
140 double y);
141
142 void SetPixelSpacing(double x,
143 double y);
144
145 double GetPixelSpacingX() const
146 {
147 return pixelSpacingX_;
148 }
149
150 double GetPixelSpacingY() const
151 {
152 return pixelSpacingY_;
153 }
154
155 double GetPanX() const
156 {
157 return panX_;
158 }
159
160 double GetPanY() const
161 {
162 return panY_;
163 }
164
165 void GetCenter(double& centerX,
166 double& centerY) const;
167
168 void GetCorner(double& x /* out */,
169 double& y /* out */,
170 Corner corner) const;
171
172 bool LookupCorner(Corner& corner /* out */,
173 double x,
174 double y,
175 double zoom,
176 double viewportDistance) const;
177
178 bool IsResizeable() const
179 {
180 return resizeable_;
181 }
182
183 void SetResizeable(bool resizeable)
184 {
185 resizeable_ = resizeable;
186 }
187
188 virtual bool GetDefaultWindowing(float& center,
189 float& width) const = 0;
190
191 virtual void Render(Orthanc::ImageAccessor& buffer,
192 const AffineTransform2D& viewTransform,
193 ImageInterpolation interpolation) const = 0;
194
195 virtual bool GetRange(float& minValue,
196 float& maxValue) const = 0;
197 };
198 }