Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyLayer.h Tue Mar 31 11:01:34 2020 +0200 +++ b/Framework/Radiography/RadiographyLayer.h Tue Mar 31 15:51:02 2020 +0200 @@ -21,6 +21,8 @@ #pragma once +#include <algorithm> + #include "../Toolbox/AffineTransform2D.h" #include "../Toolbox/Extent2D.h" #include "../Wrappers/CairoContext.h" @@ -273,11 +275,37 @@ void ResetCrop(); - void SetCrop(unsigned int x, + void SetCrop(unsigned int x, // those are pixel coordinates/size unsigned int y, unsigned int width, unsigned int height); + void SetCrop(const Extent2D& sceneExtent) + { + Extent2D imageCrop; + + { + double x = sceneExtent.GetX1(); + double y = sceneExtent.GetY1(); + GetTransformInverse().Apply(x, y); + imageCrop.AddPoint(x, y); + } + + { + double x = sceneExtent.GetX2(); + double y = sceneExtent.GetY2(); + GetTransformInverse().Apply(x, y); + imageCrop.AddPoint(x, y); + } + + SetCrop(static_cast<unsigned int>(std::max(0.0, std::floor(imageCrop.GetX1()))), + static_cast<unsigned int>(std::max(0.0, std::floor(imageCrop.GetY1()))), + std::min(width_, static_cast<unsigned int>(std::ceil(imageCrop.GetWidth()))), + std::min(height_, static_cast<unsigned int>(std::ceil(imageCrop.GetHeight()))) + ); + } + + void GetCrop(unsigned int& x, unsigned int& y, unsigned int& width, @@ -316,7 +344,7 @@ return height_; } - Extent2D GetExtent() const; + virtual Extent2D GetSceneExtent(bool minimal) const; virtual bool GetPixel(unsigned int& imageX, unsigned int& imageY,