changeset 1962:c6272d7bb6d9

display of orientation markers in Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Oct 2022 19:12:29 +0200
parents cbf54cd28d59
children 79fdc3b1f031
files Applications/StoneWebViewer/NEWS Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 2 files changed, 51 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS	Thu Oct 27 18:43:20 2022 +0200
+++ b/Applications/StoneWebViewer/NEWS	Thu Oct 27 19:12:29 2022 +0200
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* Display of orientation markers
 * New configuration options:
   - "ShowInfoPanelAtStartup" to control the info panel at startup
   - "ShowUserPreferencesButton" to show the button for setting preferences
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Thu Oct 27 18:43:20 2022 +0200
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Thu Oct 27 19:12:29 2022 +0200
@@ -1589,6 +1589,7 @@
   static const int LAYER_REFERENCE_LINES = 2;
   static const int LAYER_ANNOTATIONS_OSIRIX = 3;
   static const int LAYER_ANNOTATIONS_STONE = 4;
+  static const int LAYER_ORIENTATION_MARKERS = 5;
 
   
   class ICommand : public Orthanc::IDynamicObject
@@ -2230,6 +2231,46 @@
 
     StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frameIndex);
 
+    // Orientation markers, new in Stone Web viewer 2.4
+    std::unique_ptr<OrthancStone::MacroSceneLayer>  orientationMarkers;
+
+    if (instance.GetGeometry().IsValid())
+    {
+      orientationMarkers.reset(new OrthancStone::MacroSceneLayer);
+
+      std::string top, bottom, left, right;
+      instance.GetGeometry().GetOrientationMarkers(top, bottom, left, right);
+
+      std::unique_ptr<OrthancStone::TextSceneLayer> text;
+
+      text.reset(new OrthancStone::TextSceneLayer);
+      text->SetText(top);
+      text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()) / 2.0, 0);
+      text->SetAnchor(OrthancStone::BitmapAnchor_TopCenter);
+      orientationMarkers->AddLayer(text.release());
+
+      text.reset(new OrthancStone::TextSceneLayer);
+      text->SetText(bottom);
+      text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()) / 2.0,
+                        pixelSpacingY * static_cast<double>(frame.GetHeight()));
+      text->SetAnchor(OrthancStone::BitmapAnchor_BottomCenter);
+      orientationMarkers->AddLayer(text.release());
+
+      text.reset(new OrthancStone::TextSceneLayer);
+      text->SetText(left);
+      text->SetPosition(0, pixelSpacingY * static_cast<double>(frame.GetHeight()) / 2.0);
+      text->SetAnchor(OrthancStone::BitmapAnchor_CenterLeft);
+      orientationMarkers->AddLayer(text.release());
+
+      text.reset(new OrthancStone::TextSceneLayer);
+      text->SetText(right);
+      text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()),
+                        pixelSpacingY * static_cast<double>(frame.GetHeight()) / 2.0);
+      text->SetAnchor(OrthancStone::BitmapAnchor_CenterRight);
+      orientationMarkers->AddLayer(text.release());
+    }
+
+
     {
       std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
 
@@ -2255,6 +2296,15 @@
         scene.DeleteLayer(LAYER_ANNOTATIONS_OSIRIX);
       }
 
+      if (orientationMarkers.get() != NULL)
+      {
+        scene.SetLayer(LAYER_ORIENTATION_MARKERS, orientationMarkers.release());
+      }
+      else
+      {
+        scene.DeleteLayer(LAYER_ORIENTATION_MARKERS);
+      }
+
       stoneAnnotations_->Render(scene);  // Necessary for "FitContent()" to work
 
       if (fitNextContent_)