Refactor DICOM 3D setup to clear element before 2D loader fallback and comment out fixed height in CSS

This commit is contained in:
Ross
2025-11-10 11:25:08 +00:00
parent 72c20c13e0
commit 2a07843a6b
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -635,6 +635,11 @@ async function setUpDicom3d(element) {
// dicomViewer helper (it expects a jQuery element). // dicomViewer helper (it expects a jQuery element).
console.warn('setUpDicom3d: contains web-image(s) — falling back to 2D loader'); console.warn('setUpDicom3d: contains web-image(s) — falling back to 2D loader');
try { 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 // annotations are not available in this scope in the 3d code path; pass
// undefined for annotations and let the loader handle it. // undefined for annotations and let the loader handle it.
dicomViewer.loadCornerstone($(element), null, images, undefined, images.length > 5); 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. // URLs, fallback to the 2D cornerstone loader which handles web images.
console.warn('viewport.setStack failed, attempting 2D fallback:', err); console.warn('viewport.setStack failed, attempting 2D fallback:', err);
try { try {
try { element.innerHTML = ""; } catch (e) { $(element).empty(); }
element.style.position = element.style.position || 'relative';
dicomViewer.loadCornerstone($(element), null, images, undefined, images.length > 5); dicomViewer.loadCornerstone($(element), null, images, undefined, images.length > 5);
element._cornerstone3d = { fallback: 'cornerstone2d', imageCount: images.length }; element._cornerstone3d = { fallback: 'cornerstone2d', imageCount: images.length };
return element._cornerstone3d; return element._cornerstone3d;
+1 -1
View File
@@ -186,7 +186,7 @@ button a {
#dicom-image { #dicom-image {
width: 100%; width: 100%;
height: 600px; /* height: 600px; */
} }
.dicom-viewer { .dicom-viewer {