[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[129] | 6 | ; @file_comments |
---|
[136] | 7 | ; switch to postscript mode and define it |
---|
[2] | 8 | ; |
---|
[136] | 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. |
---|
[2] | 12 | ; |
---|
[129] | 13 | ; @keyword FILENAME |
---|
[136] | 14 | ; to define the name of the postscript file through |
---|
| 15 | ; a keyword rather than with nameps input argument |
---|
[129] | 16 | ; (in this case the keyword can be pass through |
---|
| 17 | ; different routines via _EXTRA keyword). |
---|
[16] | 18 | ; |
---|
[129] | 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. |
---|
[16] | 24 | ; |
---|
[129] | 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 | ; |
---|
[118] | 29 | ; @keyword PORTRAIT |
---|
[136] | 30 | ; |
---|
[118] | 31 | ; @keyword LANDSCAPE |
---|
[16] | 32 | ; |
---|
[136] | 33 | ; @keyword KEEPPFONT |
---|
| 34 | ; same as keep_pfont |
---|
[16] | 35 | ; |
---|
[136] | 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 |
---|
[16] | 40 | ; |
---|
[136] | 41 | ; @keyword _EXTRA |
---|
| 42 | ; used to pass any keyword to device procedure. |
---|
| 43 | ; |
---|
[118] | 44 | ; @uses cm_4ps |
---|
| 45 | ; |
---|
[104] | 46 | ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
| 47 | ; 21/12/98 |
---|
[16] | 48 | ; 1/2/98: ajout de nameps en input |
---|
[2] | 49 | ; 1/9/1999: ajout du mot cle FILENAME et du widget |
---|
[118] | 50 | ; June 2005: Sebastien Masson, cleaning, english version with new commons |
---|
| 51 | ; |
---|
| 52 | ; @version $Id$ |
---|
| 53 | ; |
---|
[2] | 54 | ;- |
---|
| 55 | ;------------------------------------------------------------ |
---|
| 56 | ;------------------------------------------------------------ |
---|
| 57 | ;------------------------------------------------------------ |
---|
[16] | 58 | pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $ |
---|
| 59 | , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $ |
---|
| 60 | , PORTRAIT = portrait, LANDSCAPE = landscape $ |
---|
| 61 | , LIGHTNESS = Lightness,_extra = ex |
---|
| 62 | ; |
---|
[114] | 63 | ; |
---|
| 64 | compile_opt idl2, strictarrsubs |
---|
| 65 | ; |
---|
[16] | 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 |
---|
| 73 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 74 | @updatenew |
---|
| 75 | ENDIF |
---|
| 76 | ;------------------------------------------------------------ |
---|
[136] | 77 | ; close the postscript device if we are already in postscript mode |
---|
[16] | 78 | IF !d.name EQ 'PS' THEN device, /close |
---|
| 79 | ; switch to postscript mode |
---|
[2] | 80 | set_plot,'ps' |
---|
| 81 | ;------------------------------------------------------------ |
---|
[16] | 82 | ; if we use keyword Lightness |
---|
| 83 | ; save the actual color palette in a temporary file |
---|
| 84 | ; (to be restored when calling closeps |
---|
[2] | 85 | ;------------------------------------------------------------ |
---|
[16] | 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 |
---|
[2] | 94 | ;------------------------------------------------------------ |
---|
[16] | 95 | ; we define the name of the file |
---|
[2] | 96 | ;------------------------------------------------------------ |
---|
[16] | 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) |
---|
[2] | 107 | ;------------------------------------------------------------ |
---|
[118] | 108 | ; we define xsize, ysize, xoffset et yoffset |
---|
[2] | 109 | ;------------------------------------------------------------ |
---|
[69] | 110 | IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $ |
---|
[16] | 111 | key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) |
---|
[69] | 112 | |
---|
[16] | 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] | 118 | ENDIF ELSE BEGIN |
---|
[16] | 119 | xs = max(page_size) |
---|
| 120 | ys = min(page_size) |
---|
| 121 | xoff = 0. |
---|
| 122 | yoff = max(page_size) |
---|
[118] | 123 | ENDELSE |
---|
[2] | 124 | ;------------------------------------------------------------ |
---|
[16] | 125 | ; We define the device of the postscript mode |
---|
[2] | 126 | ;------------------------------------------------------------ |
---|
[16] | 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, _extra = ex |
---|
| 131 | ; to make smaller postcripts |
---|
| 132 | IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $ |
---|
[118] | 133 | THEN !p.font = 0 |
---|
[16] | 134 | ; show some informations |
---|
| 135 | IF arg_present(infowidget) THEN $ |
---|
| 136 | infowidget = xnotice('Postcript file is currently processed...') |
---|
[2] | 137 | ; |
---|
[16] | 138 | RETURN |
---|
[2] | 139 | END |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | |
---|