Mercurial > hg > orthanc-stone
diff Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1996:6e4ef6e3b2bf
linear interpolation of images can be turned off in the user preferences
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Nov 2022 19:41:03 +0100 |
parents | 317a53d4fdc6 |
children | 1fa3f484008e |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Nov 01 19:04:34 2022 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Nov 01 19:41:03 2022 +0100 @@ -2022,6 +2022,8 @@ // the center of the top-left pixel boost::shared_ptr<OrthancStone::AnnotationsSceneLayer> stoneAnnotations_; + bool linearInterpolation_; + void ScheduleNextPrefetch() { @@ -2159,7 +2161,7 @@ assert(layer.get() != NULL); - layer->SetLinearInterpolation(true); + layer->SetLinearInterpolation(linearInterpolation_); double pixelSpacingX, pixelSpacingY; @@ -2213,6 +2215,7 @@ if (accessor.IsValid()) { overlay.reset(accessor.CreateTexture()); + overlay->SetLinearInterpolation(false); } } @@ -2507,7 +2510,8 @@ const OrthancStone::DicomSource& source, const std::string& canvas, boost::shared_ptr<FramesCache> cache, - bool softwareRendering) : + bool softwareRendering, + bool linearInterpolation) : context_(context), source_(source), framesCache_(cache), @@ -2519,7 +2523,8 @@ centralPhysicalWidth_(1), centralPhysicalHeight_(1), centralPixelSpacingX_(1), - centralPixelSpacingY_(1) + centralPixelSpacingY_(1), + linearInterpolation_(linearInterpolation) { if (!framesCache_) { @@ -2700,10 +2705,11 @@ const OrthancStone::DicomSource& source, const std::string& canvas, boost::shared_ptr<FramesCache> cache, - bool softwareRendering) + bool softwareRendering, + bool linearInterpolation) { boost::shared_ptr<ViewerViewport> viewport( - new ViewerViewport(context, source, canvas, cache, softwareRendering)); + new ViewerViewport(context, source, canvas, cache, softwareRendering, linearInterpolation)); { std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(context.Lock()); @@ -3420,6 +3426,15 @@ } } } + + void SetLinearInterpolation(bool linearInterpolation) + { + if (linearInterpolation_ != linearInterpolation) + { + linearInterpolation_ = linearInterpolation; + Redraw(); + } + } }; @@ -3689,6 +3704,7 @@ static boost::shared_ptr<OrthancStone::WebAssemblyLoadersContext> context_; static std::string stringBuffer_; static bool softwareRendering_ = false; +static bool linearInterpolation_ = true; static WebViewerAction leftButtonAction_ = WebViewerAction_Windowing; static WebViewerAction middleButtonAction_ = WebViewerAction_Pan; static WebViewerAction rightButtonAction_ = WebViewerAction_Zoom; @@ -3735,7 +3751,7 @@ if (found == allViewports_.end()) { boost::shared_ptr<ViewerViewport> viewport( - ViewerViewport::Create(*context_, source_, canvas, framesCache_, softwareRendering_)); + ViewerViewport::Create(*context_, source_, canvas, framesCache_, softwareRendering_, linearInterpolation_)); viewport->SetMouseButtonActions(leftButtonAction_, middleButtonAction_, rightButtonAction_); viewport->AcquireObserver(new WebAssemblyObserver); viewport->SetOsiriXAnnotations(osiriXAnnotations_); @@ -4254,6 +4270,23 @@ EMSCRIPTEN_KEEPALIVE + void SetLinearInterpolation(int linearInterpolation) + { + linearInterpolation_ = linearInterpolation; + + try + { + for (Viewports::iterator it = allViewports_.begin(); it != allViewports_.end(); ++it) + { + assert(it->second != NULL); + it->second->SetLinearInterpolation(linearInterpolation); + } + } + EXTERN_CATCH_EXCEPTIONS; + } + + + EMSCRIPTEN_KEEPALIVE void SetMouseButtonActions(int leftAction, int middleAction, int rightAction)