changeset 1380:6ea4062c1a0d broker

Integration from default into broker
author Benjamin Golinvaux <bgo@osimis.io>
date Wed, 22 Apr 2020 14:05:12 +0200
parents 5b750a4e1b52 (current diff) 4431ffdcc2a4 (diff)
children f4a06ad1580b 2ab121773f4a
files Framework/Radiography/RadiographyScene.cpp Framework/Radiography/RadiographyScene.h Framework/Scene2D/Scene2D.cpp Framework/Scene2D/Scene2D.h
diffstat 5 files changed, 80 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyMaskLayer.cpp	Wed Apr 22 14:02:34 2020 +0200
+++ b/Framework/Radiography/RadiographyMaskLayer.cpp	Wed Apr 22 14:05:12 2020 +0200
@@ -85,8 +85,7 @@
     { // get the extent of the in-mask area
       Extent2D sceneExtent;
 
-      for (std::vector<Orthanc::ImageProcessing::ImagePoint>::const_iterator
-             corner = corners_.begin(); corner != corners_.end(); ++corner)
+      for (std::vector<Orthanc::ImageProcessing::ImagePoint>::const_iterator corner = corners_.begin(); corner != corners_.end(); ++corner)
       {
         double x = static_cast<double>(corner->GetX());
         double y = static_cast<double>(corner->GetY());
--- a/Framework/Radiography/RadiographyScene.cpp	Wed Apr 22 14:02:34 2020 +0200
+++ b/Framework/Radiography/RadiographyScene.cpp	Wed Apr 22 14:05:12 2020 +0200
@@ -26,6 +26,9 @@
 #include "RadiographyTextLayer.h"
 #include "RadiographyMaskLayer.h"
 #include "../Deprecated/Toolbox/DicomFrameConverter.h"
+#include "../Scene2D/CairoCompositor.h"
+#include "../Scene2D/FloatTextureSceneLayer.h"
+#include "../Scene2D/TextSceneLayer.h"
 
 #include <Core/Images/Image.h>
 #include <Core/Images/ImageProcessing.h>
@@ -910,4 +913,56 @@
     }
   }
 
+  void RadiographyScene::ExportToScene2D(Scene2D& output) const
+  {
+    int depth = 0;
+    for (Layers::const_iterator it = layers_.begin();
+         it != layers_.end(); ++it)
+    {
+      assert(it->second != NULL);
+
+      std::unique_ptr<ISceneLayer> layer;
+      if (dynamic_cast<RadiographyDicomLayer*>(it->second))
+      {
+        RadiographyDicomLayer* oldLayer = dynamic_cast<RadiographyDicomLayer*>(it->second);
+
+        std::unique_ptr<FloatTextureSceneLayer> newLayer(new FloatTextureSceneLayer(*(oldLayer->GetSourceImage())));
+
+        newLayer->SetOrigin(oldLayer->GetGeometry().GetPanX(),
+                            oldLayer->GetGeometry().GetPanY()
+                            );
+        newLayer->SetAngle(oldLayer->GetGeometry().GetAngle());
+
+        layer.reset(newLayer.release());
+
+        // TODO: windowing dynamic_cast
+      }
+      else if (dynamic_cast<RadiographyTextLayer*>(it->second))
+      {
+        RadiographyTextLayer* oldLayer = dynamic_cast<RadiographyTextLayer*>(it->second);
+
+        std::unique_ptr<TextSceneLayer> newLayer(new TextSceneLayer());
+
+        newLayer->SetText(oldLayer->GetText());
+        newLayer->SetColor(oldLayer->GetForegroundGreyLevel(),
+                           oldLayer->GetForegroundGreyLevel(),
+                           oldLayer->GetForegroundGreyLevel()
+                           );
+        newLayer->SetPosition(oldLayer->GetGeometry().GetPanX(),
+                              oldLayer->GetGeometry().GetPanY()
+                              );
+        newLayer->SetFontIndex(1);
+        newLayer->SetAnchor(BitmapAnchor_TopLeft);
+        //newLayer->SetAngle(oldLayer->GetGeometry().GetAngle());
+
+        layer.reset(newLayer.release());
+      }
+
+      output.SetLayer(depth++, layer.release());
+
+    }
+
+  }
+
 }
+
--- a/Framework/Radiography/RadiographyScene.h	Wed Apr 22 14:02:34 2020 +0200
+++ b/Framework/Radiography/RadiographyScene.h	Wed Apr 22 14:05:12 2020 +0200
@@ -29,6 +29,8 @@
 #include "Core/Images/Image.h"
 #include "Core/Images/ImageProcessing.h"
 
+#include "../Scene2D/Scene2D.h"
+
 namespace OrthancStone
 {
   class RadiographyDicomLayer;
@@ -299,6 +301,8 @@
     void GetRange(float& minValue,
                   float& maxValue) const;
 
+    void ExportToScene2D(Scene2D& output) const;
+
     // Export using PAM is faster than using PNG, but requires Orthanc
     // core >= 1.4.3
     void ExportDicom(Deprecated::OrthancApiClient& orthanc,
--- a/Framework/Scene2D/Scene2D.cpp	Wed Apr 22 14:02:34 2020 +0200
+++ b/Framework/Scene2D/Scene2D.cpp	Wed Apr 22 14:05:12 2020 +0200
@@ -222,22 +222,29 @@
     canvasToScene_ = inverse;
   }
 
+  void Scene2D::GetBoundingBox(Extent2D &target) const
+  {
+    target.Reset();
+
+    for (Content::const_iterator it = content_.begin();
+         it != content_.end(); ++it)
+    {
+      assert(it->second != NULL);
+
+      Extent2D tmp;
+      if (it->second->GetLayer().GetBoundingBox(tmp))
+      {
+        target.Union(tmp);
+      }
+    }
+  }
+
   void Scene2D::FitContent(unsigned int canvasWidth,
                            unsigned int canvasHeight)
   {
     Extent2D extent;
 
-    for (Content::const_iterator it = content_.begin(); 
-         it != content_.end(); ++it)
-    {
-      assert(it->second != NULL);
-      
-      Extent2D tmp;
-      if (it->second->GetLayer().GetBoundingBox(tmp))
-      {
-        extent.Union(tmp);
-      }
-    }
+    GetBoundingBox(extent);
 
     if (!extent.IsEmpty())
     {
--- a/Framework/Scene2D/Scene2D.h	Wed Apr 22 14:02:34 2020 +0200
+++ b/Framework/Scene2D/Scene2D.h	Wed Apr 22 14:05:12 2020 +0200
@@ -114,5 +114,7 @@
 
     void FitContent(unsigned int canvasWidth,
                     unsigned int canvasHeight);
+
+    void GetBoundingBox(Extent2D& target) const;
   };
 }