Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp @ 1554:6d14ed6163b1
flip x/y in Stone Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 Aug 2020 16:10:00 +0200 |
parents | 244ad1e4e76a |
children | 4fb8fdf03314 |
line wrap: on
line diff
--- a/OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp Mon Aug 17 13:25:54 2020 +0200 +++ b/OrthancStone/Sources/Scene2D/TextureBaseSceneLayer.cpp Mon Aug 17 16:10:00 2020 +0200 @@ -47,6 +47,8 @@ pixelSpacingY_ = other.pixelSpacingY_; angle_ = other.angle_; isLinearInterpolation_ = other.isLinearInterpolation_; + flipX_ = other.flipX_; + flipY_ = other.flipY_; } @@ -57,6 +59,8 @@ pixelSpacingY_(1), angle_(0), isLinearInterpolation_(false), + flipX_(false), + flipY_(false), revision_(0) { if (pixelSpacingX_ <= 0 || @@ -107,6 +111,20 @@ } + void TextureBaseSceneLayer::SetFlipX(bool flip) + { + flipX_ = flip; + IncrementRevision(); + } + + + void TextureBaseSceneLayer::SetFlipY(bool flip) + { + flipY_ = flip; + IncrementRevision(); + } + + const Orthanc::ImageAccessor& TextureBaseSceneLayer::GetTexture() const { if (!HasTexture()) @@ -123,11 +141,21 @@ AffineTransform2D TextureBaseSceneLayer::GetTransform() const { + unsigned int width = 0; + unsigned int height = 0; + + if (texture_.get() != NULL) + { + width = texture_->GetWidth(); + height = texture_->GetHeight(); + } + return AffineTransform2D::Combine( AffineTransform2D::CreateOffset(originX_, originY_), AffineTransform2D::CreateRotation(angle_), AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), - AffineTransform2D::CreateOffset(-0.5, -0.5)); + AffineTransform2D::CreateOffset(-0.5, -0.5), + AffineTransform2D::CreateFlip(flipX_, flipY_, width, height)); }