;+
; NAME:
;	qnagoya_plot
; PURPOSE:
;	Set up call to qLine widget to display Nagoya IPS data
; CATEGORY:
;	qnagoya widget
; CALLING SEQUENCE:
	PRO qnagoya_Plot, state, event
; INPUTS:
;	state		array[1]; type: structure
;					qnagoya state structure
; OUTPUTS:
;	(none)
; INCLUDE:
	@compile_opt.pro			; On error, return to caller
; CALLS:
;	qLine, qnagoya_skymap, sphere_distance
; PROCEDURE:
; MODIFICATION HISTORY:
;	JULY-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
;-

CASE IsType(event,/defined) OF
0: name = widget_info(state.wid_name, /droplist_select)
1: BEGIN
	widget_control, state.wid_draw, get_uvalue=point, /no_copy
	tmp = min( (point.xy[0,*]-event.x)^2+(point.xy[1,*]-event.y)^2 , name )
	widget_control, state.wid_name, set_droplist_select=name
	widget_control, state.wid_draw, set_uvalue=point, /no_copy
END
ENDCASE

widget_control, state.wid_name, get_uvalue=names, /no_copy
name = names[name]
widget_control, state.wid_name, set_uvalue=names, /no_copy


widget_control, state.wid_exit, get_uvalue=point_sources, /no_copy
point = point_sources
widget_control, state.wid_exit, set_uvalue=point_sources, /no_copy

list = where(point.name EQ strmid(name,0,strlen(point.name[0])) AND (finite(point.VV) OR finite(point.GG)), n)

CASE n NE 0 OF
0: message, /info, 'no data points'
1: BEGIN
	point = point[list]

	; point.pp is RA and dec in degrees.
	; Calculate elongation

	elo = big_eph( point.tt, body='sun', center='earth', /to_equatorial, /to_sphere, /degrees, /precess, /onebody)
	elo = sphere_distance(point.pp, elo[0:1,*], /degrees)

	qLine, indgen(n),						$
		transpose([[point.VV], [point.GG], [elo]]),$
		xmargin  = [10,10],					$
		title	 = 'IPS source '+name,		$
		ytitle	 = ['data points','IPS speed (km/s)','IPS g-level', 'elongation (degrees)'],	$
		newyaxis = [0,1,1,1],				$
		linestyle= [0,0,2,0],				$
		time	 = point.TT
END
ENDCASE

qnagoya_skymap, state

RETURN  &  END
