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

Last change on this file since 167 was 167, checked in by smasson, 18 years ago

clean div, curl, grad + minors bugfix

  • 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
15; a keyword rather than with nameps input 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;
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 $Id$
53;
54;-
55;------------------------------------------------------------
56;------------------------------------------------------------
57;------------------------------------------------------------
58pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $
59            , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $
60            , PORTRAIT = portrait, LANDSCAPE = landscape $
61            , LIGHTNESS = Lightness,_extra = ex
62;
63;
64  compile_opt idl2, strictarrsubs
65;
66   IF lmgr(/demo) EQ 1 THEN BEGIN
67      dummy = report('impossible to create a PS in demo mode')
68      return
69   ENDIF
70;------------------------------------------------------------
71; include commons
72@cm_4ps
73IF NOT keyword_set(key_forgetold) THEN BEGIN
74@updatenew
75ENDIF
76;------------------------------------------------------------
77; close the postscript device if we are already in postscript mode
78   IF !d.name EQ 'PS' THEN device, /close
79; switch to postscript mode
80   set_plot,'ps'
81;------------------------------------------------------------
82; if we use  keyword Lightness
83; save the actual color palette in a temporary file
84; (to be restored when calling closeps
85;------------------------------------------------------------
86   IF n_elements(Lightness) NE 0 THEN BEGIN
87     IF Lightness NE 1 THEN BEGIN
88       tvlct, red, green, blue, /get
89       def_myuniquetmpdir
90       save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat'
91       palit, Lightness, red, green, blue
92     ENDIF
93   ENDIF
94;------------------------------------------------------------
95; we define the name of the file
96;------------------------------------------------------------
97   CASE 1 OF
98     n_params() EQ 1:nameps = namepsin
99     keyword_set(filename): nameps = filename
100     ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid)
101   ENDCASE
102; make sure that nameps ends with '.ps'
103   nameps = file_dirname(nameps, /mark_directory) + $
104            file_basename(nameps, '.ps') + '.ps'
105; add path (psdir) and check that nameps is ok
106   nameps = isafile(nameps, iodir = psdir, /new)
107;------------------------------------------------------------
108; we define xsize, ysize, xoffset et  yoffset
109;------------------------------------------------------------
110   IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $
111     key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape))
112
113   if key_portrait EQ 1 then begin
114      xs = min(page_size)
115      ys = max(page_size)
116      xoff = 0.
117      yoff = 0.
118   ENDIF ELSE BEGIN
119      xs = max(page_size)
120      ys = min(page_size)
121      xoff = 0.
122      yoff = max(page_size)
123   ENDELSE
124;------------------------------------------------------------
125; We define the device of the postscript mode
126;------------------------------------------------------------
127   device, /color, /palatino, filename = strcompress(nameps, /remove_all) $
128           , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $
129           , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $
130           , bits_per_pixel = 8, language_level = 2, _extra = ex
131; to make smaller postcripts
132   IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $
133   THEN !p.font = 0
134; show some informations
135   IF arg_present(infowidget) THEN $
136    infowidget = xnotice('Postcript file is currently processed...')
137;
138   RETURN
139END
140
141
142
143
144
145
146
147
148
149
150
151
Note: See TracBrowser for help on using the repository browser.