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

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

improvements/corrections of some *.pro headers

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