diff Applications/StoneWebViewer/WebApplication/app.js @ 1552:a4d82f1bcb10

user preferences: not for diagnostic use, software rendering
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Aug 2020 15:35:01 +0200
parents bf195fc0797e
children 6d14ed6163b1
line wrap: on
line diff
--- 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({