Mercurial > hg > orthanc-stone
changeset 316:ce48c3b3b0e9
fix for new ImageAccessor API
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 08 Oct 2018 12:45:27 +0200 |
parents | 348e00b837b9 |
children | 1c2cf9216579 |
files | Applications/Samples/SingleVolumeApplication.h Applications/Sdl/SdlCairoSurface.cpp Framework/Layers/ColorFrameRenderer.cpp Framework/Layers/GrayscaleFrameRenderer.cpp Framework/Toolbox/OrthancSlicesLoader.cpp Framework/Viewport/CairoSurface.cpp Framework/Viewport/CairoSurface.h Framework/Viewport/WidgetViewport.cpp Framework/Volumes/ImageBuffer3D.cpp Framework/Volumes/ImageBuffer3D.h Framework/Widgets/CairoWidget.cpp Framework/Widgets/LayoutWidget.cpp |
diffstat | 12 files changed, 71 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Samples/SingleVolumeApplication.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Applications/Samples/SingleVolumeApplication.h Mon Oct 08 12:45:27 2018 +0200 @@ -174,7 +174,7 @@ std::auto_ptr<LayerWidget> widget(new LayerWidget); -#if 0 +#if 1 std::auto_ptr<OrthancVolumeImage> volume(new OrthancVolumeImage(context.GetWebService(), true)); if (series.empty()) { @@ -190,6 +190,15 @@ context.AddInteractor(new Interactor(*volume, *widget, projection, 0)); context.AddSlicedVolume(volume.release()); + if (1) + { + RenderStyle s; + //s.drawGrid_ = true; + s.alpha_ = 1; + s.windowing_ = ImageWindowing_Bone; + widget->SetLayerStyle(0, s); + } + else { RenderStyle s; s.alpha_ = 1;
--- a/Applications/Sdl/SdlCairoSurface.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Applications/Sdl/SdlCairoSurface.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -81,7 +81,8 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); } - Orthanc::ImageAccessor target = cairoSurface_->GetAccessor(); + Orthanc::ImageAccessor target; + cairoSurface_->GetWriteableAccessor(target); if (viewport.Render(target)) {
--- a/Framework/Layers/ColorFrameRenderer.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Layers/ColorFrameRenderer.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -30,7 +30,9 @@ { std::auto_ptr<CairoSurface> display(new CairoSurface(frame_->GetWidth(), frame_->GetHeight())); - Orthanc::ImageAccessor target = display->GetAccessor(); + Orthanc::ImageAccessor target; + display->GetWriteableAccessor(target); + Orthanc::ImageProcessing::Convert(target, *frame_); return display.release();
--- a/Framework/Layers/GrayscaleFrameRenderer.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Layers/GrayscaleFrameRenderer.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -52,7 +52,9 @@ lut = reinterpret_cast<const uint8_t*>(Orthanc::EmbeddedResources::GetFileResourceBuffer(style.lut_)); } - Orthanc::ImageAccessor target = result->GetAccessor(); + Orthanc::ImageAccessor target; + result->GetWriteableAccessor(target); + const unsigned int width = target.GetWidth(); const unsigned int height = target.GetHeight();
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Toolbox/OrthancSlicesLoader.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -626,9 +626,7 @@ } - class StringImage : - public Orthanc::ImageAccessor, - public boost::noncopyable + class StringImage : public Orthanc::ImageAccessor { private: std::string buffer_;
--- a/Framework/Viewport/CairoSurface.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/CairoSurface.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -105,24 +105,22 @@ void CairoSurface::Copy(const CairoSurface& other) { - Orthanc::ImageAccessor source = other.GetConstAccessor(); - Orthanc::ImageAccessor target = GetAccessor(); + Orthanc::ImageAccessor source, target; + other.GetReadOnlyAccessor(source); + GetWriteableAccessor(target); + Orthanc::ImageProcessing::Copy(target, source); } - Orthanc::ImageAccessor CairoSurface::GetConstAccessor() const + void CairoSurface::GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const { - Orthanc::ImageAccessor accessor; - accessor.AssignReadOnly(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); - return accessor; + target.AssignReadOnly(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); } + - - Orthanc::ImageAccessor CairoSurface::GetAccessor() + void CairoSurface::GetWriteableAccessor(Orthanc::ImageAccessor& target) { - Orthanc::ImageAccessor accessor; - accessor.AssignWritable(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); - return accessor; + target.AssignWritable(Orthanc::PixelFormat_BGRA32, width_, height_, pitch_, buffer_); } }
--- a/Framework/Viewport/CairoSurface.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/CairoSurface.h Mon Oct 08 12:45:27 2018 +0200 @@ -98,8 +98,8 @@ return surface_; } - Orthanc::ImageAccessor GetConstAccessor() const; + void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const; - Orthanc::ImageAccessor GetAccessor(); + void GetWriteableAccessor(Orthanc::ImageAccessor& target); }; }
--- a/Framework/Viewport/WidgetViewport.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Viewport/WidgetViewport.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -107,8 +107,9 @@ { return false; } - - Orthanc::ImageAccessor background = background_.GetAccessor(); + + Orthanc::ImageAccessor background; + background_.GetWriteableAccessor(background); if (backgroundChanged_ && !centralWidget_->Render(background))
--- a/Framework/Volumes/ImageBuffer3D.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Volumes/ImageBuffer3D.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -29,53 +29,47 @@ namespace OrthancStone { - Orthanc::ImageAccessor ImageBuffer3D::GetAxialSliceAccessor(unsigned int slice, - bool readOnly) const + void ImageBuffer3D::GetAxialSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const { if (slice >= depth_) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - Orthanc::ImageAccessor accessor; - if (readOnly) { - accessor.AssignReadOnly(format_, width_, height_, image_.GetPitch(), - image_.GetConstRow(height_ * (depth_ - 1 - slice))); + target.AssignReadOnly(format_, width_, height_, image_.GetPitch(), + image_.GetConstRow(height_ * (depth_ - 1 - slice))); } else { - accessor.AssignWritable(format_, width_, height_, image_.GetPitch(), - image_.GetRow(height_ * (depth_ - 1 - slice))); + target.AssignWritable(format_, width_, height_, image_.GetPitch(), + image_.GetRow(height_ * (depth_ - 1 - slice))); } - - return accessor; } - Orthanc::ImageAccessor ImageBuffer3D::GetCoronalSliceAccessor(unsigned int slice, - bool readOnly) const + void ImageBuffer3D::GetCoronalSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const { if (slice >= height_) { throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); } - Orthanc::ImageAccessor accessor; - if (readOnly) { - accessor.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_, - image_.GetConstRow(slice)); + target.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_, + image_.GetConstRow(slice)); } else { - accessor.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_, - image_.GetRow(slice)); + target.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_, + image_.GetRow(slice)); } - - return accessor; } @@ -360,16 +354,16 @@ switch (projection) { case VolumeProjection_Axial: - accessor_ = that.GetAxialSliceAccessor(slice, true); + that.GetAxialSliceAccessor(accessor_, slice, true); break; case VolumeProjection_Coronal: - accessor_ = that.GetCoronalSliceAccessor(slice, true); + that.GetCoronalSliceAccessor(accessor_, slice, true); break; case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - accessor_ = *sagittal_; + sagittal_->GetReadOnlyAccessor(accessor_); break; default: @@ -404,16 +398,16 @@ switch (projection) { case VolumeProjection_Axial: - accessor_ = that.GetAxialSliceAccessor(slice, false); + that.GetAxialSliceAccessor(accessor_, slice, false); break; case VolumeProjection_Coronal: - accessor_ = that.GetCoronalSliceAccessor(slice, false); + that.GetCoronalSliceAccessor(accessor_, slice, false); break; case VolumeProjection_Sagittal: sagittal_.reset(that.ExtractSagittalSlice(slice)); - accessor_ = *sagittal_; + sagittal_->GetWriteableAccessor(accessor_); break; default:
--- a/Framework/Volumes/ImageBuffer3D.h Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Volumes/ImageBuffer3D.h Mon Oct 08 12:45:27 2018 +0200 @@ -48,11 +48,13 @@ void ExtendImageRange(const Orthanc::ImageAccessor& slice); - Orthanc::ImageAccessor GetAxialSliceAccessor(unsigned int slice, - bool readOnly) const; - - Orthanc::ImageAccessor GetCoronalSliceAccessor(unsigned int slice, - bool readOnly) const; + void GetAxialSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const; + + void GetCoronalSliceAccessor(Orthanc::ImageAccessor& target, + unsigned int slice, + bool readOnly) const; Orthanc::Image* ExtractSagittalSlice(unsigned int slice) const;
--- a/Framework/Widgets/CairoWidget.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Widgets/CairoWidget.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -59,7 +59,9 @@ if (RenderCairo(context)) { - Orthanc::ImageProcessing::Copy(target, surface_.GetAccessor()); + Orthanc::ImageAccessor surface; + surface_.GetReadOnlyAccessor(surface); + Orthanc::ImageProcessing::Copy(target, surface); return true; } else @@ -82,7 +84,8 @@ } else { - Orthanc::ImageAccessor accessor = surface_.GetAccessor(); + Orthanc::ImageAccessor accessor; + surface_.GetWriteableAccessor(accessor); Orthanc::ImageProcessing::Copy(accessor, target); CairoContext context(surface_);
--- a/Framework/Widgets/LayoutWidget.cpp Mon Oct 01 10:46:26 2018 +0200 +++ b/Framework/Widgets/LayoutWidget.cpp Mon Oct 08 12:45:27 2018 +0200 @@ -57,7 +57,8 @@ virtual void Render(Orthanc::ImageAccessor& surface) { - Orthanc::ImageAccessor accessor = surface.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + surface.GetRegion(accessor, left_, top_, width_, height_); tracker_->Render(accessor); } @@ -142,7 +143,8 @@ } else { - Orthanc::ImageAccessor accessor = target.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + target.GetRegion(accessor, left_, top_, width_, height_); return widget_->Render(accessor); } } @@ -173,7 +175,8 @@ { if (Contains(x, y)) { - Orthanc::ImageAccessor accessor = target.GetRegion(left_, top_, width_, height_); + Orthanc::ImageAccessor accessor; + target.GetRegion(accessor, left_, top_, width_, height_); widget_->RenderMouseOver(accessor, x - left_, y - top_); }