changeset 588:2a8ac2d426db

renamed ColorTextureSceneLayer, dropped dependency on boost::chrono
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Apr 2019 13:54:42 +0200
parents 5b4890d289cf
children 3080ec4ec6b9
files Framework/Scene2D/ColorTextureSceneLayer.cpp Framework/Scene2D/ColorTextureSceneLayer.h Framework/Scene2D/ISceneLayer.h Framework/Scene2D/TextureSceneLayer.cpp Framework/Scene2D/TextureSceneLayer.h Framework/Toolbox/BaseWebService.h Platforms/Generic/DelayedCallCommand.cpp Platforms/Generic/DelayedCallCommand.h Resources/CMake/OrthancStoneConfiguration.cmake
diffstat 9 files changed, 194 insertions(+), 193 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Framework/Scene2D/ColorTextureSceneLayer.cpp	Thu Apr 25 13:54:42 2019 +0200
@@ -0,0 +1,107 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2019 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * 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 "ColorTextureSceneLayer.h"
+
+#include <Core/Images/Image.h>
+#include <Core/OrthancException.h>
+
+namespace OrthancStone
+{
+  ColorTextureSceneLayer::ColorTextureSceneLayer(const Orthanc::ImageAccessor& texture,
+                                                 double originX,  // Center of the top-left pixel
+                                                 double originY,
+                                                 double pixelSpacingX,
+                                                 double pixelSpacingY,
+                                                 double angle,
+                                                 bool isLinearInterpolation) :
+    texture_(Orthanc::Image::Clone(texture)),
+    originX_(originX),
+    originY_(originY),
+    pixelSpacingX_(pixelSpacingX),
+    pixelSpacingY_(pixelSpacingY),
+    angle_(angle),
+    isLinearInterpolation_(isLinearInterpolation)
+  {
+    if (texture_->GetFormat() != Orthanc::PixelFormat_Grayscale8 &&
+        texture_->GetFormat() != Orthanc::PixelFormat_RGBA32 &&
+        texture_->GetFormat() != Orthanc::PixelFormat_RGB24)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
+    }
+
+    if (pixelSpacingX_ <= 0 ||
+        pixelSpacingY_ <= 0)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
+  ISceneLayer* ColorTextureSceneLayer::Clone() const
+  {
+    return new ColorTextureSceneLayer(*texture_, originX_, originY_, 
+                                      pixelSpacingX_, pixelSpacingY_, angle_, 
+                                      isLinearInterpolation_);
+  }
+
+
+  AffineTransform2D ColorTextureSceneLayer::GetTransform() const
+  {
+    return AffineTransform2D::Combine(
+      AffineTransform2D::CreateOffset(originX_, originY_),
+      AffineTransform2D::CreateRotation(angle_),
+      AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_),
+      AffineTransform2D::CreateOffset(-0.5, -0.5));
+  }
+
+
+  bool ColorTextureSceneLayer::GetBoundingBox(Extent2D& target) const
+  {
+    const AffineTransform2D t = GetTransform();
+
+    target.Reset();
+    
+    double x, y;
+
+    x = 0;
+    y = 0;
+    t.Apply(x, y);
+    target.AddPoint(x, y);
+
+    x = static_cast<double>(texture_->GetWidth());
+    y = 0;
+    t.Apply(x, y);
+    target.AddPoint(x, y);
+
+    x = 0;
+    y = static_cast<double>(texture_->GetHeight());
+    t.Apply(x, y);
+    target.AddPoint(x, y);
+
+    x = static_cast<double>(texture_->GetWidth());
+    y = static_cast<double>(texture_->GetHeight());
+    t.Apply(x, y);
+    target.AddPoint(x, y);    
+
+    return true;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Framework/Scene2D/ColorTextureSceneLayer.h	Thu Apr 25 13:54:42 2019 +0200
@@ -0,0 +1,78 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2019 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Affero General Public License for more details.
+ * 
+ * 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/>.
+ **/
+
+
+#pragma once
+
+#include "ISceneLayer.h"
+#include "../Toolbox/AffineTransform2D.h"
+
+#include <Core/Images/ImageAccessor.h>
+#include <memory>
+
+namespace OrthancStone
+{
+  class ColorTextureSceneLayer : public ISceneLayer
+  {
+  private:
+    std::auto_ptr<Orthanc::ImageAccessor>  texture_;
+    double                                 originX_;
+    double                                 originY_;
+    double                                 pixelSpacingX_;
+    double                                 pixelSpacingY_;
+    double                                 angle_;
+    bool                                   isLinearInterpolation_;
+
+  public:
+    ColorTextureSceneLayer(const Orthanc::ImageAccessor& texture,
+                           double originX,  // Center of the top-left pixel
+                           double originY,
+                           double pixelSpacingX,
+                           double pixelSpacingY,
+                           double angle,
+                           bool isLinearInterpolation);
+
+    virtual ISceneLayer* Clone() const;
+
+    const Orthanc::ImageAccessor& GetTexture() const
+    {
+      return *texture_;
+    }
+
+    AffineTransform2D GetTransform() const;
+
+    bool IsLinearInterpolation() const
+    {
+      return isLinearInterpolation_;
+    }
+
+    virtual Type GetType() const
+    {
+      return Type_ColorTexture;
+    }
+
+    virtual bool GetBoundingBox(Extent2D& target) const;
+    
+    virtual uint64_t GetRevision() const
+    {
+      return 0;
+    }
+  };
+}
--- a/Framework/Scene2D/ISceneLayer.h	Mon Apr 22 10:07:34 2019 +0200
+++ b/Framework/Scene2D/ISceneLayer.h	Thu Apr 25 13:54:42 2019 +0200
@@ -34,7 +34,7 @@
     enum Type
     {
       Type_InfoPanel,
-      Type_Texture,
+      Type_ColorTexture,
       Type_Polyline,
       Type_Text
     };
--- a/Framework/Scene2D/TextureSceneLayer.cpp	Mon Apr 22 10:07:34 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- * 
- * 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 "TextureSceneLayer.h"
-
-#include <Core/Images/Image.h>
-#include <Core/OrthancException.h>
-
-namespace OrthancStone
-{
-  TextureSceneLayer::TextureSceneLayer(const Orthanc::ImageAccessor& texture,
-                                       double originX,  // Center of the top-left pixel
-                                       double originY,
-                                       double pixelSpacingX,
-                                       double pixelSpacingY,
-                                       double angle,
-                                       bool isLinearInterpolation) :
-    texture_(Orthanc::Image::Clone(texture)),
-    originX_(originX),
-    originY_(originY),
-    pixelSpacingX_(pixelSpacingX),
-    pixelSpacingY_(pixelSpacingY),
-    angle_(angle),
-    isLinearInterpolation_(isLinearInterpolation)
-  {
-    if (texture_->GetFormat() != Orthanc::PixelFormat_Grayscale8 &&
-        texture_->GetFormat() != Orthanc::PixelFormat_RGBA32 &&
-        texture_->GetFormat() != Orthanc::PixelFormat_RGB24)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
-    }
-
-    if (pixelSpacingX_ <= 0 ||
-        pixelSpacingY_ <= 0)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
-    }
-  }
-
-
-  ISceneLayer* TextureSceneLayer::Clone() const
-  {
-    return new TextureSceneLayer(*texture_, originX_, originY_, 
-                                 pixelSpacingX_, pixelSpacingY_, angle_, 
-                                 isLinearInterpolation_);
-  }
-
-
-  AffineTransform2D TextureSceneLayer::GetTransform() const
-  {
-    return AffineTransform2D::Combine(
-      AffineTransform2D::CreateOffset(originX_, originY_),
-      AffineTransform2D::CreateRotation(angle_),
-      AffineTransform2D::CreateScaling(pixelSpacingX_, pixelSpacingY_),
-      AffineTransform2D::CreateOffset(-0.5, -0.5));
-  }
-
-
-  bool TextureSceneLayer::GetBoundingBox(Extent2D& target) const
-  {
-    const AffineTransform2D t = GetTransform();
-
-    target.Reset();
-    
-    double x, y;
-
-    x = 0;
-    y = 0;
-    t.Apply(x, y);
-    target.AddPoint(x, y);
-
-    x = static_cast<double>(texture_->GetWidth());
-    y = 0;
-    t.Apply(x, y);
-    target.AddPoint(x, y);
-
-    x = 0;
-    y = static_cast<double>(texture_->GetHeight());
-    t.Apply(x, y);
-    target.AddPoint(x, y);
-
-    x = static_cast<double>(texture_->GetWidth());
-    y = static_cast<double>(texture_->GetHeight());
-    t.Apply(x, y);
-    target.AddPoint(x, y);    
-
-    return true;
-  }
-}
--- a/Framework/Scene2D/TextureSceneLayer.h	Mon Apr 22 10:07:34 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2019 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Affero General Public License for more details.
- * 
- * 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/>.
- **/
-
-
-#pragma once
-
-#include "ISceneLayer.h"
-#include "../Toolbox/AffineTransform2D.h"
-
-#include <Core/Images/ImageAccessor.h>
-#include <memory>
-
-namespace OrthancStone
-{
-  class TextureSceneLayer : public ISceneLayer
-  {
-  private:
-    std::auto_ptr<Orthanc::ImageAccessor>  texture_;
-    double                                 originX_;
-    double                                 originY_;
-    double                                 pixelSpacingX_;
-    double                                 pixelSpacingY_;
-    double                                 angle_;
-    bool                                   isLinearInterpolation_;
-
-  public:
-    TextureSceneLayer(const Orthanc::ImageAccessor& texture,
-                      double originX,  // Center of the top-left pixel
-                      double originY,
-                      double pixelSpacingX,
-                      double pixelSpacingY,
-                      double angle,
-                      bool isLinearInterpolation);
-
-    virtual ISceneLayer* Clone() const;
-
-    const Orthanc::ImageAccessor& GetTexture() const
-    {
-      return *texture_;
-    }
-
-    AffineTransform2D GetTransform() const;
-
-    bool IsLinearInterpolation() const
-    {
-      return isLinearInterpolation_;
-    }
-
-    virtual Type GetType() const
-    {
-      return Type_Texture;
-    }
-
-    virtual bool GetBoundingBox(Extent2D& target) const;
-    
-    virtual uint64_t GetRevision() const
-    {
-      return 0;
-    }
-  };
-}
--- a/Framework/Toolbox/BaseWebService.h	Mon Apr 22 10:07:34 2019 +0200
+++ b/Framework/Toolbox/BaseWebService.h	Thu Apr 25 13:54:42 2019 +0200
@@ -81,7 +81,7 @@
     class BaseWebServicePayload;
 
     bool          cacheEnabled_;
-    std::map<std::string, boost::shared_ptr<CachedHttpRequestSuccessMessage>> cache_;  // TODO: this is currently an infinite cache !
+    std::map<std::string, boost::shared_ptr<CachedHttpRequestSuccessMessage> > cache_;  // TODO: this is currently an infinite cache !
 
   public:
 
--- a/Platforms/Generic/DelayedCallCommand.cpp	Mon Apr 22 10:07:34 2019 +0200
+++ b/Platforms/Generic/DelayedCallCommand.cpp	Thu Apr 25 13:54:42 2019 +0200
@@ -36,7 +36,7 @@
     callback_(callback),
     payload_(payload),
     context_(context),
-    expirationTimePoint_(boost::chrono::system_clock::now() + boost::chrono::milliseconds(timeoutInMs)),
+    expirationTimePoint_(boost::posix_time::microsec_clock::local_time() + boost::posix_time::milliseconds(timeoutInMs)),
     timeoutInMs_(timeoutInMs)
   {
   }
@@ -44,9 +44,9 @@
 
   void DelayedCallCommand::Execute()
   {
-    while (boost::chrono::system_clock::now() < expirationTimePoint_)
+    while (boost::posix_time::microsec_clock::local_time() < expirationTimePoint_)
     {
-      boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
+      boost::this_thread::sleep(boost::posix_time::milliseconds(1));
     }
   }
 
--- a/Platforms/Generic/DelayedCallCommand.h	Mon Apr 22 10:07:34 2019 +0200
+++ b/Platforms/Generic/DelayedCallCommand.h	Thu Apr 25 13:54:42 2019 +0200
@@ -27,7 +27,8 @@
 #include "../../Framework/Messages/IObservable.h"
 #include "../../Framework/Messages/ICallable.h"
 #include "../../Applications/Generic/NativeStoneApplicationContext.h"
-#include <boost/chrono.hpp>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
 
 namespace OrthancStone
 {
@@ -37,7 +38,7 @@
     std::auto_ptr<MessageHandler<IDelayedCallExecutor::TimeoutMessage> >  callback_;
     std::auto_ptr<Orthanc::IDynamicObject>  payload_;
     NativeStoneApplicationContext&          context_;
-    boost::chrono::system_clock::time_point expirationTimePoint_;
+    boost::posix_time::ptime                expirationTimePoint_;
     unsigned int                            timeoutInMs_;
 
   public:
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Mon Apr 22 10:07:34 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Thu Apr 25 13:54:42 2019 +0200
@@ -294,7 +294,7 @@
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/PolylineSceneLayer.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/Scene2D.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/TextSceneLayer.cpp
-  ${ORTHANC_STONE_ROOT}/Framework/Scene2D/TextureSceneLayer.cpp
+  ${ORTHANC_STONE_ROOT}/Framework/Scene2D/ColorTextureSceneLayer.cpp
   ${ORTHANC_STONE_ROOT}/Framework/SmartLoader.cpp
   ${ORTHANC_STONE_ROOT}/Framework/StoneEnumerations.cpp
   ${ORTHANC_STONE_ROOT}/Framework/StoneException.h