From 2a07843a6b6c579673c2d23e8a7e2e99ed139384 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 10 Nov 2025 11:25:08 +0000 Subject: [PATCH] Refactor DICOM 3D setup to clear element before 2D loader fallback and comment out fixed height in CSS --- anatomy/static/js/anatomy.js | 7 +++++++ rad/static/css/anatomy.css | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/anatomy/static/js/anatomy.js b/anatomy/static/js/anatomy.js index 11e2645b..88515b09 100644 --- a/anatomy/static/js/anatomy.js +++ b/anatomy/static/js/anatomy.js @@ -635,6 +635,11 @@ async function setUpDicom3d(element) { // dicomViewer helper (it expects a jQuery element). console.warn('setUpDicom3d: contains web-image(s) — falling back to 2D loader'); try { + // Remove any partially-created dv3d DOM and ensure the element is a + // clean container for the 2D viewer. This ensures the `.canvas-panel` + // appended by `loadCornerstone` overlays exactly the element area. + try { element.innerHTML = ""; } catch (e) { $(element).empty(); } + element.style.position = element.style.position || 'relative'; // annotations are not available in this scope in the 3d code path; pass // undefined for annotations and let the loader handle it. dicomViewer.loadCornerstone($(element), null, images, undefined, images.length > 5); @@ -676,6 +681,8 @@ async function setUpDicom3d(element) { // URLs, fallback to the 2D cornerstone loader which handles web images. console.warn('viewport.setStack failed, attempting 2D fallback:', err); try { + try { element.innerHTML = ""; } catch (e) { $(element).empty(); } + element.style.position = element.style.position || 'relative'; dicomViewer.loadCornerstone($(element), null, images, undefined, images.length > 5); element._cornerstone3d = { fallback: 'cornerstone2d', imageCount: images.length }; return element._cornerstone3d; diff --git a/rad/static/css/anatomy.css b/rad/static/css/anatomy.css index 5c8693e4..2840f33d 100644 --- a/rad/static/css/anatomy.css +++ b/rad/static/css/anatomy.css @@ -186,7 +186,7 @@ button a { #dicom-image { width: 100%; - height: 600px; +/* height: 600px; */ } .dicom-viewer {