1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Close the Postscript mode |
---|
5 | ; |
---|
6 | ; when archive_ps ne 0, we add the name and the date at the bottom left corner |
---|
7 | ; of the postscript page. |
---|
8 | ; If the postscript is called idl.ps we change its name to number.ps |
---|
9 | ; (number automatically found to be 1 larger that any of the existing ps file) |
---|
10 | ; |
---|
11 | ; @keyword INFOWIDGET {type=long integer} |
---|
12 | ; id of the information widget (created by <pro>openps</pro>) |
---|
13 | ; that we have to destroy at the end of closeps (when the postscript is done). |
---|
14 | ; |
---|
15 | ; @uses |
---|
16 | ; cm_4ps |
---|
17 | ; |
---|
18 | ; @history |
---|
19 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
20 | ; 21/12/98 |
---|
21 | ; June 2005: Sebastien Masson, english version with new commons |
---|
22 | ; |
---|
23 | ; @version |
---|
24 | ; $Id$ |
---|
25 | ; |
---|
26 | ;- |
---|
27 | PRO closeps, INFOWIDGET = infowidget |
---|
28 | ; |
---|
29 | compile_opt idl2, strictarrsubs |
---|
30 | ; |
---|
31 | IF lmgr(/demo) EQ 1 THEN return |
---|
32 | ; |
---|
33 | @cm_4ps |
---|
34 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
35 | @updatenew |
---|
36 | ENDIF |
---|
37 | ; |
---|
38 | IF !d.name NE 'PS' THEN GOTO, last_part |
---|
39 | ;------------------------------------------------------------ |
---|
40 | ; if archive_ps /= 0 we will add its name and the date at the bottom |
---|
41 | ; left corner of the page (in case if the postscript will be archived |
---|
42 | ; in printps |
---|
43 | ;------------------------------------------------------------ |
---|
44 | IF keyword_set(archive_ps) THEN BEGIN |
---|
45 | ;------------------------------------------------------------ |
---|
46 | ; we get the name of the latest created postscript. |
---|
47 | ;------------------------------------------------------------ |
---|
48 | psdir = isadirectory(psdir, title = 'Select psdir') |
---|
49 | nameps = file_search(psdir+'*.ps' $ |
---|
50 | , /test_regular, /test_write, /nosort) |
---|
51 | dates = (file_info(nameps)).mtime |
---|
52 | lastdate = (reverse(sort(temporary(dates))))[0] |
---|
53 | nameps = nameps[lastdate] |
---|
54 | nameps = file_basename(nameps, '.ps') |
---|
55 | ; If this name is idl.ps then we change it to the number.ps |
---|
56 | IF nameps EQ 'idl' then BEGIN |
---|
57 | ; get the name of all the *.ps or *.ps.gz files available in psdir |
---|
58 | allps = file_search(psdir+'*[.ps|.ps.gz|.pdf]', /test_regular, /nosort) |
---|
59 | allps = file_basename(file_basename(allps,'.gz'),'.ps') |
---|
60 | allps = file_basename(allps,'.pdf') |
---|
61 | ; find which of these names corresponds to numbers... |
---|
62 | ; get ascii codes of the names |
---|
63 | testnumb = byte(allps) |
---|
64 | ; longest name |
---|
65 | maxstrlen = (size(testnumb, /dimensions))[0] |
---|
66 | ; ascii codes can be 0 or between byte('0') and byte('9') |
---|
67 | testnumb = testnumb EQ 0 OR $ |
---|
68 | (testnumb GE (byte('0'))[0] AND testnumb LE (byte('9'))[0]) |
---|
69 | testnumb = where(total(testnumb, 1) EQ maxstrlen, count) |
---|
70 | IF count NE 0 THEN BEGIN |
---|
71 | ; get the largest number |
---|
72 | psnumber = fix(allps[testnumb]) |
---|
73 | psnumber = (psnumber[reverse(sort(psnumber))])[0] + 1 |
---|
74 | ENDIF ELSE psnumber = 0 |
---|
75 | nameps = strtrim(psnumber, 2) |
---|
76 | ENDIF |
---|
77 | ;------------------------------------------------------------ |
---|
78 | ; we annotate the postscript |
---|
79 | ;------------------------------------------------------------ |
---|
80 | date = byte(systime(0)) ; we get the date |
---|
81 | xyouts, !d.x_px_cm, !d.y_px_cm $ |
---|
82 | , nameps+') '+string(date[4:10])+string(date[20:23]) $ |
---|
83 | , /device, charsize = .75 |
---|
84 | ENDIF |
---|
85 | ;------------------------------------------------------------ |
---|
86 | ; close the postscript mode |
---|
87 | device, /close |
---|
88 | ; |
---|
89 | last_part: |
---|
90 | ; |
---|
91 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
92 | CASE thisOS of |
---|
93 | 'MAC': SET_PLOT, thisOS |
---|
94 | 'WIN': SET_PLOT, thisOS |
---|
95 | ELSE: SET_PLOT, 'X' |
---|
96 | ENDCASE |
---|
97 | def_myuniquetmpdir |
---|
98 | colorfile = myuniquetmpdir + 'original_colors.dat' |
---|
99 | IF file_test(colorfile, /regular) THEN BEGIN |
---|
100 | restore, colorfile |
---|
101 | file_delete, colorfile, /quiet |
---|
102 | ; reload the original colors |
---|
103 | tvlct, red, green, blue |
---|
104 | ENDIF |
---|
105 | !p.font = -1 |
---|
106 | ; force background color to the last color (white) |
---|
107 | !p.BACKGROUND=(!d.n_colors-1) < 255 |
---|
108 | !p.color=0 |
---|
109 | if !d.n_colors gt 256 then !p.background='ffffff'x |
---|
110 | ;------------------------------------------------------------ |
---|
111 | if keyword_set(infowidget) then $ |
---|
112 | widget_control, long(infowidget), bad_id = toto, /destroy |
---|
113 | ;------------------------------------------------------------ |
---|
114 | return |
---|
115 | end |
---|