changeset 1138:1a73f852810a broker

integration mainline->broker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Nov 2019 07:28:39 +0100
parents cc029987b6dc (current diff) 58799b7317fa (diff)
children 8d2f1b25593c
files Framework/Deprecated/Viewport/WidgetViewport.cpp Framework/Radiography/RadiographyScene.cpp Framework/Radiography/RadiographyScene.h Framework/Radiography/RadiographyWidget.cpp Framework/Radiography/RadiographyWidget.h
diffstat 5 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Deprecated/Viewport/WidgetViewport.cpp	Wed Nov 06 20:27:20 2019 +0100
+++ b/Framework/Deprecated/Viewport/WidgetViewport.cpp	Thu Nov 07 07:28:39 2019 +0100
@@ -113,7 +113,7 @@
     {
       return false;
     }
-
+    
     if (background.GetWidth() != surface.GetWidth() ||
         background.GetHeight() != surface.GetHeight())
     {
--- a/Framework/Radiography/RadiographyScene.cpp	Wed Nov 06 20:27:20 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Thu Nov 07 07:28:39 2019 +0100
@@ -222,6 +222,8 @@
       countLayers_--;
       
       LOG(INFO) << "Removing layer, there are now : " << countLayers_ << " layers";
+
+      BroadcastMessage(RadiographyScene::LayerRemovedMessage(*this, layerIndex));
     }
   }
 
--- a/Framework/Radiography/RadiographyScene.h	Wed Nov 06 20:27:20 2019 +0100
+++ b/Framework/Radiography/RadiographyScene.h	Thu Nov 07 07:28:39 2019 +0100
@@ -101,6 +101,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	Wed Nov 06 20:27:20 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.cpp	Thu Nov 07 07:28:39 2019 +0100
@@ -199,6 +199,11 @@
     selectedLayer_ = layer;
   }
 
+  void RadiographyWidget::ClearSelectedLayer()
+  {
+    hasSelection_ = false;
+  }
+
   bool RadiographyWidget::SelectMaskLayer(size_t index)
   {
     std::vector<size_t> layerIndexes;
@@ -249,6 +254,14 @@
     NotifyContentChanged();
   }
 
+  void RadiographyWidget::OnLayerRemoved(const RadiographyScene::LayerRemovedMessage& message)
+  {
+    size_t removedLayerIndex = message.GetLayerIndex();
+    if (hasSelection_ && selectedLayer_ == removedLayerIndex)
+    {
+      ClearSelectedLayer();
+    }
+  }
   
   void RadiographyWidget::SetInvert(bool invert)
   {
@@ -260,7 +273,7 @@
   }
 
   
-  void RadiographyWidget::SwitchInvert()
+    void RadiographyWidget::SwitchInvert()
   {
     invert_ = !invert_;
     NotifyContentChanged();
@@ -283,6 +296,10 @@
     Register<RadiographyScene::GeometryChangedMessage>(*scene_, &RadiographyWidget::OnGeometryChanged);
     Register<RadiographyScene::ContentChangedMessage>(*scene_, &RadiographyWidget::OnContentChanged);
 
+    scene_->RegisterObserverCallback(
+          new Callable<RadiographyWidget, RadiographyScene::LayerRemovedMessage>
+          (*this, &RadiographyWidget::OnLayerRemoved));
+
     NotifyContentChanged();
 
     // force redraw
--- a/Framework/Radiography/RadiographyWidget.h	Wed Nov 06 20:27:20 2019 +0100
+++ b/Framework/Radiography/RadiographyWidget.h	Thu Nov 07 07:28:39 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();