Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
1602:b2941196cabf | 1603:595c0952ef7e |
---|---|
300 | 300 |
301 SeriesDragStart: function(event, seriesIndex) { | 301 SeriesDragStart: function(event, seriesIndex) { |
302 // It is necessary to use ".toString()" for Microsoft Edge Legacy (*) | 302 // It is necessary to use ".toString()" for Microsoft Edge Legacy (*) |
303 event.dataTransfer.setData('seriesIndex', seriesIndex.toString()); | 303 event.dataTransfer.setData('seriesIndex', seriesIndex.toString()); |
304 }, | 304 }, |
305 | |
306 SetViewportSeriesInstanceUid: function(viewportIndex, seriesInstanceUid) { | |
307 if (seriesInstanceUid in this.seriesIndex) { | |
308 this.SetViewportSeries(viewportIndex, this.seriesIndex[seriesInstanceUid]); | |
309 | |
310 } | |
311 }, | |
305 | 312 |
306 SetViewportSeries: function(viewportIndex, seriesIndex) { | 313 SetViewportSeries: function(viewportIndex, seriesIndex) { |
307 var series = this.series[seriesIndex]; | 314 var series = this.series[seriesIndex]; |
308 | 315 |
309 if (viewportIndex == 1) { | 316 if (viewportIndex == 1) { |
505 }, | 512 }, |
506 | 513 |
507 SetMouseButtonActions: function(left, middle, right) { | 514 SetMouseButtonActions: function(left, middle, right) { |
508 this.mouseActionsVisible = false; | 515 this.mouseActionsVisible = false; |
509 stone.SetMouseButtonActions(left, middle, right); | 516 stone.SetMouseButtonActions(left, middle, right); |
510 } | 517 }, |
518 | |
519 LoadOsiriXAnnotations: function(xml, clearPrevious) | |
520 { | |
521 if (stone.LoadOsiriXAnnotations(xml, clearPrevious)) { | |
522 var seriesInstanceUid = stone.GetStringBuffer(); | |
523 | |
524 this.SetViewportLayout('1x1'); | |
525 this.leftVisible = false; | |
526 this.SetViewportSeriesInstanceUid(1, seriesInstanceUid); | |
527 | |
528 stone.FocusFirstOsiriXAnnotation('canvas1'); | |
529 } | |
530 } | |
511 }, | 531 }, |
512 | 532 |
513 mounted: function() { | 533 mounted: function() { |
514 this.SetViewportLayout('1x1'); | 534 this.SetViewportLayout('1x1'); |
515 | 535 |
546 console.warn('Loading series: ' + series + ' from study ' + study); | 566 console.warn('Loading series: ' + series + ' from study ' + study); |
547 stone.FetchSeries(study, series); | 567 stone.FetchSeries(study, series); |
548 app.leftMode = 'full'; | 568 app.leftMode = 'full'; |
549 } | 569 } |
550 } | 570 } |
551 | |
552 | |
553 | |
554 // TODO - TEST | |
555 axios.get('length.xml') | |
556 .then(function (response) { | |
557 stone.LoadOsiriXAnnotations(response.data, false); | |
558 }); | |
559 | |
560 axios.get('angle.xml') | |
561 .then(function (response) { | |
562 stone.LoadOsiriXAnnotations(response.data, false); | |
563 }); | |
564 | |
565 axios.get('arrow.xml') | |
566 .then(function (response) { | |
567 stone.LoadOsiriXAnnotations(response.data, false); | |
568 }); | |
569 | |
570 axios.get('text.xml') | |
571 .then(function (response) { | |
572 stone.LoadOsiriXAnnotations(response.data, false); | |
573 }); | |
574 | |
575 | |
576 }); | 571 }); |
577 | 572 |
578 | 573 |
579 window.addEventListener('ResourcesLoaded', function() { | 574 window.addEventListener('ResourcesLoaded', function() { |
580 console.log('resources loaded'); | 575 console.log('resources loaded'); |
709 }); | 704 }); |
710 | 705 |
711 | 706 |
712 // Disable the selection of text using the mouse | 707 // Disable the selection of text using the mouse |
713 document.onselectstart = new Function ('return false'); | 708 document.onselectstart = new Function ('return false'); |
709 | |
710 | |
711 | |
712 | |
713 | |
714 | |
715 | |
716 //var expectedOrigin = 'http://localhost:8042'; | |
717 var expectedOrigin = ''; // TODO - INSECURE - CONFIGURATION | |
718 | |
719 window.addEventListener('message', function(e) { | |
720 if (expectedOrigin != '' && | |
721 e.origin !== expectedOrigin) { | |
722 alert('Bad origin for the message'); | |
723 return; | |
724 } | |
725 | |
726 if (e.data.type == 'show-osirix-annotations') { | |
727 app.LoadOsiriXAnnotations(e.data.xml, true /* clear previous annotations */); | |
728 } else { | |
729 alert('Unknown message type: ' + e.data.type); | |
730 } | |
731 }); | |
732 | |
733 | |
734 function Test() | |
735 { | |
736 var s = [ 'length.xml', 'arrow.xml', 'text.xml', 'angle.xml' ]; | |
737 | |
738 for (var i = 0; i < s.length; i++) { | |
739 axios.get(s[i]) | |
740 .then(function (response) { | |
741 //var targetOrigin = 'http://localhost:8000'; | |
742 var targetOrigin = '*'; // TODO - INSECURE | |
743 | |
744 window.postMessage({ | |
745 'type': 'show-osirix-annotations', | |
746 'xml': response.data | |
747 }, targetOrigin); | |
748 }); | |
749 } | |
750 } |