diff Framework/Radiography/RadiographyScene.cpp @ 1201:ab958fd99b07

RadiographyScene fixes
author Alain Mazy <alain@mazy.be>
date Fri, 29 Nov 2019 16:21:24 +0100
parents 922d2e61aa5d
children b519c1c878f1 9ee6b28f53e8
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp	Thu Nov 28 18:28:15 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Fri Nov 29 16:21:24 2019 +0100
@@ -243,6 +243,21 @@
     }
   }
 
+  RadiographyLayer& RadiographyScene::GetLayer(size_t layerIndex)
+  {
+    Layers::const_iterator found = layers_.find(layerIndex);
+
+    if (found == layers_.end())
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+    else
+    {
+      assert(found->second != NULL);
+      return *found->second;
+    }
+  }
+
   bool RadiographyScene::GetWindowing(float& center,
                                       float& width) const
   {
@@ -281,13 +296,27 @@
   }
 
 
+  RadiographyLayer& RadiographyScene::UpdateText(size_t layerIndex,
+                                                 const std::string& utf8,
+                                                 unsigned int fontSize,
+                                                 uint8_t foreground)
+  {
+    RadiographyTextLayer& textLayer = dynamic_cast<RadiographyTextLayer&>(GetLayer(layerIndex));
+    textLayer.SetText(utf8, fontSize, foreground);
+
+    BroadcastMessage(RadiographyScene::ContentChangedMessage(*this, textLayer));
+    BroadcastMessage(RadiographyScene::LayerEditedMessage(*this, textLayer));
+    return textLayer;
+  }
+
+
   RadiographyLayer& RadiographyScene::LoadText(const std::string& utf8,
                                                unsigned int fontSize,
                                                uint8_t foreground,
                                                RadiographyLayer::Geometry* geometry)
   {
     std::auto_ptr<RadiographyTextLayer>  alpha(new RadiographyTextLayer(IObservable::GetBroker(), *this));
-    alpha->LoadText(utf8, fontSize, foreground);
+    alpha->SetText(utf8, fontSize, foreground);
     if (geometry != NULL)
     {
       alpha->SetGeometry(*geometry);