Mercurial > hg > orthanc-stone
changeset 378:814fa32e2fcc
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Nov 2018 14:21:02 +0100 |
parents | 8eb4fe74000f |
children | 2308fe0b0b05 |
files | Framework/Layers/ColorFrameRenderer.cpp Framework/Layers/ColorFrameRenderer.h Framework/Layers/FrameRenderer.cpp Framework/Layers/FrameRenderer.h Framework/Layers/GrayscaleFrameRenderer.cpp Framework/Layers/GrayscaleFrameRenderer.h Framework/Layers/ILayerSource.h Framework/Layers/LayerSourceBase.cpp Framework/Layers/LayerSourceBase.h Framework/Layers/OrthancFrameLayerSource.cpp Framework/SmartLoader.cpp Framework/Toolbox/OrthancSlicesLoader.cpp Framework/Toolbox/OrthancSlicesLoader.h Framework/dev.h |
diffstat | 14 files changed, 230 insertions(+), 174 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Layers/ColorFrameRenderer.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/ColorFrameRenderer.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -22,6 +22,7 @@ #include "ColorFrameRenderer.h" #include <Core/OrthancException.h> +#include <Core/Images/Image.h> #include <Core/Images/ImageProcessing.h> namespace OrthancStone @@ -39,15 +40,15 @@ } - ColorFrameRenderer::ColorFrameRenderer(Orthanc::ImageAccessor* frame, + ColorFrameRenderer::ColorFrameRenderer(const Orthanc::ImageAccessor& frame, const CoordinateSystem3D& frameSlice, double pixelSpacingX, double pixelSpacingY, bool isFullQuality) : FrameRenderer(frameSlice, pixelSpacingX, pixelSpacingY, isFullQuality), - frame_(frame) + frame_(Orthanc::Image::Clone(frame)) { - if (frame == NULL) + if (frame_.get() == NULL) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); }
--- a/Framework/Layers/ColorFrameRenderer.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/ColorFrameRenderer.h Tue Nov 06 14:21:02 2018 +0100 @@ -34,7 +34,7 @@ virtual CairoSurface* GenerateDisplay(const RenderStyle& style); public: - ColorFrameRenderer(Orthanc::ImageAccessor* frame, // Takes ownership + ColorFrameRenderer(const Orthanc::ImageAccessor& frame, const CoordinateSystem3D& frameSlice, double pixelSpacingX, double pixelSpacingY,
--- a/Framework/Layers/FrameRenderer.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/FrameRenderer.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -117,22 +117,20 @@ } - ILayerRenderer* FrameRenderer::CreateRenderer(Orthanc::ImageAccessor* frame, + ILayerRenderer* FrameRenderer::CreateRenderer(const Orthanc::ImageAccessor& frame, const Slice& frameSlice, bool isFullQuality) { - std::auto_ptr<Orthanc::ImageAccessor> protect(frame); - - if (frame->GetFormat() == Orthanc::PixelFormat_RGB24) + if (frame.GetFormat() == Orthanc::PixelFormat_RGB24) { - return new ColorFrameRenderer(protect.release(), + return new ColorFrameRenderer(frame, frameSlice.GetGeometry(), frameSlice.GetPixelSpacingX(), frameSlice.GetPixelSpacingY(), isFullQuality); } else { - return new GrayscaleFrameRenderer(protect.release(), + return new GrayscaleFrameRenderer(frame, frameSlice.GetConverter(), frameSlice.GetGeometry(), frameSlice.GetPixelSpacingX(),
--- a/Framework/Layers/FrameRenderer.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/FrameRenderer.h Tue Nov 06 14:21:02 2018 +0100 @@ -61,7 +61,8 @@ return isFullQuality_; } - static ILayerRenderer* CreateRenderer(Orthanc::ImageAccessor* frame, + // TODO: Avoid cloning the "frame" + static ILayerRenderer* CreateRenderer(const Orthanc::ImageAccessor& frame, const Slice& frameSlice, bool isFullQuality); };
--- a/Framework/Layers/GrayscaleFrameRenderer.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/GrayscaleFrameRenderer.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -21,6 +21,7 @@ #include "GrayscaleFrameRenderer.h" +#include <Core/Images/Image.h> #include <Core/OrthancException.h> namespace OrthancStone @@ -112,19 +113,19 @@ } - GrayscaleFrameRenderer::GrayscaleFrameRenderer(Orthanc::ImageAccessor* frame, + GrayscaleFrameRenderer::GrayscaleFrameRenderer(const Orthanc::ImageAccessor& frame, const DicomFrameConverter& converter, const CoordinateSystem3D& frameSlice, double pixelSpacingX, double pixelSpacingY, bool isFullQuality) : FrameRenderer(frameSlice, pixelSpacingX, pixelSpacingY, isFullQuality), - frame_(frame), + frame_(Orthanc::Image::Clone(frame)), defaultWindowCenter_(converter.GetDefaultWindowCenter()), defaultWindowWidth_(converter.GetDefaultWindowWidth()), photometric_(converter.GetPhotometricInterpretation()) { - if (frame == NULL) + if (frame_.get() == NULL) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); }
--- a/Framework/Layers/GrayscaleFrameRenderer.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/GrayscaleFrameRenderer.h Tue Nov 06 14:21:02 2018 +0100 @@ -38,7 +38,7 @@ virtual CairoSurface* GenerateDisplay(const RenderStyle& style); public: - GrayscaleFrameRenderer(Orthanc::ImageAccessor* frame, // Takes ownership + GrayscaleFrameRenderer(const Orthanc::ImageAccessor& frame, const DicomFrameConverter& converter, const CoordinateSystem3D& frameSlice, double pixelSpacingX,
--- a/Framework/Layers/ILayerSource.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/ILayerSource.h Tue Nov 06 14:21:02 2018 +0100 @@ -67,29 +67,49 @@ } }; - struct ImageReadyMessage : public OriginMessage<MessageType_LayerSource_ImageReady, ILayerSource> + + // TODO: Rename "ImageReadyMessage" as "SliceReadyMessage" + class ImageReadyMessage : public OriginMessage<MessageType_LayerSource_ImageReady, ILayerSource> { - boost::shared_ptr<Orthanc::ImageAccessor> image_; - SliceImageQuality imageQuality_; - const Slice& slice_; + private: + const Orthanc::ImageAccessor& image_; + SliceImageQuality imageQuality_; + const Slice& slice_; + public: ImageReadyMessage(ILayerSource& origin, - boost::shared_ptr<Orthanc::ImageAccessor> image, + const Orthanc::ImageAccessor& image, SliceImageQuality imageQuality, - const Slice& slice - ) - : OriginMessage(origin), - image_(image), - imageQuality_(imageQuality), - slice_(slice) + const Slice& slice) : + OriginMessage(origin), + image_(image), + imageQuality_(imageQuality), + slice_(slice) { } + + const Orthanc::ImageAccessor& GetImage() const + { + return image_; + } + + SliceImageQuality GetImageQuality() const + { + return imageQuality_; + } + + const Slice& GetSlice() const + { + return slice_; + } }; + - ILayerSource(MessageBroker& broker) - : IObservable(broker) - {} - + ILayerSource(MessageBroker& broker) : + IObservable(broker) + { + } + virtual ~ILayerSource() { }
--- a/Framework/Layers/LayerSourceBase.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/LayerSourceBase.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -53,7 +53,7 @@ EmitMessage(ILayerSource::LayerReadyMessage(*this, renderer, slice, isError)); } - void LayerSourceBase::NotifyImageReady(boost::shared_ptr<Orthanc::ImageAccessor> image, + void LayerSourceBase::NotifyImageReady(const Orthanc::ImageAccessor& image, SliceImageQuality imageQuality, const Slice& slice) {
--- a/Framework/Layers/LayerSourceBase.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/LayerSourceBase.h Tue Nov 06 14:21:02 2018 +0100 @@ -43,7 +43,7 @@ const CoordinateSystem3D& slice, bool isError); - void NotifyImageReady(boost::shared_ptr<Orthanc::ImageAccessor> image, + void NotifyImageReady(const Orthanc::ImageAccessor& image, SliceImageQuality imageQuality, const Slice& slice);
--- a/Framework/Layers/OrthancFrameLayerSource.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Layers/OrthancFrameLayerSource.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -52,21 +52,20 @@ void OrthancFrameLayerSource::OnSliceImageReady(const OrthancSlicesLoader::SliceImageReadyMessage& message) { // first notify that the image is ready (targeted to, i.e: an image cache) - LayerSourceBase::NotifyImageReady(message.image_, message.effectiveQuality_, message.slice_); + LayerSourceBase::NotifyImageReady(message.GetImage(), message.GetEffectiveQuality(), message.GetSlice()); // then notify that the layer is ready for render - bool isFull = (message.effectiveQuality_ == SliceImageQuality_FullPng || message.effectiveQuality_ == SliceImageQuality_FullPam); - std::auto_ptr<Orthanc::ImageAccessor> accessor(new Orthanc::ImageAccessor()); - message.image_->GetReadOnlyAccessor(*accessor); + bool isFull = (message.GetEffectiveQuality() == SliceImageQuality_FullPng || + message.GetEffectiveQuality() == SliceImageQuality_FullPam); - LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(accessor.release(), message.slice_, isFull), - message.slice_.GetGeometry(), false); + LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(message.GetImage(), message.GetSlice(), isFull), + message.GetSlice().GetGeometry(), false); } void OrthancFrameLayerSource::OnSliceImageError(const OrthancSlicesLoader::SliceImageErrorMessage& message) { - LayerSourceBase::NotifyLayerReady(NULL, message.slice_.GetGeometry(), true); + LayerSourceBase::NotifyLayerReady(NULL, message.GetSlice().GetGeometry(), true); } OrthancFrameLayerSource::OrthancFrameLayerSource(MessageBroker& broker, OrthancApiClient& orthanc) :
--- a/Framework/SmartLoader.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/SmartLoader.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -74,9 +74,7 @@ { LOG(WARNING) << "ScheduleLayerCreation for CachedSlice (image is loaded): " << slice_->GetOrthancInstanceId(); bool isFull = (effectiveQuality_ == SliceImageQuality_FullPng || effectiveQuality_ == SliceImageQuality_FullPam); - std::auto_ptr<Orthanc::ImageAccessor> accessor(new Orthanc::ImageAccessor()); - image_->GetReadOnlyAccessor(*accessor); - LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(accessor.release(), *slice_, isFull), + LayerSourceBase::NotifyLayerReady(FrameRenderer::CreateRenderer(*image_, *slice_, isFull), slice_->GetGeometry(), false); } else @@ -239,9 +237,9 @@ LOG(WARNING) << "Image ready: " << sliceKeyId; boost::shared_ptr<CachedSlice> cachedSlice(new CachedSlice(IObserver::broker_)); - cachedSlice->image_ = message.image_; - cachedSlice->effectiveQuality_ = message.imageQuality_; - cachedSlice->slice_.reset(message.slice_.Clone()); + cachedSlice->image_.reset(Orthanc::Image::Clone(message.GetImage())); + cachedSlice->effectiveQuality_ = message.GetImageQuality(); + cachedSlice->slice_.reset(message.GetSlice().Clone()); cachedSlice->status_ = CachedSliceStatus_ImageLoaded; cachedSlices_[sliceKeyId] = cachedSlice;
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Toolbox/OrthancSlicesLoader.cpp Tue Nov 06 14:21:02 2018 +0100 @@ -173,17 +173,10 @@ }; void OrthancSlicesLoader::NotifySliceImageSuccess(const Operation& operation, - boost::shared_ptr<Orthanc::ImageAccessor> image) + const Orthanc::ImageAccessor& image) { - if (image.get() == NULL) - { - throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); - } - else - { - OrthancSlicesLoader::SliceImageReadyMessage msg(operation.GetSliceIndex(), operation.GetSlice(), image, operation.GetQuality()); - EmitMessage(msg); - } + OrthancSlicesLoader::SliceImageReadyMessage msg(operation.GetSliceIndex(), operation.GetSlice(), image, operation.GetQuality()); + EmitMessage(msg); } @@ -341,7 +334,7 @@ void OrthancSlicesLoader::ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message) { const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); - boost::shared_ptr<Orthanc::ImageAccessor> image; + std::auto_ptr<Orthanc::ImageAccessor> image; try { @@ -375,18 +368,18 @@ } } - NotifySliceImageSuccess(operation, image); + NotifySliceImageSuccess(operation, *image); } void OrthancSlicesLoader::ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message) { const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); - boost::shared_ptr<Orthanc::ImageAccessor> image; + std::auto_ptr<Orthanc::ImageAccessor> image; try { image.reset(new Orthanc::PamReader); - dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(std::string(reinterpret_cast<const char*>(message.GetAnswer()), message.GetAnswerSize())); + dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); } catch (Orthanc::OrthancException&) { @@ -415,7 +408,7 @@ } } - NotifySliceImageSuccess(operation, image); + NotifySliceImageSuccess(operation, *image); } @@ -461,7 +454,7 @@ } } - boost::shared_ptr<Orthanc::ImageAccessor> reader; + std::auto_ptr<Orthanc::ImageAccessor> reader; { std::string jpeg; @@ -481,7 +474,7 @@ } Orthanc::PixelFormat expectedFormat = - operation.GetSlice().GetConverter().GetExpectedPixelFormat(); + operation.GetSlice().GetConverter().GetExpectedPixelFormat(); if (reader->GetFormat() == Orthanc::PixelFormat_RGB24) // This is a color image { @@ -498,7 +491,7 @@ } else { - NotifySliceImageSuccess(operation, reader); + NotifySliceImageSuccess(operation, *reader); return; } } @@ -518,7 +511,7 @@ } else { - NotifySliceImageSuccess(operation, reader); + NotifySliceImageSuccess(operation, *reader); return; } } @@ -548,8 +541,8 @@ } // Decode a grayscale JPEG 8bpp image coming from the Web viewer - boost::shared_ptr<Orthanc::ImageAccessor> image - (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); + std::auto_ptr<Orthanc::ImageAccessor> image + (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); Orthanc::ImageProcessing::Convert(*image, *reader); reader.reset(); @@ -562,7 +555,7 @@ Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling, true); } - NotifySliceImageSuccess(operation, image); + NotifySliceImageSuccess(operation, *image); } @@ -611,9 +604,9 @@ { // This is the case of RT-DOSE (uint32_t values) - boost::shared_ptr<Orthanc::ImageAccessor> image - (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), - info.GetHeight(), raw)); + std::auto_ptr<Orthanc::ImageAccessor> image + (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), + info.GetHeight(), raw)); // TODO - Only for big endian for (unsigned int y = 0; y < image->GetHeight(); y++) @@ -625,7 +618,7 @@ } } - NotifySliceImageSuccess(operation, image); + NotifySliceImageSuccess(operation, *image); } else if (info.GetBitsAllocated() == 16 && info.GetBitsStored() == 16 && @@ -635,13 +628,13 @@ info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && raw.size() == info.GetWidth() * info.GetHeight() * 2) { - boost::shared_ptr<Orthanc::ImageAccessor> image - (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), - info.GetHeight(), raw)); + std::auto_ptr<Orthanc::ImageAccessor> image + (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), + info.GetHeight(), raw)); // TODO - Big endian ? - NotifySliceImageSuccess(operation, image); + NotifySliceImageSuccess(operation, *image); } else { @@ -764,20 +757,20 @@ switch (slice.GetConverter().GetExpectedPixelFormat()) { - case Orthanc::PixelFormat_RGB24: - uri += "/preview"; - break; + case Orthanc::PixelFormat_RGB24: + uri += "/preview"; + break; - case Orthanc::PixelFormat_Grayscale16: - uri += "/image-uint16"; - break; + case Orthanc::PixelFormat_Grayscale16: + uri += "/image-uint16"; + break; - case Orthanc::PixelFormat_SignedGrayscale16: - uri += "/image-int16"; - break; + case Orthanc::PixelFormat_SignedGrayscale16: + uri += "/image-int16"; + break; - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } orthanc_.GetBinaryAsync(uri, "image/png", @@ -794,20 +787,20 @@ switch (slice.GetConverter().GetExpectedPixelFormat()) { - case Orthanc::PixelFormat_RGB24: - uri += "/preview"; - break; + case Orthanc::PixelFormat_RGB24: + uri += "/preview"; + break; - case Orthanc::PixelFormat_Grayscale16: - uri += "/image-uint16"; - break; + case Orthanc::PixelFormat_Grayscale16: + uri += "/image-uint16"; + break; - case Orthanc::PixelFormat_SignedGrayscale16: - uri += "/image-int16"; - break; + case Orthanc::PixelFormat_SignedGrayscale16: + uri += "/image-int16"; + break; - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } orthanc_.GetBinaryAsync(uri, "image/x-portable-arbitrarymap", @@ -826,20 +819,20 @@ switch (quality) { - case SliceImageQuality_Jpeg50: - value = 50; - break; + case SliceImageQuality_Jpeg50: + value = 50; + break; - case SliceImageQuality_Jpeg90: - value = 90; - break; + case SliceImageQuality_Jpeg90: + value = 90; + break; - case SliceImageQuality_Jpeg95: - value = 95; - break; + case SliceImageQuality_Jpeg95: + value = 95; + break; - default: - throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + default: + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } // This requires the official Web viewer plugin to be installed! @@ -870,14 +863,14 @@ { switch (quality) { - case SliceImageQuality_FullPng: - ScheduleSliceImagePng(slice, index); - break; - case SliceImageQuality_FullPam: - ScheduleSliceImagePam(slice, index); - break; - default: - ScheduleSliceImageJpeg(slice, index, quality); + case SliceImageQuality_FullPng: + ScheduleSliceImagePng(slice, index); + break; + case SliceImageQuality_FullPam: + ScheduleSliceImagePam(slice, index); + break; + default: + ScheduleSliceImageJpeg(slice, index, quality); } } else
--- a/Framework/Toolbox/OrthancSlicesLoader.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/Toolbox/OrthancSlicesLoader.h Tue Nov 06 14:21:02 2018 +0100 @@ -21,13 +21,13 @@ #pragma once -#include "IWebService.h" -#include "SlicesSorter.h" +#include "../Messages/IObservable.h" #include "../StoneEnumerations.h" -#include "../Messages/IObservable.h" -#include <boost/shared_ptr.hpp> +#include "IWebService.h" #include "OrthancApiClient.h" -#include "Core/Images/Image.h" +#include "SlicesSorter.h" + +#include <Core/Images/Image.h> namespace OrthancStone @@ -39,41 +39,78 @@ typedef OriginMessage<MessageType_SliceLoader_GeometryReady, OrthancSlicesLoader> SliceGeometryReadyMessage; typedef OriginMessage<MessageType_SliceLoader_GeometryError, OrthancSlicesLoader> SliceGeometryErrorMessage; - struct SliceImageReadyMessage : public BaseMessage<MessageType_SliceLoader_ImageReady> + class SliceImageReadyMessage : public BaseMessage<MessageType_SliceLoader_ImageReady> { - unsigned int sliceIndex_; - const Slice& slice_; - boost::shared_ptr<Orthanc::ImageAccessor> image_; - SliceImageQuality effectiveQuality_; + private: + unsigned int sliceIndex_; + const Slice& slice_; + const Orthanc::ImageAccessor& image_; + SliceImageQuality effectiveQuality_; + public: SliceImageReadyMessage(unsigned int sliceIndex, const Slice& slice, - boost::shared_ptr<Orthanc::ImageAccessor> image, - SliceImageQuality effectiveQuality) - : BaseMessage(), - sliceIndex_(sliceIndex), - slice_(slice), - image_(image), - effectiveQuality_(effectiveQuality) + const Orthanc::ImageAccessor& image, + SliceImageQuality effectiveQuality) : + sliceIndex_(sliceIndex), + slice_(slice), + image_(image), + effectiveQuality_(effectiveQuality) { } - }; + + unsigned int GetSliceIndex() const + { + return sliceIndex_; + } + + const Slice& GetSlice() const + { + return slice_; + } - struct SliceImageErrorMessage : public BaseMessage<MessageType_SliceLoader_ImageError> + const Orthanc::ImageAccessor& GetImage() const + { + return image_; + } + + SliceImageQuality GetEffectiveQuality() const + { + return effectiveQuality_; + } + }; + + + class SliceImageErrorMessage : public BaseMessage<MessageType_SliceLoader_ImageError> { - const Slice& slice_; - unsigned int sliceIndex_; - SliceImageQuality effectiveQuality_; + private: + const Slice& slice_; + unsigned int sliceIndex_; + SliceImageQuality effectiveQuality_; + public: SliceImageErrorMessage(unsigned int sliceIndex, const Slice& slice, - SliceImageQuality effectiveQuality) - : BaseMessage(), - slice_(slice), - sliceIndex_(sliceIndex), - effectiveQuality_(effectiveQuality) + SliceImageQuality effectiveQuality) : + slice_(slice), + sliceIndex_(sliceIndex), + effectiveQuality_(effectiveQuality) { } + unsigned int GetSliceIndex() const + { + return sliceIndex_; + } + + const Slice& GetSlice() const + { + return slice_; + } + + SliceImageQuality GetEffectiveQuality() const + { + return effectiveQuality_; + } }; private: @@ -102,8 +139,8 @@ SlicesSorter slices_; void NotifySliceImageSuccess(const Operation& operation, - boost::shared_ptr<Orthanc::ImageAccessor> image); - + const Orthanc::ImageAccessor& image); + void NotifySliceImageError(const Operation& operation); void OnGeometryError(const OrthancApiClient::HttpErrorMessage& message);
--- a/Framework/dev.h Mon Nov 05 16:18:27 2018 +0100 +++ b/Framework/dev.h Tue Nov 06 14:21:02 2018 +0100 @@ -176,12 +176,12 @@ virtual void OnSliceImageReady(const OrthancSlicesLoader& loader, unsigned int sliceIndex, const Slice& slice, - const boost::shared_ptr<Orthanc::ImageAccessor>& image, + const Orthanc::ImageAccessor& image, SliceImageQuality quality) { { ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex); - Orthanc::ImageProcessing::Copy(writer.GetAccessor(), *image); + Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image); } SlicedVolumeBase::NotifySliceChange(sliceIndex, slice); @@ -203,30 +203,38 @@ { switch (message.GetType()) { - case MessageType_SliceLoader_GeometryReady: - OnSliceGeometryReady(dynamic_cast<const OrthancSlicesLoader&>(from)); - case MessageType_SliceLoader_GeometryError: - { - LOG(ERROR) << "Unable to download a volume image"; - SlicedVolumeBase::NotifyGeometryError(); - }; break; - case MessageType_SliceLoader_ImageReady: - { - const OrthancSlicesLoader::SliceImageReadyMessage& msg = dynamic_cast<const OrthancSlicesLoader::SliceImageReadyMessage&>(message); - OnSliceImageReady(dynamic_cast<const OrthancSlicesLoader&>(from), - msg.sliceIndex_, - msg.slice_, - msg.image_, - msg.effectiveQuality_); - }; break; - case MessageType_SliceLoader_ImageError: - { - const OrthancSlicesLoader::SliceImageErrorMessage& msg = dynamic_cast<const OrthancSlicesLoader::SliceImageErrorMessage&>(message); - LOG(ERROR) << "Cannot download slice " << msg.sliceIndex_ << " in a volume image"; - ScheduleSliceDownload(); - }; break; - default: - VLOG("unhandled message type" << message.GetType()); + case MessageType_SliceLoader_GeometryReady: + OnSliceGeometryReady(dynamic_cast<const OrthancSlicesLoader&>(from)); + break; + + case MessageType_SliceLoader_GeometryError: + LOG(ERROR) << "Unable to download a volume image"; + SlicedVolumeBase::NotifyGeometryError(); + break; + + case MessageType_SliceLoader_ImageReady: + { + const OrthancSlicesLoader::SliceImageReadyMessage& msg = + dynamic_cast<const OrthancSlicesLoader::SliceImageReadyMessage&>(message); + OnSliceImageReady(dynamic_cast<const OrthancSlicesLoader&>(from), + msg.GetSliceIndex(), + msg.GetSlice(), + msg.GetImage(), + msg.GetEffectiveQuality()); + break; + } + + case MessageType_SliceLoader_ImageError: + { + const OrthancSlicesLoader::SliceImageErrorMessage& msg = + dynamic_cast<const OrthancSlicesLoader::SliceImageErrorMessage&>(message); + LOG(ERROR) << "Cannot download slice " << msg.GetSliceIndex() << " in a volume image"; + ScheduleSliceDownload(); + break; + } + + default: + VLOG("unhandled message type" << message.GetType()); } } @@ -650,9 +658,9 @@ std::auto_ptr<Slice> slice(geometry.GetSlice(closest)); LayerSourceBase::NotifyLayerReady( - FrameRenderer::CreateRenderer(frame.release(), *slice, isFullQuality), - //new SliceOutlineRenderer(slice), - slice->GetGeometry(), false); + FrameRenderer::CreateRenderer(*frame, *slice, isFullQuality), + //new SliceOutlineRenderer(slice), + slice->GetGeometry(), false); return; } }