Commit 5abd1aab authored by Jean-Karim Heriche's avatar Jean-Karim Heriche

Fixed losing current selection due to persistence of previous input on image.

parent f4754ed3
......@@ -76,6 +76,8 @@ explore_image_server <-function(input, output, session, rv){
observe({
if(!is.null(input$pixelPosition)) {
rv$pixelPosition <- matrix(input$pixelPosition, ncol = 2, byrow = TRUE)
# Reset event to avoid triggering updates when switching workspaces
runjs("Shiny.setInputValue('explore_module-image-pixelPosition', null);")
} else {
rv$pixelPosition <- NULL
}
......@@ -94,13 +96,13 @@ explore_image_server <-function(input, output, session, rv){
if(!is.null(rv$selectedFrame)) {
for(i in 1:nrow(rv$pixelPosition)) {
if(!is.null(rv$roiFrame) && rv$roiFrame != "") {
## rv$selectedFrame should always have a unique value even when length>1
## rv$imgPath1 and rv$selectedFrame should always have a unique value even when length>1
## because the image has already been selected if we click on it
## so it's safe to use the first value
clickPosition <- data.frame(t(c(rv$pixelPosition[i,], rv$selectedFrame[1])))
## Make sure we're looking only for ROIs present in the frame currently displayed
## This assumes that we interact with imageViewer1
roiData <- rv$data[rv$data[,rv$fileCol1] == rv$imgPath1 & rv$data[,rv$roiFrame] == rv$selectedFrame[1],
roiData <- rv$data[rv$data[,rv$fileCol1] == rv$imgPath1[1] & rv$data[,rv$roiFrame] == rv$selectedFrame[1],
c(rv$roiX, rv$roiY, rv$roiFrame)]
} else {
clickPosition <- data.frame(t(c(rv$pixelPosition[i,])))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment