[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; |
---|
[104] | 6 | ; @file_comments switch to postcript mode and define it |
---|
[2] | 7 | ; |
---|
[104] | 8 | ; @param namepsin {in}{optional} name of the postscript file. Extension '.ps' is added |
---|
[16] | 9 | ; if missing. It will be stored in the psdir directory. |
---|
[2] | 10 | ; |
---|
[104] | 11 | ; @keyword FILENAME to define the name of the postcript file through |
---|
[16] | 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 | ; |
---|
[104] | 16 | ; @keyword INFOWIDGET If INFOWIDGET is present, it specifies a named |
---|
[16] | 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 | ; |
---|
[104] | 21 | ; @keyword KEEP_PFONT activate to suppress the modification of !p.font |
---|
[16] | 22 | ; (by defaut we force !p.font = 0 to make smaller postscripts) |
---|
[104] | 23 | ; @keyword KEEPPFONT same as keep_pfont |
---|
[16] | 24 | ; |
---|
[104] | 25 | ; @keyword LIGHTNESS a scalar used to change the Lightness of the color |
---|
[16] | 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 | ; |
---|
[104] | 31 | ; @keyword _EXTRA: used to pass any keyword to device procedure. |
---|
[2] | 32 | ; |
---|
[104] | 33 | ; uses cm_4ps |
---|
[16] | 34 | ; |
---|
[104] | 35 | ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
| 36 | ; 21/12/98 |
---|
[16] | 37 | ; 1/2/98: ajout de nameps en input |
---|
[2] | 38 | ; 1/9/1999: ajout du mot cle FILENAME et du widget |
---|
[16] | 39 | ; June 2005: Sebastien Masson, cleaning, english version with new commons |
---|
[2] | 40 | ;- |
---|
| 41 | ;------------------------------------------------------------ |
---|
| 42 | ;------------------------------------------------------------ |
---|
| 43 | ;------------------------------------------------------------ |
---|
[16] | 44 | pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $ |
---|
| 45 | , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $ |
---|
| 46 | , PORTRAIT = portrait, LANDSCAPE = landscape $ |
---|
| 47 | , LIGHTNESS = Lightness,_extra = ex |
---|
| 48 | ; |
---|
[114] | 49 | ; |
---|
| 50 | compile_opt idl2, strictarrsubs |
---|
| 51 | ; |
---|
[16] | 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 |
---|
| 59 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 60 | @updatenew |
---|
| 61 | ENDIF |
---|
| 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 |
---|
[2] | 66 | set_plot,'ps' |
---|
| 67 | ;------------------------------------------------------------ |
---|
[16] | 68 | ; if we use keyword Lightness |
---|
| 69 | ; save the actual color palette in a temporary file |
---|
| 70 | ; (to be restored when calling closeps |
---|
[2] | 71 | ;------------------------------------------------------------ |
---|
[16] | 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 |
---|
[2] | 80 | ;------------------------------------------------------------ |
---|
[16] | 81 | ; we define the name of the file |
---|
[2] | 82 | ;------------------------------------------------------------ |
---|
[16] | 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) |
---|
[2] | 93 | ;------------------------------------------------------------ |
---|
[16] | 94 | ; we define xsize, ysize, xoffset et yoffset |
---|
[2] | 95 | ;------------------------------------------------------------ |
---|
[69] | 96 | IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $ |
---|
[16] | 97 | key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) |
---|
[69] | 98 | |
---|
[16] | 99 | if key_portrait EQ 1 then begin |
---|
| 100 | xs = min(page_size) |
---|
| 101 | ys = max(page_size) |
---|
| 102 | xoff = 0. |
---|
| 103 | yoff = 0. |
---|
[2] | 104 | ENDIF ELSE BEGIN |
---|
[16] | 105 | xs = max(page_size) |
---|
| 106 | ys = min(page_size) |
---|
| 107 | xoff = 0. |
---|
| 108 | yoff = max(page_size) |
---|
[2] | 109 | ENDELSE |
---|
| 110 | ;------------------------------------------------------------ |
---|
[16] | 111 | ; We define the device of the postscript mode |
---|
[2] | 112 | ;------------------------------------------------------------ |
---|
[16] | 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...') |
---|
[2] | 123 | ; |
---|
[16] | 124 | RETURN |
---|
[2] | 125 | END |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|