Mercurial > hg > orthanc-stone
comparison Framework/Radiography/RadiographyScene.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 | 99c9b3238008 |
children | aee3d7941c9b |
comparison
equal
deleted
inserted
replaced
409:99c9b3238008 | 410:6decc0ba9da5 |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 #include "../Toolbox/AffineTransform2D.h" | 24 #include "RadiographyLayer.h" |
25 #include "../Toolbox/Extent2D.h" | |
26 #include "../Toolbox/OrthancApiClient.h" | 25 #include "../Toolbox/OrthancApiClient.h" |
27 #include "../Viewport/CairoContext.h" | |
28 | 26 |
29 | 27 |
30 namespace OrthancStone | 28 namespace OrthancStone |
31 { | 29 { |
32 class RadiographyScene : | 30 class RadiographyScene : |
35 { | 33 { |
36 public: | 34 public: |
37 typedef OriginMessage<MessageType_Widget_GeometryChanged, RadiographyScene> GeometryChangedMessage; | 35 typedef OriginMessage<MessageType_Widget_GeometryChanged, RadiographyScene> GeometryChangedMessage; |
38 typedef OriginMessage<MessageType_Widget_ContentChanged, RadiographyScene> ContentChangedMessage; | 36 typedef OriginMessage<MessageType_Widget_ContentChanged, RadiographyScene> ContentChangedMessage; |
39 | 37 |
40 enum Corner | |
41 { | |
42 Corner_TopLeft, | |
43 Corner_TopRight, | |
44 Corner_BottomLeft, | |
45 Corner_BottomRight | |
46 }; | |
47 | |
48 | |
49 class Layer : public boost::noncopyable | |
50 { | |
51 friend class RadiographyScene; | |
52 | |
53 private: | |
54 size_t index_; | |
55 bool hasSize_; | |
56 unsigned int width_; | |
57 unsigned int height_; | |
58 bool hasCrop_; | |
59 unsigned int cropX_; | |
60 unsigned int cropY_; | |
61 unsigned int cropWidth_; | |
62 unsigned int cropHeight_; | |
63 AffineTransform2D transform_; | |
64 AffineTransform2D transformInverse_; | |
65 double pixelSpacingX_; | |
66 double pixelSpacingY_; | |
67 double panX_; | |
68 double panY_; | |
69 double angle_; | |
70 bool resizeable_; | |
71 | |
72 | |
73 protected: | |
74 const AffineTransform2D& GetTransform() const | |
75 { | |
76 return transform_; | |
77 } | |
78 | |
79 | |
80 private: | |
81 void UpdateTransform(); | |
82 | |
83 void AddToExtent(Extent2D& extent, | |
84 double x, | |
85 double y) const; | |
86 | |
87 void GetCornerInternal(double& x, | |
88 double& y, | |
89 Corner corner, | |
90 unsigned int cropX, | |
91 unsigned int cropY, | |
92 unsigned int cropWidth, | |
93 unsigned int cropHeight) const; | |
94 | |
95 void SetIndex(size_t index) | |
96 { | |
97 index_ = index; | |
98 } | |
99 | |
100 bool Contains(double x, | |
101 double y) const; | |
102 | |
103 void DrawBorders(CairoContext& context, | |
104 double zoom); | |
105 | |
106 public: | |
107 Layer(); | |
108 | |
109 virtual ~Layer() | |
110 { | |
111 } | |
112 | |
113 size_t GetIndex() const | |
114 { | |
115 return index_; | |
116 } | |
117 | |
118 void ResetCrop() | |
119 { | |
120 hasCrop_ = false; | |
121 } | |
122 | |
123 void SetCrop(unsigned int x, | |
124 unsigned int y, | |
125 unsigned int width, | |
126 unsigned int height); | |
127 | |
128 void GetCrop(unsigned int& x, | |
129 unsigned int& y, | |
130 unsigned int& width, | |
131 unsigned int& height) const; | |
132 | |
133 void SetAngle(double angle); | |
134 | |
135 double GetAngle() const | |
136 { | |
137 return angle_; | |
138 } | |
139 | |
140 void SetSize(unsigned int width, | |
141 unsigned int height); | |
142 | |
143 unsigned int GetWidth() const | |
144 { | |
145 return width_; | |
146 } | |
147 | |
148 unsigned int GetHeight() const | |
149 { | |
150 return height_; | |
151 } | |
152 | |
153 Extent2D GetExtent() const; | |
154 | |
155 bool GetPixel(unsigned int& imageX, | |
156 unsigned int& imageY, | |
157 double sceneX, | |
158 double sceneY) const; | |
159 | |
160 void SetPan(double x, | |
161 double y); | |
162 | |
163 void SetPixelSpacing(double x, | |
164 double y); | |
165 | |
166 double GetPixelSpacingX() const | |
167 { | |
168 return pixelSpacingX_; | |
169 } | |
170 | |
171 double GetPixelSpacingY() const | |
172 { | |
173 return pixelSpacingY_; | |
174 } | |
175 | |
176 double GetPanX() const | |
177 { | |
178 return panX_; | |
179 } | |
180 | |
181 double GetPanY() const | |
182 { | |
183 return panY_; | |
184 } | |
185 | |
186 void GetCenter(double& centerX, | |
187 double& centerY) const; | |
188 | |
189 void GetCorner(double& x /* out */, | |
190 double& y /* out */, | |
191 Corner corner) const; | |
192 | |
193 bool LookupCorner(Corner& corner /* out */, | |
194 double x, | |
195 double y, | |
196 double zoom, | |
197 double viewportDistance) const; | |
198 | |
199 bool IsResizeable() const | |
200 { | |
201 return resizeable_; | |
202 } | |
203 | |
204 void SetResizeable(bool resizeable) | |
205 { | |
206 resizeable_ = resizeable; | |
207 } | |
208 | |
209 virtual bool GetDefaultWindowing(float& center, | |
210 float& width) const = 0; | |
211 | |
212 virtual void Render(Orthanc::ImageAccessor& buffer, | |
213 const AffineTransform2D& viewTransform, | |
214 ImageInterpolation interpolation) const = 0; | |
215 | |
216 virtual bool GetRange(float& minValue, | |
217 float& maxValue) const = 0; | |
218 }; | |
219 | |
220 | |
221 class LayerAccessor : public boost::noncopyable | 38 class LayerAccessor : public boost::noncopyable |
222 { | 39 { |
223 private: | 40 private: |
224 RadiographyScene& scene_; | 41 RadiographyScene& scene_; |
225 size_t index_; | 42 size_t index_; |
226 Layer* layer_; | 43 RadiographyLayer* layer_; |
227 | 44 |
228 public: | 45 public: |
229 LayerAccessor(RadiographyScene& scene, | 46 LayerAccessor(RadiographyScene& scene, |
230 size_t index); | 47 size_t index); |
231 | 48 |
245 | 62 |
246 RadiographyScene& GetScene() const; | 63 RadiographyScene& GetScene() const; |
247 | 64 |
248 size_t GetIndex() const; | 65 size_t GetIndex() const; |
249 | 66 |
250 Layer& GetLayer() const; | 67 RadiographyLayer& GetLayer() const; |
251 }; | 68 }; |
252 | 69 |
253 | 70 |
254 private: | 71 private: |
255 class AlphaLayer; | 72 class AlphaLayer; |
256 class DicomLayer; | 73 class DicomLayer; |
257 | 74 |
258 typedef std::map<size_t, Layer*> Layers; | 75 typedef std::map<size_t, RadiographyLayer*> Layers; |
259 | 76 |
260 OrthancApiClient& orthanc_; | 77 OrthancApiClient& orthanc_; |
261 size_t countLayers_; | 78 size_t countLayers_; |
262 bool hasWindowing_; | 79 bool hasWindowing_; |
263 float windowingCenter_; | 80 float windowingCenter_; |
264 float windowingWidth_; | 81 float windowingWidth_; |
265 Layers layers_; | 82 Layers layers_; |
266 | 83 |
267 Layer& RegisterLayer(Layer* layer); | 84 RadiographyLayer& RegisterLayer(RadiographyLayer* layer); |
268 | 85 |
269 void OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); | 86 void OnTagsReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); |
270 | 87 |
271 void OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); | 88 void OnFrameReceived(const OrthancApiClient::BinaryResponseReadyMessage& message); |
272 | 89 |
285 float& width) const; | 102 float& width) const; |
286 | 103 |
287 void SetWindowing(float center, | 104 void SetWindowing(float center, |
288 float width); | 105 float width); |
289 | 106 |
290 Layer& LoadText(const Orthanc::Font& font, | 107 RadiographyLayer& LoadText(const Orthanc::Font& font, |
291 const std::string& utf8); | 108 const std::string& utf8); |
292 | 109 |
293 Layer& LoadTestBlock(unsigned int width, | 110 RadiographyLayer& LoadTestBlock(unsigned int width, |
294 unsigned int height); | 111 unsigned int height); |
295 | 112 |
296 Layer& LoadDicomFrame(const std::string& instance, | 113 RadiographyLayer& LoadDicomFrame(const std::string& instance, |
297 unsigned int frame, | 114 unsigned int frame, |
298 bool httpCompression); | 115 bool httpCompression); |
299 | 116 |
300 Extent2D GetSceneExtent() const; | 117 Extent2D GetSceneExtent() const; |
301 | 118 |
302 void Render(Orthanc::ImageAccessor& buffer, | 119 void Render(Orthanc::ImageAccessor& buffer, |
303 const AffineTransform2D& viewTransform, | 120 const AffineTransform2D& viewTransform, |