Skip to content

Commit

Permalink
force loading, show loader icon until all images are loaded to preven…
Browse files Browse the repository at this point in the history
…t from going to next patient when images are not loaded (which causes problems)
  • Loading branch information
arthurmasson committed Jan 25, 2024
1 parent beabb60 commit 375eab5
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ let load_lesion_viewer = (images, image_parameters, lesion, lesion_index) => {
if(lesion['location_voxel'] != 'image_center') {
params['coordinate'] = lesion['location_voxel']
}
let loaded_viewer = []
params['smoothDisplay'] = false
params['loadingComplete'] = () => {

Expand All @@ -571,7 +572,6 @@ let load_lesion_viewer = (images, image_parameters, lesion, lesion_index) => {
}
}
}

// let container = document.getElementById('toggle-visibility-buttons')
// let checkboxes = document.getElementsByTagName('input')
// for(let checkbox of checkboxes) {
Expand All @@ -587,6 +587,11 @@ let load_lesion_viewer = (images, image_parameters, lesion, lesion_index) => {
papaya.Container.removeImage(1, 0)
papayaContainers[1].viewer.setCurrentScreenVol(0)
}
loaded_viewer.push(1)
// If both viewer are loaded: hide_loader
if(loaded_viewer.length==2 && loaded_viewer.indexOf(0) >= 0 && loaded_viewer.indexOf(1) >= 0) {
hide_loader()
}
}

let description = document.getElementById('description')
Expand Down Expand Up @@ -633,11 +638,14 @@ let load_lesion_viewer = (images, image_parameters, lesion, lesion_index) => {
papayaContainers[0].toolbar.updateImageButtons()
papayaContainers[0].viewer.setCurrentScreenVol(0)
viewer.drawViewer(true, false)
loaded_viewer.push(0)
// If both viewer are loaded: hide_loader
if(loaded_viewer.length==2 && loaded_viewer.indexOf(0) >= 0 && loaded_viewer.indexOf(1) >= 0) {
hide_loader()
}
}
papaya.Container.resetViewer(0, params);

hide_loader()

let canvas = papayaContainers[0].viewer.canvas
canvas.addEventListener('mousemove', on_mouse_move, false);
canvas.addEventListener('mousedown', on_mouse_down, false);
Expand Down Expand Up @@ -1242,17 +1250,17 @@ let load_lesion = (i, skip_current_lesion_time_update=false) => {

let image_parameters = []

let need_to_load = false
let need_to_load = true // Force loading

empty_edits()

for (let image_description of image_descriptions) {
if (loaded_images.length == 0 || loaded_images.findIndex((i) => i.file_name.split('/').at(-1) == image_description.file) < 0) {
// if (loaded_images.length == 0 || loaded_images.findIndex((i) => i.file_name == image_description.file) < 0) {
need_to_load = true;
break
}
}
// for (let image_description of image_descriptions) {
// if (loaded_images.length == 0 || loaded_images.findIndex((i) => i.file_name.split('/').at(-1) == image_description.file) < 0) {
// // if (loaded_images.length == 0 || loaded_images.findIndex((i) => i.file_name == image_description.file) < 0) {
// need_to_load = true;
// break
// }
// }

let editable_image_index = get_editable_image_index()
let draw_tools = document.getElementById('draw_tools')
Expand Down

0 comments on commit 375eab5

Please sign in to comment.