Mercurial > hg > orthanc-stone
diff Framework/Radiography/RadiographyLayer.h @ 1321:d4e6cd35107b
Clarified GetExtent/GetSceneExtent
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Fri, 20 Mar 2020 12:52:13 +0100 |
parents | 398ea4259e65 |
children | a72c2c9af49a |
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyLayer.h Mon Mar 02 18:29:50 2020 +0100 +++ b/Framework/Radiography/RadiographyLayer.h Fri Mar 20 12:52:13 2020 +0100 @@ -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; + Extent2D GetSceneExtent() const; virtual bool GetPixel(unsigned int& imageX, unsigned int& imageY,