source: trunk/SRC/Postscript/closeps.pro @ 259

Last change on this file since 259 was 259, checked in by pinsard, 17 years ago

improvment of links in idldoc outputs by modification of shell script and some pro files. add test for pro2href.sh. see 62

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
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;
28PRO closeps, INFOWIDGET = infowidget
29;
30compile_opt idl2, strictarrsubs
31;
32IF lmgr(/demo) EQ 1 THEN return
33;
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
40;------------------------------------------------------------
41; if archive_ps /= 0 we will add its name and the date at the bottom
42; left corner of the page (in case if the postscript will be archived
43; in printps
44;------------------------------------------------------------
45   IF keyword_set(archive_ps) THEN BEGIN
46;------------------------------------------------------------
47; we get the name of the latest created postscript.
48;------------------------------------------------------------
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
78;------------------------------------------------------------
79; we annotate the postscript
80;------------------------------------------------------------
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;------------------------------------------------------------
87; close the postscript mode
88   device, /close
89;
90last_part:
91;
92   thisOS = strupcase(strmid(!version.os_family, 0, 3))
93   CASE thisOS of
94     'MAC': SET_PLOT, thisOS
95     'WIN': SET_PLOT, thisOS
96     ELSE: SET_PLOT, 'X'
97   ENDCASE
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
106   !p.font = -1
107; force background color to the last color (white)
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
116end
Note: See TracBrowser for help on using the repository browser.