Mercurial > hg > orthanc-stone
diff Framework/Viewport/ViewportBase.cpp @ 1053:32b403a47b19
simplifying IViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 10 Oct 2019 15:24:48 +0200 |
parents | 0aff28f15ea2 |
children | af456106576c |
line wrap: on
line diff
--- a/Framework/Viewport/ViewportBase.cpp Thu Oct 10 14:37:23 2019 +0200 +++ b/Framework/Viewport/ViewportBase.cpp Thu Oct 10 15:24:48 2019 +0200 @@ -45,10 +45,18 @@ } - ScenePoint2D ViewportBase::GetPixelCenterCoordinates(int x, int y) const + ScenePoint2D ViewportBase::GetPixelCenterCoordinates(int x, int y) { - return ScenePoint2D( - static_cast<double>(x) + 0.5 - static_cast<double>(GetCanvasWidth()) / 2.0, - static_cast<double>(y) + 0.5 - static_cast<double>(GetCanvasHeight()) / 2.0); + if (HasCompositor()) + { + const ICompositor& compositor = GetCompositor(); + return ScenePoint2D( + static_cast<double>(x) + 0.5 - static_cast<double>(compositor.GetCanvasWidth()) / 2.0, + static_cast<double>(y) + 0.5 - static_cast<double>(compositor.GetCanvasHeight()) / 2.0); + } + else + { + return ScenePoint2D(0, 0); + } } }