;+ ; Set the element of the appropriate GUIDE data structure array. ; ; If !g.line is true, the value is copied into the !g.s, otherwise ; it is copied in to !g.c. ; ; @param data {in}{required} A data structure (continuum or spectrum) ; to put into the indicated location. ; ; @keyword index {in}{optional}{type=integer} The location to put the data. When ; not supplied the 0 location is used. ; ; @keyword ignore_line {in}{optional}{type=boolean} When set, the ; value of !g.line is ignored and the choice of which data array to ; use is determined by the contents of data. ; ; @keyword noshow {in}{optional}{type=boolean} Normally, if index is 0 ; and !g.frozen is 0 then show is called at the end. If this is set, ; that behavior is turned off. ; ; @version $Id: set_data_container.pro,v 1.10 2005/05/26 14:43:34 bgarwood Exp $ ;- pro set_data_container, data, index=index, $ ignore_line=ignore_line, noshow=noshow compile_opt idl2 ; validate data_container argument if (data_valid(data, name=name) gt 0) then begin if (n_elements(index) eq 0) then begin index = 0 endif else begin maxindex = (!g.line) ? n_elements(!g.c) : n_elements(!g.s) if (index gt maxindex) then begin message, string((maxindex-1),format='("index must be >= 0 and <= ",i2)') return endif endelse ; data_copy can't be used here because !g.s[index] and !g.c[index] are system ; variables and they will be passed by value, not reference if (not keyword_set(ignore_line)) then begin if (name eq 'SPECTRUM' and !g.line eq 0) then begin message, 'Data container is SPECTRUM but GUIDE is in continuum mode',level=-1,/info endif if (name eq 'CONTINUUM' and !g.line) then begin message, 'Data container is CONTINUUM but GUIDE is in line mode',level=-1,/info endif endif if (name eq 'SPECTRUM') then begin data_free, !g.s[index] !g.s[index] = data[0] ; now copy the pointer values, making new pointers here !g.s[index].data_ptr = ptr_new(*(data[0].data_ptr)) endif else begin data_free, !g.c[index] !g.c[index] = data[0] ; now copy the pointer values, making new pointers here !g.c[index].data_ptr = ptr_new(*(data[0].data_ptr)) ; must be CONTINUUM !g.c[index].date = ptr_new(*(data[0].date)) !g.c[index].utc = ptr_new(*(data[0].utc)) !g.c[index].mjd = ptr_new(*(data[0].mjd)) !g.c[index].longitude_axis = ptr_new(*(data[0].longitude_axis)) !g.c[index].latitude_axis = ptr_new(*(data[0].latitude_axis)) !g.c[index].lst = ptr_new(*(data[0].lst)) !g.c[index].azimuth = ptr_new(*(data[0].azimuth)) !g.c[index].elevation = ptr_new(*(data[0].elevation)) endelse ; if (!g.frozen eq 0 and index eq 0) then show if (!g.frozen eq 0 and index eq 0 and !g.line and not keyword_set(noshow)) then show if (n_elements(data) gt 1) then begin message, 'more than one item found - ignoring all but the first', level=-1,/info endif endif else begin message, 'data container appears to be empty or invalid, nothing to set',/info,level=-1 endelse return end