changeset 1373:e0cdf8688d56

wip: from RadiographyScene to Scene2D
author Alain Mazy <alain@mazy.be>
date Wed, 08 Apr 2020 14:14:51 +0200
parents 0745bd7fdf70
children 1e4878ed1d77
files Framework/Radiography/RadiographyScene.cpp Framework/Radiography/RadiographyScene.h
diffstat 2 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp	Fri Apr 03 05:36:58 2020 +0200
+++ b/Framework/Radiography/RadiographyScene.cpp	Wed Apr 08 14:14:51 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>
@@ -911,4 +914,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	Fri Apr 03 05:36:58 2020 +0200
+++ b/Framework/Radiography/RadiographyScene.h	Wed Apr 08 14:14:51 2020 +0200
@@ -28,6 +28,8 @@
 #include "Core/Images/Image.h"
 #include "Core/Images/ImageProcessing.h"
 
+#include "../Scene2D/Scene2D.h"
+
 namespace OrthancStone
 {
   class RadiographyDicomLayer;
@@ -298,6 +300,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,