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

Last change on this file since 479 was 479, checked in by smasson, 12 years ago

full integration of the batch mode with Z buffer

  • Property svn:keywords set to Id
File size: 3.7 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; <pro>cm_4ps</pro>
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;-
27PRO closeps, INFOWIDGET=infowidget
28;
29compile_opt idl2, strictarrsubs
30;
31IF 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;
89last_part:
90;
91   def_myuniquetmpdir
92   colorfile = myuniquetmpdir + 'original_colors.dat'
93   IF file_test(colorfile, /regular) THEN BEGIN
94     restore, colorfile
95     file_delete, colorfile, /quiet
96; reload the original colors
97     tvlct, red, green, blue
98   ENDIF
99   !p.font = -1
100   set_default_device
101;------------------------------------------------------------
102   if keyword_set(infowidget) then $
103    widget_control, long(infowidget), bad_id = toto, /destroy
104;------------------------------------------------------------
105   return
106end
Note: See TracBrowser for help on using the repository browser.