Mercurial > hg > orthanc-stone
comparison Framework/Radiography/RadiographyScene.cpp @ 1220:9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Sat, 07 Dec 2019 17:47:23 +0100 |
parents | ab958fd99b07 |
children | 37bc7f115f81 6af941a68472 |
comparison
equal
deleted
inserted
replaced
1219:f8bff27f1314 | 1220:9ee6b28f53e8 |
---|---|
296 } | 296 } |
297 | 297 |
298 | 298 |
299 RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex, | 299 RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex, |
300 const std::string& utf8, | 300 const std::string& utf8, |
301 const std::string& font, | |
301 unsigned int fontSize, | 302 unsigned int fontSize, |
302 uint8_t foreground) | 303 uint8_t foreground) |
303 { | 304 { |
304 RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex)); | 305 RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex)); |
305 textLayer.SetText(utf8, fontSize, foreground); | 306 textLayer.SetText(utf8, font, fontSize, foreground); |
306 | 307 |
307 BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer)); | 308 BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer)); |
308 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer)); | 309 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer)); |
309 return textLayer; | 310 return textLayer; |
310 } | 311 } |
311 | 312 |
312 | 313 |
313 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, | 314 RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, |
315 const std::string& font, | |
314 unsigned int fontSize, | 316 unsigned int fontSize, |
315 uint8_t foreground, | 317 uint8_t foreground, |
316 RadiographyLayer::Geometry* geometry) | 318 RadiographyLayer::Geometry* centerGeometry, |
319 bool isCenterGeometry) | |
317 { | 320 { |
318 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); | 321 std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); |
319 alpha->SetText(utf8, fontSize, foreground); | 322 alpha->SetText(utf8, font, fontSize, foreground); |
320 if (geometry != NULL) | 323 if (centerGeometry != NULL) |
321 { | 324 { |
322 alpha->SetGeometry(*geometry); | 325 if (isCenterGeometry) |
326 { | |
327 // modify geometry to reference the top left corner | |
328 double tlx = centerGeometry->GetPanX(); | |
329 double tly = centerGeometry->GetPanY(); | |
330 Extent2D textExtent = alpha->GetExtent(); | |
331 tlx = tlx - (textExtent.GetWidth() / 2) * centerGeometry->GetPixelSpacingX(); | |
332 tly = tly - (textExtent.GetHeight() / 2) * centerGeometry->GetPixelSpacingY(); | |
333 centerGeometry->SetPan(tlx, tly); | |
334 } | |
335 alpha->SetGeometry(*centerGeometry); | |
323 } | 336 } |
324 | 337 |
325 RadiographyLayer& registeredLayer = RegisterLayer(alpha.release()); | 338 RadiographyLayer& registeredLayer = RegisterLayer(alpha.release()); |
326 | 339 |
327 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, registeredLayer)); | 340 BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, registeredLayer)); |