changeset 86:02c3a7a4938f wasm

removing of the Start() mechanism
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 13:42:50 +0200
parents bd48431ac285
children 4a541cd4fa83
files Applications/BasicApplicationContext.cpp Framework/Layers/ILayerSource.h Framework/Layers/LayerSourceBase.cpp Framework/Layers/LayerSourceBase.h Framework/Layers/OrthancFrameLayerSource.cpp Framework/Layers/OrthancFrameLayerSource.h Framework/Viewport/IViewport.h Framework/Viewport/WidgetViewport.cpp Framework/Viewport/WidgetViewport.h Framework/Widgets/EmptyWidget.h Framework/Widgets/IWidget.h Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h Framework/Widgets/WidgetBase.h Platforms/Generic/Oracle.cpp
diffstat 15 files changed, 14 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/BasicApplicationContext.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Applications/BasicApplicationContext.cpp	Fri May 26 13:42:50 2017 +0200
@@ -137,6 +137,7 @@
   {
     oracle_.Start();
 
+    // TODO REMOVE THIS
     for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)
     {
       assert(*it != NULL);
@@ -148,8 +149,6 @@
       stopped_ = false;
       updateThread_ = boost::thread(UpdateThread, this);
     }
-
-    viewport_.Start();
   }
 
 
@@ -162,6 +161,7 @@
       updateThread_.join();
     }
     
+    // TODO REMOVE THIS
     for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)
     {
       assert(*it != NULL);
--- a/Framework/Layers/ILayerSource.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Layers/ILayerSource.h	Fri May 26 13:42:50 2017 +0200
@@ -73,7 +73,5 @@
                            const SliceGeometry& viewportSlice) = 0;
 
     virtual void ScheduleLayerCreation(const SliceGeometry& viewportSlice) = 0;
-
-    virtual void Start() = 0;
   };
 }
--- a/Framework/Layers/LayerSourceBase.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Layers/LayerSourceBase.cpp	Fri May 26 13:42:50 2017 +0200
@@ -27,11 +27,6 @@
 {
   void LayerSourceBase::NotifyGeometryReady()
   {
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ != NULL)
     {
       observer_->NotifyGeometryReady(*this);
@@ -40,11 +35,6 @@
     
   void LayerSourceBase::NotifyGeometryError()
   {
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ != NULL)
     {
       observer_->NotifyGeometryError(*this);
@@ -53,11 +43,6 @@
     
   void LayerSourceBase::NotifySourceChange()
   {
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ != NULL)
     {
       observer_->NotifySourceChange(*this);
@@ -66,11 +51,6 @@
 
   void LayerSourceBase::NotifySliceChange(const Slice& slice)
   {
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ != NULL)
     {
       observer_->NotifySliceChange(*this, slice);
@@ -82,11 +62,6 @@
   {
     std::auto_ptr<ILayerRenderer> tmp(layer);
     
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (layer == NULL)
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
@@ -100,11 +75,6 @@
 
   void LayerSourceBase::NotifyLayerError(const SliceGeometry& slice)
   {
-    if (!started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ != NULL)
     {
       observer_->NotifyLayerError(*this, slice);
@@ -113,11 +83,6 @@
 
   void LayerSourceBase::SetObserver(IObserver& observer)
   {
-    if (started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-
     if (observer_ == NULL)
     {
       observer_ = &observer;
@@ -128,17 +93,4 @@
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
     }
   }
-
-  void LayerSourceBase::Start()
-  {
-    if (started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-    else
-    {
-      started_ = true;
-      StartInternal();
-    }
-  }
 }
--- a/Framework/Layers/LayerSourceBase.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Layers/LayerSourceBase.h	Fri May 26 13:42:50 2017 +0200
@@ -29,14 +29,8 @@
   {
   private:
     IObserver*  observer_;
-    bool        started_;
 
   protected:
-    bool IsStarted()
-    {
-      return started_;
-    }
-
     void NotifyGeometryReady();
     
     void NotifyGeometryError();
@@ -51,17 +45,12 @@
     
     void NotifyLayerError(const SliceGeometry& slice);
 
-    virtual void StartInternal() = 0;
-
   public:
     LayerSourceBase() :
-      observer_(NULL),
-      started_(false)
+      observer_(NULL)
     {
     }
     
     virtual void SetObserver(IObserver& observer);
-
-    virtual void Start();
   };
 }
--- a/Framework/Layers/OrthancFrameLayerSource.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Layers/OrthancFrameLayerSource.cpp	Fri May 26 13:42:50 2017 +0200
@@ -91,22 +91,12 @@
     loader_(*this, orthanc),
     observer2_(NULL)
   {
+    loader_.ScheduleLoadInstance(instanceId_, frame_);
   }
 
 
-  void OrthancFrameLayerSource::StartInternal()
-  {
-    loader_.ScheduleLoadInstance(instanceId_, frame_);
-  }
-  
-
   void OrthancFrameLayerSource::SetObserver(IVolumeSlicesObserver& observer)
   {
-    if (IsStarted())
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-    }
-    
     if (observer2_ == NULL)
     {
       observer2_ = &observer;
@@ -163,14 +153,16 @@
   {
     size_t index;
 
-    if (loader_.IsGeometryReady() &&
-        loader_.LookupSlice(index, viewportSlice))
+    if (loader_.IsGeometryReady())
     {
-      loader_.ScheduleLoadSliceImage(index);
-    }
-    else
-    {
-      LayerSourceBase::NotifyLayerError(viewportSlice);
+      if (loader_.LookupSlice(index, viewportSlice))
+      {
+        loader_.ScheduleLoadSliceImage(index);
+      }
+      else
+      {
+        LayerSourceBase::NotifyLayerError(viewportSlice);
+      }
     }
   }
 }
--- a/Framework/Layers/OrthancFrameLayerSource.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Layers/OrthancFrameLayerSource.h	Fri May 26 13:42:50 2017 +0200
@@ -51,9 +51,6 @@
                                        unsigned int sliceIndex,
                                        const Slice& slice);
 
-  protected:
-    virtual void StartInternal();
-
   public:
     using LayerSourceBase::SetObserver;
 
--- a/Framework/Viewport/IViewport.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Viewport/IViewport.h	Fri May 26 13:42:50 2017 +0200
@@ -87,7 +87,5 @@
 
     // Should only be called from IWidget
     virtual void NotifyChange(const IWidget& widget) = 0;
-
-    virtual void Start() = 0;
   };
 }
--- a/Framework/Viewport/WidgetViewport.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Viewport/WidgetViewport.cpp	Fri May 26 13:42:50 2017 +0200
@@ -265,13 +265,4 @@
       centralWidget_->UpdateContent();
     }
   }
-
-
-  void WidgetViewport::Start()
-  {
-    if (centralWidget_.get() != NULL)
-    {
-      centralWidget_->Start();
-    }
-  }
 }
--- a/Framework/Viewport/WidgetViewport.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Viewport/WidgetViewport.h	Fri May 26 13:42:50 2017 +0200
@@ -88,7 +88,5 @@
     virtual bool HasUpdateContent();
 
     virtual void UpdateContent();
-
-    virtual void Start();
   };
 }
--- a/Framework/Widgets/EmptyWidget.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Widgets/EmptyWidget.h	Fri May 26 13:42:50 2017 +0200
@@ -112,10 +112,6 @@
       {
         return false;
       }
-
-      virtual void Start()
-      {
-      }
     };
   }
 }
--- a/Framework/Widgets/IWidget.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Widgets/IWidget.h	Fri May 26 13:42:50 2017 +0200
@@ -74,7 +74,5 @@
     // Subclasses can call this method to signal the display of the
     // widget must be refreshed
     virtual void NotifyChange() = 0;
-
-    virtual void Start() = 0;
   };
 }
--- a/Framework/Widgets/LayerWidget.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Widgets/LayerWidget.cpp	Fri May 26 13:42:50 2017 +0200
@@ -451,7 +451,7 @@
     if (LookupLayer(index, source) &&
         slice.IsSamePlane(slice_, THIN_SLICE_THICKNESS))  // Whether the slice comes from an older request
     {
-      LOG(ERROR) << "Error on layer " << index;
+      LOG(INFO) << "Unable to load a slice from layer " << index;
 
       double x1, y1, x2, y2;
       if (GetAndFixExtent(x1, y1, x2, y2, source))
@@ -460,19 +460,4 @@
       }
     }
   }    
-
-
-  void LayerWidget::Start()
-  {
-    if (started_)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);      
-    }
-    
-    for (size_t i = 0; i < layers_.size(); i++)
-    {
-      assert(layers_[i] != NULL);
-      layers_[i]->Start();
-    }
-  }
 }
--- a/Framework/Widgets/LayerWidget.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Widgets/LayerWidget.h	Fri May 26 13:42:50 2017 +0200
@@ -103,7 +103,5 @@
     {
       return slice_;
     }
-
-    virtual void Start();
   };
 }
--- a/Framework/Widgets/WidgetBase.h	Fri May 26 12:20:26 2017 +0200
+++ b/Framework/Widgets/WidgetBase.h	Fri May 26 13:42:50 2017 +0200
@@ -105,9 +105,5 @@
     }
 
     virtual void NotifyChange();
-
-    virtual void Start()
-    {
-    }
   };
 }
--- a/Platforms/Generic/Oracle.cpp	Fri May 26 12:20:26 2017 +0200
+++ b/Platforms/Generic/Oracle.cpp	Fri May 26 13:42:50 2017 +0200
@@ -112,9 +112,6 @@
       switch (state_)
       {
         case State_Init:
-          LOG(ERROR) << "You must call Oracle::Start()";
-          throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
-
         case State_Started:
           queue_.Enqueue(protection.release());
           break;