changeset 1132:58799b7317fa

merge
author Alain Mazy <alain@mazy.be>
date Wed, 06 Nov 2019 10:47:05 +0100
parents 4663f158c748 (diff) 45df56448b2a (current diff)
children 1a73f852810a 76705b430c78
files
diffstat 5 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Deprecated/Viewport/WidgetViewport.cpp	Tue Nov 05 18:26:59 2019 +0100
+++ b/Framework/Deprecated/Viewport/WidgetViewport.cpp	Wed Nov 06 10:47:05 2019 +0100
@@ -116,7 +116,7 @@
     {
       return false;
     }
-
+    
     if (background.GetWidth() != surface.GetWidth() ||
         background.GetHeight() != surface.GetHeight())
     {
--- a/Framework/Radiography/RadiographyScene.cpp	Tue Nov 05 18:26:59 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Wed Nov 06 10:47:05 2019 +0100
@@ -224,6 +224,8 @@
       countLayers_--;
       
       LOG(INFO) << "Removing layer, there are now : " << countLayers_ << " layers";
+
+      BroadcastMessage(RadiographyScene::LayerRemovedMessage(*this, layerIndex));
     }
   }
 
--- a/Framework/Radiography/RadiographyScene.h	Tue Nov 05 18:26:59 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.h	Wed Nov 06 10:47:05 2019 +0100
@@ -100,6 +100,27 @@
       }
     };
 
+    class LayerRemovedMessage : public OriginMessage<RadiographyScene>
+    {
+      ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
+
+    private:
+      size_t&        layerIndex_;
+
+    public:
+      LayerRemovedMessage(const RadiographyScene& origin,
+                          size_t& layerIndex) :
+        OriginMessage(origin),
+        layerIndex_(layerIndex)
+      {
+      }
+
+      size_t& GetLayerIndex() const
+      {
+        return layerIndex_;
+      }
+    };
+
 
     ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, WindowingChangedMessage, RadiographyScene);
 
--- a/Framework/Radiography/RadiographyWidget.cpp	Tue Nov 05 18:26:59 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.cpp	Wed Nov 06 10:47:05 2019 +0100
@@ -201,6 +201,11 @@
     selectedLayer_ = layer;
   }
 
+  void RadiographyWidget::ClearSelectedLayer()
+  {
+    hasSelection_ = false;
+  }
+
   bool RadiographyWidget::SelectMaskLayer(size_t index)
   {
     std::vector<size_t> layerIndexes;
@@ -251,6 +256,14 @@
     NotifyContentChanged();
   }
 
+  void RadiographyWidget::OnLayerRemoved(const RadiographyScene::LayerRemovedMessage& message)
+  {
+    size_t removedLayerIndex = message.GetLayerIndex();
+    if (hasSelection_ && selectedLayer_ == removedLayerIndex)
+    {
+      ClearSelectedLayer();
+    }
+  }
   
   void RadiographyWidget::SetInvert(bool invert)
   {
@@ -262,7 +275,7 @@
   }
 
   
-  void RadiographyWidget::SwitchInvert()
+    void RadiographyWidget::SwitchInvert()
   {
     invert_ = !invert_;
     NotifyContentChanged();
@@ -295,6 +308,10 @@
           new Callable<RadiographyWidget, RadiographyScene::ContentChangedMessage>
           (*this, &RadiographyWidget::OnContentChanged));
 
+    scene_->RegisterObserverCallback(
+          new Callable<RadiographyWidget, RadiographyScene::LayerRemovedMessage>
+          (*this, &RadiographyWidget::OnLayerRemoved));
+
     NotifyContentChanged();
 
     // force redraw
--- a/Framework/Radiography/RadiographyWidget.h	Tue Nov 05 18:26:59 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.h	Wed Nov 06 10:47:05 2019 +0100
@@ -78,6 +78,8 @@
 
     void Select(size_t layer);
 
+    void ClearSelectedLayer();
+
     bool SelectMaskLayer(size_t index = 0);
 
     bool LookupSelectedLayer(size_t& layer);
@@ -86,6 +88,8 @@
 
     void OnContentChanged(const RadiographyScene::ContentChangedMessage& message);
 
+    void OnLayerRemoved(const RadiographyScene::LayerRemovedMessage& message);
+
     void SetInvert(bool invert);
 
     void SwitchInvert();