comparison Framework/Scene2D/Scene2D.cpp @ 1380:6ea4062c1a0d broker

Integration from default into broker
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 22 Apr 2020 14:05:12 +0200
parents 257f2c9a02ac 1e4878ed1d77
children 30deba7bc8e2
comparison
equal deleted inserted replaced
1378:5b750a4e1b52 1380:6ea4062c1a0d
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();