1 | ; |
---|
2 | ; procedure def_work |
---|
3 | ; |
---|
4 | ; called by post_it |
---|
5 | ; reads each command line |
---|
6 | ; calls plt_map for each plot/window/overlay |
---|
7 | ; |
---|
8 | ; 11-6-99 EG |
---|
9 | ; |
---|
10 | PRO def_work, data_base_list, out_ps, cmdline, out_all, other_file, spec_base_list |
---|
11 | |
---|
12 | @common |
---|
13 | @com_eg |
---|
14 | ; Data bases |
---|
15 | data_bases = data_base_list |
---|
16 | spec_bases = spec_base_list |
---|
17 | |
---|
18 | ; |
---|
19 | ; Graphic init |
---|
20 | ; set plot graphic defaults |
---|
21 | resolve_routine, 'plt_def' |
---|
22 | plt_def |
---|
23 | |
---|
24 | ; other inits |
---|
25 | fld_flag = 1 |
---|
26 | ; |
---|
27 | ; other input file ? |
---|
28 | ; |
---|
29 | IF other_file NE '-' THEN BEGIN |
---|
30 | |
---|
31 | resolve_routine, other_file |
---|
32 | res = execute(other_file) |
---|
33 | |
---|
34 | cmdline = cmdline2 |
---|
35 | |
---|
36 | ENDIF |
---|
37 | |
---|
38 | cmdline_main = cmdline |
---|
39 | |
---|
40 | ; |
---|
41 | ; Field init |
---|
42 | ; |
---|
43 | fld_prev = '-' |
---|
44 | movie_count = 0 |
---|
45 | |
---|
46 | ; Open history file |
---|
47 | ; |
---|
48 | get_lun, nulhis |
---|
49 | openw, nulhis, '.hist_post_it' |
---|
50 | ; |
---|
51 | ; |
---|
52 | ; Interpret command lines |
---|
53 | ; |
---|
54 | nlines = n_elements(cmdline) |
---|
55 | iline = 0 |
---|
56 | iplot = 0 |
---|
57 | |
---|
58 | WHILE iline LE nlines-2 DO BEGIN |
---|
59 | |
---|
60 | cmd = decode_cmd(cmdline, iline) |
---|
61 | |
---|
62 | IF out_all NE '-' THEN cmd.out = out_all |
---|
63 | |
---|
64 | IF cmd.on EQ 1 THEN BEGIN |
---|
65 | iplot = iplot + 1 |
---|
66 | print, ' ' |
---|
67 | print, ' -------------' |
---|
68 | print, ' Plot No.', iplot, format = '(A10,I2)' |
---|
69 | print, ' -------------' |
---|
70 | print, ' ' |
---|
71 | printf, nulhis, ' ' |
---|
72 | printf, nulhis, ' -------------' |
---|
73 | printf, nulhis, ' Plot No.', iplot, format = '(A10,I2)' |
---|
74 | printf, nulhis, ' -------------' |
---|
75 | printf, nulhis, ' ' |
---|
76 | |
---|
77 | |
---|
78 | ; format of output |
---|
79 | |
---|
80 | posP = rstrpos(cmd.disp, 'P') |
---|
81 | posL = rstrpos(cmd.disp, 'L') |
---|
82 | len = strlen(cmd.disp) |
---|
83 | IF posP GE 0 THEN BEGIN |
---|
84 | landscape = 0 |
---|
85 | key_portrait = 1 |
---|
86 | ENDIF ELSE BEGIN |
---|
87 | landscape = 1 |
---|
88 | key_portrait = 0 |
---|
89 | ENDELSE |
---|
90 | |
---|
91 | IF strmid(cmd.out, 0, 2) EQ 'ps' THEN BEGIN |
---|
92 | reinitplt, /z,/invert |
---|
93 | fileps = 'idl_out_p'+strtrim(string(iplot), 2)+'.ps' |
---|
94 | openps, out_ps+fileps |
---|
95 | set_ps_devices |
---|
96 | ENDIF ELSE BEGIN |
---|
97 | set_plot,dev_type |
---|
98 | set_x_devices |
---|
99 | ENDELSE |
---|
100 | |
---|
101 | ; windows management : decode cmd.disp = n[xm][or] |
---|
102 | |
---|
103 | display = cmd.disp |
---|
104 | IF posP GT 0 OR posL GT 0 THEN display = strmid(cmd.disp, 0, len-1) |
---|
105 | posx = rstrpos(display, 'x') |
---|
106 | IF posx GT 0 THEN BEGIN |
---|
107 | nwin = long(strmid(display, 0, posx)) |
---|
108 | mwin = long(strmid(display, posx+1, len-posx+1)) |
---|
109 | ENDIF ELSE BEGIN |
---|
110 | IF posP GT 0 THEN BEGIN |
---|
111 | nwin = 1 |
---|
112 | mwin = long(display) |
---|
113 | ENDIF ELSE BEGIN |
---|
114 | nwin = long(display) |
---|
115 | mwin = 1 |
---|
116 | ENDELSE |
---|
117 | ENDELSE |
---|
118 | nwin_tot = nwin*mwin |
---|
119 | |
---|
120 | ; plot inits |
---|
121 | |
---|
122 | idx_pal = 0 |
---|
123 | iwin = 1 |
---|
124 | nb_lines = 0 |
---|
125 | |
---|
126 | ; make loop on number of windows |
---|
127 | WHILE iwin LE nwin*mwin DO BEGIN |
---|
128 | |
---|
129 | index_over = 0 |
---|
130 | |
---|
131 | win = [nwin, mwin, iwin] |
---|
132 | |
---|
133 | idx = iline + nb_lines |
---|
134 | |
---|
135 | cmdi = decode_cmd(cmdline, idx) |
---|
136 | cmdm = cmdi |
---|
137 | |
---|
138 | ; specific formatting for legend |
---|
139 | leg_format = '' |
---|
140 | IF strpos(cmdi.proj, '[') NE -1 THEN BEGIN |
---|
141 | leg_format = extract_str(cmdi.proj, '[', ']') |
---|
142 | cmdi.proj = strmid(cmdi.proj, 0, strpos(cmdi.proj, '[')) |
---|
143 | ENDIF ELSE leg_format = default_txt_format |
---|
144 | ; decode proj for number of overlays in window (min=1) |
---|
145 | overl = strpos(cmdi.proj, 'o') |
---|
146 | IF overl GE 0 THEN BEGIN |
---|
147 | nover = 1+max([1, long(strmid(cmdi.proj, overl+1, strlen(cmdi.proj)-overl-1))]) |
---|
148 | ENDIF ELSE BEGIN |
---|
149 | nover = 1 |
---|
150 | ENDELSE |
---|
151 | |
---|
152 | ; make loop on number of overlays |
---|
153 | iover = 1 |
---|
154 | WHILE iover LE nover DO BEGIN |
---|
155 | |
---|
156 | idx = iline + nb_lines + iover - 1 |
---|
157 | cmdo = decode_cmd(cmdline, idx) |
---|
158 | idx_main=idx |
---|
159 | ; print, ' plot,window,overlay = ', iplot, iwin, iover |
---|
160 | ; print, ' max win, max over = ', nwin, nover |
---|
161 | ; print, ' index = ', idx |
---|
162 | |
---|
163 | CASE cmdo.exp OF |
---|
164 | 'CT': BEGIN |
---|
165 | data_domain = 'global' |
---|
166 | print, 'WARNING set data_domain = global in def_work' |
---|
167 | END |
---|
168 | 'GloSea40':BEGIN |
---|
169 | data_domain = 'glosea' |
---|
170 | print, 'WARNING set data_domain = glosea in def_work' |
---|
171 | END |
---|
172 | ELSE: |
---|
173 | ENDCASE |
---|
174 | ; make overlay |
---|
175 | |
---|
176 | plt_map, cmdo, iplot, win, iover, landscape |
---|
177 | |
---|
178 | ; end of loop on overlays |
---|
179 | iover = iover+1 |
---|
180 | ENDWHILE |
---|
181 | nb_lines = nb_lines + nover |
---|
182 | |
---|
183 | ; special case y=f(next) on 2 lines |
---|
184 | |
---|
185 | IF strpos(cmdi.var, '=f(next)') GT -1 THEN nb_lines = nb_lines + 1 |
---|
186 | |
---|
187 | ; end of loop on windows |
---|
188 | iwin = iwin + 1 |
---|
189 | ENDWHILE |
---|
190 | |
---|
191 | |
---|
192 | ; close ps |
---|
193 | |
---|
194 | IF strmid(cmd.out, 0, 2) EQ 'ps' THEN BEGIN |
---|
195 | iodir = out_ps |
---|
196 | closeps |
---|
197 | nfile_name = fileps |
---|
198 | ; save to file |
---|
199 | IF save_ps EQ 1 THEN BEGIN |
---|
200 | ; open last name file |
---|
201 | IF strmid(cmd.out, 0, 3) ne 'psm' OR movie_count EQ 0 THEN BEGIN |
---|
202 | get_lun, nullst |
---|
203 | openr, nullst, '.last_name_post' |
---|
204 | dir_name = ' ' |
---|
205 | file_name = ' ' |
---|
206 | readf, nullst, dir_name |
---|
207 | readf, nullst, file_name |
---|
208 | close, nullst |
---|
209 | free_lun, nullst |
---|
210 | print, ' Save PostScript '+strtrim(string(iplot), 2)+' file to ( - to ignore / save_ps=0 to turn off - NO EXTENSIONS PLEASE) :' |
---|
211 | print, ' directory is (d to change) : '+dir_name |
---|
212 | nfile_name = xquestion(' ', file_name, /chkwid) |
---|
213 | IF nfile_name NE '-' THEN BEGIN |
---|
214 | IF nfile_name EQ 'd' THEN BEGIN |
---|
215 | dir_name = xquestion(' New Directory ', dir_name, /chkwid) |
---|
216 | nfile_name = xquestion(' New file', file_name, /chkwid) |
---|
217 | ENDIF |
---|
218 | openw, nullst, '.last_name_post' |
---|
219 | printf, nullst, dir_name |
---|
220 | printf, nullst, nfile_name |
---|
221 | close, nullst |
---|
222 | free_lun, nullst |
---|
223 | ENDIF ELSE BEGIN |
---|
224 | print, ' Do not save - OK' |
---|
225 | ENDELSE |
---|
226 | IF strmid(cmd.out, 0, 3) eq 'psm' THEN BEGIN |
---|
227 | ; movie stuff (slide 1) |
---|
228 | print, ' movie series, will create file_<n> files' |
---|
229 | file_suffix = '_'+strtrim(string(movie_count+1), 2) |
---|
230 | movie_count = movie_count + 1 |
---|
231 | ENDIF ELSE file_suffix = '' |
---|
232 | ENDIF ELSE BEGIN |
---|
233 | ; movie stuff (slides >1 ) |
---|
234 | get_lun, nullst |
---|
235 | openr, nullst, '.last_name_post' |
---|
236 | dir_name = ' ' |
---|
237 | file_name = ' ' |
---|
238 | readf, nullst, dir_name |
---|
239 | readf, nullst, nfile_name |
---|
240 | close, nullst |
---|
241 | free_lun, nullst |
---|
242 | file_suffix = '_'+strtrim(string(movie_count+1), 2) |
---|
243 | movie_count = movie_count + 1 |
---|
244 | print, ' saving file <base name>= '+nfile_name+file_suffix |
---|
245 | ENDELSE |
---|
246 | |
---|
247 | conv = 'cp ' |
---|
248 | ext = '.ps' |
---|
249 | IF strpos(cmd.out, 'gif') NE -1 THEN BEGIN |
---|
250 | conv = 'convert ' |
---|
251 | IF landscape EQ 1 THEN BEGIN |
---|
252 | conv = conv+'-rotate -90 ' |
---|
253 | ENDIF |
---|
254 | print, ' converting to gif... to make the movie use:' |
---|
255 | print, ' convert -delay 50 -loop 100 image_?.gif image_??.gif image_???.gif movie.gif' |
---|
256 | ext = '.gif' |
---|
257 | ENDIF |
---|
258 | line = conv+out_ps+'/'+fileps+' '+dir_name+'/'+nfile_name+file_suffix+ext |
---|
259 | spawn, line, prtout |
---|
260 | |
---|
261 | ENDIF |
---|
262 | IF strlen(cmd.out) EQ 3 AND strmid(cmd.out, 0, 3) NE 'psm' THEN BEGIN |
---|
263 | CASE cmd.out OF |
---|
264 | 'psb': BEGIN & mess = 'printer' & cmdf = prt_BW & END |
---|
265 | 'psc': BEGIN & mess = 'color printer' & cmdf = prt_col & END |
---|
266 | 'pst': BEGIN & mess = 'transp printer' & cmdf = prt_tra & END |
---|
267 | ELSE: BEGIN & mess = 'ghostview ' & cmdf = ghost & END |
---|
268 | ENDCASE |
---|
269 | print, ' ' |
---|
270 | print, ' Sending ', nfile_name+'_'+cmdf, ' to ', mess, ' (',cmdf, ' + option ',lp_opt, ')' |
---|
271 | line = 'cd '+out_ps+'; \cp '+fileps+' '+fileps+'_'+cmdf+'; '+homedir+'bin/'+cmdf+' '+fileps+'_'+cmdf+' '+lp_opt+'; cd '+hom_idl |
---|
272 | spawn, line, prtout |
---|
273 | print, prtout |
---|
274 | |
---|
275 | ENDIF ELSE BEGIN |
---|
276 | mess = 'ps' |
---|
277 | ENDELSE |
---|
278 | ENDIF ELSE BEGIN |
---|
279 | |
---|
280 | ; next plot/data |
---|
281 | |
---|
282 | CASE cmd.out OF |
---|
283 | 'cdf': |
---|
284 | ELSE: BEGIN |
---|
285 | ready = '' |
---|
286 | read,'<Return> for next plot ', ready |
---|
287 | END |
---|
288 | ENDCASE |
---|
289 | ENDELSE |
---|
290 | |
---|
291 | ENDIF ELSE nb_lines = 1 |
---|
292 | |
---|
293 | ; end of loop on command lines |
---|
294 | iline = iline + nb_lines |
---|
295 | |
---|
296 | ENDWHILE |
---|
297 | |
---|
298 | ; close history file |
---|
299 | |
---|
300 | free_lun, nulhis |
---|
301 | close, nulhis |
---|
302 | |
---|
303 | END |
---|