Mercurial > hg > orthanc-stone
diff Applications/StoneWebViewer/WebApplication/app.js @ 1603:595c0952ef7e
focusing on osirix annotations in Stone Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 28 Oct 2020 18:49:01 +0100 |
parents | 4fb8fdf03314 |
children | 787db80a5a1b |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebApplication/app.js Wed Oct 28 16:35:45 2020 +0100 +++ b/Applications/StoneWebViewer/WebApplication/app.js Wed Oct 28 18:49:01 2020 +0100 @@ -302,6 +302,13 @@ // It is necessary to use ".toString()" for Microsoft Edge Legacy (*) event.dataTransfer.setData('seriesIndex', seriesIndex.toString()); }, + + SetViewportSeriesInstanceUid: function(viewportIndex, seriesInstanceUid) { + if (seriesInstanceUid in this.seriesIndex) { + this.SetViewportSeries(viewportIndex, this.seriesIndex[seriesInstanceUid]); + + } + }, SetViewportSeries: function(viewportIndex, seriesIndex) { var series = this.series[seriesIndex]; @@ -507,7 +514,20 @@ SetMouseButtonActions: function(left, middle, right) { this.mouseActionsVisible = false; stone.SetMouseButtonActions(left, middle, right); - } + }, + + LoadOsiriXAnnotations: function(xml, clearPrevious) + { + if (stone.LoadOsiriXAnnotations(xml, clearPrevious)) { + var seriesInstanceUid = stone.GetStringBuffer(); + + this.SetViewportLayout('1x1'); + this.leftVisible = false; + this.SetViewportSeriesInstanceUid(1, seriesInstanceUid); + + stone.FocusFirstOsiriXAnnotation('canvas1'); + } + } }, mounted: function() { @@ -548,31 +568,6 @@ app.leftMode = 'full'; } } - - - - // TODO - TEST - axios.get('length.xml') - .then(function (response) { - stone.LoadOsiriXAnnotations(response.data, false); - }); - - axios.get('angle.xml') - .then(function (response) { - stone.LoadOsiriXAnnotations(response.data, false); - }); - - axios.get('arrow.xml') - .then(function (response) { - stone.LoadOsiriXAnnotations(response.data, false); - }); - - axios.get('text.xml') - .then(function (response) { - stone.LoadOsiriXAnnotations(response.data, false); - }); - - }); @@ -711,3 +706,45 @@ // Disable the selection of text using the mouse document.onselectstart = new Function ('return false'); + + + + + + + +//var expectedOrigin = 'http://localhost:8042'; +var expectedOrigin = ''; // TODO - INSECURE - CONFIGURATION + +window.addEventListener('message', function(e) { + if (expectedOrigin != '' && + e.origin !== expectedOrigin) { + alert('Bad origin for the message'); + return; + } + + if (e.data.type == 'show-osirix-annotations') { + app.LoadOsiriXAnnotations(e.data.xml, true /* clear previous annotations */); + } else { + alert('Unknown message type: ' + e.data.type); + } +}); + + +function Test() +{ + var s = [ 'length.xml', 'arrow.xml', 'text.xml', 'angle.xml' ]; + + for (var i = 0; i < s.length; i++) { + axios.get(s[i]) + .then(function (response) { + //var targetOrigin = 'http://localhost:8000'; + var targetOrigin = '*'; // TODO - INSECURE + + window.postMessage({ + 'type': 'show-osirix-annotations', + 'xml': response.data + }, targetOrigin); + }); + } +}