feat(series): Add functions for inferring native spacings and resampling volumes for optimization
This commit is contained in:
@@ -455,19 +455,44 @@
|
||||
}, 200);
|
||||
});
|
||||
|
||||
const getStackPosition = window[`getCurrentStackPosition_${apiKey}`] || window.getCurrentStackPosition_root;
|
||||
function resolveViewerApi(baseName) {
|
||||
const candidates = [
|
||||
`${baseName}_${apiKey}`,
|
||||
`${baseName}_root`,
|
||||
`${baseName}_truncate_modal_viewer`,
|
||||
`${baseName}_truncate-modal-viewer`,
|
||||
];
|
||||
|
||||
document.getElementById('truncate-set-lower-btn')?.addEventListener('click', () => {
|
||||
for (const name of candidates) {
|
||||
if (typeof window[name] === 'function') {
|
||||
return window[name];
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: first matching function name from global scope.
|
||||
const dyn = Object.keys(window).find(
|
||||
(k) => k.startsWith(`${baseName}_`) && typeof window[k] === 'function'
|
||||
);
|
||||
return dyn ? window[dyn] : null;
|
||||
}
|
||||
|
||||
document.getElementById('truncate-set-lower-btn')?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const getStackPosition = resolveViewerApi('getCurrentStackPosition');
|
||||
if (getStackPosition) {
|
||||
const pos = getStackPosition(0) + 1;
|
||||
const current = getStackPosition(0);
|
||||
const pos = Number.isFinite(current) ? current + 1 : 1;
|
||||
document.getElementById('truncate-lower-input').value = pos;
|
||||
syncOptimizeBounds();
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('truncate-set-upper-btn')?.addEventListener('click', () => {
|
||||
document.getElementById('truncate-set-upper-btn')?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const getStackPosition = resolveViewerApi('getCurrentStackPosition');
|
||||
if (getStackPosition) {
|
||||
const pos = getStackPosition(0) + 1;
|
||||
const current = getStackPosition(0);
|
||||
const pos = Number.isFinite(current) ? current + 1 : 1;
|
||||
document.getElementById('truncate-upper-input').value = pos;
|
||||
syncOptimizeBounds();
|
||||
}
|
||||
@@ -476,7 +501,8 @@
|
||||
document.getElementById('truncate-lower-input')?.addEventListener('input', syncOptimizeBounds);
|
||||
document.getElementById('truncate-upper-input')?.addEventListener('input', syncOptimizeBounds);
|
||||
|
||||
document.getElementById('truncate-test-modal-btn')?.addEventListener('click', () => {
|
||||
document.getElementById('truncate-test-modal-btn')?.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const lower = parseInt(document.getElementById('truncate-lower-input').value) - 1;
|
||||
const upper = parseInt(document.getElementById('truncate-upper-input').value) - 1;
|
||||
|
||||
@@ -485,7 +511,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const truncateFn = window[`truncateStack_${apiKey}`] || window.truncateStack_root;
|
||||
const truncateFn = resolveViewerApi('truncateStack');
|
||||
if (truncateFn) {
|
||||
const ok = truncateFn(lower, upper);
|
||||
if (ok) {
|
||||
@@ -523,8 +549,17 @@
|
||||
}
|
||||
|
||||
compareWrap.classList.remove('d-none');
|
||||
compareViewer.dataset.namedStacks = namedStacks;
|
||||
compareViewer.dataset.autoCacheStack = 'false';
|
||||
|
||||
// Recreate element to force a clean mount with new stacks.
|
||||
const fresh = document.createElement('div');
|
||||
fresh.id = 'downsample-compare-viewer';
|
||||
fresh.className = 'dicom-viewer-root w-100';
|
||||
fresh.style.height = '240px';
|
||||
fresh.style.background = '#222';
|
||||
fresh.setAttribute('data-auto-cache-stack', 'false');
|
||||
fresh.setAttribute('data-named-stacks', namedStacks);
|
||||
|
||||
compareViewer.replaceWith(fresh);
|
||||
|
||||
try {
|
||||
if (window.mountDicomViewers) {
|
||||
|
||||
Reference in New Issue
Block a user