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

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments Close the Postscript mode
6;
7;  when archive_ps ne 0, we add the name and the date
8;  at the bottom left corner of the postcript page. If the
9;  postscript is called idl.ps we change its name to number.ps
10;  (number automatically found to be 1 larger that any of the
11;  existing ps file)
12;
13; @keyword INFOWIDGET A long integer giving the id of the information
14;           widget (created by openps) that we have de destroy at
15;           the end of closeps (when the postscript is done)
16;
17; @uses cm_4ps
18;
19; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
20;                       21/12/98
21; June 2005: Sebastien Masson, english version with new commons
22;-
23;------------------------------------------------------------
24;------------------------------------------------------------
25;------------------------------------------------------------
26PRO closeps, INFOWIDGET = infowidget
27;
28;
29  compile_opt idl2, strictarrsubs
30;
31   IF lmgr(/demo) EQ 1 THEN return
32;------------------------------------------------------------
33; include commons
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 annote 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 postcript 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.