Mercurial > hg > orthanc-stone
comparison Framework/Radiography/RadiographyLayer.h @ 1336:379c00958553 broker
integration mainline->broker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 31 Mar 2020 15:51:02 +0200 |
parents | 7ec8fea061b9 a72c2c9af49a |
children |
comparison
equal
deleted
inserted
replaced
1334:04055b6b9e2c | 1336:379c00958553 |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 #include <algorithm> | |
25 | |
24 #include "../Toolbox/AffineTransform2D.h" | 26 #include "../Toolbox/AffineTransform2D.h" |
25 #include "../Toolbox/Extent2D.h" | 27 #include "../Toolbox/Extent2D.h" |
26 #include "../Wrappers/CairoContext.h" | 28 #include "../Wrappers/CairoContext.h" |
27 #include "../Messages/IMessage.h" | 29 #include "../Messages/IMessage.h" |
28 #include "../Messages/IObservable.h" | 30 #include "../Messages/IObservable.h" |
271 | 273 |
272 void SetGeometry(const Geometry& geometry); | 274 void SetGeometry(const Geometry& geometry); |
273 | 275 |
274 void ResetCrop(); | 276 void ResetCrop(); |
275 | 277 |
276 void SetCrop(unsigned int x, | 278 void SetCrop(unsigned int x, // those are pixel coordinates/size |
277 unsigned int y, | 279 unsigned int y, |
278 unsigned int width, | 280 unsigned int width, |
279 unsigned int height); | 281 unsigned int height); |
282 | |
283 void SetCrop(const Extent2D& sceneExtent) | |
284 { | |
285 Extent2D imageCrop; | |
286 | |
287 { | |
288 double x = sceneExtent.GetX1(); | |
289 double y = sceneExtent.GetY1(); | |
290 GetTransformInverse().Apply(x, y); | |
291 imageCrop.AddPoint(x, y); | |
292 } | |
293 | |
294 { | |
295 double x = sceneExtent.GetX2(); | |
296 double y = sceneExtent.GetY2(); | |
297 GetTransformInverse().Apply(x, y); | |
298 imageCrop.AddPoint(x, y); | |
299 } | |
300 | |
301 SetCrop(static_cast<unsigned int>(std::max(0.0, std::floor(imageCrop.GetX1()))), | |
302 static_cast<unsigned int>(std::max(0.0, std::floor(imageCrop.GetY1()))), | |
303 std::min(width_, static_cast<unsigned int>(std::ceil(imageCrop.GetWidth()))), | |
304 std::min(height_, static_cast<unsigned int>(std::ceil(imageCrop.GetHeight()))) | |
305 ); | |
306 } | |
307 | |
280 | 308 |
281 void GetCrop(unsigned int& x, | 309 void GetCrop(unsigned int& x, |
282 unsigned int& y, | 310 unsigned int& y, |
283 unsigned int& width, | 311 unsigned int& width, |
284 unsigned int& height) const; | 312 unsigned int& height) const; |
314 unsigned int GetHeight() const | 342 unsigned int GetHeight() const |
315 { | 343 { |
316 return height_; | 344 return height_; |
317 } | 345 } |
318 | 346 |
319 Extent2D GetExtent() const; | 347 virtual Extent2D GetSceneExtent(bool minimal) const; |
320 | 348 |
321 virtual bool GetPixel(unsigned int& imageX, | 349 virtual bool GetPixel(unsigned int& imageX, |
322 unsigned int& imageY, | 350 unsigned int& imageY, |
323 double sceneX, | 351 double sceneX, |
324 double sceneY) const; | 352 double sceneY) const; |