changeset 1142:76705b430c78 toa2019110801

Merge
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 08 Nov 2019 14:36:24 +0100
parents 7681f3943748 (current diff) 58799b7317fa (diff)
children e2212644eab3
files
diffstat 5 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Deprecated/Viewport/WidgetViewport.cpp	Fri Nov 08 14:25:35 2019 +0100
+++ b/Framework/Deprecated/Viewport/WidgetViewport.cpp	Fri Nov 08 14:36:24 2019 +0100
@@ -116,7 +116,7 @@
     {
       return false;
     }
-
+    
     if (background.GetWidth() != surface.GetWidth() ||
         background.GetHeight() != surface.GetHeight())
     {
--- a/Framework/Radiography/RadiographyScene.cpp	Fri Nov 08 14:25:35 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Fri Nov 08 14:36:24 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	Fri Nov 08 14:25:35 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.h	Fri Nov 08 14:36:24 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	Fri Nov 08 14:25:35 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.cpp	Fri Nov 08 14:36:24 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	Fri Nov 08 14:25:35 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.h	Fri Nov 08 14:36:24 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();