[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[129] | 3 | ; @file_comments |
---|
[136] | 4 | ; switch to postscript mode and define it |
---|
[2] | 5 | ; |
---|
[136] | 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. |
---|
[2] | 9 | ; |
---|
[129] | 10 | ; @keyword FILENAME |
---|
[231] | 11 | ; to define the name of the postscript file through a keyword rather than with |
---|
[232] | 12 | ; namepsin input argument (in this case the keyword can be pass through |
---|
[129] | 13 | ; different routines via _EXTRA keyword). |
---|
[16] | 14 | ; |
---|
[129] | 15 | ; @keyword INFOWIDGET |
---|
[231] | 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 |
---|
[186] | 18 | ; long integer. |
---|
[231] | 19 | ; This id is needed by <pro>closeps</pro> to kill the information widget. |
---|
[16] | 20 | ; |
---|
[129] | 21 | ; @keyword KEEP_PFONT |
---|
| 22 | ; activate to suppress the modification of !p.font |
---|
[230] | 23 | ; (by default we force !p.font = 0 to make smaller postscripts) |
---|
[129] | 24 | ; |
---|
[118] | 25 | ; @keyword PORTRAIT |
---|
[136] | 26 | ; |
---|
[118] | 27 | ; @keyword LANDSCAPE |
---|
[16] | 28 | ; |
---|
[136] | 29 | ; @keyword KEEPPFONT |
---|
| 30 | ; same as keep_pfont |
---|
[16] | 31 | ; |
---|
[136] | 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 |
---|
[16] | 36 | ; |
---|
[136] | 37 | ; @keyword _EXTRA |
---|
[260] | 38 | ; Used to pass keywords to <proidl>DEVICE</proidl>. |
---|
[136] | 39 | ; |
---|
[238] | 40 | ; @uses |
---|
[231] | 41 | ; cm_4ps |
---|
[118] | 42 | ; |
---|
[238] | 43 | ; @history |
---|
| 44 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[104] | 45 | ; 21/12/98 |
---|
[16] | 46 | ; 1/2/98: ajout de nameps en input |
---|
[2] | 47 | ; 1/9/1999: ajout du mot cle FILENAME et du widget |
---|
[118] | 48 | ; June 2005: Sebastien Masson, cleaning, english version with new commons |
---|
| 49 | ; |
---|
[230] | 50 | ; @version |
---|
| 51 | ; $Id$ |
---|
[118] | 52 | ; |
---|
[2] | 53 | ;- |
---|
[231] | 54 | ; |
---|
[238] | 55 | PRO openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $ |
---|
[16] | 56 | , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $ |
---|
| 57 | , PORTRAIT = portrait, LANDSCAPE = landscape $ |
---|
[232] | 58 | , LIGHTNESS = Lightness,_EXTRA = ex |
---|
[16] | 59 | ; |
---|
[114] | 60 | ; |
---|
| 61 | compile_opt idl2, strictarrsubs |
---|
| 62 | ; |
---|
[16] | 63 | IF lmgr(/demo) EQ 1 THEN BEGIN |
---|
| 64 | dummy = report('impossible to create a PS in demo mode') |
---|
| 65 | return |
---|
| 66 | ENDIF |
---|
[231] | 67 | ; |
---|
[16] | 68 | @cm_4ps |
---|
| 69 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 70 | @updatenew |
---|
| 71 | ENDIF |
---|
| 72 | ;------------------------------------------------------------ |
---|
[136] | 73 | ; close the postscript device if we are already in postscript mode |
---|
[16] | 74 | IF !d.name EQ 'PS' THEN device, /close |
---|
| 75 | ; switch to postscript mode |
---|
[2] | 76 | set_plot,'ps' |
---|
| 77 | ;------------------------------------------------------------ |
---|
[16] | 78 | ; if we use keyword Lightness |
---|
| 79 | ; save the actual color palette in a temporary file |
---|
| 80 | ; (to be restored when calling closeps |
---|
[2] | 81 | ;------------------------------------------------------------ |
---|
[16] | 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 |
---|
[2] | 90 | ;------------------------------------------------------------ |
---|
[16] | 91 | ; we define the name of the file |
---|
[2] | 92 | ;------------------------------------------------------------ |
---|
[16] | 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) |
---|
[2] | 103 | ;------------------------------------------------------------ |
---|
[296] | 104 | ; we define xsize, ysize, xoffset and yoffset |
---|
[2] | 105 | ;------------------------------------------------------------ |
---|
[69] | 106 | IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $ |
---|
[16] | 107 | key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) |
---|
[69] | 108 | |
---|
[16] | 109 | if key_portrait EQ 1 then begin |
---|
| 110 | xs = min(page_size) |
---|
| 111 | ys = max(page_size) |
---|
| 112 | xoff = 0. |
---|
| 113 | yoff = 0. |
---|
[118] | 114 | ENDIF ELSE BEGIN |
---|
[16] | 115 | xs = max(page_size) |
---|
| 116 | ys = min(page_size) |
---|
| 117 | xoff = 0. |
---|
| 118 | yoff = max(page_size) |
---|
[118] | 119 | ENDELSE |
---|
[2] | 120 | ;------------------------------------------------------------ |
---|
[16] | 121 | ; We define the device of the postscript mode |
---|
[2] | 122 | ;------------------------------------------------------------ |
---|
[16] | 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 $ |
---|
[232] | 126 | , bits_per_pixel = 8, language_level = 2, _EXTRA = ex |
---|
[16] | 127 | ; to make smaller postcripts |
---|
| 128 | IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $ |
---|
[118] | 129 | THEN !p.font = 0 |
---|
[16] | 130 | ; show some informations |
---|
| 131 | IF arg_present(infowidget) THEN $ |
---|
[292] | 132 | infowidget = xnotice('Postscript file is currently processed...') |
---|
[2] | 133 | ; |
---|
[16] | 134 | RETURN |
---|
[2] | 135 | END |
---|