diff Framework/Scene2DViewport/MeasureToolsToolbox.cpp @ 1203:f3bb9a6dd949 broker

locking abstraction in IViewport
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 29 Nov 2019 21:22:21 +0100
parents f6be9412e42a
children ab06dfdf3b75
line wrap: on
line diff
--- a/Framework/Scene2DViewport/MeasureToolsToolbox.cpp	Fri Nov 29 11:03:41 2019 +0100
+++ b/Framework/Scene2DViewport/MeasureToolsToolbox.cpp	Fri Nov 29 21:22:21 2019 +0100
@@ -306,28 +306,30 @@
     for (int i = startingLayerIndex; i < startingLayerIndex + 5; ++i)
     {
       TextSceneLayer* textLayer = layerHolder->GetTextLayer(i);
-      ORTHANC_ASSERT(textLayer != NULL);
-      textLayer->SetText(text);
-
-      if (i == startingLayerIndex + 4)
-      {
-        textLayer->SetColor(TEXT_COLOR_RED,
-          TEXT_COLOR_GREEN,
-          TEXT_COLOR_BLUE);
-      }
-      else
+      if (textLayer != NULL)
       {
-        textLayer->SetColor(TEXT_OUTLINE_COLOR_RED,
-          TEXT_OUTLINE_COLOR_GREEN,
-          TEXT_OUTLINE_COLOR_BLUE);
-      }
+        textLayer->SetText(text);
 
-      ScenePoint2D textAnchor;
-      int offIndex = i - startingLayerIndex;
-      ORTHANC_ASSERT(offIndex >= 0 && offIndex < 5);
-      textLayer->SetPosition(
-        p.GetX() + xoffsets[offIndex] * pixelToScene,
-        p.GetY() + yoffsets[offIndex] * pixelToScene);
+        if (i == startingLayerIndex + 4)
+        {
+          textLayer->SetColor(TEXT_COLOR_RED,
+                              TEXT_COLOR_GREEN,
+                              TEXT_COLOR_BLUE);
+        }
+        else
+        {
+          textLayer->SetColor(TEXT_OUTLINE_COLOR_RED,
+                              TEXT_OUTLINE_COLOR_GREEN,
+                              TEXT_OUTLINE_COLOR_BLUE);
+        }
+
+        ScenePoint2D textAnchor;
+        int offIndex = i - startingLayerIndex;
+        ORTHANC_ASSERT(offIndex >= 0 && offIndex < 5);
+        textLayer->SetPosition(
+          p.GetX() + xoffsets[offIndex] * pixelToScene,
+          p.GetY() + yoffsets[offIndex] * pixelToScene);
+      }
     }
   }
 #else
@@ -339,20 +341,21 @@
     , int layerIndex)
   {
     TextSceneLayer* textLayer = layerHolder->GetTextLayer(layerIndex);
-    ORTHANC_ASSERT(textLayer != NULL);
-    textLayer->SetText(text);
+    if (textLayer != NULL)
+    {
+      textLayer->SetText(text);
+      textLayer->SetColor(TEXT_COLOR_RED, TEXT_COLOR_GREEN, TEXT_COLOR_BLUE);
 
-    textLayer->SetColor(TEXT_COLOR_RED, TEXT_COLOR_GREEN, TEXT_COLOR_BLUE);
-
-    ScenePoint2D textAnchor;
-    textLayer->SetPosition(p.GetX(), p.GetY());
+      ScenePoint2D textAnchor;
+      textLayer->SetPosition(p.GetX(), p.GetY());
+    }
   }
 #endif 
 
-  std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p)
-  {
-    os << "x = " << p.GetX() << " , y = " << p.GetY();
-    return os;
-  }
+  std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p)
+  {
+    os << "x = " << p.GetX() << " , y = " << p.GetY();
+    return os;
+  }
 
 }