changeset 1903:c7bc9e1776a6

fix rendering of RT sample
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 31 Jan 2022 18:00:10 +0100
parents 1cfd602de69d
children 738814c24574
files Applications/Samples/Common/RtViewerApp.cpp Applications/Samples/Common/RtViewerApp.h Applications/Samples/Common/RtViewerView.cpp
diffstat 3 files changed, 24 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/Common/RtViewerApp.cpp	Sat Jan 29 18:30:26 2022 +0100
+++ b/Applications/Samples/Common/RtViewerApp.cpp	Mon Jan 31 18:00:10 2022 +0100
@@ -25,25 +25,25 @@
 #include "SampleHelpers.h"
 
 // Stone of Orthanc
-#include "../../../OrthancStone/Sources/StoneInitialization.h"
+#include "../../../OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.h"
 #include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h"
 #include "../../../OrthancStone/Sources/Scene2D/ColorTextureSceneLayer.h"
+#include "../../../OrthancStone/Sources/Scene2D/GrayscaleStyleConfigurator.h"
+#include "../../../OrthancStone/Sources/Scene2D/LookupTableStyleConfigurator.h"
 #include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h"
 #include "../../../OrthancStone/Sources/Scene2D/PanSceneTracker.h"
+#include "../../../OrthancStone/Sources/Scene2D/RotateSceneTracker.h"
 #include "../../../OrthancStone/Sources/Scene2D/ZoomSceneTracker.h"
-#include "../../../OrthancStone/Sources/Scene2D/RotateSceneTracker.h"
-#include "../../../OrthancStone/Sources/Scene2DViewport/UndoStack.h"
+#include "../../../OrthancStone/Sources/Scene2DViewport/CreateAngleMeasureTracker.h"
 #include "../../../OrthancStone/Sources/Scene2DViewport/CreateLineMeasureTracker.h"
-#include "../../../OrthancStone/Sources/Scene2DViewport/CreateAngleMeasureTracker.h"
 #include "../../../OrthancStone/Sources/Scene2DViewport/IFlexiblePointerTracker.h"
 #include "../../../OrthancStone/Sources/Scene2DViewport/MeasureTool.h"
 #include "../../../OrthancStone/Sources/Scene2DViewport/PredeclaredTypes.h"
+#include "../../../OrthancStone/Sources/Scene2DViewport/UndoStack.h"
+#include "../../../OrthancStone/Sources/StoneException.h"
+#include "../../../OrthancStone/Sources/StoneInitialization.h"
+#include "../../../OrthancStone/Sources/Volumes/DicomVolumeImageMPRSlicer.h"
 #include "../../../OrthancStone/Sources/Volumes/VolumeSceneLayerSource.h"
-#include "../../../OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.h"
-#include "../../../OrthancStone/Sources/Scene2D/GrayscaleStyleConfigurator.h"
-#include "../../../OrthancStone/Sources/Scene2D/LookupTableStyleConfigurator.h"
-#include "../../../OrthancStone/Sources/Volumes/DicomVolumeImageMPRSlicer.h"
-#include "../../../OrthancStone/Sources/StoneException.h"
 
 // Orthanc
 #include <Logging.h>
@@ -84,7 +84,8 @@
     // Create the volumes that will be filled later on
     ctVolume_(boost::make_shared<DicomVolumeImage>()),
     doseVolume_(boost::make_shared<DicomVolumeImage>()),
-    undoStack_(new UndoStack)
+    undoStack_(new UndoStack),
+    isFirstSlice_(true)
   {
   }
 
@@ -142,9 +143,6 @@
     Register<DicomVolumeImage::GeometryReadyMessage>
       (*ctLoader_, &RtViewerApp::HandleGeometryReady);
 
-    Register<OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality>
-      (*ctLoader_, &RtViewerApp::HandleCTLoaded);
-
     Register<DicomVolumeImage::ContentUpdatedMessage>
       (*ctLoader_, &RtViewerApp::HandleCTContentUpdated);
 
@@ -197,22 +195,9 @@
 
   void RtViewerApp::HandleGeometryReady(const DicomVolumeImage::GeometryReadyMessage& message)
   {
-    for (size_t i = 0; i < views_.size(); ++i)
-    {
-      views_[i]->RetrieveGeometry();
-    }
-    FitContent();
     UpdateLayersInAllViews();
   }
 
-  void RtViewerApp::FitContent()
-  {
-    for (size_t i = 0; i < views_.size(); ++i)
-    {
-      views_[i]->FitContent();
-    }
-  }
-
   void RtViewerApp::UpdateLayersInAllViews()
   {
     for (size_t i = 0; i < views_.size(); ++i)
@@ -221,17 +206,19 @@
     }
   }
 
-  void RtViewerApp::HandleCTLoaded(const OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality& message)
-  {
-    for (size_t i = 0; i < views_.size(); ++i)
-    {
-      views_[i]->RetrieveGeometry();
-    }
-    UpdateLayersInAllViews();
-  }
-
   void RtViewerApp::HandleCTContentUpdated(const DicomVolumeImage::ContentUpdatedMessage& message)
   {
+    if (isFirstSlice_)
+    {
+      for (size_t i = 0; i < views_.size(); ++i)
+      {
+        views_[i]->RetrieveGeometry();
+        views_[i]->FitContent();
+      }
+
+      isFirstSlice_ = false;
+    }
+    
     UpdateLayersInAllViews();
   }
 
--- a/Applications/Samples/Common/RtViewerApp.h	Sat Jan 29 18:30:26 2022 +0100
+++ b/Applications/Samples/Common/RtViewerApp.h	Mon Jan 31 18:00:10 2022 +0100
@@ -126,7 +126,6 @@
     void HandleGeometryReady(const DicomVolumeImage::GeometryReadyMessage& message);
     
     // TODO: wire this
-    void HandleCTLoaded(const OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality& message);
     void HandleCTContentUpdated(const DicomVolumeImage::ContentUpdatedMessage& message);
     void HandleDoseLoaded(const DicomVolumeImage::ContentUpdatedMessage& message);
     void HandleStructuresReady(const DicomStructureSetLoader::StructuresReady& message);
@@ -135,7 +134,6 @@
 
   private:
     void RetrieveGeometry();
-    void FitContent();
     void InvalidateAllViewports();
     void UpdateLayersInAllViews();
 
@@ -162,6 +160,8 @@
     boost::shared_ptr<IFlexiblePointerTracker> activeTracker_;
 
     boost::shared_ptr<UndoStack> undoStack_;
+
+    bool isFirstSlice_;
   };
 
 }
--- a/Applications/Samples/Common/RtViewerView.cpp	Sat Jan 29 18:30:26 2022 +0100
+++ b/Applications/Samples/Common/RtViewerView.cpp	Mon Jan 31 18:00:10 2022 +0100
@@ -217,8 +217,6 @@
     {
       planes_[z] = geometry.GetProjectionSlice(projection_, z);
     }
-
-    UpdateLayers();
   }
 
   void RtViewerView::UpdateLayers()