comparison Framework/Radiography/RadiographyScene.cpp @ 1224:37bc7f115f81 broker

integration mainline->broker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 07 Dec 2019 18:45:37 +0100
parents 21c2b0eee53c 9ee6b28f53e8
children 0ca50d275b9a
comparison
equal deleted inserted replaced
1222:21c2b0eee53c 1224:37bc7f115f81
293 } 293 }
294 294
295 295
296 RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex, 296 RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex,
297 const std::string& utf8, 297 const std::string& utf8,
298 const std::string& font,
298 unsigned int fontSize, 299 unsigned int fontSize,
299 uint8_t foreground) 300 uint8_t foreground)
300 { 301 {
301 RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex)); 302 RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex));
302 textLayer.SetText(utf8, fontSize, foreground); 303 textLayer.SetText(utf8, font, fontSize, foreground);
303 304
304 BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer)); 305 BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer));
305 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer)); 306 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer));
306 return textLayer; 307 return textLayer;
307 } 308 }
308 309
309 310
310 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, 311 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8,
312 const std::string& font,
311 unsigned int fontSize, 313 unsigned int fontSize,
312 uint8_t foreground, 314 uint8_t foreground,
313 RadiographyLayer::Geometry* geometry) 315 RadiographyLayer::Geometry* centerGeometry,
316 bool isCenterGeometry)
314 { 317 {
315 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(*this)); 318 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(*this));
316 alpha->SetText(utf8, fontSize, foreground); 319 alpha->SetText(utf8, font, fontSize, foreground);
317 if (geometry != NULL) 320 if (centerGeometry != NULL)
318 { 321 {
319 alpha->SetGeometry(*geometry); 322 if (isCenterGeometry)
323 {
324 // modify geometry to reference the top left corner
325 double tlx = centerGeometry->GetPanX();
326 double tly = centerGeometry->GetPanY();
327 Extent2D textExtent = alpha->GetExtent();
328 tlx = tlx - (textExtent.GetWidth() / 2) * centerGeometry->GetPixelSpacingX();
329 tly = tly - (textExtent.GetHeight() / 2) * centerGeometry->GetPixelSpacingY();
330 centerGeometry->SetPan(tlx, tly);
331 }
332 alpha->SetGeometry(*centerGeometry);
320 } 333 }
321 334
322 RadiographyLayer& registeredLayer = RegisterLayer(alpha.release()); 335 RadiographyLayer& registeredLayer = RegisterLayer(alpha.release());
323 336
324 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, registeredLayer)); 337 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, registeredLayer));