Mercurial > hg > orthanc-stone
changeset 2030:f36de3ba43c8
added button "Stretch to whole range" in the "Change windowing" menu
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Dec 2022 17:30:12 +0100 |
parents | 0d8a07e98cb8 |
children | a56f7ed0cdf9 b2738d7a388d |
files | Applications/StoneWebViewer/NEWS Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/index.html Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp |
diffstat | 4 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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) ========================
--- 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 != '') {
--- 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 }} <small>({{ preset.info }})</small> </a> </li> + <li class="wvToolbar__windowingPresetListItem"> + <a href="#" v-on:click="StretchWindowing()"> + Stretch to whole range + </a> + </li> <li v-for="preset in globalConfiguration.WindowingPresets" class="wvToolbar__windowingPresetListItem"> <a href="#" v-on:click="SetWindowing(preset.WindowCenter, preset.WindowWidth)">
--- 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<OrthancStone::IViewport::ILock> 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<OrthancStone::FloatTextureSceneLayer&>( + 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