changeset 2232:ce5eaba0008d

dicom-sr: colors and fit to page width
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 26 Apr 2025 10:48:32 +0200
parents 2161277b4586
children 112d29cce40f
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp OrthancStone/Sources/Scene2D/Scene2D.cpp OrthancStone/Sources/Scene2D/Scene2D.h
diffstat 3 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Fri Apr 25 19:02:22 2025 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Sat Apr 26 10:48:32 2025 +0200
@@ -3022,7 +3022,17 @@
       if (fitNextContent_)
       {
         lock->RefreshCanvasSize();
-        lock->GetCompositor().FitContent(scene);
+
+        if (instance.GetSopClassUid() == OrthancStone::SopClassUid_ComprehensiveSR)
+        {
+          // Fit to the width of the textual report
+          scene.FitTopContent(lock->GetCompositor().GetCanvasWidth(), lock->GetCompositor().GetCanvasHeight(), 0.1);
+        }
+        else
+        {
+          lock->GetCompositor().FitContent(scene);
+        }
+
         stoneAnnotations_->Render(scene);
         fitNextContent_ = false;
       }
@@ -3151,7 +3161,7 @@
           if (instance.GetSopClassUid() == OrthancStone::SopClassUid_ComprehensiveSR)
           {
             OrthancStone::DicomStructuredReport report(const_cast<Orthanc::ParsedDicomFile&>(accessor->GetDicom()));
-            frame.reset(report.Render(font_, OrthancStone::Color(255, 0, 0), OrthancStone::Color(0, 255, 0)));
+            frame.reset(report.Render(font_, GetHighlightedColorInternal(), GetAnnotationsColorInternal()));
           }
           else
           {
--- a/OrthancStone/Sources/Scene2D/Scene2D.cpp	Fri Apr 25 19:02:22 2025 +0200
+++ b/OrthancStone/Sources/Scene2D/Scene2D.cpp	Sat Apr 26 10:48:32 2025 +0200
@@ -297,6 +297,27 @@
   }
 
 
+  void Scene2D::FitTopContent(unsigned int canvasWidth,
+                              unsigned int canvasHeight,
+                              double topMargin)
+  {
+    // This is used to focus on the top of a DICOM-SR textual report
+    Extent2D extent;
+    GetBoundingBox(extent);
+
+    if (!extent.IsEmpty())
+    {
+      double zoom = static_cast<double>(canvasWidth) / extent.GetWidth();
+
+      AffineTransform2D t1 = AffineTransform2D::CreateOffset(-extent.GetCenterX(), -extent.GetY1());
+      AffineTransform2D t2 = AffineTransform2D::CreateScaling(zoom, zoom);
+      AffineTransform2D t3 = AffineTransform2D::CreateOffset(0, static_cast<double>(canvasHeight) * (topMargin - 0.5));
+
+      SetSceneToCanvasTransform(AffineTransform2D::Combine(t3, t2, t1));
+    }
+  }
+
+
   void Scene2D::RotateViewport(double angle,
                                unsigned int canvasWidth,
                                unsigned int canvasHeight)
--- a/OrthancStone/Sources/Scene2D/Scene2D.h	Fri Apr 25 19:02:22 2025 +0200
+++ b/OrthancStone/Sources/Scene2D/Scene2D.h	Sat Apr 26 10:48:32 2025 +0200
@@ -121,6 +121,10 @@
     void FitContent(unsigned int canvasWidth,
                     unsigned int canvasHeight);
 
+    void FitTopContent(unsigned int canvasWidth,
+                       unsigned int canvasHeight,
+                       double topMargin /* In percents */);
+
     void GetBoundingBox(Extent2D& target) const;
 
     void RotateViewport(double angle,