# HG changeset patch # User Sebastien Jodogne # Date 1496133057 -7200 # Node ID f8bce1bebe01f887f3da757c70533732fe838c6a # Parent f47349f4815c9d44673f13a7a2198bac2fa4ff44 removal of the NotifyLayerError callback diff -r f47349f4815c -r f8bce1bebe01 Applications/Samples/SingleFrameApplication.h --- a/Applications/Samples/SingleFrameApplication.h Tue May 30 10:12:54 2017 +0200 +++ b/Applications/Samples/SingleFrameApplication.h Tue May 30 10:30:57 2017 +0200 @@ -123,12 +123,8 @@ virtual void NotifyLayerReady(std::auto_ptr& layer, const ILayerSource& source, - const Slice& slice) - { - } - - virtual void NotifyLayerError(const ILayerSource& source, - const SliceGeometry& slice) + const Slice& slice, + bool isError) { } diff -r f47349f4815c -r f8bce1bebe01 Framework/Layers/ILayerSource.h --- a/Framework/Layers/ILayerSource.h Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Layers/ILayerSource.h Tue May 30 10:30:57 2017 +0200 @@ -51,15 +51,12 @@ virtual void NotifySliceChange(const ILayerSource& source, const Slice& slice) = 0; - // The layer must be deleted by the observer. "layer" will never - // be "NULL", otherwise "NotifyLayerError()" would have been - // called. + // The layer must be deleted by the observer that releases the + // std::auto_ptr virtual void NotifyLayerReady(std::auto_ptr& layer, const ILayerSource& source, - const Slice& slice) = 0; - - virtual void NotifyLayerError(const ILayerSource& source, - const SliceGeometry& slice) = 0; + const Slice& slice, + bool isError) = 0; }; virtual ~ILayerSource() diff -r f47349f4815c -r f8bce1bebe01 Framework/Layers/LayerSourceBase.cpp --- a/Framework/Layers/LayerSourceBase.cpp Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Layers/LayerSourceBase.cpp Tue May 30 10:30:57 2017 +0200 @@ -32,23 +32,22 @@ private: std::auto_ptr layer_; const Slice& slice_; + bool isError_; public: LayerReadyFunctor(ILayerRenderer* layer, - const Slice& slice) : + const Slice& slice, + bool isError) : layer_(layer), - slice_(slice) + slice_(slice), + isError_(isError) { - if (layer == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); - } } void operator() (ILayerSource::IObserver& observer, const ILayerSource& source) { - observer.NotifyLayerReady(layer_, source, slice_); + observer.NotifyLayerReady(layer_, source, slice_, isError_); } }; } @@ -74,17 +73,13 @@ } void LayerSourceBase::NotifyLayerReady(ILayerRenderer* layer, - const Slice& slice) + const Slice& slice, + bool isError) { - LayerReadyFunctor functor(layer, slice); + LayerReadyFunctor functor(layer, slice, isError); observers_.Notify(*this, functor); } - void LayerSourceBase::NotifyLayerError(const SliceGeometry& slice) - { - observers_.Apply(*this, &IObserver::NotifyLayerError, slice); - } - void LayerSourceBase::Register(IObserver& observer) { observers_.Register(observer); diff -r f47349f4815c -r f8bce1bebe01 Framework/Layers/LayerSourceBase.h --- a/Framework/Layers/LayerSourceBase.h Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Layers/LayerSourceBase.h Tue May 30 10:30:57 2017 +0200 @@ -43,9 +43,8 @@ void NotifySliceChange(const Slice& slice); void NotifyLayerReady(ILayerRenderer* layer, - const Slice& slice); - - void NotifyLayerError(const SliceGeometry& slice); + const Slice& slice, + bool isError); public: virtual void Register(IObserver& observer); diff -r f47349f4815c -r f8bce1bebe01 Framework/Layers/OrthancFrameLayerSource.cpp --- a/Framework/Layers/OrthancFrameLayerSource.cpp Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Layers/OrthancFrameLayerSource.cpp Tue May 30 10:30:57 2017 +0200 @@ -55,7 +55,7 @@ SliceImageQuality quality) { bool isFull = (quality == SliceImageQuality_Full); - LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(image, slice, isFull), slice); + LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(image, slice, isFull), slice, false); } void OrthancFrameLayerSource::NotifySliceImageError(const OrthancSlicesLoader& loader, @@ -63,7 +63,7 @@ const Slice& slice, SliceImageQuality quality) { - LayerSourceBase::NotifyLayerError(slice.GetGeometry()); + LayerSourceBase::NotifyLayerReady(NULL, slice, true); } OrthancFrameLayerSource::OrthancFrameLayerSource(IWebService& orthanc, @@ -130,7 +130,8 @@ } else { - LayerSourceBase::NotifyLayerError(viewportSlice); + Slice slice; + LayerSourceBase::NotifyLayerReady(NULL, slice, true); } } } diff -r f47349f4815c -r f8bce1bebe01 Framework/Widgets/LayerWidget.cpp --- a/Framework/Widgets/LayerWidget.cpp Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Widgets/LayerWidget.cpp Tue May 30 10:30:57 2017 +0200 @@ -481,36 +481,24 @@ void LayerWidget::NotifyLayerReady(std::auto_ptr& renderer, const ILayerSource& source, - const Slice& slice) + const Slice& slice, + bool isError) { size_t index; - if (LookupLayer(index, source) && + if (renderer.get() != NULL && + LookupLayer(index, source) && slice.ContainsPlane(slice_)) // Whether the slice comes from an older request { - LOG(INFO) << "Renderer ready for layer " << index; + if (isError) + { + LOG(ERROR) << "Using error renderer on layer " << index; + } + else + { + LOG(INFO) << "Renderer ready for layer " << index; + } + UpdateLayer(index, renderer.release(), slice); } } - - - void LayerWidget::NotifyLayerError(const ILayerSource& source, - const SliceGeometry& slice) - { - size_t index; - - Slice expected(slice_, THIN_SLICE_THICKNESS); - - if (LookupLayer(index, source) && - expected.ContainsPlane(slice)) // Whether the slice comes from an older request - { - LOG(INFO) << "Unable to load a slice from layer " << index; - - double x1, y1, x2, y2; - if (GetAndFixExtent(x1, y1, x2, y2, *layers_[index])) - { - printf("**%d** %f %f %f %f\n", index, x1, y1, x2, y2); - UpdateLayer(index, new MissingLayerRenderer(x1, y1, x2, y2), Slice(slice, THIN_SLICE_THICKNESS)); - } - } - } } diff -r f47349f4815c -r f8bce1bebe01 Framework/Widgets/LayerWidget.h --- a/Framework/Widgets/LayerWidget.h Tue May 30 10:12:54 2017 +0200 +++ b/Framework/Widgets/LayerWidget.h Tue May 30 10:30:57 2017 +0200 @@ -66,10 +66,8 @@ virtual void NotifyLayerReady(std::auto_ptr& renderer, const ILayerSource& source, - const Slice& slice); - - virtual void NotifyLayerError(const ILayerSource& source, - const SliceGeometry& slice); + const Slice& slice, + bool isError); protected: