# HG changeset patch # User Sebastien Jodogne # Date 1671813012 -3600 # Node ID f36de3ba43c8684262a1e7e7f52818819ca64625 # Parent 0d8a07e98cb80439ff3b4874a44368febb5622a5 added button "Stretch to whole range" in the "Change windowing" menu diff -r 0d8a07e98cb8 -r f36de3ba43c8 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Tue Dec 20 08:51:43 2022 +0100 +++ b/Applications/StoneWebViewer/NEWS Fri Dec 23 17:30:12 2022 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* New button "Stretch to whole range" in the "Change windowing" menu + Version 2.5 (2022-12-05) ======================== diff -r 0d8a07e98cb8 -r f36de3ba43c8 Applications/StoneWebViewer/WebApplication/app.js --- a/Applications/StoneWebViewer/WebApplication/app.js Tue Dec 20 08:51:43 2022 +0100 +++ b/Applications/StoneWebViewer/WebApplication/app.js Fri Dec 23 17:30:12 2022 +0100 @@ -1034,6 +1034,14 @@ } }, + StretchWindowing: function(center, width) { + this.showWindowing = false; + var canvas = this.GetActiveCanvas(); + if (canvas != '') { + stone.StretchWindowing(canvas); + } + }, + InvertContrast: function() { var canvas = this.GetActiveCanvas(); if (canvas != '') { diff -r 0d8a07e98cb8 -r f36de3ba43c8 Applications/StoneWebViewer/WebApplication/index.html --- a/Applications/StoneWebViewer/WebApplication/index.html Tue Dec 20 08:51:43 2022 +0100 +++ b/Applications/StoneWebViewer/WebApplication/index.html Fri Dec 23 17:30:12 2022 +0100 @@ -476,6 +476,11 @@ {{ preset.name }} ({{ preset.info }}) +
  • + + Stretch to whole range + +
  • diff -r 0d8a07e98cb8 -r f36de3ba43c8 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Tue Dec 20 08:51:43 2022 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Dec 23 17:30:12 2022 +0100 @@ -3094,6 +3094,34 @@ } } + void StretchWindowing() + { + float minValue, maxValue; + + { + std::unique_ptr lock(viewport_->Lock()); + + if (!lock->GetController().GetScene().HasLayer(LAYER_TEXTURE) || + lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() != + OrthancStone::ISceneLayer::Type_FloatTexture) + { + return; + } + + const Orthanc::ImageAccessor& texture = + dynamic_cast( + lock->GetController().GetScene().GetLayer(LAYER_TEXTURE)).GetTexture(); + if (texture.GetFormat() != Orthanc::PixelFormat_Float32) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + + Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, texture); + } + + SetWindowing((minValue + maxValue) / 2.0f, maxValue - minValue); + } + void FlipX() { { @@ -4271,6 +4299,17 @@ EMSCRIPTEN_KEEPALIVE + void StretchWindowing(const char* canvas) + { + try + { + GetViewport(canvas)->StretchWindowing(); + } + EXTERN_CATCH_EXCEPTIONS; + } + + + EMSCRIPTEN_KEEPALIVE void InvertContrast(const char* canvas) { try