; ; procedure def_work ; ; called by post_it ; reads each command line ; calls plt_map for each plot/window/overlay ; ; 11-6-99 EG ; PRO def_work, data_base_list, out_ps, cmdline, out_all, other_file, spec_base_list @common @com_eg ; Data bases data_bases = data_base_list spec_bases = spec_base_list ; ; Graphic init ; set plot graphic defaults resolve_routine, 'plt_def' plt_def ; other inits fld_flag = 1 ; ; other input file ? ; IF other_file NE '-' THEN BEGIN resolve_routine, other_file res = execute(other_file) cmdline = cmdline2 ENDIF cmdline_main = cmdline ; ; Field init ; fld_prev = '-' movie_count = 0 ; Open history file ; get_lun, nulhis openw, nulhis, '.hist_post_it' ; ; ; Interpret command lines ; nlines = n_elements(cmdline) iline = 0 iplot = 0 WHILE iline LE nlines-2 DO BEGIN cmd = decode_cmd(cmdline, iline) IF out_all NE '-' THEN cmd.out = out_all IF cmd.on EQ 1 THEN BEGIN iplot = iplot + 1 print, ' ' print, ' -------------' print, ' Plot No.', iplot, format = '(A10,I2)' print, ' -------------' print, ' ' printf, nulhis, ' ' printf, nulhis, ' -------------' printf, nulhis, ' Plot No.', iplot, format = '(A10,I2)' printf, nulhis, ' -------------' printf, nulhis, ' ' ; format of output posP = rstrpos(cmd.disp, 'P') posL = rstrpos(cmd.disp, 'L') len = strlen(cmd.disp) IF posP GE 0 THEN BEGIN landscape = 0 key_portrait = 1 ENDIF ELSE BEGIN landscape = 1 key_portrait = 0 ENDELSE IF strmid(cmd.out, 0, 2) EQ 'ps' THEN BEGIN reinitplt, /z,/invert fileps = 'idl_out_p'+strtrim(string(iplot), 2)+'.ps' openps, out_ps+fileps set_ps_devices ENDIF ELSE BEGIN set_plot,dev_type set_x_devices ENDELSE ; windows management : decode cmd.disp = n[xm][or] display = cmd.disp IF posP GT 0 OR posL GT 0 THEN display = strmid(cmd.disp, 0, len-1) posx = rstrpos(display, 'x') IF posx GT 0 THEN BEGIN nwin = long(strmid(display, 0, posx)) mwin = long(strmid(display, posx+1, len-posx+1)) ENDIF ELSE BEGIN IF posP GT 0 THEN BEGIN nwin = 1 mwin = long(display) ENDIF ELSE BEGIN nwin = long(display) mwin = 1 ENDELSE ENDELSE nwin_tot = nwin*mwin ; plot inits idx_pal = 0 iwin = 1 nb_lines = 0 ; make loop on number of windows WHILE iwin LE nwin*mwin DO BEGIN index_over = 0 win = [nwin, mwin, iwin] idx = iline + nb_lines cmdi = decode_cmd(cmdline, idx) cmdm = cmdi ; specific formatting for legend leg_format = '' IF strpos(cmdi.proj, '[') NE -1 THEN BEGIN leg_format = extract_str(cmdi.proj, '[', ']') cmdi.proj = strmid(cmdi.proj, 0, strpos(cmdi.proj, '[')) ENDIF ELSE leg_format = default_txt_format ; decode proj for number of overlays in window (min=1) overl = strpos(cmdi.proj, 'o') IF overl GE 0 THEN BEGIN nover = 1+max([1, long(strmid(cmdi.proj, overl+1, strlen(cmdi.proj)-overl-1))]) ENDIF ELSE BEGIN nover = 1 ENDELSE ; make loop on number of overlays iover = 1 WHILE iover LE nover DO BEGIN idx = iline + nb_lines + iover - 1 cmdo = decode_cmd(cmdline, idx) idx_main=idx ; print, ' plot,window,overlay = ', iplot, iwin, iover ; print, ' max win, max over = ', nwin, nover ; print, ' index = ', idx CASE cmdo.exp OF 'CT': BEGIN data_domain = 'global' print, 'WARNING set data_domain = global in def_work' END 'GloSea40':BEGIN data_domain = 'glosea' print, 'WARNING set data_domain = glosea in def_work' END ELSE: ENDCASE ; make overlay plt_map, cmdo, iplot, win, iover, landscape ; end of loop on overlays iover = iover+1 ENDWHILE nb_lines = nb_lines + nover ; special case y=f(next) on 2 lines IF strpos(cmdi.var, '=f(next)') GT -1 THEN nb_lines = nb_lines + 1 ; end of loop on windows iwin = iwin + 1 ENDWHILE ; close ps IF strmid(cmd.out, 0, 2) EQ 'ps' THEN BEGIN iodir = out_ps closeps nfile_name = fileps ; save to file IF save_ps EQ 1 THEN BEGIN ; open last name file IF strmid(cmd.out, 0, 3) ne 'psm' OR movie_count EQ 0 THEN BEGIN get_lun, nullst openr, nullst, '.last_name_post' dir_name = ' ' file_name = ' ' readf, nullst, dir_name readf, nullst, file_name close, nullst free_lun, nullst print, ' Save PostScript '+strtrim(string(iplot), 2)+' file to ( - to ignore / save_ps=0 to turn off - NO EXTENSIONS PLEASE) :' print, ' directory is (d to change) : '+dir_name nfile_name = xquestion(' ', file_name, /chkwid) IF nfile_name NE '-' THEN BEGIN IF nfile_name EQ 'd' THEN BEGIN dir_name = xquestion(' New Directory ', dir_name, /chkwid) nfile_name = xquestion(' New file', file_name, /chkwid) ENDIF openw, nullst, '.last_name_post' printf, nullst, dir_name printf, nullst, nfile_name close, nullst free_lun, nullst ENDIF ELSE BEGIN print, ' Do not save - OK' ENDELSE IF strmid(cmd.out, 0, 3) eq 'psm' THEN BEGIN ; movie stuff (slide 1) print, ' movie series, will create file_ files' file_suffix = '_'+strtrim(string(movie_count+1), 2) movie_count = movie_count + 1 ENDIF ELSE file_suffix = '' ENDIF ELSE BEGIN ; movie stuff (slides >1 ) get_lun, nullst openr, nullst, '.last_name_post' dir_name = ' ' file_name = ' ' readf, nullst, dir_name readf, nullst, nfile_name close, nullst free_lun, nullst file_suffix = '_'+strtrim(string(movie_count+1), 2) movie_count = movie_count + 1 print, ' saving file = '+nfile_name+file_suffix ENDELSE conv = 'cp ' ext = '.ps' IF strpos(cmd.out, 'gif') NE -1 THEN BEGIN conv = 'convert ' IF landscape EQ 1 THEN BEGIN conv = conv+'-rotate -90 ' ENDIF print, ' converting to gif... to make the movie use:' print, ' convert -delay 50 -loop 100 image_?.gif image_??.gif image_???.gif movie.gif' ext = '.gif' ENDIF line = conv+out_ps+'/'+fileps+' '+dir_name+'/'+nfile_name+file_suffix+ext spawn, line, prtout ENDIF IF strlen(cmd.out) EQ 3 AND strmid(cmd.out, 0, 3) NE 'psm' THEN BEGIN CASE cmd.out OF 'psb': BEGIN & mess = 'printer' & cmdf = prt_BW & END 'psc': BEGIN & mess = 'color printer' & cmdf = prt_col & END 'pst': BEGIN & mess = 'transp printer' & cmdf = prt_tra & END ELSE: BEGIN & mess = 'ghostview ' & cmdf = ghost & END ENDCASE print, ' ' print, ' Sending ', nfile_name+'_'+cmdf, ' to ', mess, ' (',cmdf, ' + option ',lp_opt, ')' line = 'cd '+out_ps+'; \cp '+fileps+' '+fileps+'_'+cmdf+'; '+homedir+'bin/'+cmdf+' '+fileps+'_'+cmdf+' '+lp_opt+'; cd '+hom_idl spawn, line, prtout print, prtout ENDIF ELSE BEGIN mess = 'ps' ENDELSE ENDIF ELSE BEGIN ; next plot/data CASE cmd.out OF 'cdf': ELSE: BEGIN ready = '' read,' for next plot ', ready END ENDCASE ENDELSE ENDIF ELSE nb_lines = 1 ; end of loop on command lines iline = iline + nb_lines ENDWHILE ; close history file free_lun, nulhis close, nulhis END