File cvisRenderWindow tcl Package Vizamrai Copyright 1997-2000 The Reg

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
##
## File: cvisRenderWindow.tcl
## Package: Vizamrai
## Copyright: (c) 1997-2000 The Regents of the University of California
## Revision: $Revision$
## Modified: $Date$
## Description: Render Window for 3D data
##
proc cvisTkCon {} {
set tracervar [::itcl::local cvisTrace #auto]
if {[info exists ::tkcon::PRIV(root)]} {
if [winfo ismapped $::tkcon::PRIV(root)] {
tkcon hide
} {
tkcon show
}
} {
global argv argc
# tkCon is reading command line args, this is bad
set argv ""
set argc 0
font create vizamraitkconn -family Courier -size 10
tkcon font vizamraitkconn
tkcon attach Main
}
}
class cvisView {
variable Views
variable ViewNames
constructor {} {
::cvis::RestartFile::Add $this
}
method SetClippingRange {name min max} {
set ViewNames($name) 1
set Views($name,ClippingRange) "$min $max"
}
method SetDistance {name distance} {
set ViewNames($name) 1
set Views($name,Distance) $distance
}
method SetEyeAngle {name angle} {
set ViewNames($name) 1
set Views($name,EyeAngle) $angle
}
method SetFocalDisk {name focaldisk} {
set ViewNames($name) 1
set Views($name,FocalDisk) $focaldisk
}
method SetFocalPoint {name x y z} {
set ViewNames($name) 1
set Views($name,FocalPoint) "$x $y $z"
}
method SetPosition {name x y z} {
set ViewNames($name) 1
set Views($name,Position) "$x $y $z"
}
method SetParallelProjection {name parallelprojection} {
set ViewNames($name) 1
set Views($name,ParallelProjection) $parallelprojection
}
method SetThickness {name thickness} {
set Views($name,Thickness) $thickness
}
method SetViewAngle {name viewangle} {
set Views($name,ViewAngle) $viewangle
}
method SetViewUp {name x y z} {
set Views($name,ViewUp) "$x $y $z"
}
method Save {file} {
foreach name [array names ViewNames] {
foreach i "ClippingRange Distance EyeAngle FocalDisk FocalPoint ParallelProjection Position Thickness ViewAngle ViewUp" {
puts $file "$this Set$i $name $Views($name,$i)"
}
}
}
# Sets view based on a camera
method SetViewFromCamera {name camera} {
set ViewNames($name) 1
set Views($name,ClippingRange) [$camera GetClippingRange]
set Views($name,Distance) [$camera GetDistance]
set Views($name,EyeAngle) [$camera GetEyeAngle]
set Views($name,FocalDisk) [$camera GetFocalDisk]
set Views($name,FocalPoint) [$camera GetFocalPoint]
set Views($name,Position) [$camera GetPosition]
set Views($name,ParallelProjection) \
[expr int([$camera GetParallelProjection])]
set Views($name,Thickness) [$camera GetThickness]
set Views($name,ViewAngle) [$camera GetViewAngle]
set Views($name,ViewUp) [$camera GetViewUp]
}
method GetViewToCamera {name camera} {
if {[array exists ViewNames]} {
if {[array names ViewNames $name] > 0 } {
eval $camera SetClippingRange $Views($name,ClippingRange)
$camera SetDistance $Views($name,Distance)
$camera SetEyeAngle $Views($name,EyeAngle)
$camera SetFocalDisk $Views($name,FocalDisk)
eval $camera SetFocalPoint $Views($name,FocalPoint)
eval $camera SetPosition $Views($name,Position)
$camera SetParallelProjection $Views($name,ParallelProjection)
$camera SetThickness $Views($name,Thickness)
$camera SetViewAngle $Views($name,ViewAngle)
eval $camera SetViewUp $Views($name,ViewUp)
return 1
}
}
return 0
}
method GetViewNames {} {
return [array names ViewNames]
}
}
class cvisRenderWindow {
variable Name
variable Create 1
variable UniformScaling 0
variable ParallelProjection 0
variable WindowNameProp
variable Renderer ""
variable RenderWindow ""
variable RenderWidget ""
variable ImageWriter ""
variable Size
# Interactors
variable InExpose 0
variable RubberZoomPerformed 0
variable RendererFound 0
variable LastX 0
variable LastY 0
variable WindowCenterX 0
variable WindowCenterY 0
variable TkInteractor_InteractiveUpdateRate 15.0
variable TkInteractor_StillUpdateRate 1.0E-37
variable InteractiveUpdateRate 15.0
variable StillUpdateRate 1.0E-37
# Rubber band zoom objects
variable RubberBandPoints ""
variable RubberBandLines ""
variable RubberBandScalars ""
variable RubberBandPolyData ""
variable RubberBandMapper ""
variable RubberBandActor ""
variable RubberBandColors ""
# State of the rubber band zoom
variable StartRubberZoomX 0
variable StartRubberZoomY 0
variable EndRubberZoomX 0
variable EndRubberZoomY 0
variable ComputeBoundsFlag 1
variable Bounds
variable Interface ""
method SetInterface {interface} {
set Interface $interface
}
method GetInterface {} {
return $Interface
}
method Save {file} {
set camera [$Renderer GetActiveCamera]
foreach i "ClippingRange Distance EyeAngle FocalDisk FocalPoint ParallelProjection Position Thickness ViewAngle ViewUp" {
puts $file "$this Set$i [$camera Get$i]"
}
}
method SetClippingRange {min max} {
[$Renderer GetActiveCamera] SetClippingRange $min $max
}
method SetDistance { distance} {
[$Renderer GetActiveCamera] SetDistance $distance
}
method SetEyeAngle { angle} {
[$Renderer GetActiveCamera] SetEyeAngle $angle
}
method SetFocalDisk { focaldisk} {
[$Renderer GetActiveCamera] SetFocalDisk $focaldisk
}
method SetFocalPoint { x y z} {
[$Renderer GetActiveCamera] SetFocalPoint $x $y $z
}
method SetPosition { x y z} {
[$Renderer GetActiveCamera] SetPosition $x $y $z
}
method SetParallelProjection { parallelprojection} {
[$Renderer GetActiveCamera] SetParallelProjection $parallelprojection
}
method SetThickness { thickness} {
[$Renderer GetActiveCamera] SetThickness $thickness
}
method SetViewAngle { viewangle} {
[$Renderer GetActiveCamera] SetViewAngle $viewangle
}
method SetViewUp { x y z} {
[$Renderer GetActiveCamera] SetViewUp $x $y $z
}
method UpdateRenderer {x y} {
set tracervar [::itcl::local cvisTrace #auto]
update
# Get the renderer window dimensions
set WindowX [lindex [$RenderWidget configure -width] 4]
set WindowY [lindex [$RenderWidget configure -height] 4]
# Find which renderer event has occurred in
set renderers [$RenderWindow GetRenderers]
set numRenderers [$renderers GetNumberOfItems]
# SGS removed multi renderer capablity
$renderers InitTraversal;
set CurrentRenderer [$renderers GetNextItem]
set viewport [$CurrentRenderer GetViewport]
set vpxmin [lindex $viewport 0]
set vpymin [lindex $viewport 1]
set vpxmax [lindex $viewport 2]
set vpymax [lindex $viewport 3]
set RendererFound 1
set WindowCenterX [expr double($WindowX)*(($vpxmax + $vpxmin)/2.0)]
set WindowCenterY [expr double($WindowY)*(($vpymax + $vpymin)/2.0)]
set CurrentCamera [$Renderer GetActiveCamera]
set LastX $x
set LastY $y
}
variable CurrentCamera ""
method StartPan {widget x y} {
$this StartMotion $widget $x $y
$widget select
}
method EndPan {widget x y} {
$this EndMotion $widget $x $y
$widget deselect
}
method StartRotate {widget x y} {
$this StartMotion $widget $x $y
$widget select
}
method EndRotate {widget x y} {
$this EndMotion $widget $x $y
$widget deselect
}
method StartZoom {widget x y} {
$this StartMotion $widget $x $y
$widget select
}
method EndZoom {widget x y} {
$this EndMotion $widget $x $y
$widget deselect
}
method StartMotion {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
UpdateRenderer $x $y
if { $RendererFound } {
set RubberZoomPerformed 0
$RenderWindow SetDesiredUpdateRate $InteractiveUpdateRate
}
}
method EndMotion {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
if { $RendererFound } {
$RenderWindow SetDesiredUpdateRate $StillUpdateRate
if { $RubberZoomPerformed } {
$Renderer RemoveProp $RubberBandActor
DoRubberZoom $widget
}
RenderInteractive
}
}
method Wireframe {} {
set tracervar [::itcl::local cvisTrace #auto]
set actors [$Renderer GetActors]
$actors InitTraversal
set actor [$actors GetNextItem]
while { $actor != "" } {
[$actor GetProperty] SetRepresentationToWireframe
set actor [$actors GetNextItem]
}
Render
}
method Surface {} {
set tracervar [::itcl::local cvisTrace #auto]
set actors [$Renderer GetActors]
$actors InitTraversal
set actor [$actors GetNextItem]
while { $actor != "" } {
[$actor GetProperty] SetRepresentationToSurface
set actor [$actors GetNextItem]
}
Render
}
variable PickedAssembly ""
variable PrePickedProperty ""
method PickActor {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
set WindowY [lindex [$widget configure -height] 4]
if { ! $RendererFound } { return }
if { $PickedAssembly != "" && $PrePickedProperty != "" } {
$PickedAssembly SetProperty $PrePickedProperty
# release hold on the property
$PrePickedProperty UnRegister $PrePickedProperty
set PrePickedProperty ""
}
if { $assembly != "" } {
set PickedAssembly $assembly
set PrePickedProperty [$PickedAssembly GetProperty]
# hold onto the property
$PrePickedProperty Register $PrePickedProperty
}
RenderInteractive
}
method Reset {} {
$Renderer ResetCamera
RenderInteractive
}
method ResetInteractorFullScreen {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
vtkMath math
set PI [math Pi]
ComputeBounds
set camera [$Renderer GetActiveCamera]
set vn(x) [expr double([lindex [$camera GetViewPlaneNormal] 0])]
set vn(y) [expr double([lindex [$camera GetViewPlaneNormal] 1])]
set vn(z) [expr double([lindex [$camera GetViewPlaneNormal] 2])]
set center(x) [expr ($Bounds(min,x) + $Bounds(max,x))/2.0]
set center(y) [expr ($Bounds(min,y) + $Bounds(max,y))/2.0]
set center(z) [expr ($Bounds(min,z) + $Bounds(max,z))/2.0]
set pscale [expr ($Bounds(max,x) - $Bounds(min,x)) / 2.0 ]
if { $pscale > [expr ($Bounds(max,y) - $Bounds(min,y)) / 2.0] } {
set pscale [expr ($Bounds(max,y) - $Bounds(min,y)) / 2.0]
}
set width [expr $Bounds(max,y) - $Bounds(min,y)]
if { $width < [expr $Bounds(max,x) - $Bounds(min,x)] } {
set width [expr $Bounds(max,x) - $Bounds(min,x)]
}
set viewangle [expr double([$camera GetViewAngle])]
set distance [expr 0.8 * $width / tan($viewangle * $PI/360.0)]
set distance [expr $distance + ($Bounds(max,z) - $Bounds(min,z))/2.0]
set vup(x) [expr double([lindex [$camera GetViewUp] 0])]
set vup(y) [expr double([lindex [$camera GetViewUp] 1])]
set vup(z) [expr double([lindex [$camera GetViewUp] 2])]
set dot [expr ($vup(x) * $vn(x)) + ($vup(y) * $vn(y)) + ($vup(z) * $vn(z))]
if {$dot > 0.999} {
$camera SetViewUp [expr -$vup(z)] $vup(0) $vup(1)
}
$camera SetFocalPoint $center(x) $center(y) $center(z)
$camera SetPosition \
[expr $center(x) + $distance*$vn(x)] \
[expr $center(y) + $distance*$vn(y)] \
[expr $center(z) + $distance*$vn(z)]
$Renderer ResetCameraClippingRange
Render
set center(x) [expr double([lindex [$camera GetFocalPoint] 0])]
set center(y) [expr double([lindex [$camera GetFocalPoint] 1])]
set center(z) [expr double([lindex [$camera GetFocalPoint] 2])]
set position(x) [expr double([lindex [$camera GetPosition] 0])]
set position(y) [expr double([lindex [$camera GetPosition] 1])]
set position(z) [expr double([lindex [$camera GetPosition] 2])]
$Renderer SetWorldPoint $center(x) $center(y) $center(z) 1.0
$Renderer WorldToDisplay
set center_screen(x) [lindex [$Renderer GetDisplayPoint] 0]
set center_screen(y) [lindex [$Renderer GetDisplayPoint] 1]
set center_screen(z) [lindex [$Renderer GetDisplayPoint] 2]
set old_pscale [$camera GetParallelScale]
foreach plane "x y" {
set Screen(max,$plane) [expr -$::cvis::math::FLT_MAX]
}
set screen_size(x) [expr double([lindex [$Renderer GetSize] 0])]
set screen_size(y) [expr double([lindex [$Renderer GetSize] 1])]
foreach bounds_x {min max min max min max min max} bounds_y {min min max max min min max max} bounds_z {min min min min max max max max} {
$Renderer SetWorldPoint $Bounds($bounds_x,x) $Bounds($bounds_y,y)\
$Bounds($bounds_z,z) 1.0
$Renderer WorldToDisplay
set x [lindex [$Renderer GetDisplayPoint] 0]
set y [lindex [$Renderer GetDisplayPoint] 1]
set z [lindex [$Renderer GetDisplayPoint] 2]
if { $Screen(max,x) < abs($x - $screen_size(x) / 2.0) } {
set Screen(max,x) [expr abs($x - $screen_size(x) / 2.0)]
set Screen(max,zx) $z
}
if { $Screen(max,y) < abs($y - $screen_size(y) / 2.0) } {
set Screen(max,y) [expr abs($y - $screen_size(y) / 2.0)]
set Screen(max,zy) $z
}
}
set pscale [expr double(2*$Screen(max,x)) / $screen_size(x)]
if { $pscale < [expr double(2*$Screen(max,y)) / $screen_size(y)] } {
set pscale [expr double(2*$Screen(max,y)) / $screen_size(y)]
$Renderer SetDisplayPoint \
[expr $screen_size(x)/2.0] \
[expr $screen_size(y)/2.0] \
$Screen(max,zy)
$Renderer DisplayToWorld
set nearFocalPoint [$Renderer GetWorldPoint]
set nearFocalPoint0 [lindex $nearFocalPoint 0]
set nearFocalPoint1 [lindex $nearFocalPoint 1]
set nearFocalPoint2 [lindex $nearFocalPoint 2]
set nearFocalPoint3 [lindex $nearFocalPoint 3]
if { $nearFocalPoint3 != 0.0 } {
set nearFocalPoint0 [expr $nearFocalPoint0 / $nearFocalPoint3]
set nearFocalPoint1 [expr $nearFocalPoint1 / $nearFocalPoint3]
set nearFocalPoint2 [expr $nearFocalPoint2 / $nearFocalPoint3]
}
$Renderer SetDisplayPoint \
[expr $screen_size(x)/2.0] \
[expr $screen_size(y)/2.0 + $Screen(max,y)] \
$Screen(max,zy)
$Renderer DisplayToWorld
set nearFocalEdge [$Renderer GetWorldPoint]
set nearFocalEdge0 [expr double([lindex $nearFocalEdge 0])]
set nearFocalEdge1 [expr double([lindex $nearFocalEdge 1])]
set nearFocalEdge2 [expr double([lindex $nearFocalEdge 2])]
set nearFocalEdge3 [expr double([lindex $nearFocalEdge 3])]
if { $nearFocalEdge3 != 0.0 } {
set nearFocalEdge0 [expr $nearFocalEdge0 / $nearFocalEdge3]
set nearFocalEdge1 [expr $nearFocalEdge1 / $nearFocalEdge3]
set nearFocalEdge2 [expr $nearFocalEdge2 / $nearFocalEdge3]
}
$Renderer SetDisplayPoint \
[expr $screen_size(x)/2.0] \
0.0 \
$center_screen(z)
$Renderer DisplayToWorld
set projectionPlaneEdge [$Renderer GetWorldPoint]
set projectionPlaneEdge0 [expr double([lindex $projectionPlaneEdge 0])]
set projectionPlaneEdge1 [expr double([lindex $projectionPlaneEdge 1])]
set projectionPlaneEdge2 [expr double([lindex $projectionPlaneEdge 2])]
set projectionPlaneEdge3 [expr double([lindex $projectionPlaneEdge 3])]
if { $projectionPlaneEdge3 != 0.0 } {
set projectionPlaneEdge0 [expr $projectionPlaneEdge0 / $projectionPlaneEdge3]
set projectionPlaneEdge1 [expr $projectionPlaneEdge1 / $projectionPlaneEdge3]
set projectionPlaneEdge2 [expr $projectionPlaneEdge2 / $projectionPlaneEdge3]
}
} {
$Renderer SetDisplayPoint \
[expr $screen_size(x)/2.0] \
[expr $screen_size(y)/2.0] \
$Screen(max,zx)
$Renderer DisplayToWorld
set nearFocalPoint [$Renderer GetWorldPoint]
set nearFocalPoint0 [lindex $nearFocalPoint 0]
set nearFocalPoint1 [lindex $nearFocalPoint 1]
set nearFocalPoint2 [lindex $nearFocalPoint 2]
set nearFocalPoint3 [lindex $nearFocalPoint 3]
if { $nearFocalPoint3 != 0.0 } {
set nearFocalPoint0 [expr $nearFocalPoint0 / $nearFocalPoint3]
set nearFocalPoint1 [expr $nearFocalPoint1 / $nearFocalPoint3]
set nearFocalPoint2 [expr $nearFocalPoint2 / $nearFocalPoint3]
}
$Renderer SetDisplayPoint \
[expr $screen_size(x)/2.0 + $Screen(max,x)] \
[expr $screen_size(y)/2.0] \
$Screen(max,zx)
$Renderer DisplayToWorld
set nearFocalEdge [$Renderer GetWorldPoint]
set nearFocalEdge0 [expr double([lindex $nearFocalEdge 0])]
set nearFocalEdge1 [expr double([lindex $nearFocalEdge 1])]
set nearFocalEdge2 [expr double([lindex $nearFocalEdge 2])]
set nearFocalEdge3 [expr double([lindex $nearFocalEdge 3])]
if { $nearFocalEdge3 != 0.0 } {
set nearFocalEdge0 [expr $nearFocalEdge0 / $nearFocalEdge3]
set nearFocalEdge1 [expr $nearFocalEdge1 / $nearFocalEdge3]
set nearFocalEdge2 [expr $nearFocalEdge2 / $nearFocalEdge3]
}
$Renderer SetDisplayPoint \
0.0 \
[expr $screen_size(y)/2.0] \
$center_screen(z)
$Renderer DisplayToWorld
set projectionPlaneEdge [$Renderer GetWorldPoint]
set projectionPlaneEdge0 [expr double([lindex $projectionPlaneEdge 0])]
set projectionPlaneEdge1 [expr double([lindex $projectionPlaneEdge 1])]
set projectionPlaneEdge2 [expr double([lindex $projectionPlaneEdge 2])]
set projectionPlaneEdge3 [expr double([lindex $projectionPlaneEdge 3])]
if { $projectionPlaneEdge3 != 0.0 } {
set projectionPlaneEdge0 [expr $projectionPlaneEdge0 / $projectionPlaneEdge3]
set projectionPlaneEdge1 [expr $projectionPlaneEdge1 / $projectionPlaneEdge3]
set projectionPlaneEdge2 [expr $projectionPlaneEdge2 / $projectionPlaneEdge3]
}
}
#
set opp_dist [expr \
sqrt( \
($projectionPlaneEdge0 - $center(x))*($projectionPlaneEdge0 - $center(x)) + \
($projectionPlaneEdge1 - $center(y))*($projectionPlaneEdge1 - $center(y)) + \
($projectionPlaneEdge2 - $center(z))*($projectionPlaneEdge2 - $center(z)) )]
set adj_dist [expr \
sqrt( \
($position(x) - $center(x))*($position(x) - $center(x)) + \
($position(y) - $center(y))*($position(y) - $center(y)) + \
($position(z) - $center(z))*($position(z) - $center(z)) )]
set angle [expr atan($opp_dist / $adj_dist)]
set ydist [expr \
sqrt( \
($nearFocalPoint0 - $nearFocalEdge0)*($nearFocalPoint0 - $nearFocalEdge0) + \
($nearFocalPoint1 - $nearFocalEdge1)*($nearFocalPoint1 - $nearFocalEdge1) + \
($nearFocalPoint2 - $nearFocalEdge2)*($nearFocalPoint2 - $nearFocalEdge2) )]
set d [expr $ydist/tan($angle)]
set nearDist [expr \
sqrt( \
($nearFocalPoint0 - $center(x))*($nearFocalPoint0 - $center(x)) + \
($nearFocalPoint1 - $center(y))*($nearFocalPoint1 - $center(y)) + \
($nearFocalPoint2 - $center(z))*($nearFocalPoint2 - $center(z)) )]
set factor [expr [$camera GetDistance] / ($d + $nearDist)]
$CurrentCamera Dolly $factor
# I do this better than rubber band zoom!
$camera SetParallelScale [expr $old_pscale * $pscale]
$Renderer ResetCameraClippingRange
Render
math Delete
}
method ResetInteractor {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
# Get the renderer window dimensions
set WindowX [lindex [$widget configure -width] 4]
set WindowY [lindex [$widget configure -height] 4]
# Find which renderer event has occurred in
set CurrentRenderWindow [$widget GetRenderWindow]
set renderers [$CurrentRenderWindow GetRenderers]
set numRenderers [$renderers GetNumberOfItems]
$renderers InitTraversal; set RendererFound 0
for {set i 0} {$i < $numRenderers} {incr i} {
set CurrentRenderer [$renderers GetNextItem]
set vx [expr double($x) / $WindowX]
set vy [expr ($WindowY - double($y)) / $WindowY]
set viewport [$CurrentRenderer GetViewport]
set vpxmin [lindex $viewport 0]
set vpymin [lindex $viewport 1]
set vpxmax [lindex $viewport 2]
set vpymax [lindex $viewport 3]
if { $vx >= $vpxmin && $vx <= $vpxmax && \
$vy >= $vpymin && $vy <= $vpymax} {
set RendererFound 1
break
}
}
if { $RendererFound } {$CurrentRenderer ResetCamera}
Render
}
method HideSideToolbar {widget} {
if {[winfo ismapped $widget.tools]} {
pack forget $widget.tools
pack $widget.empty
} {
pack forget $widget.empty
pack $widget.tools
}
}
method HideBottomToolbar {widget} {
if {[winfo ismapped $widget.tools]} {
pack forget $widget.tools
pack $widget.empty
} {
pack forget $widget.empty
pack $widget.tools -fill x
}
}
method Rotate {x y} {
set tracervar [::itcl::local cvisTrace #auto]
if { $RendererFound } {
$CurrentCamera Azimuth [expr ($LastX - $x)]
$CurrentCamera Elevation [expr ($y - $LastY)]
$CurrentCamera OrthogonalizeViewUp
$Renderer ResetCameraClippingRange
set LastX $x
set LastY $y
RenderInteractive
}
}
method Pan {x y} {
set tracervar [::itcl::local cvisTrace #auto]
if { ! $RendererFound } { return }
set FPoint [$CurrentCamera GetFocalPoint]
set FPoint0 [lindex $FPoint 0]
set FPoint1 [lindex $FPoint 1]
set FPoint2 [lindex $FPoint 2]
set PPoint [$CurrentCamera GetPosition]
set PPoint0 [lindex $PPoint 0]
set PPoint1 [lindex $PPoint 1]
set PPoint2 [lindex $PPoint 2]
$Renderer SetWorldPoint $FPoint0 $FPoint1 $FPoint2 1.0
$Renderer WorldToDisplay
set DPoint [$Renderer GetDisplayPoint]
set focalDepth [lindex $DPoint 2]
set APoint0 [expr $WindowCenterX + ($x - $LastX)]
set APoint1 [expr $WindowCenterY - ($y - $LastY)]
$Renderer SetDisplayPoint $APoint0 $APoint1 $focalDepth
$Renderer DisplayToWorld
set RPoint [$Renderer GetWorldPoint]
set RPoint0 [lindex $RPoint 0]
set RPoint1 [lindex $RPoint 1]
set RPoint2 [lindex $RPoint 2]
set RPoint3 [lindex $RPoint 3]
if { $RPoint3 != 0.0 } {
set RPoint0 [expr $RPoint0 / $RPoint3]
set RPoint1 [expr $RPoint1 / $RPoint3]
set RPoint2 [expr $RPoint2 / $RPoint3]
}
$CurrentCamera SetFocalPoint \
[expr ($FPoint0 - $RPoint0)/2.0 + $FPoint0] \
[expr ($FPoint1 - $RPoint1)/2.0 + $FPoint1] \
[expr ($FPoint2 - $RPoint2)/2.0 + $FPoint2]
$CurrentCamera SetPosition \
[expr ($FPoint0 - $RPoint0)/2.0 + $PPoint0] \
[expr ($FPoint1 - $RPoint1)/2.0 + $PPoint1] \
[expr ($FPoint2 - $RPoint2)/2.0 + $PPoint2]
set LastX $x
set LastY $y
RenderInteractive
}
method WheelZoom {d} {
set tracervar [::itcl::local cvisTrace #auto]
if { ! $RendererFound } {
return
}
set zoomFactor [expr pow(1.02,$d/20)]
$this DoZoom $zoomFactor
}
method Zoom {x y} {
set tracervar [::itcl::local cvisTrace #auto]
if { ! $RendererFound } {
return
}
set zoomFactor [expr pow(1.02,(0.5*($y - $LastY)))]
$this DoZoom $zoomFactor
set LastX $x
set LastY $y
}
method DoZoom {zoomFactor} {
if {[$CurrentCamera GetParallelProjection]} {
set parallelScale [expr [$CurrentCamera GetParallelScale] * $zoomFactor];
$CurrentCamera SetParallelScale $parallelScale;
} else {
$CurrentCamera Dolly $zoomFactor
$Renderer ResetCameraClippingRange
}
RenderInteractive
}
method Top {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) $FPoint(x)
set CPoint(y) $FPoint(y)
set CPoint(z) [expr $FPoint(z) + 10.0]
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 1 0
Reset
}
method Bottom {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) $FPoint(x)
set CPoint(y) $FPoint(y)
set CPoint(z) [expr $FPoint(z) - 10.0]
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 -1 0
Reset
}
method Left {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) [expr $FPoint(x) - 10.0]
set CPoint(y) $FPoint(y)
set CPoint(z) $FPoint(z)
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 0 1
Reset
}
method Right {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) [expr $FPoint(x) + 10.0]
set CPoint(y) $FPoint(y)
set CPoint(z) $FPoint(z)
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 0 1
Reset
}
method Front {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) $FPoint(x)
set CPoint(y) [expr $FPoint(y) + 10.0]
set CPoint(z) $FPoint(z)
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 0 1
Reset
}
method Back {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) $FPoint(x)
set CPoint(y) [expr $FPoint(y) - 10.0]
set CPoint(z) $FPoint(z)
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 0 1
Reset
}
method BirdsEye {} {
ComputeBounds
set FPoint(x) [expr ($Bounds(max,x) + $Bounds(min,x)) / 2.0 ]
set FPoint(y) [expr ($Bounds(max,y) + $Bounds(min,y)) / 2.0 ]
set FPoint(z) [expr ($Bounds(max,z) + $Bounds(min,z)) / 2.0 ]
set CPoint(x) [expr $FPoint(x) + 10.0]
set CPoint(y) [expr $FPoint(y) + 10.0]
set CPoint(z) [expr $FPoint(z) + 10.0]
set camera [$Renderer GetActiveCamera]
$camera SetFocalPoint $FPoint(x) $FPoint(y) $FPoint(z)
$camera SetPosition $CPoint(x) $CPoint(y) $CPoint(z)
$camera SetViewUp 0 0 1
Reset
}
method SetView {name} {
$this.views SetViewFromCamera $name [$Renderer GetActiveCamera]
}
method GetView {name} {
# Get View if it exists otherwise default to birds eye
if {[$this.views GetViewToCamera $name [$Renderer GetActiveCamera]]} {
Render
} {
BirdsEye
}
}
method GetBounds {} {
return "$Bounds(min,x) $Bounds(max,x) $Bounds(min,y) $Bounds(max,y) $Bounds(min,z) $Bounds(max,z)"
}
method ComputeBounds {} {
if {$ComputeBoundsFlag} {
set ComputeBoundsFlag 0
foreach plane "x y z" {
# SGS where can we get these from, VTK class
set Bounds(min,$plane) $::cvis::math::FLT_MAX
set Bounds(max,$plane) [expr -$::cvis::math::FLT_MAX]
}
set collection $this.cvisActors
$collection InitTraversal
set item [$collection GetNextItem]
while {[string length $item]} {
if {[$item GetVisibility]} {
scan [$item GetBounds] "%f %f %f %f %f %f" \
real(min,x) real(max,x) \
real(min,y) real(max,y) \
real(min,z) real(max,z)
foreach plane "x y z" {
if { $Bounds(min,$plane) > $real(min,$plane) } {
set Bounds(min,$plane) $real(min,$plane)
}
if { $Bounds(max,$plane) < $real(max,$plane) } {
set Bounds(max,$plane) $real(max,$plane)
}
}
}
set item [$collection GetNextItem]
}
}
}
method Expose {} {
set tracervar [::itcl::local cvisTrace #auto]
if {$InExpose == 1 } {
return
}
set InExpose 1
$RenderWindow SetDesiredUpdateRate $StillUpdateRate
update
RenderInteractive
set InExpose 0
}
variable OldFocus ""
method Enter {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
set OldFocus [focus]
focus $widget
UpdateRenderer $x $y
}
method Exit {} {
set tracervar [::itcl::local cvisTrace #auto]
# SGS seems to not work very well why to VTK folks want this
# focus $OldFocus
}
method ExitApplication {} {
::cvis::Exit
}
variable PickPointColor "1.0 1.0 1.0"
method SetPickPointColor {r g b} {
set PickPointColor "$r $g $b"
if {[string length [info commands $this.pickerActor]]} {
}
if {[string length [info commands $this.boundaryActor]]} {
eval [$this.boundaryActor GetProperty] SetColor $PickPointColor
}
}
variable PickPointIsVisible 1
method SetPickPointVisibility {visible} {
if {$visible != $PickPointIsVisible} {
set PickPointIsVisible $visible
if {[string compare $PickBounds "0 0 0 0 0 0"]} {
$this.boundaryActor SetVisibility $PickPointIsVisible
} {
$this.boundaryActor SetVisibility 0
}
}
}
method GetPickPointVisibility {} {
return $PickPointIsVisible
}
method SetPickPoint {x y z} {
set PickPoint(x) $x
set PickPoint(y) $y
set PickPoint(z) $z
# Force A redraw of the text widget
# Update
# Picker in render window is in 3D space
set camera [$Renderer GetActiveCamera]
$PickPoint(x) $PickPoint(y) $PickPoint(z)
# Set the size of the picker
set distance [$camera GetDistance]
set view_angle [$camera GetViewAngle]
set view_angle [expr $::cvis::math::DEGREESTORADIANS * $view_angle]
set scale [$camera GetParallelScale]
set width [expr $distance * tan($view_angle / 2.0) * 0.01]
# Text message for pick location
"($PickPoint(x), $PickPoint(y), $PickPoint(z))"
RenderInteractive
}
variable BoundaryEdgeWidth 3
variable PickBounds "0 0 0 0 0 0"
method SetPickBounds {min_x max_x min_y max_y min_z max_z} {
set PickBounds "$min_x $max_x $min_y $max_y $min_z $max_z"
cvisActor $this.boundaryActor
eval [$this.boundaryActor GetProperty] SetColor $PickPointColor
[$this.boundaryActor GetProperty] SetAmbient 1
[$this.boundaryActor GetProperty] SetDiffuse 0
[$this.boundaryActor GetProperty] SetSpecular 0
[$this.boundaryActor GetProperty] SetLineWidth \
$BoundaryEdgeWidth
$Renderer AddActor [$this.boundaryActor GetActor]
}
if {[string compare $PickBounds "0 0 0 0 0 0"]} {
$this.boundaryActor SetVisibility $PickPointIsVisible
} {
$this.boundaryActor SetVisibility 0
}
RenderInteractive
}
method GetPickBounds {} {
return $PickBounds
}
method PickMethod { } {
} {
pick_position(x) pick_position(y) pick_position(z)
SetPickPoint $pick_position(x) $pick_position(y) $pick_position(z)
foreach object $Pickers {
$object SetPickPoint \
$pick_position(x) $pick_position(y) $pick_position(z)
}
}
}
variable AutoResize 1
method SetAutoResize {resize} {
set AutoResize $resize
}
method GetAutoResize {} {
return $AutoResize
}
method DecorationHeight {} {
}
method DecorationWidth {} {
}
method ResizeSize {widget width height} {
if {!$InSetSize} {
if {$AutoResize} {
# Account for toolbar and button bar
set Size(x) [expr $Size(x) - [DecorationWidth]]
set Size(y) [expr $Size(y) - [DecorationHeight]]
if {[string length $Interface]} {
$Interface SetSize $Size(x) $Size(y)
} {
SetSize $Size(x) $Size(y)
}
}
}
}
}
variable Pickers ""
method AddPicker {object} {
lappend Pickers $object
}
constructor {name} {
global cvis_library
::cvis::RestartFile::Add $this
set Size(x) 640
set Size(y) 480
set Name $name
cvisView $this.views
cvisCollection $this.cvisActors
cvisCollection $this.vtkActors
# Need to turn off the culler so we don't drop small items from
# the render
set cullers [$Renderer GetCullers]
$cullers InitTraversal
set culler [$cullers GetNextItem]
$culler SetMinimumCoverage 1e-12
# Objects for the rubber band zoom feature
$RubberBandPolyData SetPoints $RubberBandPoints
$RubberBandPolyData SetLines $RubberBandLines
$RubberBandMapper SetInput $RubberBandPolyData
$RubberBandMapper SetLookupTable $RubberBandColors
$RubberBandActor SetMapper $RubberBandMapper
$RubberBandColors SetNumberOfTableValues 2
$RubberBandColors SetNumberOfColors 2
$RubberBandColors SetTableValue 0 1.0 0.0 0.0 1.0
$RubberBandColors SetTableValue 1 1.0 1.0 1.0 1.0
[$RubberBandPolyData GetPointData] SetScalars $RubberBandScalars
$RubberBandMapper SetScalarRange 0 1
$RubberBandPoints InsertPoint 0 0 0 0
$RubberBandPoints InsertPoint 1 0 10 0
$RubberBandPoints InsertPoint 2 10 10 0
$RubberBandPoints InsertPoint 3 10 0 0
$RubberBandLines InsertNextCell 5
$RubberBandLines InsertCellPoint 0
$RubberBandLines InsertCellPoint 1
$RubberBandLines InsertCellPoint 2
$RubberBandLines InsertCellPoint 3
$RubberBandLines InsertCellPoint 0
$RubberBandScalars InsertNextTuple1 0
$RubberBandScalars InsertNextTuple1 1
$RubberBandScalars InsertNextTuple1 0
$RubberBandScalars InsertNextTuple1 1
$RubberBandMapper ScalarVisibilityOn
set PickedAssembly ""
set PrePickedProperty ""
iwidgets::menubar $frame.menuBar -menubuttons {
menubutton file -text "File" -menu {
options -tearoff false
command Open -label "Open" -command {$this Open} \
-helpstr "Open saved state file"
command SaveAs -label "SaveAs" -command {$this SaveAs} \
-helpstr "Save state to a file"
command exit -label "Exit" -command {$this ExitApplication} \
-helpstr "Exit Vizamrai"
}
menubutton help -text "Help" -menu {
options -tearoff false
command help -label "Help Contents" \
-command {$this HelpContents} \
-helpstr "Help Contents"
command about -label "About" -command {$this About} \
-helpstr "About Vizamrai"
}
}
pack $frame.menuBar -side top -fill x
#****************************************
#****************************************
# SGS Working here
frame $frame.sidebar
pack $frame.sidebar -side left -fill y
frame $frame.sidebar.empty
frame $frame.sidebar.tools
set toolbar $frame.sidebar.tools.view
iwidgets::toolbar $toolbar -orient vertical
set widget [$toolbar add checkbutton center \
-command "$this Reset" \
-balloonstr "Center" \
-image [image create photo -file \
[file join $cvis_library images resetoff.gif]] \
-selectimage [image create photo -file \
[file join $cvis_library images reseton.gif]] \
]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
bind $widget <Button-1> "%W select"
set widget [$toolbar add checkbutton pan \
-balloonstr "Pan" \
-image [image create photo -file \
[file join $cvis_library images panoff.gif]] \
-selectimage [image create photo -file \
[file join $cvis_library images panon.gif]] \
]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
$widget configure -command "$widget deselect"
bind $widget <B1-Motion> "$this Pan %x %y"
bind $widget <Button-1> "$this StartPan %W %x %y"
bind $widget <ButtonRelease-1> "$this EndPan %W %x %y"
set widget [$toolbar add checkbutton rotate \
-balloonstr "Rotate" \
-image [image create photo -file \
[file join $cvis_library images rotateoff.gif]] \
-selectimage [image create photo -file \
[file join $cvis_library images rotateon.gif]] \
]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
$widget configure -command "$widget deselect"
bind $widget <B1-Motion> "$this Rotate %x %y"
bind $widget <ButtonPress-1> "$this StartRotate %W %x %y"
bind $widget <ButtonRelease-1> "$this EndRotate %W %x %y"
set widget [$toolbar add checkbutton zoom \
-balloonstr "Zoom" \
-image [image create photo -file \
[file join $cvis_library images zoomoff.gif]] \
-selectimage [image create photo -file \
[file join $cvis_library images zoomon.gif]] \
]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
$widget configure -command "$widget deselect"
bind $widget <B1-Motion> "$this Zoom %x %y"
bind $widget <ButtonPress-1> "$this StartZoom %W %x %y"
bind $widget <ButtonRelease-1> "$this EndZoom %W %x %y"
pack $toolbar -anchor n -side top -fill y
# ******************************************
set toolbar $frame.sidebar.tools.user
iwidgets::toolbar $toolbar -orient vertical
set widget [$toolbar add button birdseye \
-command "$this BirdsEye" \
-balloonstr "BirdsEye" \
-image [image create photo -file \
[file join $cvis_library images bird.gif]]]
$widget configure -bd 0
frame $toolbar.memorydot
iwidgets::toolbar $toolbar.memorydot.left -orient vertical
foreach i {1 3 5} {
set button [$toolbar.memorydot.left add button b$i \
-command "$this GetView $i" \
-balloonstr "View $i" \
-image [image create photo -file \
[file join $cvis_library images memorydot.gif]]]
$button configure -bd 0
bind $button <B3-ButtonRelease> "$this SetView $i"
}
iwidgets::toolbar $toolbar.memorydot.right -orient vertical
foreach i {2 4 6} {
set button [$toolbar.memorydot.right add button b$i \
-command "$this GetView $i" \
-balloonstr "View $i" \
-image [image create photo -file \
[file join $cvis_library images memorydot.gif]]]
$button configure -bd 0
bind $button <B3-ButtonRelease> "$this SetView $i"
}
pack $toolbar.memorydot.left -side left
pack $toolbar.memorydot.right -side right
pack $toolbar.memorydot -side bottom -fill y
pack $toolbar -side bottom -fill y
# *************************************************
set toolbar $frame.sidebar.tools.presetl
iwidgets::toolbar $toolbar -orient vertical
set widget [$toolbar add button top \
-command "$this Top" \
-balloonstr "Top" \
-image [image create photo -file \
[file join $cvis_library images top.gif]]]
$widget configure -bd 0
set widget [$toolbar add button left \
-command "$this Left" \
-balloonstr "Left" \
-image [image create photo -file \
[file join $cvis_library images left.gif]]]
$widget configure -bd 0
set widget [$toolbar add button front \
-command "$this Front" \
-balloonstr "Front" \
-image [image create photo -file \
[file join $cvis_library images front.gif]]]
$widget configure -bd 0
pack $toolbar -anchor n -side left -fill y
# **********************************************8
set toolbar $frame.sidebar.tools.presetr
iwidgets::toolbar $toolbar -orient vertical
set widget [$toolbar add button bottom \
-command "$this Bottom" \
-balloonstr "Bottom" \
-image [image create photo -file \
[file join $cvis_library images bottom.gif]]]
$widget configure -bd 0
set widget [$toolbar add button right \
-command "$this Right" \
-balloonstr "Right" \
-image [image create photo -file \
[file join $cvis_library images right.gif]]]
$widget configure -bd 0
set widget [$toolbar add button back \
-command "$this Back" \
-balloonstr "Back" \
-image [image create photo -file \
[file join $cvis_library images back.gif]]]
$widget configure -bd 0
pack $toolbar -anchor n -side left -fill y
#****************************************
#****************************************
set widget [button $frame.sideToolbarControl \
-command "$this HideSideToolbar $frame.sidebar" \
-image [image create photo -file \
[file join $cvis_library images verthandleoff.gif]]]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
pack $widget -side left -fill y
pack $frame.sidebar.tools
# SGS Working here
#****************************************
#****************************************
frame $frame.bottombar
pack $frame.bottombar -side bottom -fill x
frame $frame.bottombar.empty
frame $frame.bottombar.tools
set toolbar $frame.bottombar.tools.view
iwidgets::toolbar $toolbar
$toolbar add button saveImage \
-command "$this Write" \
-balloonstr "Save image to file" \
-image [image create photo -file \
[file join $cvis_library images save.gif]]
$toolbar add button render \
-command "$this RenderNow" \
-balloonstr "Render" \
-image [image create photo -file \
[file join $cvis_library images render.gif]]
set RenderPipelineOnImage [image create photo -file \
[file join $cvis_library images pipeon.gif]]
set RenderPipelineOffImage [image create photo -file \
[file join $cvis_library images pipeoff.gif]]
set RenderPipelineWidget [$toolbar add button pipe \
-command "$this RenderPipeToggle" \
-balloonstr "Render Pipeline" \
-image $RenderPipelineOnImage]
set RenderWireFrameImage [image create photo -file \
[file join $cvis_library images wireframe.gif]]
set RenderFullFrameImage [image create photo -file \
[file join $cvis_library images fullframe.gif]]
set RenderWireFrameWidget [$toolbar add button wireframe \
-command "$this RenderWireFrameToggle" \
-balloonstr "Wireframe/Full Render" \
-image $RenderFullFrameImage]
$toolbar add button command \
-command "cvisTkCon" \
-balloonstr "Command Line Interface" \
-image [image create photo -file \
[file join $cvis_library images command.gif]]
pack $toolbar -side bottom -fill x
set widget [button $frame.bottomToolbarControl \
-command "$this HideBottomToolbar $frame.bottombar" \
-image [image create photo -file \
[file join $cvis_library images horizhandleoff.gif]]]
$widget configure \
-borderwidth 0 \
-activebackground [$widget cget -background]
pack $widget -side bottom -fill x
pack $frame.bottombar.tools -fill x
set RenderWidget $widget
vtkTkRenderWidget $widget \
-width $Size(x) -height $Size(y)
pack $widget -expand true
# Bindings
bind $widget <Expose> "$this Expose"
bind $widget <Enter> "$this Enter %W %x %y"
bind $widget <Leave> "$this Exit"
bind $widget <Any-ButtonPress> "$this StartMotion %W %x %y"
bind $widget <Any-ButtonRelease> "$this EndMotion %W %x %y"
bind $widget <B1-Motion> "$this Rotate %x %y"
bind $widget <B2-Motion> "$this Pan %x %y"
bind $widget <Shift-B1-Motion> "$this Pan %x %y"
bind $widget <B3-Motion> "$this Zoom %x %y"
bind $widget <Shift-B3-Motion> "$this RubberZoom %W %x %y"
# This currently will only work on Windows only.
bind $widget <MouseWheel> "$this WheelZoom %D"
bind $widget <KeyPress-c> {cvisTkCon}
bind $widget <KeyPress-r> "$this ResetInteractor %W %x %y"
bind $widget <KeyPress-f> "$this ResetInteractorFullScreen %W %x %y"
bind $widget <KeyPress-w> "$this Wireframe"
bind $widget <KeyPress-s> "$this Surface"
bind $widget <KeyPress-space> "$this PickActor %W %x %y"
bind $widget <KeyPress-o> "$this Write"
set RenderWindow [$widget GetRenderWindow]
$RenderWindow AddRenderer $Renderer
set WindowNameProp [cvisProperty $name.WindowName]
$name.WindowName AddCallback "$this UpdateWindowName"
# SGS this was added to create a default light but
# there should be some better way of doing this?
# If this is not here then we get no light and nothing
# ever shows up
$Renderer Render
UpdateRenderer 0 0
if { [file exists $::cvis::options::DEFAULT_CAMERA] } {
RestoreView $::cvis::options::DEFAULT_CAMERA
}
foreach plane "x y z" {
set Bounds(min,$plane) 0.0
set Bounds(max,$plane) 1.0
}
foreach light {1 2 3 4} {
vtkLight $this.light$light
$this.light$light SetLightType 3
$this.light$light SetSwitch 0
$Renderer AddLight $this.light$light
}
}
destructor {
$Renderer Delete
}
method GetImageWriter { } {
return [namespace current]::$ImageWriter
}
method GetPicker { } {
set tracervar [::itcl::local cvisTrace #auto]
}
method GetRenderWindowInteractor { } {
set tracervar [::itcl::local cvisTrace #auto]
}
method GetRenderer { } {
set tracervar [::itcl::local cvisTrace #auto]
return $Renderer
}
method GetWindowName {} {
set tracervar [::itcl::local cvisTrace #auto]
return [$WindowNameProp GetValue]
}
method GetWindowNameProp {} {
set tracervar [::itcl::local cvisTrace #auto]
return [$WindowNameProp GetReference]
}
method SetWindowName {windowname} {
set tracervar [::itcl::local cvisTrace #auto]
$WindowNameProp SetValue $windowname
}
method SetEquivWindowName { property } {
set tracervar [::itcl::local cvisTrace #auto]
$WindowNameProp SetEquiv $property
}
method UpdateWindowName { windowname } {
set tracervar [::itcl::local cvisTrace #auto]
}
method GetRenderWindow { } {
set tracervar [::itcl::local cvisTrace #auto]
return $RenderWindow
}
method SetBackground { r g b } {
set tracervar [::itcl::local cvisTrace #auto]
$Renderer SetBackground $r $g $b
Render
}
method GetBackground {r g b} {
set tracervar [::itcl::local cvisTrace #auto]
return [$Renderer GetBackground]
}
variable RenderWireFrameWidget
variable RenderWireFrame 0
variable RenderWireFrameImage
variable RenderFullFrameImage
method RenderWireFrameToggle {} {
if {$RenderWireFrame} {
set RenderWireFrame 0
$RenderWireFrameWidget configure -image $RenderFullFrameImage
Surface
} {
set RenderWireFrame 1
$RenderWireFrameWidget configure -image $RenderWireFrameImage
Wireframe
}
$RenderWindow SetDesiredUpdateRate $StillUpdateRate
}
variable RenderPipelineWidget
variable RenderPipeline 1
variable RenderPipelineOnImage
variable RenderPipelineOffImage
method RenderPipeToggle {} {
if {$RenderPipeline} {
set RenderPipeline 0
::cvis::queue::SetPipeline 0
$RenderPipelineWidget configure -image $RenderPipelineOffImage
} {
set RenderPipeline 1
::cvis::queue::SetPipeline 1
$RenderPipelineWidget configure -image $RenderPipelineOnImage
}
}
# Force a Render now, regardless of the current pipeline state
method RenderNow {} {
set tracervar [::itcl::local cvisTrace #auto]
Render
if {![::cvis::queue::GetPipeline]} {
::cvis::queue::SetPipeline 1
::cvis::queue::SetPipeline 0
}
}
# Schedule a Render
method Render { } {
set tracervar [::itcl::local cvisTrace #auto]
# Schedule a render operation
::cvis::queue::Add "$this Execute"
# Excute the waiting operations, if any
::cvis::queue::Execute
}
# Called by interactive changes (things which
# only effect the renderer, not other elements)
method RenderInteractive {} {
# If interactive just render now otherwise schedule
# a render for later
if {$RenderPipeline} {
$RenderWindow Render
} {
Render
}
}
method Execute { } {
set tracervar [::itcl::local cvisTrace #auto]
$RenderWindow Render
}
method Write {} {
set tracervar [::itcl::local cvisTrace #auto]
set filename [GetFileName]
if {[string length [GetFileName]]} {
RenderNow
}
}
method SetFileName { filename } {
set tracervar [::itcl::local cvisTrace #auto]
}
method GetFileName { } {
set tracervar [::itcl::local cvisTrace #auto]
}
variable InSetSize 0
method SetSize { size_x size_y } {
set tracervar [::itcl::local cvisTrace #auto]
set Size(x) $size_x
set Size(y) $size_y
set InSetSize 1
if { ($Size(x) > $current_max_width) || \
($Size(y) > $current_max_height) } {
"[expr $Size(x) + [DecorationWidth]]x[expr $Size(y) + [DecorationHeight]]"
}
-height $Size(y)
update
set InSetSize 0
}
method SaveState { filename } {
set tracervar [::itcl::local cvisTrace #auto]
SaveView [$Renderer GetActiveCamera] $filename
}
method RestoreState { filename} {
set tracervar [::itcl::local cvisTrace #auto]
RestoreView [$Renderer GetActiveCamera] $filename
Render
}
method AddActor { actor } {
set tracervar [::itcl::local cvisTrace #auto]
if { ![string compare [$actor GetClassName] "cvisActor"] } {
$this.cvisActors AddItem $actor
$Renderer AddActor [$actor GetActor]
} {
$this.vtkActors AddItem $actor
$Renderer AddActor $actor
}
set ComputeBoundsFlag 1
}
method RemoveActor { actor } {
set tracervar [::itcl::local cvisTrace #auto]
if { ![string compare [$actor GetClassName] "cvisActor"] } {
$Renderer RemoveActor [$actor GetActor]
$this.cvisActors RemoveItem $actor
} {
$Renderer RemoveActor $actor
$this.vtkActors RemoveItem $actor
}
set ComputeBoundsFlag 1
}
method AddVolume { volume } {
set tracervar [::itcl::local cvisTrace #auto]
$Renderer AddVolume $volume
set ComputeBoundsFlag 1
}
method RemoveVolume { volume } {
set tracervar [::itcl::local cvisTrace #auto]
$Renderer RemoveVolume $volume
set ComputeBoundsFlag 1
}
method SetOffScreenRendering {value} {
set tracervar [::itcl::local cvisTrace #auto]
$RenderWindow SetOffScreenRendering $value
}
method GetOffScreenRendering {} {
set tracervar [::itcl::local cvisTrace #auto]
return [$RenderWindow GetOffScreenRendering]
}
method SetUniformScaling {uniformscaling} {
set tracervar [::itcl::local cvisTrace #auto]
set UniformScaling $uniformscaling
SetScaling
}
method SetScaling { } {
set tracervar [::itcl::local cvisTrace #auto]
if {$UniformScaling } {
# Reset scaling for bounds computation
# This does not seem to cause a speed problem but is
# there a better way to compute this
set collection $this.cvisActors
$collection InitTraversal
set item [$collection GetNextItem]
while {[string length $item]} {
$item SetScale 1.0 1.0 1.0
set item [$collection GetNextItem]
}
# Scale display objects so they have the same size
# along each of their dimensions.
foreach plane "x y z" {
# SGS where can we get these from, VTK class
set bounds(min,$plane) $::cvis::math::FLT_MAX
set bounds(max,$plane) [expr -$::cvis::math::FLT_MAX]
}
set collection $this.cvisActors
$collection InitTraversal
set item [$collection GetNextItem]
while {[string length $item]} {
scan [$item GetBounds] "%f %f %f %f %f %f" \
real(min,x) real(max,x) \
real(min,y) real(max,y) \
real(min,z) real(max,z)
foreach plane "x y z" {
if { $bounds(min,$plane) > $real(min,$plane) } {
set bounds(min,$plane) $real(min,$plane)
}
if { $bounds(max,$plane) < $real(max,$plane) } {
set bounds(max,$plane) $real(max,$plane)
}
}
set item [$collection GetNextItem]
}
# SGS instead of scaling to 1000.0 what about scaling to
# Max extent size to avoid size changing as much
set scaleto [expr -$::cvis::math::FLT_MAX]
foreach plane "x y z" {
if { $bounds(max,$plane) > $scaleto } {
set scaleto $bounds(max,$plane)
}
}
set Scaling(x) [expr $scaleto / \
( $bounds(max,x) - $bounds(min,x) )]
set Scaling(y) [expr $scaleto / \
( $bounds(max,y) - $bounds(min,y) )]
set Scaling(z) [expr $scaleto / \
( $bounds(max,y) - $bounds(min,y) )]
} {
# Do not do any scaling
set Scaling(x) 1.0
set Scaling(y) 1.0
set Scaling(z) 1.0
}
set collection "$this.cvisActors"
$collection InitTraversal
set item [$collection GetNextItem]
while {[string length $item]} {
$item SetScale $Scaling(x) $Scaling(y) $Scaling(z)
set item [$collection GetNextItem]
}
}
variable AutoSave 0
method SetAutoSave { autosave } {
set tracervar [::itcl::local cvisTrace #auto]
set AutoSave $autosave
}
method GetAutoSave { } {
set tracervar [::itcl::local cvisTrace #auto]
return $AutoSave
}
method Update {} {
set tracervar [::itcl::local cvisTrace #auto]
# SGS If autosave turned on then save the image to the current
# file
if {$AutoSave} {
::cvis::queue::Add "$this Write"
}
}
variable FileBrowser ".null"
# Save the current state of the camera to a file.
# If not filename is passed in a file browser will be displayed
method SaveView {{filename ""}} {
set tracervar [::itcl::local cvisTrace #auto]
set camera [[GetRenderer] GetActiveCamera]
set types {
{{vtk Camera } {.cam} }
{{All Files } * }
}
if { $filename == "" } {
if {[string length [find objects $FileBrowser]]} {
$FileBrowser SetSavePrompt
} {
set FileBrowser [cvisFileBrowser #auto]
$FileBrowser SetTitle "Select Camera File"
$FileBrowser SetFileTypes $types
$FileBrowser SetSavePrompt
}
set filename [$FileBrowser Prompt]
}
if { $filename != "" } {
set fp [open $filename w]
if { $fp == "" } {
puts "Error opening camera view file"
} else {
puts $fp "# vtk CameraFile Version 2.0"
puts $fp "Clipping Range: [$camera GetClippingRange]"
puts $fp "Distance: [$camera GetDistance]"
puts $fp "Eye Angle: [$camera GetEyeAngle]"
puts $fp "Focal Disk: [$camera GetFocalDisk]"
puts $fp "Focal Point: [$camera GetFocalPoint]"
puts $fp "Position: [$camera GetPosition]"
puts $fp "Parallel Projection: [$camera GetParallelProjection]"
puts $fp "Thickness: [$camera GetThickness]"
puts $fp "View Angle: [$camera GetViewAngle]"
puts $fp "View Up: [$camera GetViewUp]"
close $fp
}
}
}
## Recover view from saved file
## Provide camera name
method RestoreView {{filename ""}} {
set tracervar [::itcl::local cvisTrace #auto]
set camera [[GetRenderer] GetActiveCamera]
set types {
{{vtk Camera } {.cam} }
{{All Files } * }
}
if { $filename == "" } {
if {[string length [find objects $FileBrowser]]} {
$FileBrowser SetOpenPrompt
} {
set FileBrowser [cvisFileBrowser #auto]
$FileBrowser SetTitle "Select Camera File"
$FileBrowser SetFileTypes $types
$FileBrowser SetOpenPrompt
}
set filename [$FileBrowser Prompt]
}
if { $filename != "" } {
set fp [open $filename r]
if { $fp == "" } {
puts "Error opening camera view file"
} else {
set line [read $fp]
if { [string first "# vtk CameraFile Version 2.0" $line] == -1} {
puts "Can't read this file, can't find cookie"
} else {
set loc [string first "Clipping Range:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 15] end]
scan $substr "%f %f" min max
$camera SetClippingRange $min $max
}
set loc [string first "Distance:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 9] end]
scan $substr "%f" distance
$camera SetDistance $distance
}
set loc [string first "Eye Angle:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 10] end]
scan $substr "%f" angle
$camera SetEyeAngle $angle
}
set loc [string first "Focal Disk:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 11] end]
scan $substr "%f" fd
$camera SetFocalDisk $fd
}
set loc [string first "Focal Point:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 12] end]
scan $substr "%f %f %f" fp1 fp2 fp3
$camera SetFocalPoint $fp1 $fp2 $fp3
}
set loc [string first "Position:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 9] end]
scan $substr "%f %f %f" p1 p2 p3
$camera SetPosition $p1 $p2 $p3
}
set loc [string first "Parallel Projection:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 20] end]
scan $substr "%d" pp
$camera SetParallelProjection $pp
}
set loc [string first "Thickness:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 10] end]
scan $substr "%f" t
$camera SetThickness $t
}
set loc [string first "View Angle:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 11] end]
scan $substr "%f" va
$camera SetViewAngle $va
}
set loc [string first "View Up:" $line]
if { $loc != -1 } {
set substr [string range $line [expr $loc + 8] end]
scan $substr "%f %f %f" vup1 vup2 vup3
$camera SetViewUp $vup1 $vup2 $vup3
}
}
# Need to force a render otherwise will only
# happen when user causes a window update
[GetRenderWindow] Render
}
}
}
variable FileName ""
variable FileTypes {{{Vizamrai State File} {.vstate}}}
method Open {} {
set ImageFileBrowser [cvisFileBrowser #auto]
$ImageFileBrowser SetTitle "Select Vizamrai Save State File"
$ImageFileBrowser SetFileTypes $FileTypes
$ImageFileBrowser SetOpenPrompt
set FileName [$ImageFileBrowser Prompt]
::cvis::RestartFile::Open $FileName
}
method SaveAs {} {
set ImageFileBrowser [cvisFileBrowser #auto]
$ImageFileBrowser SetTitle "Select Vizamrai Save State File"
$ImageFileBrowser SetFileTypes $FileTypes
$ImageFileBrowser SetSavePrompt
set FileName [$ImageFileBrowser Prompt]
::cvis::RestartFile::Save $FileName
}
method HelpContents { } {
set tracervar [::itcl::local cvisTrace #auto]
global cvis_library
if { [winfo exists .help] } {
.help activate
} {
iwidgets::hyperhelp .help \
-title "Vizamrai Help" \
-modality none \
-topics {Contents} \
-helpdir [file join $cvis_library help]
.help showtopic Contents
.help activate
}
}
method About { } {
set tracervar [::itcl::local cvisTrace #auto]
::cvis::gui::About
}
# SGS modified from DoRubberZoom
method DoFullZoom { widget depth factor} {
set tracervar [::itcl::local cvisTrace #auto]
# Return if there is no renderer, or the rubber band is less
# that 5 pixels in either direction
if { ! $RendererFound } { return }
if { [expr $StartRubberZoomX - $EndRubberZoomX] < 5 && \
[expr $StartRubberZoomX - $EndRubberZoomX] > -5 } { return }
if { [expr $StartRubberZoomY - $EndRubberZoomY] < 5 && \
[expr $StartRubberZoomY - $EndRubberZoomY] > -5 } { return }
# We'll need the window height later
set WindowY [expr double([lindex [$widget configure -height] 4])]
# What is the center of the rubber band box in pixels?
set centerX [expr ($StartRubberZoomX + $EndRubberZoomX)/2.0]
set centerY [expr ($StartRubberZoomY + $EndRubberZoomY)/2.0]
# Convert the focal point to a display coordinate in order to get the
# depth of the focal point in display units
set FPoint [$CurrentCamera GetFocalPoint]
set FPoint0 [expr double([lindex $FPoint 0])]
set FPoint1 [expr double([lindex $FPoint 1])]
set FPoint2 [expr double([lindex $FPoint 2])]
$Renderer SetWorldPoint $FPoint0 $FPoint1 $FPoint2 1.0
$Renderer WorldToDisplay
set DPoint [$Renderer GetDisplayPoint]
set focalDepth [expr double([lindex $DPoint 2])]
# Convert the position of the camera to a display coordinate in order
# to get the depth of the camera in display coordinates. Note this is
# a negative number (behind the near clipping plane of 0) but it works
# ok anyway
set PPoint [$CurrentCamera GetPosition]
set PPoint0 [expr double([lindex $PPoint 0])]
set PPoint1 [expr double([lindex $PPoint 1])]
set PPoint2 [expr double([lindex $PPoint 2])]
$Renderer SetWorldPoint $PPoint0 $PPoint1 $PPoint2 1.0
$Renderer WorldToDisplay
set DPoint [$Renderer GetDisplayPoint]
set positionDepth [expr double([lindex $DPoint 2])]
# Find out the world position of where our new focal point should
# be - it will be at the center of the box, back at the same focal depth
# Don't actually set it now - we need to do all our computations before
# we modify the camera
$Renderer SetDisplayPoint $centerX $centerY $focalDepth
$Renderer DisplayToWorld
set newFocalPoint [$Renderer GetWorldPoint]
set newFocalPoint0 [expr double([lindex $newFocalPoint 0])]
set newFocalPoint1 [expr double([lindex $newFocalPoint 1])]
set newFocalPoint2 [expr double([lindex $newFocalPoint 2])]
set newFocalPoint3 [expr double([lindex $newFocalPoint 3])]
if { $newFocalPoint3 != 0.0 } {
set newFocalPoint0 [expr $newFocalPoint0 / $newFocalPoint3]
set newFocalPoint1 [expr $newFocalPoint1 / $newFocalPoint3]
set newFocalPoint2 [expr $newFocalPoint2 / $newFocalPoint3]
}
# Find out where the new camera position will be - at the center of
# the rubber band box at the position depth. Don't set it yet...
$Renderer SetDisplayPoint $centerX $centerY $positionDepth
$Renderer DisplayToWorld
set newPosition [$Renderer GetWorldPoint]
set newPosition0 [expr double([lindex $newPosition 0])]
set newPosition1 [expr double([lindex $newPosition 1])]
set newPosition2 [expr double([lindex $newPosition 2])]
set newPosition3 [expr double([lindex $newPosition 3])]
if { $newPosition3 != 0.0 } {
set newPosition0 [expr $newPosition0 / $newPosition3]
set newPosition1 [expr $newPosition1 / $newPosition3]
set newPosition2 [expr $newPosition2 / $newPosition3]
}
# We figured out how to position the camera to be centered, now we
# need to "zoom". In parallel, this is simple since we only need to
# change our parallel scale to encompass the entire y range of the
# rubber band box. In perspective, we assume the box is drawn on the
# near plane - this means that it is not possible that someone can
# draw a rubber band box around a nearby object and dolly past it. It
# also means that you won't get very close to distance objects - but that
# seems better than getting lost.
if {[$CurrentCamera GetParallelProjection]} {
# the new scale is just based on the y size of the rubber band box
# compared to the y size of the window
set ydiff [expr ($StartRubberZoomX - $EndRubberZoomX)]
if { $ydiff < 0.0 } { set ydiff [expr $ydiff * -1.0] }
set newScale [$CurrentCamera GetParallelScale]
set newScale [expr $newScale * $ydiff / $WindowY]
# now we can actually modify the camera
$CurrentCamera SetFocalPoint $newFocalPoint0 $newFocalPoint1 $newFocalPoint2
$CurrentCamera SetPosition $newPosition0 $newPosition1 $newPosition2
$CurrentCamera SetParallelScale $newScale
} else {
# find out the center of the rubber band box on the near plane
$Renderer SetDisplayPoint $centerX $centerY $depth
$Renderer DisplayToWorld
set nearFocalPoint [$Renderer GetWorldPoint]
set nearFocalPoint0 [expr double([lindex $nearFocalPoint 0])]
set nearFocalPoint1 [expr double([lindex $nearFocalPoint 1])]
set nearFocalPoint2 [expr double([lindex $nearFocalPoint 2])]
set nearFocalPoint3 [expr double([lindex $nearFocalPoint 3])]
if { $nearFocalPoint3 != 0.0 } {
set nearFocalPoint0 [expr $nearFocalPoint0 / $nearFocalPoint3]
set nearFocalPoint1 [expr $nearFocalPoint1 / $nearFocalPoint3]
set nearFocalPoint2 [expr $nearFocalPoint2 / $nearFocalPoint3]
}
# find the world coordinates of the point centered on the rubber band box
# in x, on the border in y, and at the near plane depth.
$Renderer SetDisplayPoint $centerX $StartRubberZoomY $depth
$Renderer DisplayToWorld
set focalEdge [$Renderer GetWorldPoint]
set focalEdge0 [expr double([lindex $focalEdge 0])]
set focalEdge1 [expr double([lindex $focalEdge 1])]
set focalEdge2 [expr double([lindex $focalEdge 2])]
set focalEdge3 [expr double([lindex $focalEdge 3])]
if { $focalEdge3 != 0.0 } {
set focalEdge0 [expr $focalEdge0 / $focalEdge3]
set focalEdge1 [expr $focalEdge1 / $focalEdge3]
set focalEdge2 [expr $focalEdge2 / $focalEdge3]
}
# how far is this "rubberband edge point" from the focal point?
set ydist [expr \
sqrt( \
($nearFocalPoint0 - $focalEdge0)*($nearFocalPoint0 - $focalEdge0) + \
($nearFocalPoint1 - $focalEdge1)*($nearFocalPoint1 - $focalEdge1) + \
($nearFocalPoint2 - $focalEdge2)*($nearFocalPoint2 - $focalEdge2) )]
# We need to know how far back we must be so that when we view the scene
# with the current view angle, we see all of the y range of the rubber
# band box. Use a simple tangent equation - opposite / adjacent = tan theta
# where opposite is half the y height of the rubber band box on the near
# plane, adjacent is the distance we are solving for, and theta is half
# the viewing angle. This distance that we solve for is the new distance
# to the near plane - to find the new distance to the focal plane we
# must take the old distance to the focal plane, subtract the near plane
# distance, and add in the distance we solved for.
set angle [expr 0.5 * (3.141592 / 180.0) * [$CurrentCamera GetViewAngle]]
set d [expr $ydist/tan($angle)]
set range [$CurrentCamera GetClippingRange]
set nearplane [expr double([lindex $range 0])]
# now we can actually modify the camera
$CurrentCamera SetFocalPoint $newFocalPoint0 $newFocalPoint1 $newFocalPoint2
$CurrentCamera SetPosition $newPosition0 $newPosition1 $newPosition2
$CurrentCamera Dolly $factor
$Renderer ResetCameraClippingRange
}
}
method DoRubberZoom { widget } {
set tracervar [::itcl::local cvisTrace #auto]
# Return if there is no renderer, or the rubber band is less
# that 5 pixels in either direction
if { ! $RendererFound } { return }
if { [expr $StartRubberZoomX - $EndRubberZoomX] < 5 && \
[expr $StartRubberZoomX - $EndRubberZoomX] > -5 } { return }
if { [expr $StartRubberZoomY - $EndRubberZoomY] < 5 && \
[expr $StartRubberZoomY - $EndRubberZoomY] > -5 } { return }
# We'll need the window height later
set WindowY [expr double([lindex [$widget configure -height] 4])]
# What is the center of the rubber band box in pixels?
set centerX [expr ($StartRubberZoomX + $EndRubberZoomX)/2.0]
set centerY [expr ($StartRubberZoomY + $EndRubberZoomY)/2.0]
# Convert the focal point to a display coordinate in order to get the
# depth of the focal point in display units
set FPoint [$CurrentCamera GetFocalPoint]
set FPoint0 [expr double([lindex $FPoint 0])]
set FPoint1 [expr double([lindex $FPoint 1])]
set FPoint2 [expr double([lindex $FPoint 2])]
$Renderer SetWorldPoint $FPoint0 $FPoint1 $FPoint2 1.0
$Renderer WorldToDisplay
set DPoint [$Renderer GetDisplayPoint]
set focalDepth [expr double([lindex $DPoint 2])]
# Convert the position of the camera to a display coordinate in order
# to get the depth of the camera in display coordinates. Note this is
# a negative number (behind the near clipping plane of 0) but it works
# ok anyway
set PPoint [$CurrentCamera GetPosition]
set PPoint0 [expr double([lindex $PPoint 0])]
set PPoint1 [expr double([lindex $PPoint 1])]
set PPoint2 [expr double([lindex $PPoint 2])]
$Renderer SetWorldPoint $PPoint0 $PPoint1 $PPoint2 1.0
$Renderer WorldToDisplay
set DPoint [$Renderer GetDisplayPoint]
set positionDepth [expr double([lindex $DPoint 2])]
# Find out the world position of where our new focal point should
# be - it will be at the center of the box, back at the same focal depth
# Don't actually set it now - we need to do all our computations before
# we modify the camera
$Renderer SetDisplayPoint $centerX $centerY $focalDepth
$Renderer DisplayToWorld
set newFocalPoint [$Renderer GetWorldPoint]
set newFocalPoint0 [expr double([lindex $newFocalPoint 0])]
set newFocalPoint1 [expr double([lindex $newFocalPoint 1])]
set newFocalPoint2 [expr double([lindex $newFocalPoint 2])]
set newFocalPoint3 [expr double([lindex $newFocalPoint 3])]
if { $newFocalPoint3 != 0.0 } {
set newFocalPoint0 [expr $newFocalPoint0 / $newFocalPoint3]
set newFocalPoint1 [expr $newFocalPoint1 / $newFocalPoint3]
set newFocalPoint2 [expr $newFocalPoint2 / $newFocalPoint3]
}
# Find out where the new camera position will be - at the center of
# the rubber band box at the position depth. Don't set it yet...
$Renderer SetDisplayPoint $centerX $centerY $positionDepth
$Renderer DisplayToWorld
set newPosition [$Renderer GetWorldPoint]
set newPosition0 [expr double([lindex $newPosition 0])]
set newPosition1 [expr double([lindex $newPosition 1])]
set newPosition2 [expr double([lindex $newPosition 2])]
set newPosition3 [expr double([lindex $newPosition 3])]
if { $newPosition3 != 0.0 } {
set newPosition0 [expr $newPosition0 / $newPosition3]
set newPosition1 [expr $newPosition1 / $newPosition3]
set newPosition2 [expr $newPosition2 / $newPosition3]
}
# We figured out how to position the camera to be centered, now we
# need to "zoom". In parallel, this is simple since we only need to
# change our parallel scale to encompass the entire y range of the
# rubber band box. In perspective, we assume the box is drawn on the
# near plane - this means that it is not possible that someone can
# draw a rubber band box around a nearby object and dolly past it. It
# also means that you won't get very close to distance objects - but that
# seems better than getting lost.
if {[$CurrentCamera GetParallelProjection]} {
# the new scale is just based on the y size of the rubber band box
# compared to the y size of the window
set ydiff [expr ($StartRubberZoomX - $EndRubberZoomX)]
if { $ydiff < 0.0 } { set ydiff [expr $ydiff * -1.0] }
set newScale [$CurrentCamera GetParallelScale]
set newScale [expr $newScale * $ydiff / $WindowY]
# now we can actually modify the camera
$CurrentCamera SetFocalPoint $newFocalPoint0 $newFocalPoint1 $newFocalPoint2
$CurrentCamera SetPosition $newPosition0 $newPosition1 $newPosition2
$CurrentCamera SetParallelScale $newScale
} else {
# find out the center of the rubber band box on the near plane
$Renderer SetDisplayPoint $centerX $centerY 0.0
$Renderer DisplayToWorld
set nearFocalPoint [$Renderer GetWorldPoint]
set nearFocalPoint0 [expr double([lindex $nearFocalPoint 0])]
set nearFocalPoint1 [expr double([lindex $nearFocalPoint 1])]
set nearFocalPoint2 [expr double([lindex $nearFocalPoint 2])]
set nearFocalPoint3 [expr double([lindex $nearFocalPoint 3])]
if { $nearFocalPoint3 != 0.0 } {
set nearFocalPoint0 [expr $nearFocalPoint0 / $nearFocalPoint3]
set nearFocalPoint1 [expr $nearFocalPoint1 / $nearFocalPoint3]
set nearFocalPoint2 [expr $nearFocalPoint2 / $nearFocalPoint3]
}
# find the world coordinates of the point centered on the rubber band box
# in x, on the border in y, and at the near plane depth.
$Renderer SetDisplayPoint $centerX $StartRubberZoomY 0.0
$Renderer DisplayToWorld
set focalEdge [$Renderer GetWorldPoint]
set focalEdge0 [expr double([lindex $focalEdge 0])]
set focalEdge1 [expr double([lindex $focalEdge 1])]
set focalEdge2 [expr double([lindex $focalEdge 2])]
set focalEdge3 [expr double([lindex $focalEdge 3])]
if { $focalEdge3 != 0.0 } {
set focalEdge0 [expr $focalEdge0 / $focalEdge3]
set focalEdge1 [expr $focalEdge1 / $focalEdge3]
set focalEdge2 [expr $focalEdge2 / $focalEdge3]
}
# how far is this "rubberband edge point" from the focal point?
set ydist [expr \
sqrt( \
($nearFocalPoint0 - $focalEdge0)*($nearFocalPoint0 - $focalEdge0) + \
($nearFocalPoint1 - $focalEdge1)*($nearFocalPoint1 - $focalEdge1) + \
($nearFocalPoint2 - $focalEdge2)*($nearFocalPoint2 - $focalEdge2) )]
# We need to know how far back we must be so that when we view the scene
# with the current view angle, we see all of the y range of the rubber
# band box. Use a simple tangent equation - opposite / adjacent = tan theta
# where opposite is half the y height of the rubber band box on the near
# plane, adjacent is the distance we are solving for, and theta is half
# the viewing angle. This distance that we solve for is the new distance
# to the near plane - to find the new distance to the focal plane we
# must take the old distance to the focal plane, subtract the near plane
# distance, and add in the distance we solved for.
set angle [expr 0.5 * (3.141592 / 180.0) * [$CurrentCamera GetViewAngle]]
set d [expr $ydist/tan($angle)]
set range [$CurrentCamera GetClippingRange]
set nearplane [expr double([lindex $range 0])]
set factor [expr [$CurrentCamera GetDistance] / \
([$CurrentCamera GetDistance] - $nearplane + $d)]
# now we can actually modify the camera
$CurrentCamera SetFocalPoint $newFocalPoint0 $newFocalPoint1 $newFocalPoint2
$CurrentCamera SetPosition $newPosition0 $newPosition1 $newPosition2
$CurrentCamera Dolly $factor
$Renderer ResetCameraClippingRange
}
}
method RubberZoom {widget x y} {
set tracervar [::itcl::local cvisTrace #auto]
if { ! $RendererFound } { return }
set WindowY [lindex [$widget configure -height] 4]
if { ! $RubberZoomPerformed } {
$Renderer AddProp $RubberBandActor
set StartRubberZoomX $x
set StartRubberZoomY [expr $WindowY - $y - 1]
set RubberZoomPerformed 1
}
set EndRubberZoomX $x
set EndRubberZoomY [expr $WindowY - $y - 1]
$RubberBandPoints SetPoint 0 $StartRubberZoomX $StartRubberZoomY 0
$RubberBandPoints SetPoint 1 $StartRubberZoomX $EndRubberZoomY 0
$RubberBandPoints SetPoint 2 $EndRubberZoomX $EndRubberZoomY 0
$RubberBandPoints SetPoint 3 $EndRubberZoomX $StartRubberZoomY 0
Render
}
method GetLight {light} {
if {[string compare "camera" $light]} {
return $this.light$light
} {
# Camera light is the default camera, first in list
set lights [$Renderer GetLights]
$lights InitTraversal
return [$lights GetNextItem]
}
}
}