source: trunk/SRC/Postscript/openps.pro @ 231

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

improvements/corrections of some *.pro headers

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