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 | ; cm_4ps |
---|
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 | ;- |
---|
54 | ; |
---|
55 | PRO 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 | @cm_4ps |
---|
69 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
70 | @updatenew |
---|
71 | ENDIF |
---|
72 | ;------------------------------------------------------------ |
---|
73 | ; close the postscript device if we are already in postscript mode |
---|
74 | IF !d.name EQ 'PS' THEN device, /close |
---|
75 | ; switch to postscript mode |
---|
76 | set_plot,'ps' |
---|
77 | ;------------------------------------------------------------ |
---|
78 | ; if we use keyword Lightness |
---|
79 | ; save the actual color palette in a temporary file |
---|
80 | ; (to be restored when calling closeps |
---|
81 | ;------------------------------------------------------------ |
---|
82 | IF n_elements(Lightness) NE 0 THEN BEGIN |
---|
83 | IF Lightness NE 1 THEN BEGIN |
---|
84 | tvlct, red, green, blue, /get |
---|
85 | def_myuniquetmpdir |
---|
86 | save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat' |
---|
87 | palit, Lightness, red, green, blue |
---|
88 | ENDIF |
---|
89 | ENDIF |
---|
90 | ;------------------------------------------------------------ |
---|
91 | ; we define the name of the file |
---|
92 | ;------------------------------------------------------------ |
---|
93 | CASE 1 OF |
---|
94 | n_params() EQ 1:nameps = namepsin |
---|
95 | keyword_set(filename): nameps = filename |
---|
96 | ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid) |
---|
97 | ENDCASE |
---|
98 | ; make sure that nameps ends with '.ps' |
---|
99 | nameps = file_dirname(nameps, /mark_directory) + $ |
---|
100 | file_basename(nameps, '.ps') + '.ps' |
---|
101 | ; add path (psdir) and check that nameps is ok |
---|
102 | nameps = isafile(nameps, iodir = psdir, /new) |
---|
103 | ;------------------------------------------------------------ |
---|
104 | ; we define xsize, ysize, xoffset et yoffset |
---|
105 | ;------------------------------------------------------------ |
---|
106 | IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $ |
---|
107 | key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) |
---|
108 | |
---|
109 | if key_portrait EQ 1 then begin |
---|
110 | xs = min(page_size) |
---|
111 | ys = max(page_size) |
---|
112 | xoff = 0. |
---|
113 | yoff = 0. |
---|
114 | ENDIF ELSE BEGIN |
---|
115 | xs = max(page_size) |
---|
116 | ys = min(page_size) |
---|
117 | xoff = 0. |
---|
118 | yoff = max(page_size) |
---|
119 | ENDELSE |
---|
120 | ;------------------------------------------------------------ |
---|
121 | ; We define the device of the postscript mode |
---|
122 | ;------------------------------------------------------------ |
---|
123 | device, /color, /palatino, filename = strcompress(nameps, /remove_all) $ |
---|
124 | , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $ |
---|
125 | , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $ |
---|
126 | , bits_per_pixel = 8, language_level = 2, _EXTRA = ex |
---|
127 | ; to make smaller postcripts |
---|
128 | IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $ |
---|
129 | THEN !p.font = 0 |
---|
130 | ; show some informations |
---|
131 | IF arg_present(infowidget) THEN $ |
---|
132 | infowidget = xnotice('Postcript file is currently processed...') |
---|
133 | ; |
---|
134 | RETURN |
---|
135 | END |
---|