Commit bdd91d6e authored by luroth's avatar luroth
Browse files

modal dialog extension for project management

parent c13bec1d
{
"input": {
"n_pix_x": 6000,
"plot_size_x": 1.5,
"d_sensor_x": 35.6,
"n_pix_y": 4000,
"plot_size_y": 2,
"d_sensor_y": 23.8,
"config_tab": "Sensor/Lens",
"position_edge2_lat": 47.451,
"exposure_value": 14,
"positioning_precision": 3,
"gcp_arrangement_pattern": "quad",
"position_edge2_long": 8.6821,
"side_lap": 60,
"end_lap": 80,
"position_start_lat": 47.45,
"flight_height": 30,
"aperture": "8",
"max_number_of_wp": 99,
"mapping_area_x": 36,
"freq_max": 2,
"ISO_max": 6400,
"mapping_area_y": 40,
"spacing_between_exposures": 2.6,
"spacing_between_flight_lines": 7.77,
"sensor_and_lens_select": "Sony A9 on DJI M600P",
"f": 55,
"position_start_long": 8.6827,
"flight_max": 15,
"gcp_n_in_x": 6,
"recalc_waypoint_map": 0,
"gcp_n_in_y": 3,
"settings": null,
"position_edge1_lat": 47.451,
"shutter_speed": "16000",
"project_name": "Sony A9 Sample Project",
"edit_ground_sampling_distance": false,
"iso": 6250,
"edit_spacing": false,
"position_edge1_long": 8.6825,
"t_max": 32000,
"flip_camera": "FALSE",
"motion_blur": 0.04,
"results": "Photography",
"ground_sampling_distance": 3.24
},
"derived": {
"end_lap": 80,
"f": 0.055,
"diffraction_green": "G (530 nm): 1.74 * circle of conf.",
"image_recording_speed": 0.8,
"shutter_speed": 16000,
"field_of_view_x": 19.418,
"number_of_photos": 189,
"diffraction_blue": "B (470 nm): 1.55 * circle of conf.",
"field_of_view_y": 12.982,
"d_sensor_x": 0.0356,
"focus_distance": 25.285,
"aperture": 8,
"d_sensor_y": 0.0238,
"hit_per_gcp": {
"x": [ 0, 0, 0, 7.2, 7.2, 7.2, 14.4, 14.4, 14.4, 21.6, 21.6, 21.6, 28.8, 28.8, 28.8, 36, 36, 36 ],
"y": [ 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40 ],
"Recover.frequency": [ 12, 15, 15, 12, 15, 15, 12, 15, 15, 12, 15, 15, 8, 10, 10, 8, 10, 10 ]
},
"number_of_gcp": 18,
"angle_of_view_x": 0.626,
"ground_sampling_distance": 0.00324,
"angle_of_view_y": 0.42616,
"side_lap": 60,
"gcp": {
"x": [ 0, 0, 0, 7.2, 7.2, 7.2, 14.4, 14.4, 14.4, 21.6, 21.6, 21.6, 28.8, 28.8, 28.8, 36, 36, 36 ],
"y": [ 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40, 0, 20, 40 ]
},
"hyperfocal_distance": 63.784,
"depth_of_field_far": 41.857,
"flight_height": 30,
"flight_speed": 2.0736,
"depth_of_field_near": 18.114,
"hit_per_image": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
"spacing_between_flight_lines": 7.77,
"flight_duration": 7,
"circle_of_confusion": 5.9333e-06,
"field_of_view_y_sensor": 12.982,
"spacing_between_exposures": 2.6,
"field_of_view_x_sensor": 19.418,
"diffraction_red": "R (700 nm): 2.3 * circle of conf.",
"photo_positions": {
"x": [ -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -15.54, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, -7.77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 7.77, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 15.54, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 23.31, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 31.08, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 38.85, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62, 46.62 ],
"y": [ -6.4909, -3.8909, -1.2909, 1.3091, 3.9091, 6.5091, 9.1091, 11.709, 14.309, 16.909, 19.509, 22.109, 24.709, 27.309, 29.909, 32.509, 35.109, 37.709, 40.309, 42.909, 45.509, 45.509, 42.909, 40.309, 37.709, 35.109, 32.509, 29.909, 27.309, 24.709, 22.109, 19.509, 16.909, 14.309, 11.709, 9.1091, 6.5091, 3.9091, 1.3091, -1.2909, -3.8909, -6.4909, -6.4909, -3.8909, -1.2909, 1.3091, 3.9091, 6.5091, 9.1091, 11.709, 14.309, 16.909, 19.509, 22.109, 24.709, 27.309, 29.909, 32.509, 35.109, 37.709, 40.309, 42.909, 45.509, 45.509, 42.909, 40.309, 37.709, 35.109, 32.509, 29.909, 27.309, 24.709, 22.109, 19.509, 16.909, 14.309, 11.709, 9.1091, 6.5091, 3.9091, 1.3091, -1.2909, -3.8909, -6.4909, -6.4909, -3.8909, -1.2909, 1.3091, 3.9091, 6.5091, 9.1091, 11.709, 14.309, 16.909, 19.509, 22.109, 24.709, 27.309, 29.909, 32.509, 35.109, 37.709, 40.309, 42.909, 45.509, 45.509, 42.909, 40.309, 37.709, 35.109, 32.509, 29.909, 27.309, 24.709, 22.109, 19.509, 16.909, 14.309, 11.709, 9.1091, 6.5091, 3.9091, 1.3091, -1.2909, -3.8909, -6.4909, -6.4909, -3.8909, -1.2909, 1.3091, 3.9091, 6.5091, 9.1091, 11.709, 14.309, 16.909, 19.509, 22.109, 24.709, 27.309, 29.909, 32.509, 35.109, 37.709, 40.309, 42.909, 45.509, 45.509, 42.909, 40.309, 37.709, 35.109, 32.509, 29.909, 27.309, 24.709, 22.109, 19.509, 16.909, 14.309, 11.709, 9.1091, 6.5091, 3.9091, 1.3091, -1.2909, -3.8909, -6.4909, -6.4909, -3.8909, -1.2909, 1.3091, 3.9091, 6.5091, 9.1091, 11.709, 14.309, 16.909, 19.509, 22.109, 24.709, 27.309, 29.909, 32.509, 35.109, 37.709, 40.309, 42.909, 45.509 ]
},
"iso": 6250
}
}
......@@ -125,6 +125,62 @@ server_ <- function(input, output, session) {
# Object to store reactive values in (e.g. GUI values that needed conversion before using in formulas)
derived_values <- reactiveValues()
# Modal start dialog
start_model_data <- reactiveValues()
start_modal <- function(project_name) {
modalDialog(
tags$p(img(src="CSLogo_black_40.png"), tags$h2(HTML("Pheno<b>Fly Planning Tool</b>"))),
tags$style(".shiny-file-input-progress {display: none}"),
tags$hr(),
tags$h4("Enter/edit project name"),
textInput("project_name", NULL, value= project_name, width='100%'),
tags$hr(),
tags$h4("Load existing project"),
fileInput("settings", label=NULL, buttonLabel="Open project", placeholder ="None", width='600%',
multiple = FALSE,
accept = c("text/json",
".json")),
tags$hr(),
tags$h4("Load predefined settings"),
selectInput("start_modal_predefined", NULL, choices = list.files("./sample_projects")),
actionButton("model_load_predefined", "Load", icon=icon("briefcase")),
tags$hr(),
tags$h4("Clear all settings"),
actionButton("start_modal_clear", "Clear all", icon=icon("trash")),
tags$hr(),
footer = tagList(
actionButton("start_model_ok", "OK")
)
)
}
# Event to show modal start dialog
observeEvent(input$show_start_modal, {
showModal(start_modal(derived_values$project_name))
})
# Always show at start
showModal(start_modal(NULL))
observeEvent(input$start_model_ok, {
derived_values$project_name <- input$project_name
output$project_name <- renderText(input$project_name)
removeModal()
})
observeEvent(input$model_load_predefined, {
settings <- fromJSON(paste0("./sample_projects/", input$start_modal_predefined))
loadSettings(settings)
})
observeEvent(input$start_modal_clear, {
session$reload()
})
############################################################
### Input tabs
......@@ -946,6 +1002,9 @@ server_ <- function(input, output, session) {
input$flip_camera, derived_values$f>0)
withProgress(message = 'Calculating pixel frequency', {
showModal(modalDialog(
tags$p('Calculating pixel frequency'), title="Calculation in progress", footer=NULL))
incProgress(0.0)
# Init parameters
no_of_lanes_x <- ceiling((input$mapping_area_x + derived_values$field_of_view_x) / derived_values$spacing_between_flight_lines)
......@@ -959,6 +1018,7 @@ server_ <- function(input, output, session) {
ret_list <- calc_pixel_freq_xy(input$plot_size_x, input$plot_size_y, derived_values$spacing_between_flight_lines, derived_values$spacing_between_exposures,
no_of_lanes_x, no_of_lanes_y, n_pix_x, n_pix_y, input$positioning_precision, derived_values$ground_sampling_distance)
incProgress(1)
removeModal()
return(ret_list)
})
......@@ -1035,6 +1095,9 @@ server_ <- function(input, output, session) {
withProgress(message = 'Ploting geometry', {
showModal(modalDialog(
tags$p('Calculating ploting geometry'), title="Calculation in progress", footer=NULL))
ret_list <- pixel_frequency()
pixel_frequency_data_xy <- ret_list[[1]]
incProgress(0.2)
......@@ -1061,6 +1124,8 @@ server_ <- function(input, output, session) {
ggtheme_default
incProgress(1)
removeModal()
plot_zenith
})
})
......@@ -1158,16 +1223,14 @@ server_ <- function(input, output, session) {
output$download_params <- downloadHandler(
filename = function() {
return(paste(input$project_name, Sys.Date(), '.json', sep=''))
return(paste(derived_values$project_name, Sys.Date(), '.json', sep=''))
},
content = function(con) {
writeLines(toJSON(list(input=reactiveValuesToList(input), derived=reactiveValuesToList(derived_values))), con)
}
)
observe({
req(input$settings)
settings <- fromJSON(input$settings$datapath)
loadSettings <- function(settings) {
for(param in names(settings$input))
{
if(length(settings$input[param][[1]])==1) {
......@@ -1178,13 +1241,19 @@ server_ <- function(input, output, session) {
}
}
shutter_speed <- as.numeric(shutter_speed_values[which.min(abs(1.0/as.numeric(shutter_speed_values) - 1.0/settings$derived[['shutter_speed']]))])
print(shutter_speed)
req(isTruthy(input$t_max))
updateSelectizeInput(session, "shutter_speed", choices = shutter_speed_values[as.numeric(shutter_speed_values)<=input$t_max], selected=shutter_speed)
derived_values$shutter_speed <- shutter_speed
showNotification(type = "default", "New settings loaded")
}
observe({
req(input$settings)
settings <- fromJSON(input$settings$datapath)
loadSettings(settings)
})
output$download_report <- downloadHandler(
......
......@@ -36,18 +36,18 @@ default_no_gcp_y <- 3
default_flip_camera <- FALSE
default_plot_size_x <- 1.5
default_plot_size_y <- 2
default_position_precision <- 3
default_sensor_name <- "Sony A9 on DJI M600P"
default_d_sensor_x<- 35.6
default_d_sensor_y<- 23.8
default_n_pix_x<- 6000
default_n_pix_y<- 4000
default_position_precision <- NULL
default_sensor_name <- NULL
default_d_sensor_x<- NULL
default_d_sensor_y<- NULL
default_n_pix_x<- NULL
default_n_pix_y<- NULL
default_lens_aperture<- 8
default_focal_lenght<- 55
default_t_max<- 32000
default_ISO_max<- 6400
default_freq_max<- 2
default_flight_max<- 15
default_focal_lenght<- NULL
default_t_max<- NULL
default_ISO_max<- NULL
default_freq_max<- NULL
default_flight_max<- NULL
default_max_number_of_wp <- 99
default_position_edge1_lat <- 47.450812627526901
......@@ -68,12 +68,10 @@ ui_ <- fluidPage(
fluidRow(
column(4, img(src="CSLogo_black_40.png"), HTML("Pheno<b>Fly Planning Tool</b>"),
tags$style(".shiny-file-input-progress {display: none}")),
column(3, textInput("project_name", NULL, value= "Enter project name", width='100%')),
column(4, textOutput("project_name")),
column(2, actionButton("show_start_modal", "Edit project", width = '100%', icon=icon("edit"))),
tags$style(type='text/css', "#show_start_modal { width:100%; margin-top: -6px;}"),
column(2, downloadButton("download_params", "Save project", width='100%')),
column(3, fileInput("settings", label=NULL, buttonLabel="Open project", placeholder ="None", width='600%',
multiple = FALSE,
accept = c("text/json",
".json"))),
tags$style(type='text/css', "#download_params { width:100%; margin-top: -6px;}")
))
......
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