diff Framework/Widgets/LayerWidget.cpp @ 89:f244018a4e4b wasm

BUGGY- trying to remove IVolumeSlicesObserver
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 18:27:59 +0200
parents 4a541cd4fa83
children 64e60018943f
line wrap: on
line diff
--- a/Framework/Widgets/LayerWidget.cpp	Fri May 26 16:11:52 2017 +0200
+++ b/Framework/Widgets/LayerWidget.cpp	Fri May 26 18:27:59 2017 +0200
@@ -94,6 +94,11 @@
       return countMissing_ == 0;
     }
 
+    unsigned int GetCountMissing() const
+    {
+      return countMissing_;
+    }
+
     bool RenderScene(CairoContext& context,
                      const ViewportGeometry& view)
     {
@@ -101,6 +106,11 @@
 
       for (size_t i = 0; i < renderers_.size(); i++)
       {
+        if (renderers_[i] != NULL)
+        {
+          LOG(ERROR) << "...............";
+        }
+
         if (renderers_[i] != NULL &&
             !renderers_[i]->RenderLayer(context, view, slice_))
         {
@@ -302,6 +312,7 @@
       pendingScene_->SetLayer(index, tmp.release());
 
       if (currentScene_.get() == NULL ||
+          !currentScene_->IsComplete() ||
           pendingScene_->IsComplete())
       {
         currentScene_ = pendingScene_;
@@ -340,6 +351,7 @@
     layersIndex_[layer] = index;
 
     ResetPendingScene();
+    LOG(ERROR) << "*****************************";
     layer->SetObserver(*this);
 
     return index;
@@ -373,43 +385,39 @@
 
   void LayerWidget::SetSlice(const SliceGeometry& slice)
   {
-    if (!slice_.IsSamePlane(slice, THIN_SLICE_THICKNESS))
+    if (currentScene_.get() == NULL ||
+        (pendingScene_.get() != NULL &&
+         pendingScene_->IsComplete()))
     {
-      if (currentScene_.get() == NULL ||
-          (pendingScene_.get() != NULL &&
-           pendingScene_->IsComplete()))
-      {
-        currentScene_ = pendingScene_;
-      }
-        
-      slice_ = slice;
-      ResetPendingScene();
+      currentScene_ = pendingScene_;
+    }
+
+    slice_ = slice;
+    ResetPendingScene();
+  }
 
-      for (size_t i = 0; i < layers_.size(); i++)
-      {
-        assert(layers_[i] != NULL);
-        layers_[i]->ScheduleLayerCreation(slice_);
-      }
+
+  void LayerWidget::InvalidateAllLayers()
+  {
+    for (size_t i = 0; i < layers_.size(); i++)
+    {
+      assert(layers_[i] != NULL);
+      layers_[i]->ScheduleLayerCreation(slice_);
     }
   }
 
-  
-  void LayerWidget::NotifyGeometryReady(const ILayerSource& source)
+
+  void LayerWidget::InvalidateLayer(size_t layer)
   {
-    size_t i;
-    if (LookupLayer(i, source))
+    if (layer >= layers_.size())
     {
-      LOG(INFO) << "Geometry ready for layer " << i;
-      layers_[i]->ScheduleLayerCreation(slice_);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
-  }
-  
 
-  void LayerWidget::NotifyGeometryError(const ILayerSource& source)
-  {
-    LOG(ERROR) << "Cannot get geometry";
+    assert(layers_[layer] != NULL);
+    layers_[layer]->ScheduleLayerCreation(slice_);
   }
-  
+
 
   void LayerWidget::NotifyContentChange(const ILayerSource& source)
   {
@@ -434,7 +442,7 @@
     }
   }
   
-
+  
   void LayerWidget::NotifyLayerReady(ILayerRenderer* renderer,
                                      const ILayerSource& source,
                                      const Slice& slice)
@@ -456,8 +464,10 @@
   {
     size_t index;
 
+    Slice expected(slice_, THIN_SLICE_THICKNESS);
+
     if (LookupLayer(index, source) &&
-        slice.IsSamePlane(slice_, THIN_SLICE_THICKNESS))  // Whether the slice comes from an older request
+        expected.ContainsPlane(slice))  // Whether the slice comes from an older request
     {
       LOG(INFO) << "Unable to load a slice from layer " << index;