-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
71 lines (46 loc) · 1.38 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
options(rgl.useNULL = TRUE)
library(shiny)
library(rgl)
library(pavo)
shinyServer(function(input, output, session) {
spcs <- reactive({
# Load flowers data if user doesn't add data
if(is.null(input$indat)){
data(flowers)
spcs <- flowers
}
# Load user data
if(!is.null(input$indat)){
df <- input$indat
pt <- df$datapath
spcs <- try(getspec(where = dirname(pt[1]) , ext=c('txt','ttt', 'TXT', 'Txt', 'TTT', 'Ttt')), silent=TRUE)
if('try-error' %in% class(spcs))
spcs <- try(getspec(where = dirname(pt[1]) , ext=c('txt','ttt', 'TXT', 'Txt', 'TTT', 'Ttt'), dec=','), silent=TRUE)
if('try-error' %in% class(spcs))
stop('Could not open spectral files.')
}
spcs
})
res <- reactive({colspace(vismodel(spcs(), visual=input$vissystem, achro=FALSE))})
ptcol <- reactive({
ptcol <- switch(input$ptcol,
black = 'black',
varcol = spec2rgb(spcs())
)
})
apt <- reactive({'achro' %in% input$options})
flr <- reactive({'floor' %in% input$options})
grd <- reactive({'grid' %in% input$options})
fil <- reactive({'fill' %in% input$options})
output$tcs <- renderRglwidget({
tcsplot(res(),
size = input$ptsize/100,
col=ptcol(),
achro=apt(),
floor = flr(),
achrosize=0.015, lwd=3, lcol='grey')
if(any(c(grd(),fil()))) tcsvol(res(), grid = grd(), fill= fil())
rglwidget()
}
)
})