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

Last change on this file since 129 was 129, checked in by pinsard, 18 years ago

improvements of Postscript/*.pro header

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