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

Last change on this file since 487 was 487, checked in by smasson, 11 years ago

bugfix to be used in batch mode

  • 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; namepsin 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 <proidl>DEVICE</proidl>.
39;
40; @uses
41; <pro>cm_4ps</pro>
42;
43; @history
44; Sebastien Masson (smasson\@lodyc.jussieu.fr)
45; 21/12/98
46; 1/2/98: ajout de nameps en input
47; 1/9/1999: ajout du mot cle FILENAME et du widget
48; June 2005: Sebastien Masson, cleaning, english version with new commons
49;
50; @version
51; $Id$
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;------------------------------------------------------------
102; we define xsize, ysize, xoffset and yoffset
103;------------------------------------------------------------
104   IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $
105     key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape))
106
107   if key_portrait EQ 1 then begin
108      xs = min(page_size)
109      ys = max(page_size)
110      xoff = 0.
111      yoff = 0.
112   ENDIF ELSE BEGIN
113      xs = max(page_size)
114      ys = min(page_size)
115      xoff = 0.
116      yoff = max(page_size)
117   ENDELSE
118;------------------------------------------------------------
119; We define the device of the postscript mode
120;------------------------------------------------------------
121   device, /color, /palatino, filename = strcompress(nameps, /remove_all) $
122           , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $
123           , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $
124           , bits_per_pixel = 8, language_level = 2, _EXTRA = ex
125; to make smaller postcripts
126   IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $
127   THEN !p.font = 0
128; show some informations
129   IF arg_present(infowidget) THEN $
130    infowidget = xnotice('Postscript file is currently processed...')
131;
132   RETURN
133END
Note: See TracBrowser for help on using the repository browser.