Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
1553:bf02a90ca9ca | 1554:6d14ed6163b1 |
---|---|
45 originY_ = other.originY_; | 45 originY_ = other.originY_; |
46 pixelSpacingX_ = other.pixelSpacingX_; | 46 pixelSpacingX_ = other.pixelSpacingX_; |
47 pixelSpacingY_ = other.pixelSpacingY_; | 47 pixelSpacingY_ = other.pixelSpacingY_; |
48 angle_ = other.angle_; | 48 angle_ = other.angle_; |
49 isLinearInterpolation_ = other.isLinearInterpolation_; | 49 isLinearInterpolation_ = other.isLinearInterpolation_; |
50 flipX_ = other.flipX_; | |
51 flipY_ = other.flipY_; | |
50 } | 52 } |
51 | 53 |
52 | 54 |
53 TextureBaseSceneLayer::TextureBaseSceneLayer() : | 55 TextureBaseSceneLayer::TextureBaseSceneLayer() : |
54 originX_(0), | 56 originX_(0), |
55 originY_(0), | 57 originY_(0), |
56 pixelSpacingX_(1), | 58 pixelSpacingX_(1), |
57 pixelSpacingY_(1), | 59 pixelSpacingY_(1), |
58 angle_(0), | 60 angle_(0), |
59 isLinearInterpolation_(false), | 61 isLinearInterpolation_(false), |
62 flipX_(false), | |
63 flipY_(false), | |
60 revision_(0) | 64 revision_(0) |
61 { | 65 { |
62 if (pixelSpacingX_ <= 0 || | 66 if (pixelSpacingX_ <= 0 || |
63 pixelSpacingY_ <= 0) | 67 pixelSpacingY_ <= 0) |
64 { | 68 { |
105 isLinearInterpolation_ = isLinearInterpolation; | 109 isLinearInterpolation_ = isLinearInterpolation; |
106 IncrementRevision(); | 110 IncrementRevision(); |
107 } | 111 } |
108 | 112 |
109 | 113 |
114 void TextureBaseSceneLayer::SetFlipX(bool flip) | |
115 { | |
116 flipX_ = flip; | |
117 IncrementRevision(); | |
118 } | |
119 | |
120 | |
121 void TextureBaseSceneLayer::SetFlipY(bool flip) | |
122 { | |
123 flipY_ = flip; | |
124 IncrementRevision(); | |
125 } | |
126 | |
127 | |
110 const Orthanc::ImageAccessor& TextureBaseSceneLayer::GetTexture() const | 128 const Orthanc::ImageAccessor& TextureBaseSceneLayer::GetTexture() const |
111 { | 129 { |
112 if (!HasTexture()) | 130 if (!HasTexture()) |
113 { | 131 { |
114 LOG(ERROR) << "TextureBaseSceneLayer::GetTexture(): (!HasTexture())"; | 132 LOG(ERROR) << "TextureBaseSceneLayer::GetTexture(): (!HasTexture())"; |
121 } | 139 } |
122 | 140 |
123 | 141 |
124 AffineTransform2D TextureBaseSceneLayer::GetTransform() const | 142 AffineTransform2D TextureBaseSceneLayer::GetTransform() const |
125 { | 143 { |
144 unsigned int width = 0; | |
145 unsigned int height = 0; | |
146 | |
147 if (texture_.get() != NULL) | |
148 { | |
149 width = texture_->GetWidth(); | |
150 height = texture_->GetHeight(); | |
151 } | |
152 | |
126 return AffineTransform2D::Combine( | 153 return AffineTransform2D::Combine( |
127 AffineTransform2D::CreateOffset(originX_, originY_), | 154 AffineTransform2D::CreateOffset(originX_, originY_), |
128 AffineTransform2D::CreateRotation(angle_), | 155 AffineTransform2D::CreateRotation(angle_), |
129 AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), | 156 AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_), |
130 AffineTransform2D::CreateOffset(-0.5, -0.5)); | 157 AffineTransform2D::CreateOffset(-0.5, -0.5), |
158 AffineTransform2D::CreateFlip(flipX_, flipY_, width, height)); | |
131 } | 159 } |
132 | 160 |
133 | 161 |
134 bool TextureBaseSceneLayer::GetBoundingBox(Extent2D& target) const | 162 bool TextureBaseSceneLayer::GetBoundingBox(Extent2D& target) const |
135 { | 163 { |