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