;+ ; NAME: ; qImage_Pick ; PURPOSE: ; Called by qImage_Event to select a new image using the IDL 'pickfile' dialog. ; CATEGORY: ; sat/idl/widget/qimage ; CALLING SEQUENCE: FUNCTION qImage_Pick, state, image ; 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: ; SetFileSpec, GetFileSpec, img_read, IsType, smei_buf_split_frame ; unhide_env ; 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. ; > img_read is called with the /pseudo keyword set to reduce true color images to ; a 2D image array. ; > 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) ; MAR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added call to smei_buf_split_frame to handle SMEI L1A frame headers. ;- ; Pick up file filter from widget widget_control, state.wid_folder, get_value=folder widget_control, state.wid_filter, get_value=filter filter = filepath(root=unhide_env(folder[0]),filter[0]) ; Check for the presence of wildcards wildcard = strpos(filter, '*') NE -1 OR $ strpos(filter, '?') NE -1 OR $ strpos(filter, '%') NE -1 ; Use pickfile dialog if a wildcard was found; otherwise ; just try to read the file CASE wildcard OF 0: file = filter 1: BEGIN ; Select single file SetFileSpec, filter file = dialog_pickfile( $ path = GetFileSpec(upto='directory'), $ filter = GetFileSpec(from='name',upto='type'), $ group = state.wid_pick, title='Select image file') file = file[0] END ENDCASE status = file NE '' IF status THEN BEGIN widget_control, state.wid_ftsext, get_value=exten_no status = img_read(file, tmp, /pseudo, img_info=info, exten_no=exten_no) CASE status OF 0: tmp = dialog_message('Error reading image file '+file) 1: BEGIN image = tmp tmp = IsType(image, name=name) tmp = size(image, /dim) info = [file,' ',strjoin( strcompress(tmp, /rem), ' x ')+' '+name+' array', ' ', info[0]] widget_control, state.wid_info, set_uvalue=info, /no_copy ; Centroid calculations require float array IF IsType(image, /generic_int) THEN image = float(image) END ENDCASE ENDIF RETURN, status & END