From 588741ba2435f33e89269c56548feb1f06e611c2 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 11 Nov 2021 22:37:32 +0000 Subject: [PATCH] . --- rapids/templates/rapids/rapid_form.html | 6 +-- static/js/dicomViewer.js | 55 ++++++++++++------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html index 6ee79853..2e3f5a22 100755 --- a/rapids/templates/rapids/rapid_form.html +++ b/rapids/templates/rapids/rapid_form.html @@ -479,14 +479,14 @@ if (el.files[0].type.startsWith("image")) { base = await blobToBase64(el.files[0]); imageId = "base64://" + base.split(",")[1]; - imageId2 = base; + //imageId2 = base; } else { let url = URL.createObjectURL(el.files[0]) imageId = `wadouri:${url}`; - imageId2 = url + //imageId2 = url } console.log(imageId) - const element = $(`
`).get(0) + const element = $(`
`).get(0) $(el).parent().parent().prepend(element); cornerstone.enable(element); cornerstone.loadAndCacheImage(imageId).then(function (image) { diff --git a/static/js/dicomViewer.js b/static/js/dicomViewer.js index 6aff7a08..cde0f199 100644 --- a/static/js/dicomViewer.js +++ b/static/js/dicomViewer.js @@ -541,6 +541,10 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l loadAnnotation(imageId, annotation); imageIds.push(imageId); + } else if (data_url.startsWith("base64://") || data_url.startsWith("wadouri:")) { + loadAnnotation(data_url, annotation); + + imageIds.push(data_url); // Treat application/octet-stream as if they are dicoms } else if (data_url.startsWith("data:application/dicom") || data_url.startsWith("data:application/octet-stream")) { @@ -602,6 +606,22 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l }); } + function loadCornerstoneThumb(image) { + img = $("
").get(0); + img.id = "thumb-image-" + id; + img.class = "thumbnail"; + img.title = + "Click on the thumbnail to view and manipulate the image."; + img.draggable = "false"; + img.style = "height: 100px; width: 100px"; + $("#thumb-" + id).append(img); + + const element = document.getElementById("thumb-image-" + id); + cornerstone.enable(element); + cornerstone.displayImage(element, image); + cornerstone.resize(element); + } + if (images.length > 1 && load_as_stack == false) { $(".canvas-panel").append("
"); for (let id = 0; id < images.length; id++) { @@ -647,24 +667,12 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l dfile ); cornerstone.loadAndCacheImage(imageId).then(function (image) { - img = $("
").get(0); - img.id = "thumb-image-" + id; - img.class = "thumbnail"; - img.title = - "Click on the thumbnail to view and manipulate the image."; - img.draggable = "false"; - img.style = "height: 100px; width: 100px"; - $("#thumb-" + id).append(img); - - const element = document.getElementById("thumb-image-" + id); - cornerstone.enable(element); - cornerstone.displayImage(element, image); - cornerstone.resize(element); + loadCornerstoneThumb(); }); //.catch( function(error) { }); } } else { - if (!image_url.endsWith("dicom") && !image_url.endsWith("dcm")) { + if ((!image_url.endsWith("dicom") && !image_url.endsWith("dcm")) || image_url.startsWith("base64")) { img = $("", { src: image_url, id: "thumb-image-" + id, @@ -677,24 +685,15 @@ export function loadCornerstone(main_element, db, images, annotations_to_load, l $("#thumb-" + id).append(img); // otherwise try to load it as a dicom + } else if (!image_url.startsWith("wadouri")) { + cornerstone.loadAndCacheImage(url).then(function (image) { + loadCornerstoneThumb(); + }); } else { let url = "wadouri:" + image_url; - console.log(url) cornerstone.loadAndCacheImage(url).then(function (image) { - img = $("
").get(0); - img.id = "thumb-image-" + id; - img.class = "thumbnail"; - img.title = - "Click on the thumbnail to view and manipulate the image."; - img.draggable = "false"; - img.style = "height: 100px; width: 100px"; - $("#thumb-" + id).append(img); - - const element = document.getElementById("thumb-image-" + id); - cornerstone.enable(element); - cornerstone.displayImage(element, image); - cornerstone.resize(element); + loadCornerstoneThumb(); }); } }