source: trunk/SRC/Postscript/openps.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.9 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5;
6; @file_comments
7; switch to postscript mode and define it
8;
9; @param namepsin {in}{optional}
10; name of the postscript file.
11; Extension '.ps' is added if missing. It will be stored in the psdir directory.
12;
13; @keyword FILENAME
14; to define the name of the postscript file through a keyword rather than with
15; nameps input argument (in this case the keyword can be pass through
16; different routines via _EXTRA keyword).
17;
18; @keyword INFOWIDGET
19; If INFOWIDGET is present, it specifies a named variable into which the id of
20; the widget giving information about the postscript creation is stored as a
21; long integer.
22; This id is needed by <a href="./closeps.html">closeps</a> to kill
23; the information widget.
24;
25; @keyword KEEP_PFONT
26; activate to suppress the modification of !p.font
27; (by default we force !p.font = 0  to make smaller postscripts)
28;
29; @keyword PORTRAIT
30;
31; @keyword LANDSCAPE
32;
33; @keyword KEEPPFONT
34; same as keep_pfont
35;
36; @keyword LIGHTNESS
37; a scalar used to change the Lightness of the color palette to be able to
38; adjust according to the printer we use, the media (paper or slide)...
39; > 1 to get darker colors
40;
41; @keyword _EXTRA
42; used to pass any keyword to device procedure.
43;
44; @uses cm_4ps
45;
46; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
47; 21/12/98
48; 1/2/98: ajout de nameps en input
49; 1/9/1999: ajout du mot cle FILENAME et du widget
50; June 2005: Sebastien Masson, cleaning, english version with new commons
51;
52; @version
53; $Id$
54;
55;-
56;------------------------------------------------------------
57;------------------------------------------------------------
58;------------------------------------------------------------
59pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $
60            , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $
61            , PORTRAIT = portrait, LANDSCAPE = landscape $
62            , LIGHTNESS = Lightness,_extra = ex
63;
64;
65  compile_opt idl2, strictarrsubs
66;
67   IF lmgr(/demo) EQ 1 THEN BEGIN
68      dummy = report('impossible to create a PS in demo mode')
69      return
70   ENDIF
71;------------------------------------------------------------
72; include commons
73@cm_4ps
74IF NOT keyword_set(key_forgetold) THEN BEGIN
75@updatenew
76ENDIF
77;------------------------------------------------------------
78; close the postscript device if we are already in postscript mode
79   IF !d.name EQ 'PS' THEN device, /close
80; switch to postscript mode
81   set_plot,'ps'
82;------------------------------------------------------------
83; if we use  keyword Lightness
84; save the actual color palette in a temporary file
85; (to be restored when calling closeps
86;------------------------------------------------------------
87   IF n_elements(Lightness) NE 0 THEN BEGIN
88     IF Lightness NE 1 THEN BEGIN
89       tvlct, red, green, blue, /get
90       def_myuniquetmpdir
91       save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat'
92       palit, Lightness, red, green, blue
93     ENDIF
94   ENDIF
95;------------------------------------------------------------
96; we define the name of the file
97;------------------------------------------------------------
98   CASE 1 OF
99     n_params() EQ 1:nameps = namepsin
100     keyword_set(filename): nameps = filename
101     ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid)
102   ENDCASE
103; make sure that nameps ends with '.ps'
104   nameps = file_dirname(nameps, /mark_directory) + $
105            file_basename(nameps, '.ps') + '.ps'
106; add path (psdir) and check that nameps is ok
107   nameps = isafile(nameps, iodir = psdir, /new)
108;------------------------------------------------------------
109; we define xsize, ysize, xoffset et  yoffset
110;------------------------------------------------------------
111   IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $
112     key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape))
113
114   if key_portrait EQ 1 then begin
115      xs = min(page_size)
116      ys = max(page_size)
117      xoff = 0.
118      yoff = 0.
119   ENDIF ELSE BEGIN
120      xs = max(page_size)
121      ys = min(page_size)
122      xoff = 0.
123      yoff = max(page_size)
124   ENDELSE
125;------------------------------------------------------------
126; We define the device of the postscript mode
127;------------------------------------------------------------
128   device, /color, /palatino, filename = strcompress(nameps, /remove_all) $
129           , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $
130           , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $
131           , bits_per_pixel = 8, language_level = 2, _extra = ex
132; to make smaller postcripts
133   IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $
134   THEN !p.font = 0
135; show some informations
136   IF arg_present(infowidget) THEN $
137    infowidget = xnotice('Postcript file is currently processed...')
138;
139   RETURN
140END
141
142
143
144
145
146
147
148
149
150
151
152
Note: See TracBrowser for help on using the repository browser.