Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/cancel_xsec.pro'
;+
; NAME:
;	Cancel_Xsec
; PURPOSE:
;	Cancel the new approximate cross-section in the widget state structure.
;	Stop events from the draw widget (x-sec plot) and
;	start accepting events from the energy level list widget.
;	Called by pro Approx_Xsecs_Ev (in file approx_xsecs.pro).
; CALLING:
;	Cancel_Xsec, state
; INPUTS:
;	state = structure variable, state of the widget.
; OUTPUTS:
;	state = new state of the widget.
; EXTERNAL CALLS:
;	function Level_info
; PROCEDURE:
;	Free the handles, replot the original x-secs, enable List selection.
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1995.
;-

pro Cancel_Xsec, state

	if Handle_info( state.ELevel ) then begin
		Handle_value, state.ELevel, ELevel,/NO_COPY
		if Handle_info( ELevel.freq_approx ) then begin
			Handle_free, ELevel.freq_approx
			Handle_free, ELevel.xsec_approx
		   endif
		Handle_value, state.ELevel, ELevel,/NO_COPY,/SET
		Handle_free, state.ELevel
	   endif

   	if (state.Lsel GE 0) then begin
		Handle_value, state.ELevs, ELevs,/NO_COPY
		ELevel = ELevs(state.Lsel)
		Handle_value, state.ELevs, ELevs,/NO_COPY,/SET
		wset, state.window
		Plot_Xsec, ELevel, TITLE=Level_info( ELevel )
		state.Lsel = -1
		state.modified = 0
		Widget_Control, state.info_wid, SET_VAL="Canceled"
	   endif

	Widget_Control, state.List_wid, /SENSITIVE
	Widget_Control, state.cursor_wid, SET_VAL="Cursor:"
	Widget_Control, state.instr_wid, SET_VAL="Select from List"
	Widget_Control, state.draw_wid, DRAW_BUTT=0, DRAW_MOT=0
	Widget_Control, state.axes_wid, SENS=0

	for i=0,1 do begin
     		Widget_Control, state.x_wids(i),SENS=0
     		Widget_Control, state.y_wids(i),SENS=0
	  endfor
end