;+ ;================================================================= ; ; filename CPONE.PRO - includes CPONE_EV, CPONE ; ;================================================================= ; ; ; NAME: ; CPONE_EV ; ; PURPOSE: ; The event handler for single image menu widget. ; ; CATEGORY: ; CP diplay ; ; CALLING SEQUENCE: ; CPONE_EV, EV ; ; CALLED BY: ; CPONE (via XMANAGER) ; ; CALLS TO: ; CPTVCOPY, XLOADCT, XPALETTE, CPDISPLAY ; ; INPUTS: ; EV: the event structure, variable depending on type of item clicked ; also, values in commons ; ; OPTIONAL INPUTS: ; none ; ; OUTPUTS: ; none explicit, only through commons ; ; OPTIONAL OUTPUTS: ; none ; ; COMMON BLOCKS: ; COLORS to change R_CURR, G_CURR, B_CURR to desired table ; CPCOLORS to load CP color tables ; CPDISPFILES to pass current filename ; CPKEYWORDS for current options conditions ; CPLASTPASS for file names used last pass ; CPONE_DIR for widget ID for filename list(s) ; CPWIDGBASES for the widget IDs of informational widgets ; ; SIDE EFFECTS: ; Changes may be may to the current color table. ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; Process the events from the single image menu widget. Continue ; recieving events until "Ready" is clicked, thus calling CPDISPLAY ; to output image. Or until "Cancel" is click, returning control to ; the main options menu. ; ; MODIFICATION HISTORY: ; 1991 - Elaine Einfalt (HSTX) ; ;- @cpsuncen ; compile now for hardcopy case pro cpone_ev, ev @cpcolors.common @cpdispfiles.common @cpkeywords.common @cplastpass.common @cpone_dir.common @cpwidgbases.common common colors, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr widget_control, ev.id, get_uvalue=input ; which widget was clicked if n_elements(input) eq 0 then input = '' type = strmid(tag_names(ev, /structure_name),7,1000) ; get widget type case type of 'BUTTON' : case input of 'ONEKILL': widget_control, ev.top, /destroy ; kill current widget 'HARDBW' : if ev.select ne 0 then begin colo=0 ; output to b/w print widget_control, comment, set_value=$ 'Starting print...', /append widget_control, onebase, sensitive=0 filename = last_filename diffname1 = last_diffname1 diffname2 = last_diffname2 cpdisplay, norm_diff=norm_diff, $ donorth=donorth, dodisk=dodisk, $ doradii=doradii, doradial=doradial, $ ruletimes=4, rulecondition=rulecondition, $ posfac=posfac, negfac=negfac, sin_mov=sin_mov widget_control, onebase, sensitive=1 if colo ne -1 then colo = -1 ; always reset to screen endif 'HARDCOL': if ev.select ne 0 then begin colo=1 ; output to color print widget_control, comment, set_value=$ 'Starting print...', /append widget_control, onebase, sensitive=0 filename = last_filename diffname1 = last_diffname1 diffname2 = last_diffname2 cpdisplay, norm_diff=norm_diff, $ donorth=donorth, dodisk=dodisk, $ doradii=doradii, doradial=doradial, $ ruletimes=4, rulecondition=rulecondition, $ posfac=posfac, negfac=negfac, sin_mov=sin_mov widget_control, onebase, sensitive=1 if colo ne -1 then colo = -1 ; always reset to screen endif 'SCRBW' : if ev.select ne 0 then begin ; copy tv to b/w printer if !d.window ne -1 then begin widget_control, onebase, sensitive=0 cptvcopy, colo=0, norm_diff=norm_diff endif else widget_control, comment, $ set_value='No window active to copy', /append endif 'SCRCOL' : if ev.select ne 0 then begin ; copy tv to color if !d.window ne -1 then begin widget_control, onebase, sensitive=0 cptvcopy, colo=1, norm_diff=norm_diff endif else widget_control, comment, $ set_value='No window active to copy', /append endif 'RESTABLE': if ev.select ne 0 then begin colreset=1 ; now use appropriate color if not(norm_diff) then begin ; norm image is shown r_curr=norm_r & g_curr=norm_g & b_curr=norm_b endif else begin ; diff image is shown r_curr=diff_r & g_curr=diff_g & b_curr=diff_b endelse tvlct, r_curr, g_curr, b_curr ; load this table now r_orig=r_curr & g_orig=g_curr & b_orig=g_curr endif 'RESTABBW': if ev.select ne 0 then begin colreset=0 ; use this colors r_curr=norm_r & g_curr=norm_g & b_curr=norm_b tvlct, r_curr, g_curr, b_curr ; load this table now endif 'RESTABDF': if ev.select ne 0 then begin colreset=0 ; use this colors r_curr=diff_r & g_curr=diff_g & b_curr=diff_b tvlct, r_curr, g_curr, b_curr ; load this table now endif 'IDLXLDCT': if ev.select ne 0 then begin colreset=0 ; don't use CP standard colors xloadct endif 'IDLPALET': if ev.select ne 0 then begin colreset=0 ; don't use CP standard colors xpalette endif 'IMGDISP' : begin widget_control, onebase, sensitive=0 if norm_diff eq 0 then if n_elements(last_filename) ne 0 $ then filename=last_filename $ else return $ else if n_elements(last_diffname1) ne 0 and $ n_elements(last_diffname2) ne 0 then begin diffname1 = last_diffname1 diffname2 = last_diffname2 endif else return cpdisplay, norm_diff=norm_diff, $ donorth=donorth, dodisk=dodisk, $ doradii=doradii, doradial=doradial, $ ruletimes=ruletimes, rulecondition=rulecondition, $ posfac=posfac, negfac=negfac, sin_mov=sin_mov widget_control, onebase, sensitive=1 ;3/93 if colo ne -1 then colo = -1 ; always reset to screen end else : widget_control, comment, set_value='Invalid BUTTON value in '+$ 'CPONE: ' + input, /append endcase 'TEXT' : begin widget_control, ev.id, get_value=value, set_value='' wild = strpos(value(0),'*') > strpos(value(0),'%') $ > strpos(value(0),'?') ; any wildcards if wild ge 0 then begin ; yes wildcard widget_control, comment, set_value='Invalid to use wildcard for '+$ ' single image ' + value(0), /append return endif if strpos(strupcase(value(0)), '.MOV') ge 0 then begin widget_control, comment, set_value='Invalid to select already ' +$ 'created movies in "Display one image" mode', /append return endif case input of 'FILENAM' : begin filename = value(0) mess = 'Entered: ' + filename end 'DIFNAM1' : begin diffname1 = value(0) mess = 'Base entered: ' + diffname1 end 'DIFNAM2' : begin diffname2 = value(0) mess = 'Subtraction entered: ' + diffname2 end else : mess = 'Invalid TEXT value in '+ 'CPONE: '+ input endcase widget_control, comment, set_value=mess, /append widget_control, onebase, sensitive=0 cpdisplay, norm_diff=norm_diff, $ donorth=donorth, dodisk=dodisk, $ doradii=doradii, doradial=doradial, $ ruletimes=ruletimes, rulecondition=rulecondition, $ posfac=posfac, negfac=negfac, sin_mov=sin_mov widget_control, onebase, sensitive=1 end 'LIST' : begin value=input(ev.index) & myvalue = strmid(value,0,7) value = strmid(value,7,strlen(value)) if strpos(value, 'MO_VIE') ge 0 then begin ; no movies in one image widget_control, comment, set_value='Movies are inappropriate ' + $ 'with "Display one image"', /append return endif case myvalue of ; Getting the list of files in selected subdirectory ; 'DIRLIST': list when normal image ; 'DIR1LIS': list for base image when differencing ; 'DIR2LIS': list for substraction when differencing 'DIRLIST' : begin list = findfile(value + '*.V*') ; get files in subdir. if list(0) ne '' then begin ; show this subdir.'s files widget_control, all2, sensitive=1, $ set_value=list, set_uvalue='DATALIS'+list mess = 'Files: ' + value + '*.V*' endif else begin widget_control, all2, sensitive=0, $ set_value=' No files in subdirectory' filename = 'no_file_entered' mess = 'No files ' + value + '*.V*' endelse end 'DIR1LIS' : begin list = findfile(value + '*.V*') ; get files in subdir if list(0) ne '' then begin ; show this subdir.'s files widget_control, all2, sensitive=1, $ set_value=list, set_uvalue='FRSTLIS'+list mess = 'Files: ' + value + '*.V*' endif else begin widget_control, all2, sensitive=0, $ set_value=' No files in subdirectory' diffname1 = 'no_file_entered' mess = 'No files ' + value + '*.V*' endelse end 'DIR2LIS' : begin list = findfile(value + '*.V*') ; get files in subdir. if list(0) ne '' then begin ; show this subdir. 'sfiles widget_control, all4, sensitive=1, $ set_value=list, set_uvalue='SECNLIS'+list mess = 'Files: ' + value + '*.V*' endif else begin widget_control, all4, sensitive=0, $ set_value=' No files in subdirectory' diffname2 = 'no_file_entered' mess = 'No files ' + value + '*.V*' endelse end ; Getting the individual filename that will be display ; 'DATALIS' : when normal image ; 'FRSTLIS' : for base image when differencing ; 'SECNLIS' : for substraction when differencing 'DATALIS' : begin filename = value ; file user picked mess = 'Selected: ' + filename end 'FRSTLIS' : begin diffname1 = value ; file user picked mess = 'Base selected: ' + diffname1 end 'SECNLIS' : begin diffname2 = value ; file user picked mess ='Subtraction selected: ' + diffname2 end else : mess = 'Invalid type of LIST in CPONE: '+ myvalue endcase if n_elements(mess) eq 0 then mess='' ; just incase widget_control, comment, set_value=mess, /append ; inform user if (myvalue eq 'DATALIS') or $ ( ((myvalue eq 'FRSTLIS') or (myvalue eq 'SECNLIS')) and $ (diffname1 ne 'no_file_entered') and $ (diffname2 ne 'no_file_entered') ) then begin ; ; Just selected a file so go and process the image ; widget_control, onebase, sensitive=0 cpdisplay, norm_diff=norm_diff, $ donorth=donorth, dodisk=dodisk, $ doradii=doradii, doradial=doradial, $ ruletimes=ruletimes, rulecondition=rulecondition, $ posfac=posfac, negfac=negfac, sin_mov=sin_mov widget_control, onebase, sensitive=1 filename = 'no_file_entered' ; initial with non-null diffname1 = 'no_file_entered' diffname2 = 'no_file_entered' endif end else : widget_control, comment, set_value= 'Invalid type of widget '+$ 'in CPONE: ' + type, /append endcase end ;================================================ ;+ ; ; NAME: ; CPONE ; ; PURPOSE: ; Create the single image menu widget ; ; CATEGORY: ; CP display ; ; CALLING SEQUENCE: ; CPONE, GROUP_LEADER=GROUP ; ; CALLED BY: ; CP.PRO ; ; CALLS TO: ; ACKNOWLEDGE, XPDMENU, CPONE_EV (via XMANAGER) ; ; INPUTS: ; GROUP : The widget ID of the parent widget. ; also, values in commons ; ; OPTIONAL INPUTS: ; none ; ; OUTPUTS: ; none explicit, only through commons ; ; OPTIONAL OUTPUTS: ; none ; ; COMMON BLOCKS: ; CPONE_DIR for widget ID for filename list(s) ; CPDISPFILES to pass current frame filename ; CPKEYWORDS for current options conditions ; CPLOGIC_ENVRON for location of data ; CPWIDGBASES for the widget IDs of parents and informational ; ; SIDE EFFECTS: ; none ; ; RESTRICTIONS: ; none ; ; PROCEDURE: ; Create the single image menu widget and populate the list widgets ; with subdirectories of CP data. ; ; MODIFICATION HISTORY: ; 1991 - Elaine Einfalt (HSTX) ; Apr 93 - Removed the ready button requirement, file selection iniates ; processing and redisplay will do it again. ; ;- pro cpone, group_leader=group @cpdispfiles.common @cpkeywords.common @cplogic_envron.common @cpone_dir.common @cpwidgbases.common ; Because want to be able to change option there is no /modal ; but still only want one at a time if xregistered('cpone') then begin ; currently have cpone mess = (['You already have an active ', $ '"Display one image"']) acknowledge, message=mess return endif else if xregistered('cpmovie') then begin ; currently have cpmovie mess = (['Cancel the active ', $ '"Create a movie" ', $ 'Only one widget of this', $ 'class allow at one time.']) acknowledge, message=mess return endif colo = -1 ; output to screen filename = 'no_file_entered' ; initial with non-null diffname1 = 'no_file_entered' diffname2 = 'no_file_entered' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; IDL handles findfile differently for VMS and ULTRIX ; We want the subdirectories (usually one per day) that contain the data ; The user will select desired day, and later select specific observation. ; Add some stuff (you know...stuff) to make life easier later. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; case !version.os of ; get subdirectories and prepare path name 'vms' : begin ; will need to contruct subdirectory name ; must be specific dirlist = findfile(dataplace + '*.dir', count=count) dirend = strpos(dirlist(0), ']') ; end of parent directory name dirlist = strmid(dirlist, 0, dirend) + '.' + $ strmid(dirlist, dirend+1, 6) +']' end 'ultrix' : begin ; can't be specific with file dirlist = findfile(dataplace, count=count) dirlist = dataplace + dirlist + '/' ; because unix findfile ; doesn't return full ; name in the array end 'IRIX' : begin ; can't be specific with file dirlist = findfile(dataplace, count=count) dirlist = dataplace + dirlist + '/' ; because unix findfile ; doesn't return full ; name in the array end else : dirlist = '' endcase ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Make widget which allows user to pick image using scroll or editable text ; There are two situations: are we doing a normal image, or a difference. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mainbase_o = widget_base(title='Display one C/P image', /column, space=10, $ xpad=20, ypad=20) onebase = widget_base(mainbase_o, /column) ;4/93 onedirec = widget_label(onebase, value='Select a data file and click READY') ; ; the program controls (RUN, COLOR, HARDCOPY and CANCEL) ; contrl = widget_base(onebase, /row, space=20) ready = widget_button(contrl, value='Redisplay', uvalue='IMGDISP') xpdmenu, ['"Adjust color palette" {', $ '"Use appropriate C/P color table" RESTABLE', $ '"Use C/P black/white color table" RESTABBW', $ '"Use C/P difference color table" RESTABDF', $ '"Use IDL Palette to create table (xpalette)" IDLPALET', $ '"Use User''s Library color tables (xloadct)" IDLXLDCT', '}' ], contrl xpdmenu, ['"Hardcopy" {', $ '"Black and white print process" HARDBW', $ '"Color printer process" HARDCOL', $ '"Copy screen to Black/White print (slow) " SCRBW', $ '"Copy screen to Color printer (slow)" SCRCOL', '}' ], contrl canit = widget_button(contrl, value='Cancel', uvalue='ONEKILL') ; ; Displays the subdirectories then displays the files in selected subdirectory ; one column if normal image two if a difference ; if not(norm_diff) then getwidg = onebase $ ; one image else begin ; difference needed two images scroll = widget_base(onebase, /frame, /row, space=10 ) getwidg = scroll endelse if dirlist(0) ne '' then begin ; there are subdirectories ; widgets to deal with normal one images or the base image of differences first = widget_base(getwidg, /column, /frame, space=10, xsize=425) if not(norm_diff) $ then inst='Click on desired subdirectory then on desired file.' $ else inst='Click on desired base subdirectory then on desired file.' lab = widget_label(first, value=inst) subd = widget_base(first, /column, /frame, space=10) ; if not(norm_diff) then inst='Click on desired subdirectory' $ ; else inst='Click on desired base subdirectory' ; lab = widget_label(subd, value=inst) if not(norm_diff) then pref='DIRLIST' + dirlist $ else pref='DIR1LIS' + dirlist all = widget_list(subd, ysize=4, value=dirlist, uvalue=pref) snames = widget_base(first, /frame, /column, space=10) ; lab = widget_label(snames, value ='Click on desired filename') if not(norm_diff) then load='DATALISno_filename' $ else load='FRSTLISno_filename' all2 = widget_list(snames, ysize=10, uvalue=load, $ value='Select subdirectory first') widget_control, all2, sensitive=0 ; no files until subdirectory manual = widget_base(first, /column, /frame, space=10) if not(norm_diff) then mess='You may enter data filename' $ else mess='You may enter base filename' lab = widget_label(manual, value=mess) if not(norm_diff) then lnam='FILENAM' $ else lnam='DIFNAM1' filedes1 = widget_text(manual, /editable, uvalue=lnam, /scroll) if norm_diff then begin ; include the subtraction image info, not present for normal images secon = widget_base(getwidg, /column, /frame, space=10, xsize=425) lab = widget_label(secon, value='Click on subtraction '+$ 'image subdirectory then on desired file.') subd2 = widget_base(secon, /column, /frame, space=10) ; lab = widget_label(subd2, value='Click on desired subtraction '+$ ; 'image subdirectory') all3 = widget_list(subd2, ysize=4, value=dirlist, $ uvalue='DIR2LIS'+dirlist) snames2 = widget_base(secon, /frame, /column, space=10) ; lab = widget_label(snames2, value ='Click on desired filename') all4 = widget_list(snames2, ysize=10, uvalue='SECNLISno_filename', $ value='Select subdirectory first') widget_control, all4, sensitive=0 ; no files until subdir manual = widget_base(secon, /column, /frame, space=10) lab = widget_label(manual, value='You may enter ' + $ 'subtraction filename') filedes2 = widget_text(manual, /editable, /scroll, $ uvalue='DIFNAM2') endif endif else $ ; there were no subdirectories mjunk = widget_label(getwidg, value='No ' + dataplace +'subdirectories') ; ; a widget that will inform user about current program events ; inform = widget_base(mainbase_o, /frame, /column) ; desc = widget_label(inform, value='Informational comments') comment = widget_text(inform, /scroll, ysize=5) widget_control, onebase, /realize widget_control, group, sensitive=1 ; give user back main option control widget_control, comment, set_value='Program comments will be displayed here.' xmanager,'cpone', mainbase_o, event_handler='cpone_ev', group_leader=group end