Mercurial > hg > orthanc-stone
diff 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 |
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp Sat Dec 07 17:46:25 2019 +0100 +++ b/Framework/Radiography/RadiographyScene.cpp Sat Dec 07 17:47:23 2019 +0100 @@ -298,11 +298,12 @@ RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex, const std::string& utf8, + const std::string& font, unsigned int fontSize, uint8_t foreground) { RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex)); - textLayer.SetText(utf8, fontSize, foreground); + textLayer.SetText(utf8, font, fontSize, foreground); BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer)); BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer)); @@ -311,15 +312,27 @@ RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8, + const std::string& font, unsigned int fontSize, uint8_t foreground, - RadiographyLayer::Geometry* geometry) + RadiographyLayer::Geometry* centerGeometry, + bool isCenterGeometry) { std::auto_ptr<RadiographyTextLayer> alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this)); - alpha->SetText(utf8, fontSize, foreground); - if (geometry != NULL) + alpha->SetText(utf8, font, fontSize, foreground); + if (centerGeometry != NULL) { - alpha->SetGeometry(*geometry); + if (isCenterGeometry) + { + // modify geometry to reference the top left corner + double tlx = centerGeometry->GetPanX(); + double tly = centerGeometry->GetPanY(); + Extent2D textExtent = alpha->GetExtent(); + tlx = tlx - (textExtent.GetWidth() / 2) * centerGeometry->GetPixelSpacingX(); + tly = tly - (textExtent.GetHeight() / 2) * centerGeometry->GetPixelSpacingY(); + centerGeometry->SetPan(tlx, tly); + } + alpha->SetGeometry(*centerGeometry); } RadiographyLayer& registeredLayer = RegisterLayer(alpha.release());