;+ ; NAME: ; qsmei_sky_pick ; PURPOSE: ; Called by qsmei_sky_Event to select a new image using the IDL 'pickfile' dialog. ; CATEGORY: ; I/O ; CALLING SEQUENCE: FUNCTION qsmei_sky_pick, state, event, skymap ; INPUTS: ; state scalar, type: structure ; the state structure for the qImage widget ; OUTPUTS: ; status scalar; type: byte ; 0: if no image read ; 1: if image available ; image array[n,m]; type: any ; 2D array if image file succesfully read, or doesn't exist ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; GetFileSpec, IsType, unhide_env, smei_sky, smei_filename ; TimeGet, unique_only ; PROCEDURE: ; > The value of state.wid_filter (displayed in the widget) is checked for ; wildcards. ; > If a wildcard is found then the filter isused to initialize the 'pickfile' ; dialog, pick a file and read the file ; > If no wildcard is present then the file is read ; > The return value is 0 or 1 depending on whether an image was read succesfully. ; > The user value of state.wid_info is set with a string containing ; file name, image dimensions and (optionally) image info (if present). ; STATE INFO USED: ; widget_control, state.wid_filter, get_value=filter ; STATE INFO MODIFIED: ; widget_control, state.wid_info, set_uvalue=info, /no_copy ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS) ;- ; Pick up directory specification ; (could be two directories separated by comma) widget_control, state.wid_folder, get_value=tmp tmp = strcompress(tmp[0], /rem) source = tmp IF strpos(source,',') NE -1 THEN BEGIN source = strtok(source,',',/extract) IF n_elements(source) EQ 1 THEN source = source[0] ENDIF FOR i=0,n_elements(source)-1 DO BEGIN source[i] = unhide_env(source[i]) IF source[i] EQ '' THEN BEGIN message, /info, 'invalid directory, '+tmp RETURN, 0 ENDIF ENDFOR ; Pick up the file selection. ; These may include directory specs. widget_control, state.wid_select, get_value=wanted_map wanted_map = strtrim(wanted_map[0],2) ; Split into two arguments if comma is present ; If there are two arguments a difference map is made IF strpos(wanted_map,',') NE -1 THEN BEGIN wanted_map = strtok(wanted_map,',',/extract) IF n_elements(wanted_map) EQ 1 THEN wanted_map = wanted_map[0] ENDIF n = widget_info(state.wid_camera, /droplist_select) widget_control, state.wid_camera, get_value=camera camera = round(flt_string(camera[n])) idnr = widget_info(state.wid_mode, /droplist_select) widget_control, state.wid_mode, get_value=mode mode = mode[idnr] exten_no = widget_info(state.wid_fitsext, /droplist_select) CASE event.id OF state.wid_mode: BEGIN widget_control, state.wid_fitsext, get_value=tmp exten_no = tmp[exten_no] tmp = smei_sky_field(droplist=strmid(mode,0,3)) exten_no = (where(exten_no EQ tmp))[0] > 0 widget_control, state.wid_fitsext, set_value=tmp, set_droplist_select=exten_no END state.wid_fitsext: BEGIN ; If the ephemeris is active it needs to be updated if the map ; resolution or map projection changes. wid_child = widget_info(state.wid_qimage_cw, /child) widget_control, wid_child, get_uvalue=qimage_cw_state, /no_copy widget_control, qimage_cw_state.wid_ephem, get_uvalue=ephem_state, /no_copy IF IsType(ephem_state,/defined) THEN BEGIN ephem_state.update = 1 widget_control, qimage_cw_state.wid_ephem, set_uvalue=ephem_state, /no_copy ENDIF widget_control, wid_child, set_uvalue=qimage_cw_state, /no_copy END state.wid_back2: wanted_map[0] = string(long(wanted_map[0])-1) state.wid_back : wanted_map = string(long(wanted_map )-1) state.wid_forw : wanted_map = string(long(wanted_map )+1) state.wid_forw2: wanted_map[0] = string(long(wanted_map[0])+1) ELSE: ENDCASE ;widget_control, state.wid_fitsext, get_value=fitsext ;fitsext = fitsext[exten_no] widget_control, state.wid_digsource, get_uvalue=digsource rmzld = strpos(mode,'-zld') NE -1 rmbkgnd = strpos(mode,'-bkg') NE -1 print, exten_no smei_sky, wanted_map , $ camera = camera , $ source = source , $ nodig = 1-digsource,$ mode = strmid(mode,0,3), $ rmzld = rmzld , $ rmbkgnd = rmbkgnd , $ skymap = skymap , $ nbin = 1 , $ hdrs = hdrs , $ exten_no= exten_no , $ /noplot , $ /fixgain , $ /exact status = IsType(skymap,/array) CASE status OF 0: BEGIN tmp = strjoin(strcompress(wanted_map,/rem),',') IF event.id EQ state.wid_back2 OR $ event.id EQ state.wid_back OR $ event.id EQ state.wid_forw OR $ event.id EQ state.wid_forw2 THEN $ widget_control, state.wid_select, set_value=tmp IF NOT flt_string(wanted_map,/test_numonly) THEN BEGIN widget_control, state.wid_back2, sensitive=0 widget_control, state.wid_back , sensitive=0 widget_control, state.wid_forw , sensitive=0 widget_control, state.wid_forw2, sensitive=0 ENDIF END 1: BEGIN nmap = n_elements(wanted_map) nhdr = n_elements(hdrs) ncam = nhdr/nmap valid = where(hdrs.file NE '') ; Updated wid_folder with source directory tmp = GetFileSpec(hdrs[valid].file, upto='directory') tmp = tmp[unique_only(tmp)] IF digsource THEN BEGIN ; Strip trailing c1/,c2/,c3/ tmp = GetFileSpec(strreverse(strmid(strreverse(tmp),1)), upto='directory') ; Strip c1/,c2/,c3/ tmp = GetFileSpec(strreverse(strmid(strreverse(tmp),1)), upto='directory') ; Strip sky/,equ/ tmp = tmp[unique_only(tmp)] ENDIF FOR i=0,n_elements(tmp)-1 DO tmp[i] = hide_env(tmp[i]) widget_control, state.wid_folder, set_value=strjoin(tmp,',') ; Update wid_select with selected orbit(s) oneorbit = (where(1-hdrs[valid].oneorbit))[0] EQ -1 CASE oneorbit OF 0: BEGIN tmp = (where(total(reform(hdrs.file NE '',ncam,nmap),2) EQ 2))[0] tmp = hdrs[tmp+ncam*indgen(nmap)].file END 1: BEGIN ; Single orbit tmp = hdrs[valid].orbit tmp = tmp[unique_only(tmp)] END ENDCASE widget_control, state.wid_back2, /sensitive widget_control, state.wid_back , /sensitive widget_control, state.wid_forw , /sensitive widget_control, state.wid_forw2, /sensitive tmp = strjoin(strcompress(tmp,/rem),',') widget_control, state.wid_select, set_value=tmp tmp = smei_filename(hdrs[valid[0]].file,mode=new_mode) IF rmbkgnd THEN new_mode += '-bkg' IF rmzld THEN new_mode += '-zld' IF new_mode NE mode THEN BEGIN ; If the mode has changed then widgets state.wid_mode ; and state.wid_fitsext need to update accordingly widget_control, state.wid_mode, get_value=tmp mode = (where(tmp EQ new_mode))[0] IF mode NE -1 THEN BEGIN widget_control, state.wid_mode , set_droplist_select=mode widget_control, state.wid_fitsext, set_value=smei_sky_field(droplist=strmid(new_mode,0,3)) ENDIF ENDIF tag = tag_names(hdrs) ntag = n_elements(tag) tag = string(tag, format='(A'+strcompress(max(strlen(tag)),/rem)+')') info = strarr(ncam,ntag,nmap) FOR i=0,ntag-1 DO BEGIN tmp = hdrs.(i) CASE 1 OF IsTime(tmp ): info[*,i,*] = tag[i]+' : '+string(TimeGet(tmp,format='YYYY_DOY_HHMMSS'),format='(A21)') IsType(tmp, /string ): info[*,i,*] = tag[i]+' : '+string(GetFileSpec(tmp,part='name'), format='(A21)') IsType(tmp, /generic_int ): info[*,i,*] = tag[i]+' : '+string(tmp,format='(I21)') IsType(tmp, /generic_float ): info[*,i,*] = tag[i]+' : '+string(tmp,format='(F21.4)') ENDCASE ENDFOR FOR i=1,ncam-1 DO info[0,*,*] += ' '+info[i,*,*] info = reform(info[0,*,*]) IF nmap EQ 2 THEN info = [info[*,0],'',info[*,1]] widget_control, state.wid_qimage_cw, set_uvalue=hdrs[valid].file+'_'+strcompress(exten_no,/rem) widget_control, state.wid_info, set_uvalue=info, /no_copy END ENDCASE RETURN, status & END