R/shiny_setcursor.R

Defines functions setcursor_shiny

setcursor_shiny<-function(sweeps, cursor="xDiff_", swp){
  #tmp<-NULL
  cursors<-CURSORS[[sweeps$Stimulus]]$cursors
  cursors<-series_events(cursors, sweeps)
	app<-shinyApp(
		ui = basicPage(
			#radioButtons("zoom","zoom",c("cursor","zoom"), inline = T),
		  
			radioButtons("cur","which?",c("zoom", names(cursors)), select=cursor, inline = T),
			plotOutput("plot", height=300,width=600,
								 brush = brushOpts(id = "plot_brush", direction ="x", resetOnNew = T),
								 dblclick = "click"
			),
			#plotOutput("IV", height=300,width=600,
			#					 brush = brushOpts(id = "plot_brush", direction ="x")
			#),
			tableOutput("capresult"),
			actionButton("myBtn", "OK")
		),
		server = function(input, output, session) {
			#if(!exists("TE671_")){data("TE671_")}
			#tmp<<-sweeps
			output$plot <- renderPlot({
				if(input$cur =="zoom"){
					if(!is.null(input$plot_brush))
						sweeps$cursors$zoom<<-c(input$plot_brush$xmin, input$plot_brush$xmax)
					if(!is.null(input$click))
						sweeps$cursors$zoom<<-NULL
				}else{
					if(!is.null(input$plot_brush)){
						CURSORS[[sweeps$Stimulus]]$cursors[[input$cur]]$range<<-c(input$plot_brush$xmin, input$plot_brush$xmax)
					}

				}



				plotAna(sweeps, sweeps = swp)




			})
			#output$IV<- renderPlot({
#try(  {
#	input$plot_brush
#	sweeps<<-calculate.cursors(sweeps)
#	#tmp<<-sweeps
#	IVplot(sweeps, "peak")
#})

#			})


			observe({
				if(input$myBtn > 0){
					stopApp(sweeps)
				}
			})
		}
	)

	runGadget(app, viewer = paneViewer(minHeight = 500) )
}
tdanker/ephys2 documentation built on Aug. 11, 2019, 12:12 p.m.