Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Scene2D.cpp @ 1374:1e4878ed1d77
added GetBoundingBox to Scene2D
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 20 Apr 2020 18:20:47 +0200 |
parents | 8a0a62189f46 |
children | 6ea4062c1a0d |
comparison
equal
deleted
inserted
replaced
1373:e0cdf8688d56 | 1374:1e4878ed1d77 |
---|---|
220 | 220 |
221 sceneToCanvas_ = transform; | 221 sceneToCanvas_ = transform; |
222 canvasToScene_ = inverse; | 222 canvasToScene_ = inverse; |
223 } | 223 } |
224 | 224 |
225 void Scene2D::GetBoundingBox(Extent2D &target) const | |
226 { | |
227 target.Reset(); | |
228 | |
229 for (Content::const_iterator it = content_.begin(); | |
230 it != content_.end(); ++it) | |
231 { | |
232 assert(it->second != NULL); | |
233 | |
234 Extent2D tmp; | |
235 if (it->second->GetLayer().GetBoundingBox(tmp)) | |
236 { | |
237 target.Union(tmp); | |
238 } | |
239 } | |
240 } | |
241 | |
225 void Scene2D::FitContent(unsigned int canvasWidth, | 242 void Scene2D::FitContent(unsigned int canvasWidth, |
226 unsigned int canvasHeight) | 243 unsigned int canvasHeight) |
227 { | 244 { |
228 Extent2D extent; | 245 Extent2D extent; |
229 | 246 |
230 for (Content::const_iterator it = content_.begin(); | 247 GetBoundingBox(extent); |
231 it != content_.end(); ++it) | |
232 { | |
233 assert(it->second != NULL); | |
234 | |
235 Extent2D tmp; | |
236 if (it->second->GetLayer().GetBoundingBox(tmp)) | |
237 { | |
238 extent.Union(tmp); | |
239 } | |
240 } | |
241 | 248 |
242 if (!extent.IsEmpty()) | 249 if (!extent.IsEmpty()) |
243 { | 250 { |
244 double zoomX = static_cast<double>(canvasWidth) / extent.GetWidth(); | 251 double zoomX = static_cast<double>(canvasWidth) / extent.GetWidth(); |
245 double zoomY = static_cast<double>(canvasHeight) / extent.GetHeight(); | 252 double zoomY = static_cast<double>(canvasHeight) / extent.GetHeight(); |