1proc x31 {{w loopback}} {
2
3    # Test setting / getting familying parameters before plinit.
4    # Save values set by plparseopts to be restored later.
5
6    $w cmd plgfam fam0 num0 bmax0
7    set fam1 0
8    set num1 10
9    set bmax1 1000
10    $w cmd plsfam $fam1 $num1 $bmax1
11
12    # Retrieve the same values?
13    $w cmd plgfam fam2 num2 bmax2
14    puts [ format "family parameters: fam, num, bmax = %d %d %d" $fam2 $num2 $bmax2 ]
15    if {$fam2 != $fam1 || $num2 != $num1 || $bmax2 != $bmax1} {
16        puts stderr "plgfam test failed"
17        set status 1
18    }
19    # Restore values set initially by plparseopts.
20    $w cmd plsfam $fam0 $num0 $bmax0
21
22    # Test setting / getting page parameters before plinit.
23    # Save values set by plparseopts to be restored later.
24    $w cmd plgpage xp0 yp0 xleng0 yleng0 xoff0 yoff0
25    set xp1 200.
26    set yp1 200.
27    set xleng1 400
28    set yleng1 200
29    set xoff1 10
30    set yoff1 20
31    $w cmd plspage $xp1 $yp1 $xleng1 $yleng1 $xoff1 $yoff1
32
33    # Retrieve the same values?
34    $w cmd plgpage xp2 yp2 xleng2 yleng2 xoff2 yoff2
35    puts [ format "page parameters: xp, yp, xleng, yleng, xoff, yoff = %f %f %d %d %d %d" $xp2 $yp2 $xleng2 $yleng2 $xoff2 $yoff2 ]
36    if {$xp2 != $xp1 || $yp2 != $yp1 || $xleng2 != $xleng1 || $yleng2 != $yleng1 || $xoff2 != $xoff1 || $yoff2 != $yoff1} {
37        puts stderr "plgpage test failed"
38        set status 1
39    }
40    # Restore values set initially by plparseopts.
41    $w cmd plspage $xp0 $yp0 $xleng0 $yleng0 $xoff0 $yoff0
42
43    # Test setting / getting compression parameter across plinit.
44    set compression1 95
45    $w cmd plscompression $compression1
46
47    $w cmd plinit
48
49    set status 0
50
51    # Test if device initialization screwed around with the preset
52    # compression parameter.
53    $w cmd plgcompression compression2
54    puts [ format "Output various PLplot parameters" ]
55    puts [ format "compression parameter = %d" $compression2 ]
56    if {$compression2 != $compression1} {
57        puts stderr "plgcompression test failed"
58        set status 1
59    }
60
61    # Exercise plscolor, plscol0, plscmap1, and plscmap1a to make sure
62    # they work without any obvious error messages.
63    $w cmd plscolor 1
64    matrix r1 i 2 = {0, 255}
65    matrix g1 i 2 = {255, 0}
66    matrix b1 i 2 = {0, 0}
67    matrix a1 f 2 = {1.0, 1.0}
68    $w cmd plscmap1 r1 g1 b1
69    $w cmd plscmap1a r1 g1 b1 a1
70
71    $w cmd plglevel level2
72    puts [ format "level parameter = %d" $level2 ]
73    if {$level2 != 1} {
74        puts stderr "plglevel test failed."
75        set status 1
76    }
77
78    $w cmd pladv 0
79    set xmin0 0.01
80    set xmax0 0.99
81    set ymin0 0.02
82    set ymax0 0.49
83    $w cmd plvpor $xmin0 $xmax0 $ymin0 $ymax0
84    $w cmd plgvpd xmin xmax ymin ymax
85    puts [ format "plvpor: xmin, xmax, ymin, ymax = %f %f %f %f" $xmin $xmax $ymin $ymax ]
86    if {$xmin != $xmin0 || $xmax != $xmax0 || $ymin != $ymin0 || $ymax != $ymax0} {
87        puts stderr "plgvpd test failed"
88        set status 1
89    }
90    set xmid [ expr {0.5*($xmin+$xmax)} ]
91    set ymid [ expr {0.5*($ymin+$ymax)} ]
92
93    set xmin0 0.2
94    set xmax0 0.3
95    set ymin0 0.4
96    set ymax0 0.5
97    $w cmd plwind $xmin0 $xmax0 $ymin0 $ymax0
98    $w cmd plgvpw xmin xmax ymin ymax
99    puts [ format "plwind: xmin, xmax, ymin, ymax = %f %f %f %f" $xmin $xmax $ymin $ymax ]
100    if {$xmin != $xmin0 || $xmax != $xmax0 || $ymin != $ymin0 || $ymax != $ymax0} {
101        puts stderr "plgvpw test failed"
102        set status 1
103    }
104
105    # Get world coordinates for middle of viewport
106     $w cmd plcalc_world $xmid $ymid wx wy win
107    puts [ format "world parameters: wx, wy, win = %f %f %d" $wx $wy $win ]
108    if {abs($wx-0.5*($xmin+$xmax)) > 1.0E-5 || abs($wy-0.5*($ymin+$ymax)) > 1.0E-5} {
109        puts stderr "plcalc_world test failed"
110        set status 1
111    }
112
113    # Retrieve and print the name of the output file (if any)
114    $w cmd plgfnam fnam
115    if {$fnam == ""} {
116	puts [ format "No output file name is set" ]
117    } {else} {
118	puts [ format "Output file name read" ]
119    }
120    puts stderr [ format "Output file name is %s" $fnam ]
121
122    # Set and get the number of digits used to display axis labels
123    # Note digits is currently ignored in pls[xyz]ax and
124    # therefore it does not make sense to test the returned value.
125    $w cmd plsxax 3 0
126    $w cmd plgxax digmax digits
127    puts [ format "x axis parameters: digmax, digits = %d %d" $digmax $digits ]
128    if {$digmax != 3} {
129	puts stderr "plgxax test failed"
130	set status 1
131    }
132
133    $w cmd plsyax 4 0
134    $w cmd plgyax digmax digits
135    puts [ format "y axis parameters: digmax, digits = %d %d" $digmax $digits ]
136    if {$digmax != 4} {
137	puts stderr "plgyax test failed"
138	set status 1
139    }
140    $w cmd plszax 5 0
141    $w cmd plgzax digmax digits
142    puts [ format "z axis parameters: digmax, digits = %d %d" $digmax $digits ]
143    if {$digmax != 5} {
144	puts stderr "plgzax test failed"
145	set status 1
146    }
147
148    set mar0 0.05
149    set aspect0 [expr {$::PLPLOT::PL_NOTSET}]
150    set jx0 0.1
151    set jy0 0.2
152    $w cmd plsdidev $mar0 $aspect0 $jx0 $jy0
153    $w cmd plgdidev mar aspect jx jy
154    puts [ format "device-space window parameters: mar, aspect, jx, jy = %f %f %f %f" $mar $aspect $jx $jy ]
155    if {$mar != $mar0 || $jx != $jx0 || $jy != $jy0} {
156	puts stderr "plgdidev test failed"
157	set status 1
158    }
159
160    set ori0 1.0
161    $w cmd plsdiori $ori0
162    $w cmd plgdiori ori
163    puts [ format "ori parameter = %f" $ori ]
164    if {$ori != $ori0 } {
165	puts stderr "plgdiori test failed"
166	set status 1
167    }
168
169    set xmin0 0.1
170    set ymin0 0.2
171    set xmax0 0.9
172    set ymax0 0.8
173    $w cmd plsdiplt $xmin0 $ymin0 $xmax0 $ymax0
174    $w cmd plgdiplt xmin ymin xmax ymax
175    puts [ format "plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f" $xmin $ymin $xmax $ymax ]
176    if {$xmin != $xmin0 || $ymin != $ymin0 || $xmax != $xmax0 || $ymax != $ymax0} {
177	puts stderr "plgdiplt test failed"
178	set status 1
179    }
180
181    set zxmin0 0.1
182    set zymin0 0.1
183    set zxmax0 0.9
184    set zymax0 0.9
185    $w cmd plsdiplz $zxmin0 $zymin0 $zxmax0 $zymax0
186    $w cmd plgdiplt zxmin zymin zxmax zymax
187    puts [ format "zoomed plot-space window parameters: xmin, ymin, xmax, ymax = %f %f %f %f" $zxmin $zymin $zxmax $zymax ]
188    if {abs($zxmin -($xmin + ($xmax-$xmin)*$zxmin0)) > 1.0E-5 || abs($zymin -($ymin+($ymax-$ymin)*$zymin0)) > 1.0E-5 || abs($zxmax -($xmin+($xmax-$xmin)*$zxmax0)) > 1.0E-5 || abs($zymax -($ymin+($ymax-$ymin)*$zymax0)) > 1.0E-5 } {
189	puts stderr "plsdiplz test failed"
190	set status 1
191    }
192
193    set r0 10
194    set g0 20
195    set b0 30
196    $w cmd plscolbg $r0 $g0 $b0
197    $w cmd plgcolbg r g b
198    puts [ format "background colour parameters: r, g, b = %d %d %d" $r $g $b ]
199    if {$r != $r0 || $g != $g0 || $b != $b0} {
200	puts stderr "plgcolbg test failed"
201	set status 1
202    }
203
204    set r0 20
205    set g0 30
206    set b0 40
207    set a0 0.5
208    $w cmd plscolbga $r0 $g0 $b0 $a0
209    $w cmd plgcolbga r g b a
210    puts [ format "background/transparency colour parameters: r, g, b, a = %d %d %d %f" $r $g $b $a ]
211    if {$r != $r0 || $g != $g0 || $b != $b0 || $a != $a0} {
212	puts stderr "plgcolbga test failed"
213	set status 1
214    }
215
216
217    # Restore defaults
218    # $w cmd plcol0 1
219    $w cmd plend
220}
221