changeset 634:6a144a45b2d8

Converted C++11 code to C++03
author Benjamin Golinvaux <bgo@osimis.io>
date Thu, 09 May 2019 14:54:12 +0200
parents b0652595b62a
children 104c379f3f1b f939f449482c
files Samples/Common/MeasureCommands.cpp Samples/Common/MeasureTools.cpp
diffstat 2 files changed, 150 insertions(+), 150 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/Common/MeasureCommands.cpp	Thu May 09 14:38:27 2019 +0200
+++ b/Samples/Common/MeasureCommands.cpp	Thu May 09 14:54:12 2019 +0200
@@ -21,7 +21,7 @@
 #include "MeasureCommands.h"
 
 namespace OrthancStone
-{
+{
   void CreateMeasureCommand::Undo()
   {
     // simply disable the measure tool upon undo
@@ -31,7 +31,7 @@
   void CreateMeasureCommand::Redo()
   {
     GetMeasureTool()->Enable();
-  }
+  }
 
   CreateMeasureCommand::CreateMeasureCommand(
     Scene2D& scene, MeasureToolList& measureTools)
--- a/Samples/Common/MeasureTools.cpp	Thu May 09 14:38:27 2019 +0200
+++ b/Samples/Common/MeasureTools.cpp	Thu May 09 14:54:12 2019 +0200
@@ -17,12 +17,12 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  **/
-
-#include <Core/Logging.h>
-#include "MeasureTools.h"
-
-namespace OrthancStone
-{
+
+#include <Core/Logging.h>
+#include "MeasureTools.h"
+
+namespace OrthancStone
+{
   void MeasureTool::Enable()
   {
     enabled_ = true;
@@ -34,7 +34,7 @@
     enabled_ = false;
     RefreshScene();
   }
-
+
   LineMeasureTool::~LineMeasureTool()
   {
     // this measuring tool is a RABI for the corresponding visual layers
@@ -42,155 +42,155 @@
     Disable();
     RemoveFromScene();
   }
-
+
   void LineMeasureTool::RemoveFromScene()
   {
     if (layersCreated)
     {
-      assert(GetScene().HasLayer(polylineZIndex_));
-      assert(GetScene().HasLayer(textZIndex_));
+      assert(GetScene().HasLayer(polylineZIndex_));
+      assert(GetScene().HasLayer(textZIndex_));
       GetScene().DeleteLayer(polylineZIndex_);
       GetScene().DeleteLayer(textZIndex_);
     }
   }
 
 
-  void LineMeasureTool::SetStart(ScenePoint2D start)
-  {
-    start_ = start;
-    RefreshScene();
-  }
-
-  void LineMeasureTool::SetEnd(ScenePoint2D end)
-  {
-    end_ = end;
-    RefreshScene();
-  }
-
+  void LineMeasureTool::SetStart(ScenePoint2D start)
+  {
+    start_ = start;
+    RefreshScene();
+  }
+
+  void LineMeasureTool::SetEnd(ScenePoint2D end)
+  {
+    end_ = end;
+    RefreshScene();
+  }
+
   void LineMeasureTool::Set(ScenePoint2D start, ScenePoint2D end)
-  {
-    start_ = start;
-    end_ = end;
-    RefreshScene();
-  }
-
-  PolylineSceneLayer* LineMeasureTool::GetPolylineLayer()
-  {
-    assert(GetScene().HasLayer(polylineZIndex_));
-    ISceneLayer* layer = &(GetScene().GetLayer(polylineZIndex_));
-    PolylineSceneLayer* concreteLayer = dynamic_cast<PolylineSceneLayer*>(layer);
-    assert(concreteLayer != NULL);
-    return concreteLayer;
-  }
-
-  TextSceneLayer* LineMeasureTool::GetTextLayer()
-  {
-    assert(GetScene().HasLayer(textZIndex_));
-    ISceneLayer* layer = &(GetScene().GetLayer(textZIndex_));
-    TextSceneLayer* concreteLayer = dynamic_cast<TextSceneLayer*>(layer);
-    assert(concreteLayer != NULL);
-    return concreteLayer;
-  }
-
-  void LineMeasureTool::RefreshScene()
-  {
-    if (IsEnabled())
-    {
-      if (!layersCreated)
-      {
-        // Create the layers if need be
-
-        assert(textZIndex_ == -1);
-        {
-          polylineZIndex_ = GetScene().GetMaxDepth() + 100;
-          LOG(INFO) << "set polylineZIndex_ to: " << polylineZIndex_;
-          std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer());
-          GetScene().SetLayer(polylineZIndex_, layer.release());
-        }
-        {
-          textZIndex_ = GetScene().GetMaxDepth() + 100;
-          LOG(INFO) << "set textZIndex_ to: " << textZIndex_;
-          std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer());
-          GetScene().SetLayer(textZIndex_, layer.release());
-        }
-        layersCreated = true;
-      }
-      else
-      {
-        assert(GetScene().HasLayer(polylineZIndex_));
-        assert(GetScene().HasLayer(textZIndex_));
-      }
-      {
-        // Fill the polyline layer with the measurement line
-
-        PolylineSceneLayer* polylineLayer = GetPolylineLayer();
-        polylineLayer->ClearAllChains();
-        polylineLayer->SetColor(0, 223, 21);
-
-        {
-          PolylineSceneLayer::Chain chain;
-          chain.push_back(start_);
-          chain.push_back(end_);
-          polylineLayer->AddChain(chain, false);
-        }
-
-        // handles
-        {
-          auto startC = start_.Apply(GetScene().GetSceneToCanvasTransform());
-          auto squareSize = 10; //TODO: take DPI into account
-          auto startHandleLX = startC.GetX() - squareSize/2;
-          auto startHandleTY = startC.GetY() - squareSize / 2;
-          auto startHandleRX = startC.GetX() + squareSize / 2;
-          auto startHandleBY = startC.GetY() + squareSize / 2;
-          auto startLTC = ScenePoint2D(startHandleLX, startHandleTY);
-          auto startRTC = ScenePoint2D(startHandleRX, startHandleTY);
-          auto startRBC = ScenePoint2D(startHandleRX, startHandleBY);
-          auto startLBC = ScenePoint2D(startHandleLX, startHandleBY);
-
-          auto startLT = startLTC.Apply(GetScene().GetCanvasToSceneTransform());
-          auto startRT = startRTC.Apply(GetScene().GetCanvasToSceneTransform());
-          auto startRB = startRBC.Apply(GetScene().GetCanvasToSceneTransform());
-          auto startLB = startLBC.Apply(GetScene().GetCanvasToSceneTransform());
-
-          PolylineSceneLayer::Chain chain;
-          chain.push_back(startLT);
-          chain.push_back(startRT);
-          chain.push_back(startRB);
-          chain.push_back(startLB);
-          polylineLayer->AddChain(chain, true);
-        }
-
-
-        
-      }
-      {
-        // Set the text layer proporeties
-
-        TextSceneLayer* textLayer = GetTextLayer();
-        double deltaX = end_.GetX() - start_.GetX();
-        double deltaY = end_.GetY() - start_.GetY();
-        double squareDist = deltaX * deltaX + deltaY * deltaY;
-        double dist = sqrt(squareDist);
-        char buf[64];
-        sprintf(buf, "%0.02f units", dist);
-        textLayer->SetText(buf);
-        textLayer->SetColor(0, 223, 21);
-
-        // TODO: for now we simply position the text overlay at the middle
-        // of the measuring segment
-        double midX = 0.5*(end_.GetX() + start_.GetX());
-        double midY = 0.5*(end_.GetY() + start_.GetY());
-        textLayer->SetPosition(midX, midY);
-      }
-    }
-    else
-    {
-      if (layersCreated)
-      {
-        RemoveFromScene();
-        layersCreated = false;
-      }
-    }
-  }
-}
-
+  {
+    start_ = start;
+    end_ = end;
+    RefreshScene();
+  }
+
+  PolylineSceneLayer* LineMeasureTool::GetPolylineLayer()
+  {
+    assert(GetScene().HasLayer(polylineZIndex_));
+    ISceneLayer* layer = &(GetScene().GetLayer(polylineZIndex_));
+    PolylineSceneLayer* concreteLayer = dynamic_cast<PolylineSceneLayer*>(layer);
+    assert(concreteLayer != NULL);
+    return concreteLayer;
+  }
+
+  TextSceneLayer* LineMeasureTool::GetTextLayer()
+  {
+    assert(GetScene().HasLayer(textZIndex_));
+    ISceneLayer* layer = &(GetScene().GetLayer(textZIndex_));
+    TextSceneLayer* concreteLayer = dynamic_cast<TextSceneLayer*>(layer);
+    assert(concreteLayer != NULL);
+    return concreteLayer;
+  }
+
+  void LineMeasureTool::RefreshScene()
+  {
+    if (IsEnabled())
+    {
+      if (!layersCreated)
+      {
+        // Create the layers if need be
+
+        assert(textZIndex_ == -1);
+        {
+          polylineZIndex_ = GetScene().GetMaxDepth() + 100;
+          LOG(INFO) << "set polylineZIndex_ to: " << polylineZIndex_;
+          std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer());
+          GetScene().SetLayer(polylineZIndex_, layer.release());
+        }
+        {
+          textZIndex_ = GetScene().GetMaxDepth() + 100;
+          LOG(INFO) << "set textZIndex_ to: " << textZIndex_;
+          std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer());
+          GetScene().SetLayer(textZIndex_, layer.release());
+        }
+        layersCreated = true;
+      }
+      else
+      {
+        assert(GetScene().HasLayer(polylineZIndex_));
+        assert(GetScene().HasLayer(textZIndex_));
+      }
+      {
+        // Fill the polyline layer with the measurement line
+
+        PolylineSceneLayer* polylineLayer = GetPolylineLayer();
+        polylineLayer->ClearAllChains();
+        polylineLayer->SetColor(0, 223, 21);
+
+        {
+          PolylineSceneLayer::Chain chain;
+          chain.push_back(start_);
+          chain.push_back(end_);
+          polylineLayer->AddChain(chain, false);
+        }
+
+        // handles
+        {
+          ScenePoint2D startC = start_.Apply(GetScene().GetSceneToCanvasTransform());
+          double squareSize = 10.0; //TODO: take DPI into account
+          double startHandleLX = startC.GetX() - squareSize/2;
+          double startHandleTY = startC.GetY() - squareSize / 2;
+          double startHandleRX = startC.GetX() + squareSize / 2;
+          double startHandleBY = startC.GetY() + squareSize / 2;
+          ScenePoint2D startLTC(startHandleLX, startHandleTY);
+          ScenePoint2D startRTC(startHandleRX, startHandleTY);
+          ScenePoint2D startRBC(startHandleRX, startHandleBY);
+          ScenePoint2D startLBC(startHandleLX, startHandleBY);
+
+          ScenePoint2D startLT = startLTC.Apply(GetScene().GetCanvasToSceneTransform());
+          ScenePoint2D startRT = startRTC.Apply(GetScene().GetCanvasToSceneTransform());
+          ScenePoint2D startRB = startRBC.Apply(GetScene().GetCanvasToSceneTransform());
+          ScenePoint2D startLB = startLBC.Apply(GetScene().GetCanvasToSceneTransform());
+
+          PolylineSceneLayer::Chain chain;
+          chain.push_back(startLT);
+          chain.push_back(startRT);
+          chain.push_back(startRB);
+          chain.push_back(startLB);
+          polylineLayer->AddChain(chain, true);
+        }
+
+
+        
+      }
+      {
+        // Set the text layer proporeties
+
+        TextSceneLayer* textLayer = GetTextLayer();
+        double deltaX = end_.GetX() - start_.GetX();
+        double deltaY = end_.GetY() - start_.GetY();
+        double squareDist = deltaX * deltaX + deltaY * deltaY;
+        double dist = sqrt(squareDist);
+        char buf[64];
+        sprintf(buf, "%0.02f units", dist);
+        textLayer->SetText(buf);
+        textLayer->SetColor(0, 223, 21);
+
+        // TODO: for now we simply position the text overlay at the middle
+        // of the measuring segment
+        double midX = 0.5*(end_.GetX() + start_.GetX());
+        double midY = 0.5*(end_.GetY() + start_.GetY());
+        textLayer->SetPosition(midX, midY);
+      }
+    }
+    else
+    {
+      if (layersCreated)
+      {
+        RemoveFromScene();
+        layersCreated = false;
+      }
+    }
+  }
+}
+