;+ ; Project : Course Computer Project ; ; Name : DECIDEOPT ; ; Purpose : Brings up a widget to choose bad fit option of Gaussfit. ; ; Explanation : This function brings up a GUI which offers the user two ; buttons: (1) do not save, (2) save results, (3) choose new profile ; boundaries, or (4) change type to absorption/emission spectrum. ; ; Use : RESULT = DECIDEOPT(STYPE, [TEXT]) ; ; Inputs : STYPE: Set this to 'emission' if spectrum is an emission line ; spectrum or 'absorption' if an absorption line spectrum. ; ; Opt. Inputs : TEXT: Message to be printed in GUI. If left out, the widget ; displays the question: "What do you want to do with this ; fit to the line profile?" ; ; Outputs : RESULT: String of either '' or '' depending ; upon the button pressed. ; ; Opt. Outputs: None. ; ; Keywords : None. ; ; Calls : None. ; ; Common : None. ; ; Restrictions: None. ; ; Side effects: None. ; ; Category : Class project, cosmology, Hubble's law, galaxies, spectra. ; ; Prev. Hist. : None. ; ; Written : Donald G. Luttermoser, ETSU/Physics, 31 March 2007 ; ; Modified : Version 1, Donald G. Luttermoser, ETSU/Physics, 31 Mar 2007 ; Initial program. ; ; Version : Version 1, 31 March 2003. ; ;- ; FUNCTION DECIDEOPT, STYPE, TEXT ; ; This procedure brings up a widget that informs the user of an error that ; needs to be addressed or an informative message. ; RESULT = '' ; IF N_PARAMS() LT 1 THEN BEGIN QRES = DIALOG_MESSAGE(['You must tell DECIDEOPT whether an emission or', $ 'absorption line spectrum is being judged.'], /ERROR) RETURN, RESULT ENDIF ICHECK = 0 IF STRLOWCASE(STYPE) EQ 'emission' THEN ICHECK = 1 IF STRLOWCASE(STYPE) EQ 'absorption' THEN ICHECK = 2 IF ICHECK EQ 0 THEN BEGIN QRES = DIALOG_MESSAGE(['You must tell DECIDEOPT whether an emission or', $ 'absorption line spectrum is being judged.', 'You passed STYPE = "'+ $ STYPE+'" to DECIDEOPT.'], /ERROR) RETURN, RESULT ENDIF IF ICHECK EQ 1 THEN $ OPT4 = ' change type to absorption spectrum ' $ ELSE OPT4 = ' change type to emission spectrum ' ; ; Make the widget. ; NLINES = N_ELEMENTS(TEXT) IF NLINES EQ 0 THEN TEXT = ['What do you want to do with', $ 'this fit to the line profile?'] NLINES = N_ELEMENTS(TEXT) BASEIN = WIDGET_BASE(TITLE='Select Option', /COLUMN, /BASE_ALIGN_CENTER) WTEXT = WIDGET_BASE(BASEIN, /COLUMN, /FRAME) WL = LONARR(NLINES) FOR I = 0, NLINES-1 DO WL(I) = WIDGET_LABEL(WTEXT, VALUE=TEXT(I)) ; WBUTT = WIDGET_BASE(BASEIN, /COLUMN) WN = WIDGET_BUTTON(WBUTT, VALUE=' do not save ') WS = WIDGET_BUTTON(WBUTT, VALUE=' save results ') WC = WIDGET_BUTTON(WBUTT, VALUE=' choose new profile boundaries ') WW = WIDGET_BUTTON(WBUTT, VALUE=' wrong line, choose another ') WP = WIDGET_BUTTON(WBUTT, VALUE=OPT4) ; WIDGET_CONTROL, BASEIN, /REALIZE TYPEIN = '' WHILE TYPEIN NE 'QUIT' DO BEGIN EVENTIN = WIDGET_EVENT(BASEIN) TYPE = TAG_NAMES(EVENTIN, /STRUCTURE) IF TYPE EQ 'WIDGET_BUTTON' THEN BEGIN WIDGET_CONTROL, EVENTIN.ID, GET_VALUE=RESULT TYPEIN = 'QUIT' ENDIF ENDWHILE ; WIDGET_CONTROL, BASEIN, /DESTROY ; RETURN, STRTRIM(RESULT, 2) END