# HG changeset patch # User Sebastien Jodogne # Date 1597412101 -7200 # Node ID a4d82f1bcb102f39a66d6293be09791dc24af455 # Parent c54bc5bffd01b2ad09403dc74ca4608b983bfd04 user preferences: not for diagnostic use, software rendering diff -r c54bc5bffd01 -r a4d82f1bcb10 Applications/StoneWebViewer/WebApplication/app.js --- a/Applications/StoneWebViewer/WebApplication/app.js Thu Aug 13 22:05:13 2020 +0200 +++ b/Applications/StoneWebViewer/WebApplication/app.js Fri Aug 14 15:35:01 2020 +0200 @@ -103,11 +103,18 @@ ready: false, leftMode: 'grid', // Can be 'small', 'grid' or 'full' leftVisible: true, - showWarning: false, viewportLayoutButtonsVisible: false, activeViewport: 0, showInfo: true, showReferenceLines: true, + + modalWarning: false, + modalNotDiagnostic: false, + modalPreferences: false, + + // User preferences (stored in the local storage) + settingNotDiagnostic: true, + settingSoftwareRendering: false, viewport1Width: '100%', viewport1Height: '100%', @@ -177,6 +184,12 @@ }, showReferenceLines: function(newVal, oldVal) { stone.ShowReferenceLines(newVal ? 1 : 0); + }, + settingNotDiagnostic: function(newVal, oldVal) { + localStorage.settingNotDiagnostic = (newVal ? '1' : '0'); + }, + settingSoftwareRendering: function(newVal, oldVal) { + localStorage.settingSoftwareRendering = (newVal ? '1' : '0'); } }, methods: { @@ -451,11 +464,29 @@ if (canvas != '') { stone.InvertContrast(canvas); } + }, + + ApplyPreferences() { + this.modalPreferences = false; + + if ((stone.IsSoftwareRendering() != 0) != this.settingSoftwareRendering) { + document.location.reload(); + } } }, mounted: function() { this.SetViewportLayout('1x1'); + + if (localStorage.settingNotDiagnostic) { + this.settingNotDiagnostic = (localStorage.settingNotDiagnostic == '1'); + } + + if (localStorage.settingSoftwareRendering) { + this.settingSoftwareRendering = (localStorage.settingSoftwareRendering == '1'); + } + + this.modalNotDiagnostic = this.settingNotDiagnostic; } }); @@ -464,6 +495,7 @@ window.addEventListener('StoneInitialized', function() { stone.Setup(Module); stone.SetOrthancRoot('..', true); + stone.SetSoftwareRendering(localStorage.settingSoftwareRendering == '1'); console.warn('Native Stone properly intialized'); var study = getParameterFromUrl('study'); @@ -565,7 +597,7 @@ // Enable support for tooltips in Bootstrap //$('[data-toggle="tooltip"]').tooltip(); - //app.showWarning = true; + //app.modalWarning = true; $('#windowing-popover').popover({ diff -r c54bc5bffd01 -r a4d82f1bcb10 Applications/StoneWebViewer/WebApplication/index.html --- a/Applications/StoneWebViewer/WebApplication/index.html Thu Aug 13 22:05:13 2020 +0200 +++ b/Applications/StoneWebViewer/WebApplication/index.html Fri Aug 14 15:35:01 2020 +0200 @@ -41,7 +41,7 @@
-
+

Warning!

@@ -53,7 +53,55 @@
- + +
+
+ + +
+
+ +

Warning!

+

+ This viewer is not suitable for diagnostic usage. +

+ +
+ + +
+
+
+
+ +
+
+ + +
+
+ +

Preferences

+ +
+ + +
+ +
+ + +
+
+
+
+
@@ -106,7 +154,7 @@
-

For patients, teachers and researchers.

+
@@ -279,6 +327,13 @@
+ +
+ +
diff -r c54bc5bffd01 -r a4d82f1bcb10 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Aug 13 22:05:13 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Aug 14 15:35:01 2020 +0200 @@ -1522,11 +1522,10 @@ ViewerViewport(OrthancStone::ILoadersContext& context, const OrthancStone::DicomSource& source, const std::string& canvas, - boost::shared_ptr cache) : + boost::shared_ptr cache, + bool softwareRendering) : context_(context), source_(source), - viewport_(OrthancStone::WebGLViewport::Create(canvas)), - //viewport_(OrthancStone::WebAssemblyCairoViewport::Create(canvas)), cache_(cache), fitNextContent_(true), isCtrlDown_(false) @@ -1535,6 +1534,17 @@ { throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); } + + if (softwareRendering) + { + LOG(INFO) << "Creating Cairo viewport in canvas: " << canvas; + viewport_ = OrthancStone::WebAssemblyCairoViewport::Create(canvas); + } + else + { + LOG(INFO) << "Creating WebGL viewport in canvas: " << canvas; + viewport_ = OrthancStone::WebGLViewport::Create(canvas); + } emscripten_set_wheel_callback(viewport_->GetCanvasCssSelector().c_str(), this, true, OnWheel); emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, this, false, OnKey); @@ -1598,10 +1608,11 @@ static boost::shared_ptr Create(OrthancStone::ILoadersContext::ILock& lock, const OrthancStone::DicomSource& source, const std::string& canvas, - boost::shared_ptr cache) + boost::shared_ptr cache, + bool softwareRendering) { boost::shared_ptr viewport( - new ViewerViewport(lock.GetContext(), source, canvas, cache)); + new ViewerViewport(lock.GetContext(), source, canvas, cache, softwareRendering)); viewport->loader_ = OrthancStone::DicomResourcesLoader::Create(lock); viewport->Register( @@ -1910,6 +1921,7 @@ static boost::shared_ptr cache_; static boost::shared_ptr context_; static std::string stringBuffer_; +static bool softwareRendering_ = false; @@ -1954,7 +1966,8 @@ if (found == allViewports_.end()) { std::unique_ptr lock(context_->Lock()); - boost::shared_ptr viewport(ViewerViewport::Create(*lock, source_, canvas, cache_)); + boost::shared_ptr viewport( + ViewerViewport::Create(*lock, source_, canvas, cache_, softwareRendering_)); viewport->AcquireObserver(new WebAssemblyObserver); allViewports_[canvas] = viewport; return viewport; @@ -2269,4 +2282,18 @@ } EXTERN_CATCH_EXCEPTIONS; } + + + EMSCRIPTEN_KEEPALIVE + void SetSoftwareRendering(int softwareRendering) + { + softwareRendering_ = softwareRendering; + } + + + EMSCRIPTEN_KEEPALIVE + int IsSoftwareRendering() + { + return softwareRendering_; + } }