changeset 376:70256a53ff21

fix compatibility with Visual Studio 2008
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Nov 2018 13:25:03 +0100
parents d6136a7e914d
children 8eb4fe74000f
files Applications/Samples/SingleFrameApplication.h Applications/Samples/SingleFrameEditorApplication.h Framework/Layers/CircleMeasureTracker.cpp Framework/Widgets/LayerWidget.cpp
diffstat 4 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/SingleFrameApplication.h	Mon Nov 05 10:06:18 2018 +0100
+++ b/Applications/Samples/SingleFrameApplication.h	Mon Nov 05 13:25:03 2018 +0100
@@ -28,6 +28,9 @@
 
 #include <Core/Logging.h>
 
+#include <boost/math/constants/constants.hpp>
+
+
 namespace OrthancStone
 {
   namespace Samples
@@ -161,7 +164,7 @@
           GetMainWidget().SetSlice(source_->GetSlice(slice_).GetGeometry());
 #else
           // TEST for scene extents - Rotate the axes
-          double a = 15.0 / 180.0 * M_PI;
+          double a = 15.0 / 180.0 * boost::math::constants::pi<double>();
 
 #if 1
           Vector x; GeometryToolbox::AssignVector(x, cos(a), sin(a), 0);
--- a/Applications/Samples/SingleFrameEditorApplication.h	Mon Nov 05 10:06:18 2018 +0100
+++ b/Applications/Samples/SingleFrameEditorApplication.h	Mon Nov 05 13:25:03 2018 +0100
@@ -42,6 +42,8 @@
 
 
 #include <boost/math/constants/constants.hpp>
+#include <boost/math/special_functions/round.hpp>
+
 
 namespace OrthancStone
 {
@@ -1493,7 +1495,7 @@
 
       static int ToDegrees(double angle)
       {
-        return static_cast<int>(round(angle * 180.0 / boost::math::constants::pi<double>()));
+        return boost::math::iround(angle * 180.0 / boost::math::constants::pi<double>());
       }
       
     protected:
@@ -1581,7 +1583,7 @@
 
         if (roundAngles_)
         {
-          angle = round(angle / ROUND_ANGLE) * ROUND_ANGLE;
+          angle = boost::math::round<double>((angle / ROUND_ANGLE) * ROUND_ANGLE);
         }
           
         accessor_.GetBitmap().SetAngle(angle);
@@ -1990,7 +1992,7 @@
 
         if (roundScaling_)
         {
-          scaling = round(scaling / ROUND_SCALING) * ROUND_SCALING;
+          scaling = boost::math::round<double>((scaling / ROUND_SCALING) * ROUND_SCALING);
         }
           
         BitmapStack::Bitmap& bitmap = accessor_.GetBitmap();
@@ -2152,7 +2154,9 @@
       }
       else
       {
-        tmp = log2(delta);
+        // NB: Visual Studio 2008 does not provide "log2f()", so we
+        // implement it by ourselves
+        tmp = logf(delta) / logf(2.0f);
       }
 
       strength_ = tmp - 7;
@@ -2796,10 +2800,10 @@
       if (widget.GetStack().GetWindowing(center, width))
       {
         json["Tags"][Orthanc::DICOM_TAG_WINDOW_CENTER.Format()] =
-          boost::lexical_cast<std::string>(lroundf(center));
+          boost::lexical_cast<std::string>(boost::math::iround(center));
 
         json["Tags"][Orthanc::DICOM_TAG_WINDOW_WIDTH.Format()] =
-          boost::lexical_cast<std::string>(lroundf(width));
+          boost::lexical_cast<std::string>(boost::math::iround(width));
       }
 
 #if EXPORT_USING_PAM == 1
--- a/Framework/Layers/CircleMeasureTracker.cpp	Mon Nov 05 10:06:18 2018 +0100
+++ b/Framework/Layers/CircleMeasureTracker.cpp	Mon Nov 05 13:25:03 2018 +0100
@@ -19,12 +19,10 @@
  **/
 
 
-#define _USE_MATH_DEFINES  // To access M_PI in Visual Studio
-#include <cmath>
-
 #include "CircleMeasureTracker.h"
 
 #include <stdio.h>
+#include <boost/math/constants/constants.hpp>
 
 namespace OrthancStone
 {
@@ -66,7 +64,7 @@
     cairo_save(cr);
     cairo_set_line_width(cr, 2.0 / zoom);
     cairo_translate(cr, x, y);
-    cairo_arc(cr, 0, 0, r, 0, 2 * M_PI);
+    cairo_arc(cr, 0, 0, r, 0, 2.0 * boost::math::constants::pi<double>());
     cairo_stroke_preserve(cr);
     cairo_stroke(cr);
     cairo_restore(cr);
--- a/Framework/Widgets/LayerWidget.cpp	Mon Nov 05 10:06:18 2018 +0100
+++ b/Framework/Widgets/LayerWidget.cpp	Mon Nov 05 13:25:03 2018 +0100
@@ -27,6 +27,9 @@
 
 #include <Core/Logging.h>
 
+#include <boost/math/constants/constants.hpp>
+
+
 static const double THIN_SLICE_THICKNESS = 100.0 * std::numeric_limits<double>::epsilon();
 
 namespace OrthancStone
@@ -179,8 +182,8 @@
         double s = 5.0 / view.GetZoom();
         cairo_rectangle(cr, -s, -s, 2.0 * s, 2.0 * s);
 #else
-        // TODO Drawing circles makes WebAssembly crash!
-        cairo_arc(cr, 0, 0, 5.0 / view.GetZoom(), 0, 2 * M_PI);
+        // TODO Drawing filled circles makes WebAssembly crash!
+        cairo_arc(cr, 0, 0, 5.0 / view.GetZoom(), 0, 2.0 * boost::math::constants::pi<double>());
 #endif
         
         cairo_set_line_width(cr, 2.0 / view.GetZoom());