source: trunk/SRC/Utilities/set_default_device.pro @ 479

Last change on this file since 479 was 479, checked in by smasson, 12 years ago

full integration of the batch mode with Z buffer

File size: 1.8 KB
Line 
1;+
2;
3; @file_comments
4; set X or Z devices with the good arguments...
5; defined key_batch to use IDL in batch mode through the Z buffer
6;
7; @categories
8; devide managment and default definitions
9;
10; @examples
11;
12;   set_default_device
13;
14; @keyword BATCH {in}{optional}{type=0 or 1}
15; define this keyword to 0 or 1 to force the definition of key_batch
16; if neither this keyword or key_batch are defined, define set
17; key_batch based on <proidl>FSTAT</proidl> result
18;
19; @history
20;
21;   * August 2012: creation by pinsardf and massons
22;     thanks to fstat help and
23;     http://idl.tamu.edu/headless_X.html for z-buffer usage
24;     IDL instruction HELP,/FILES,-2,-1,0 might also be usefull here
25;
26; @version
27;
28; $Id$
29;
30; $URL$
31;
32;-
33pro set_default_device, BATCH = batch
34;
35  compile_opt idl2, strictarrsubs
36;
37@cm_general
38;
39; define key_batch if it not already done...
40  IF n_elements(batch) EQ 0 THEN BEGIN
41    IF n_elements(key_batch) EQ 0 THEN BEGIN   ; if not already defined
42      fstat0_structure = FSTAT(0)              ; automatic definition
43      key_batch = 1 - fstat0_structure.isatty
44    ENDIF
45  ENDIF ELSE key_batch = batch  ; force the definition with batch keyword
46;
47  IF keyword_set(key_batch) THEN BEGIN
48    set_plot, 'Z'
49; nb of colors is set to 8 in order to allow color number from 0 to 256
50    device, SET_PIXEL_DEPTH = 8, Z_BUFFERING = 0
51  ENDIF ELSE BEGIN
52    thisOS = strupcase(strmid(!version.os_family, 0, 3))
53    CASE thisOS of
54      'WIN': SET_PLOT, thisOS
55      ELSE: SET_PLOT, 'X'
56    ENDCASE
57  ENDELSE
58  device, DECOMPOSED = 0 ; use color indexes
59; force background color index to the last color (white)
60  !p.BACKGROUND = (!d.n_colors-1) < 255
61; force drawing color index to the first color (black)
62  !p.color = 0
63  IF !d.name EQ 'Z' THEN erase  ; apply these changes in !p
64;
65  RETURN
66END
Note: See TracBrowser for help on using the repository browser.