changeset 2018:6099c7925202

synchronized browsing against the vertical slider
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 03 Dec 2022 08:45:36 +0100
parents 7e45941acc1d
children fe9999d6a636
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Sat Dec 03 08:27:14 2022 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Sat Dec 03 08:45:36 2022 +0100
@@ -3458,6 +3458,23 @@
     stoneAnnotations_->AddTextAnnotation(label, pointedPosition, labelPosition);
     Redraw();
   }
+
+
+  void SignalSynchronizedBrowsing()
+  {
+    if (synchronizationEnabled_ &&
+        frames_.get() != NULL &&
+        cursor_.get() != NULL)
+    {
+      const size_t currentCursorIndex = cursor_->GetCurrentIndex();
+
+      const OrthancStone::CoordinateSystem3D current =
+        frames_->GetFrameGeometry(currentCursorIndex);
+      
+      observer_->SignalSynchronizedBrowsing(
+        *this, current.GetOrigin() + synchronizationOffset_, current.GetNormal());
+    }
+  }
 };
 
 
@@ -4164,7 +4181,9 @@
   {
     try
     {
-      return GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Minus, isCircular) ? 1 : 0;
+      bool changed = GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Minus, isCircular);
+      GetViewport(canvas)->SignalSynchronizedBrowsing();
+      return changed ? 1 : 0;
     }
     EXTERN_CATCH_EXCEPTIONS;
     return 0;
@@ -4177,7 +4196,9 @@
   {
     try
     {
-      return GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Plus, isCircular) ? 1 : 0;
+      bool changed = GetViewport(canvas)->ChangeFrame(SeriesCursor::Action_Plus, isCircular);
+      GetViewport(canvas)->SignalSynchronizedBrowsing();
+      return changed ? 1 : 0;
     }
     EXTERN_CATCH_EXCEPTIONS;
     return 0;
@@ -4193,6 +4214,7 @@
       if (frameNumber >= 0)
       {
         GetViewport(canvas)->SetFrame(static_cast<unsigned int>(frameNumber));
+        GetViewport(canvas)->SignalSynchronizedBrowsing();
       }
     }
     EXTERN_CATCH_EXCEPTIONS;
@@ -4205,6 +4227,7 @@
     try
     {
       GetViewport(canvas)->GoToFirstFrame();
+      GetViewport(canvas)->SignalSynchronizedBrowsing();
     }
     EXTERN_CATCH_EXCEPTIONS;
   }
@@ -4216,6 +4239,7 @@
     try
     {
       GetViewport(canvas)->GoToLastFrame();
+      GetViewport(canvas)->SignalSynchronizedBrowsing();
     }
     EXTERN_CATCH_EXCEPTIONS;
   }