Mercurial > hg > orthanc-stone
changeset 380:ba5ad93f935a
ILayerSource::LayerErrorMessage
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Nov 2018 14:59:20 +0100 |
parents | 2308fe0b0b05 |
children | 19bd222283ae |
files | Framework/Layers/DicomStructureSetRendererFactory.cpp Framework/Layers/ILayerSource.h Framework/Layers/LayerSourceBase.cpp Framework/Layers/LayerSourceBase.h Framework/Layers/OrthancFrameLayerSource.cpp Framework/Messages/MessageType.h Framework/SmartLoader.cpp Framework/Widgets/LayerWidget.cpp Framework/Widgets/LayerWidget.h Framework/dev.h |
diffstat | 10 files changed, 68 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Layers/DicomStructureSetRendererFactory.cpp Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Layers/DicomStructureSetRendererFactory.cpp Tue Nov 06 14:59:20 2018 +0100 @@ -130,7 +130,7 @@ { if (loader_.HasStructureSet()) { - NotifyLayerReady(new Renderer(loader_.GetStructureSet(), viewportSlice), viewportSlice, false); + NotifyLayerReady(new Renderer(loader_.GetStructureSet(), viewportSlice), viewportSlice); } } }
--- a/Framework/Layers/ILayerSource.h Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Layers/ILayerSource.h Tue Nov 06 14:59:20 2018 +0100 @@ -60,20 +60,16 @@ class LayerReadyMessage : public OriginMessage<MessageType_LayerSource_LayerReady, ILayerSource> { private: - std::auto_ptr<ILayerRenderer> renderer_; - const CoordinateSystem3D& slice_; - bool isError_; + std::auto_ptr<ILayerRenderer> renderer_; + const CoordinateSystem3D& slice_; public: LayerReadyMessage(ILayerSource& origin, ILayerRenderer* renderer, // Takes ownership => TODO Remove this! - const CoordinateSystem3D& slice, - bool isError // TODO => create NotifyLayerError - ) : + const CoordinateSystem3D& slice) : OriginMessage(origin), renderer_(renderer), - slice_(slice), - isError_(isError) + slice_(slice) { } @@ -92,10 +88,25 @@ { return slice_; } + }; - bool IsError() const + + class LayerErrorMessage : public OriginMessage<MessageType_LayerSource_LayerError, ILayerSource> + { + private: + const CoordinateSystem3D& slice_; + + public: + LayerErrorMessage(ILayerSource& origin, + const CoordinateSystem3D& slice) : + OriginMessage(origin), + slice_(slice) { - return isError_; + } + + const CoordinateSystem3D& GetSlice() const + { + return slice_; } };
--- a/Framework/Layers/LayerSourceBase.cpp Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Layers/LayerSourceBase.cpp Tue Nov 06 14:59:20 2018 +0100 @@ -46,10 +46,14 @@ } void LayerSourceBase::NotifyLayerReady(ILayerRenderer* layer, - const CoordinateSystem3D& slice, - bool isError) + const CoordinateSystem3D& slice) { - EmitMessage(ILayerSource::LayerReadyMessage(*this, layer, slice, isError)); + EmitMessage(ILayerSource::LayerReadyMessage(*this, layer, slice)); + } + + void LayerSourceBase::NotifyLayerError(const CoordinateSystem3D& slice) + { + EmitMessage(ILayerSource::LayerErrorMessage(*this, slice)); } void LayerSourceBase::NotifyImageReady(const Orthanc::ImageAccessor& image,
--- a/Framework/Layers/LayerSourceBase.h Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Layers/LayerSourceBase.h Tue Nov 06 14:59:20 2018 +0100 @@ -40,8 +40,9 @@ void NotifySliceChange(const Slice& slice); void NotifyLayerReady(ILayerRenderer* layer, - const CoordinateSystem3D& slice, - bool isError); + const CoordinateSystem3D& slice); + + void NotifyLayerError(const CoordinateSystem3D& slice); void NotifyImageReady(const Orthanc::ImageAccessor& image, SliceImageQuality imageQuality,
--- a/Framework/Layers/OrthancFrameLayerSource.cpp Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Layers/OrthancFrameLayerSource.cpp Tue Nov 06 14:59:20 2018 +0100 @@ -59,13 +59,13 @@ message.GetEffectiveQuality() == SliceImageQuality_FullPam); LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(message.GetImage(), message.GetSlice(), isFull), - message.GetSlice().GetGeometry(), false); + message.GetSlice().GetGeometry()); } void OrthancFrameLayerSource::OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message) { - LayerSourceBase::NotifyLayerReady(NULL, message.GetSlice().GetGeometry(), true); + LayerSourceBase::NotifyLayerError(message.GetSlice().GetGeometry()); } OrthancFrameLayerSource::OrthancFrameLayerSource(MessageBroker& broker, OrthancApiClient& orthanc) :
--- a/Framework/Messages/MessageType.h Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Messages/MessageType.h Tue Nov 06 14:59:20 2018 +0100 @@ -33,6 +33,7 @@ MessageType_LayerSource_SliceChanged, MessageType_LayerSource_ImageReady, // instance pixels data have been loaded MessageType_LayerSource_LayerReady, // layer is ready to be rendered + MessageType_LayerSource_LayerError, MessageType_SliceLoader_GeometryReady, MessageType_SliceLoader_GeometryError,
--- a/Framework/SmartLoader.cpp Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/SmartLoader.cpp Tue Nov 06 14:59:20 2018 +0100 @@ -73,9 +73,10 @@ if (status_ == CachedSliceStatus_ImageLoaded) { LOG(WARNING) << "ScheduleLayerCreation for CachedSlice (image is loaded): " << slice_->GetOrthancInstanceId(); - bool isFull = (effectiveQuality_ == SliceImageQuality_FullPng || effectiveQuality_ == SliceImageQuality_FullPam); + bool isFull = (effectiveQuality_ == SliceImageQuality_FullPng || + effectiveQuality_ == SliceImageQuality_FullPam); LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(*image_, *slice_, isFull), - slice_->GetGeometry(), false); + slice_->GetGeometry()); } else {
--- a/Framework/Widgets/LayerWidget.cpp Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Widgets/LayerWidget.cpp Tue Nov 06 14:59:20 2018 +0100 @@ -387,6 +387,7 @@ layer.RegisterObserverCallback(new Callable<LayerWidget, ILayerSource::SliceChangedMessage>(*this, &LayerWidget::OnSliceChanged)); layer.RegisterObserverCallback(new Callable<LayerWidget, ILayerSource::ContentChangedMessage>(*this, &LayerWidget::OnContentChanged)); layer.RegisterObserverCallback(new Callable<LayerWidget, ILayerSource::LayerReadyMessage>(*this, &LayerWidget::OnLayerReady)); + layer.RegisterObserverCallback(new Callable<LayerWidget, ILayerSource::LayerErrorMessage>(*this, &LayerWidget::OnLayerError)); } @@ -587,32 +588,38 @@ size_t index; if (LookupLayer(index, message.GetOrigin())) { - if (message.IsError()) - { - LOG(ERROR) << "Using error renderer on layer " << index; - } - else - { - LOG(INFO) << "Renderer ready for layer " << index; - } + LOG(INFO) << "Renderer ready for layer " << index; // TODO -- REMOVE THIS UGLY STUFF ILayerSource::LayerReadyMessage& ugly = const_cast<ILayerSource::LayerReadyMessage&>(message); - if (ugly.GetRendererRaw().get() != NULL) - { - UpdateLayer(index, ugly.GetRendererRaw().release(), message.GetSlice()); - } - else if (message.IsError()) + if (ugly.GetRendererRaw().get() == NULL) { - // TODO - //UpdateLayer(index, new SliceOutlineRenderer(slice), slice); + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); } + + UpdateLayer(index, ugly.GetRendererRaw().release(), message.GetSlice()); } + EmitMessage(LayerWidget::ContentChangedMessage(*this)); } + void LayerWidget::OnLayerError(const ILayerSource::LayerErrorMessage& message) + { + size_t index; + if (LookupLayer(index, message.GetOrigin())) + { + LOG(ERROR) << "Using error renderer on layer " << index; + + // TODO + //UpdateLayer(index, new SliceOutlineRenderer(slice), slice); + + EmitMessage(LayerWidget::ContentChangedMessage(*this)); + } + } + + void LayerWidget::ResetChangedLayers() { changedLayers_.resize(layers_.size());
--- a/Framework/Widgets/LayerWidget.h Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/Widgets/LayerWidget.h Tue Nov 06 14:59:20 2018 +0100 @@ -67,6 +67,8 @@ virtual void OnLayerReady(const ILayerSource::LayerReadyMessage& message); + virtual void OnLayerError(const ILayerSource::LayerErrorMessage& message); + void ObserveLayer(ILayerSource& source); void ResetChangedLayers();
--- a/Framework/dev.h Tue Nov 06 14:41:36 2018 +0100 +++ b/Framework/dev.h Tue Nov 06 14:59:20 2018 +0100 @@ -660,14 +660,14 @@ LayerSourceBase::NotifyLayerReady( FrameRenderer::CreateRenderer(*frame, *slice, isFullQuality), //new SliceOutlineRenderer(slice), - slice->GetGeometry(), false); + slice->GetGeometry()); return; } } // Error CoordinateSystem3D slice; - LayerSourceBase::NotifyLayerReady(NULL, slice, true); + LayerSourceBase::NotifyLayerError(slice); } }; @@ -870,7 +870,7 @@ viewportSlice.GetOrigin(), viewportSlice.GetNormal())) { // The two slice are parallel, don't try and display the intersection - NotifyLayerReady(NULL, reference.GetGeometry(), false); + NotifyLayerError(reference.GetGeometry()); } else { @@ -885,12 +885,12 @@ extent.GetX1(), extent.GetY1(), extent.GetX2(), extent.GetY2())) { - NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference.GetGeometry(), false); + NotifyLayerReady(new LineLayerRenderer(x1, y1, x2, y2, slice), reference.GetGeometry()); } else { - // Parallel slices - NotifyLayerReady(NULL, reference.GetGeometry(), false); + // Error: Parallel slices + NotifyLayerError(reference.GetGeometry()); } } }