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

Last change on this file since 129 was 129, checked in by pinsard, 18 years ago

improvements of Postscript/*.pro header

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