From 5d8272d364ead09210fa5d1ca602983fb35b33f0 Mon Sep 17 00:00:00 2001 From: Firesieht Date: Thu, 27 Oct 2022 22:10:43 +0300 Subject: [PATCH] add post & bug with draw --- .vscode/settings.json | 3 ++ index.js | 73 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/index.js b/index.js index 7af0cd9..41e9202 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,71 @@ -// create the dwv app -var app = new dwv.App(); -// initialise with the id of the container div -app.init({ - dataViewConfigs: {'*': [{divId: 'layerGroup0'}]}, - tools: { - Scroll: {} +var filterList = ['Threshold', 'Sharpen', 'Sobel']; + +var shapeList = [ + 'Arrow', + 'Ruler', + 'Protractor', + 'Rectangle', + 'Roi', + 'Ellipse', + 'Circle', + 'FreeHand' +]; + +var toolList = { + Scroll: {}, + Opacity: {}, + WindowLevel: {}, + ZoomAndPan: {}, + Draw: { + options: shapeList, + type: 'factory', + events: ['drawcreate', 'drawchange', 'drawmove', 'drawdelete'] + }, + Livewire: { + events: ['drawcreate', 'drawchange', 'drawmove', 'drawdelete'] + }, + Filter: { + options: filterList, + type: 'instance', + events: ['filterrun', 'filterundo'] + }, + Floodfill: { + events: ['drawcreate', 'drawchange', 'drawmove', 'drawdelete'] } -}); +}; + +// initialise the application +var options = { + dataViewConfigs: {'*': [{divId: 'layerGroup0'}]}, + tools: toolList +}; + +// main application +var app = new dwv.App(); +app.init(options); // activate tool once done loading app.addEventListener('load', function () { app.setTool('Scroll'); + + app.setTool('Draw'); + app.setDrawShape(toolList.Draw.options[0]); + }); -// load dicom data -app.loadURLs(['https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm','https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323707.dcm','https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323563.dcm']); + + +function receiveMessage(event) +{ + console.log(event.data, "FFFFFFFFF") + let data = JSON.parse(event.data) + if (data.type == "setDicom"){ + app.loadURLs([data.data]) + } else if(data.type == "setTool"){ + app.setTool('Draw'); + app.setDrawShape("Circle"); + } +} +window.addEventListener("message", receiveMessage, false); + // var range = document.getElementById('sliceRange');