;+ ; ; @file_comments ; set X or Z devices with the good arguments... ; defined key_batch to use IDL in batch mode through the Z buffer ; ; @categories ; devide managment and default definitions ; ; @examples ; ; set_default_device ; ; @keyword BATCH {in}{optional}{type=0 or 1} ; define this keyword to 0 or 1 to force the definition of key_batch ; if neither this keyword or key_batch are defined, define set ; key_batch based on FSTAT result ; ; @history ; ; * August 2012: creation by pinsardf and massons ; thanks to fstat help and ; http://idl.tamu.edu/headless_X.html for z-buffer usage ; IDL instruction HELP,/FILES,-2,-1,0 might also be usefull here ; ; @version ; ; $Id$ ; ; $URL$ ; ;- pro set_default_device, BATCH = batch ; compile_opt idl2, strictarrsubs ; @cm_general ; ; define key_batch if it not already done... IF n_elements(batch) EQ 0 THEN BEGIN IF n_elements(key_batch) EQ 0 THEN BEGIN ; if not already defined fstat0_structure = FSTAT(0) ; automatic definition key_batch = 1 - fstat0_structure.isatty ENDIF ENDIF ELSE key_batch = batch ; force the definition with batch keyword ; IF keyword_set(key_batch) THEN BEGIN set_plot, 'Z' ; nb of colors is set to 8 in order to allow color number from 0 to 256 device, SET_PIXEL_DEPTH = 8, Z_BUFFERING = 0 ENDIF ELSE BEGIN thisOS = strupcase(strmid(!version.os_family, 0, 3)) CASE thisOS of 'WIN': SET_PLOT, thisOS ELSE: SET_PLOT, 'X' ENDCASE ENDELSE device, DECOMPOSED = 0 ; use color indexes ; force background color index to the last color (white) !p.BACKGROUND = (!d.n_colors-1) < 255 ; force drawing color index to the first color (black) !p.color = 0 IF !d.name EQ 'Z' THEN erase ; apply these changes in !p ; RETURN END