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

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

new compilation options (compile_opt idl2, strictarrsubs) in each routine

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