From 13872563b4765493a45b0960783022b2a7692af8 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 7 Apr 2022 22:55:22 +0100 Subject: [PATCH] . --- static/js/dicomViewer.js | 49 ++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/static/js/dicomViewer.js b/static/js/dicomViewer.js index 0d9929b2..71187a6b 100644 --- a/static/js/dicomViewer.js +++ b/static/js/dicomViewer.js @@ -791,6 +791,12 @@ function keyDownHandler(e, element) { } e.preventDefault(); // Needed to stop the default action (scroll) break; + case 38: // Up + manualScrollDicom(1, element); + break; + case 40: // down + manualScrollDicom(-1, element); + break; case 46: // . //toggleFlagged(); break; @@ -1125,16 +1131,6 @@ function onImageRendered(e) { $(".thumb").removeClass("thumb-active"); $("#thumb-" + stack.currentImageIdIndex).addClass("thumb-active"); } - //if (stack.imageIds.length > 1) { - // $("option[value=scroll").prop("disabled", false); - // $("option[value=scroll").prop("hidden", false); - // $("option[value=scroll").text( - // "scroll (" + - // (stack.currentImageIdIndex + 1) + - // "/" + - // stack.imageIds.length + - // ")" - // ); } function stopEvent(evt) { @@ -1276,4 +1272,37 @@ export function getNextAnnotationImage(element) { } } } +} + +function manualScrollDicom(n, dicom_element) { + // There must be a better way to do this... + //dicom_element = document.getElementById("dicom-image"); + let c = cornerstone.getEnabledElement(dicom_element); + + let max = c.toolStateManager.toolState.stack.data[0].imageIds.length; + + if (max < 2) { + return; + } + + let current_index = + c.toolStateManager.toolState.stack.data[0].currentImageIdIndex; + + let new_index = current_index + n + + let corrected_index = Math.min(Math.max(new_index, 0), max) + + // TODO: if loop + //if (new_index >= max) { + // corrected_index = new_index - max; + //} else if (new_index < 0) { + // corrected_index = new_index + max; + //} + + c.toolStateManager.toolState.stack.data[0].currentImageIdIndex = corrected_index; + let id = c.toolStateManager.toolState.stack.data[0].imageIds[corrected_index]; + cornerstone.loadImage(id).then((b) => { + cornerstone.displayImage(dicom_element, b); + }); + // c = cornerstone.getEnabledElement(dicom_element) } \ No newline at end of file