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

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

debug + new xxx

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