;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ ;+ ; NAME:openps ; ; PURPOSE:switch to postcript mode and define it ; ; CALLING SEQUENCE:openps[,nameps] ; ; OPTIONAL INPUT: ; nameps: name of the postscript file. Extension '.ps' is added ; if missing. It will be stored in the psdir directory. ; ; KEYWORD PARAMETERS: ; ; FILENAME: to define the name of the postcript file through ; a keyword rather than with nameps inut argument ; (in this case the keyword can be pass through ; different routines via _extra keyword). ; ; INFOWIDGET: If INFOWIDGET is present, it specifies a named ; variable into which the id of the widget giving informations ; about the postscript creation is stored as a long integer. ; This id is needed by close ps to kill the information widget. ; ; KEEP_PFONT: activate to suppress the modification of !p.font ; (by defaut we force !p.font = 0 to make smaller postscripts) ; KEEPPFONT: same as keep_pfont ; ; LIGHTNESS: a scalar used to change the Lightness of the color ; palette to be abble to adjust according to the printer we use, ; the media (paper or slide)... ; lightness < 1 to get lighter colors ; > 1 to get darker colors ; ; _EXTRA: used to pass any keyword to device procedure. ; ; COMMON BLOCKS: cm_4ps ; ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) ; 21/12/98 ; 1/2/98: ajout de nameps en input ; 1/9/1999: ajout du mot cle FILENAME et du widget ; June 2005: Sebastien Masson, cleaning, english version with new commons ;- ;------------------------------------------------------------ ;------------------------------------------------------------ ;------------------------------------------------------------ pro openps, namepsin, FILENAME = filename, INFOWIDGET = infowidget $ , KEEPPFONT = keeppfont, KEEP_PFONT = keep_pfont $ , PORTRAIT = portrait, LANDSCAPE = landscape $ , LIGHTNESS = Lightness,_extra = ex ; IF lmgr(/demo) EQ 1 THEN BEGIN dummy = report('impossible to create a PS in demo mode') return ENDIF ;------------------------------------------------------------ ; include commons @cm_4ps IF NOT keyword_set(key_forgetold) THEN BEGIN @updatenew ENDIF ;------------------------------------------------------------ ; close the postcript device if we are already in postcsrit mode IF !d.name EQ 'PS' THEN device, /close ; switch to postscript mode set_plot,'ps' ;------------------------------------------------------------ ; if we use keyword Lightness ; save the actual color palette in a temporary file ; (to be restored when calling closeps ;------------------------------------------------------------ IF n_elements(Lightness) NE 0 THEN BEGIN IF Lightness NE 1 THEN BEGIN tvlct, red, green, blue, /get def_myuniquetmpdir save, red, green, blue, filename = myuniquetmpdir + 'original_colors.dat' palit, Lightness, red, green, blue ENDIF ENDIF ;------------------------------------------------------------ ; we define the name of the file ;------------------------------------------------------------ CASE 1 OF n_params() EQ 1:nameps = namepsin keyword_set(filename): nameps = filename ELSE:nameps = xquestion('Name of the postscript file?', 'idl.ps', /chkwid) ENDCASE ; make sure that nameps ends with '.ps' nameps = file_dirname(nameps, /mark_directory) + $ file_basename(nameps, '.ps') + '.ps' ; add path (psdir) and check that nameps is ok nameps = isafile(nameps, iodir = psdir, /new) ;------------------------------------------------------------ ; we define xsize, ysize, xoffset et yoffset ;------------------------------------------------------------ IF n_elements(portrait) NE 0 OR n_elements(landscape) NE 0 THEN $ key_portrait = keyword_set(portrait) * (1 - keyword_set(landscape)) if key_portrait EQ 1 then begin xs = min(page_size) ys = max(page_size) xoff = 0. yoff = 0. ENDIF ELSE BEGIN xs = max(page_size) ys = min(page_size) xoff = 0. yoff = max(page_size) ENDELSE ;------------------------------------------------------------ ; We define the device of the postscript mode ;------------------------------------------------------------ device, /color, /palatino, filename = strcompress(nameps, /remove_all) $ , LANDSCAPE = 1 - key_portrait, PORTRAIT = key_portrait $ , xsize = xs, ysize = ys, xoffset = xoff, yoffset = yoff $ , bits_per_pixel = 8, _extra = ex ; to make smaller postcripts IF NOT (keyword_set(keeppfont) OR keyword_set(keep_pfont)) $ THEN !p.font = 0 ; show some informations IF arg_present(infowidget) THEN $ infowidget = xnotice('Postcript file is currently processed...') ; RETURN END